Summary
Keywords
Full Transcript
Covariant & Contravariant types are the topic that boggles our minds sometimes. In this video, I try to explain it in more detail the way I wish someone explained it to me when I was learning it because this is one of the topics that was somewhat difficult to grasp in the beginning. 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! 🛠️ TOOLS & SERVICES I USE Digital Ocean Hosting - Get 100$ credit - https://m.do.co/c/38b935ad74e5 Domains on Namecheap - https://namecheap.pxf.io/rnRjdQ Envato Elements - https://1.envato.market/c/2937311/298927/4662 Adobe Photoshop & Premiere - https://clk.tradedoubler.com/click?p=264355&a=3250276 COURSE PLAYLIST https://www.youtube.com/playlist?list=PLr3d3QYzkw2xabQRUpcZ_IBk9W50M9pe- RESOURCES Docs - https://www.php.net/manual/en/language.oop5.variance.php RFC that added covariant return & contravariant parameter type support - https://wiki.php.net/rfc/covariant-returns-and-contravariant-parameters Great article by Nikita Popov about type variance - https://www.npopov.com/2021/11/08/Type-variance-in-PHP.html Another great article about LSP & type safety - https://stitcher.io/blog/liskov-and-type-safety Online PHP Shell - https://3v4l.org/ TABLE OF CONTENTS 00:00 - Covariant & Contravariant Types 01:40 - Return Type Covariance Example 04:38 - Paramter Type Contravariance Example 06:39 - Testing Covariance & Contravariance In PHP 7.3 08:06 - Covariant Parameter & Contravariant Return Type Support? 10:16 - Covariance & Contravariance With Union & Intersection Types 11:48 - Liskov Substitution Principle (LSP) ** Affiliate Disclaimer: Some of the above links may be affiliate links, which may generate me a sales commission at no additional cost to you.
