Created
November 12, 2019 16:25
-
-
Save krmgns/43ea9ea0e53d690fe4e23005a98e5cfa to your computer and use it in GitHub Desktop.
nö!
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
<?php | |
// ok, cos converted to ?int = null, right? | |
function foo(int $i = null) {} | |
// ok, all ok, right? | |
$a = new class { | |
public $i; | |
public function check(): bool { | |
return ($this->i != null); | |
} | |
}; | |
// all ok, right? | |
if ($a->check()) { | |
$a->i++; | |
} | |
var_dump($a->i); | |
var_dump((int) $a->i); | |
var_dump((int) ($a->i ?? 0)); | |
var_dump((int) ($a->i ?? null)); | |
// so why this? | |
$b = new class { | |
// ok but oppressive, hasn't already null(?) indicator, so why have to do? | |
// all uninitialized vars are null already, like $a.i above, right? | |
// public ?int $i = null; | |
// this is a nullable int, ok. we understand that $i is an int and nullable, so | |
// why that fucking php does not understand that fuck and screaming out like a bitch, | |
// "Typed property class@anonymous::$i must not be accessed before initialization", fuck?! | |
// and why not simply converted to null and letting the developer to check $i != null? | |
public ?int $i; | |
public function check(): bool { | |
// while this ugly fuck is ok, | |
// return ($this->i ?? null) != null; | |
// this fuck causing error thrown, and this is LITERALLY BULLSHIT FUCK! | |
return ($this->i != null); | |
} | |
}; | |
// ok but why have to this? | |
// $b->i = null; | |
// but wtf is "[i] => uninitialized(?int)"! ok, you hipsters invented something new, yeah! | |
// if ($b->check()) { | |
// $b->i++; | |
// } | |
// all fuck! | |
// var_dump($b->i); | |
// var_dump((int) $b->i); | |
// var_dump((int) ($b->i ?? 0)); // ok, but WHAT THE FUCK! | |
// var_dump((int) ($b->i ?? null)); // ok again, but again WHAT THE FUCK! | |
// these, like mentioned above, throwing error, yes FUCK! | |
// $b->i != null; | |
// $b->check(); | |
// by the way, that is surprisingly yielding just a notice like "Notice: Undefined property: | |
// class@anonymous::$i" and keeping work not throwing error, yes again FUCK but a bigger | |
// FUUUUUUUUUUUUUUUUUUUCK!! | |
$b->i++; | |
var_dump($b); | |
// in conclusion: | |
// $b->i != null; and $b->check(); are fuck. | |
// $b->++; is fuck again | |
// or literally all fuck? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment