Summary
Keywords
Full Transcript
In this lesson, you will learn what anonymous classes are in PHP, how to create & use them. Anonymous classes like anonymous functions are nameless. You are able to create one-off objects using anonymous classes. You can either assign an anonymous class to a variable that will simply give you the object of that anonymous class, or just pass it as an argument since it's just an expression. Note that at 4:54 I copied constructor promoted properties & pasted them into the anonymous class. Promoted properties should not be used inside an anonymous class when you are extending from a base class since those already exist on the base class. SOME OF THE WAYS YOU CAN SUPPORT THE CHANNEL 👍 Smash the like button 🤝 Subscribe to the channel & turn the notifications on 💬 Post comments, any feedback is greatly appreciated ⭐ Become a Patreon: https://www.patreon.com/programwithgio THANK YOU! LESSON 2.15 Course Outline - https://github.com/ggelashvili/learnphptherightway-outline Course Playlist - https://www.youtube.com/playlist?list=PLr3d3QYzkw2xabQRUpcZ_IBk9W50M9pe- RESOURCES Anonymous Classes RFC - https://wiki.php.net/rfc/anonymous_classes
