rfc:protectedlookup
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
rfc:protectedlookup [2008/06/01 11:15] – robinf | rfc:protectedlookup [2008/06/03 13:37] – fix typo in code sample robinf | ||
---|---|---|---|
Line 251: | Line 251: | ||
* Possibly confusing at first, as code that reads C1::f() may in fact result in an invocation of P::f(). | * Possibly confusing at first, as code that reads C1::f() may in fact result in an invocation of P::f(). | ||
+ | |||
+ | ===== Appendix ===== | ||
+ | ==== Other potential LSP violations ==== | ||
+ | If Option 1 is rejected on the grounds of a breach of LSP, then other arguable violations of LSP should be reviewed too. | ||
+ | Below is a list of examples to be considered. | ||
+ | === Private static methods === | ||
+ | <code php> | ||
+ | <?php | ||
+ | class P { | ||
+ | | ||
+ | | ||
+ | |||
+ | | ||
+ | $class = get_class($liskov); | ||
+ | echo " | ||
+ | $liskov-> | ||
+ | echo " | ||
+ | $class:: | ||
+ | } | ||
+ | } | ||
+ | |||
+ | class C extends P { | ||
+ | | ||
+ | | ||
+ | } | ||
+ | |||
+ | P::test(new P); | ||
+ | P::test(new C); // Valid Liskov substitution - should this fail? | ||
+ | ?> | ||
+ | </ | ||
+ | === Private static properties === | ||
+ | <code php> | ||
+ | <?php | ||
+ | class P { | ||
+ | | ||
+ | | ||
+ | |||
+ | | ||
+ | $class = get_class($liskov); | ||
+ | echo " | ||
+ | echo $liskov-> | ||
+ | echo " | ||
+ | echo $class::$sa . " | ||
+ | } | ||
+ | } | ||
+ | |||
+ | class C extends P { | ||
+ | | ||
+ | | ||
+ | } | ||
+ | |||
+ | P::test(new P); | ||
+ | P::test(new C); // Valid Liskov substitution - should this fail? | ||
+ | ?> | ||
+ | </ |
rfc/protectedlookup.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1