In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "how to understand PHP7.2 ignore parent method and Liskov replacement principle related problems", in daily operation, I believe many people in how to understand PHP7.2 ignore parent method and Liskov replacement principle related problems have doubts, small make up consult all kinds of information, sort out simple and easy to use operation method, hope to answer "how to understand PHP7.2 ignore parent method and Liskov replacement principle related problems" doubts helpful! Next, please follow the small series to learn together!
PHP 7.2 subclass coverage method omitting parameter type features and Liskov substitution principle
PHP 7.2 has been out for a while, and as for what new improvements are available in the new version, as long as you care about PHP development, you should have read them. Here is just one new feature that can be misunderstood.
PHP 7.2 allows you to ignore the type hint of the parameter defined by the parent class method when a subclass overrides the parent class method:
class Foo{ public function bar(SomeClass $obj) {}}class Foobar extends Foo{ public function bar($obj) {} //This was an error before PHP 7.2}
I see some websites introduce this feature, saying that its purpose is to facilitate refactoring. If the parameter type of the parent class method changes later, the child class does not have to change it all again." Sounds like a good idea. Implicit in this statement is that if a subclass ignores the parameter type of a parent class method, it will still check the parameter type when called. The actual situation is not like this. Do an experiment and you will know:
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.