Last active
November 22, 2019 21:07
-
-
Save krmgns/74a9c1e887ef8770bc38f0071685250b to your computer and use it in GitHub Desktop.
php bugreport that was gone spam
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Link: https://bugs.php.net/bug.php?id=78809 | |
| --- | |
| Uninitialized typed properties | |
| While throwing when try to access to any uninitialized typed property (eg: $o->x == null), | |
| the codes below are just causing notice. | |
| BTW, error message is so weird. We were expecting something like this; | |
| "Do not touch that f**king TYPED PROPERTY, it's a f**king TYPED PROPERTY and you poor should | |
| know your place while coding with highness PHP! Respect and behave yourself!" | |
| AND, while some other main stream languages allowing to access them (to uninitialized properties) | |
| simply saying null (or nil), why PHP is forcing us to use empty(), isset() or ?? operator? Does PHP | |
| want a to be cruel language or enjoying to usage of empty() and other likely-stuff above, denying us | |
| to do checks with null ($o->x == null)? Also it is not just a null check issue, but to access in any | |
| other way (eg: $o->x < 0, !($o->x ^ 0) etc). | |
| All aside, I am not angry or hating PHP, but simply was expecting more easiness, productivity and | |
| better development experience while coding with PHP all after 15 years my own PHP experience... | |
| Dropping here some links hoping you to check them; | |
| https://twitter.com/krmgns/status/1194293566899675136 | |
| https://twitter.com/nikita_ppv/status/1194301509036658691 (nikic' comment) | |
| https://gist.github.com/k-gun/43ea9ea0e53d690fe4e23005a98e5cfa | |
| Some other languages behavior for uninitialized properties. | |
| https://gist.github.com/k-gun/514e8ad8cd9b95eadf8910ab10f4e373 | |
| $a = new class { var int $i; }; | |
| var_dump($a->i == null); | |
| var_dump($a->i++); | |
| Expected result: | |
| Fatal error: Uncaught Error: Typed property class@anonymous::$i must not be accessed before | |
| initialization in /var/www/a.php:14 | |
| Actual result: | |
| PHP Notice: Undefined property: class@anonymous::$i in /var/www/a.php on line 14 | |
| NULL | |
| $a = new class { var string $s; }; | |
| var_dump($a->s == null); | |
| var_dump($a->s .= ""); | |
| Expected result: | |
| Fatal error: Uncaught Error: Typed property class@anonymous::$s must not be accessed before | |
| initialization in /var/www/a.php:14 | |
| Actual result: | |
| PHP Notice: Undefined property: class@anonymous::$s in /var/www/a.php on line 14 | |
| string(0) "" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment