Created
March 5, 2020 10:02
-
-
Save woprrr/bd0ee94c740f5b8f7ab2d455dd5c3cc2 to your computer and use it in GitHub Desktop.
Revisions
-
Alexandre Mallet created this gist
Mar 5, 2020 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ <?php # Typed Properties 2.0 # OLD WAY (PHP < 7.4 ) class User { public $id; public $name; public function __construct(int $id, string $name) { $this->id = $id; $this->name = $name; } } $user = new User(10, []); // This Will throw a Fatal error. # Typed Properties with PHP 7.4 All types are supported, with the exception of void and callable. class NewUser { public int $id; public string $name; } $newUser = new NewUser; $newUser->id = 10; $newUser->name = []; // This Will throw a Fatal error too !!