Last active
August 29, 2015 14:18
-
-
Save ChristopheBoucaut/d2ca5b1ec6984a017b8a to your computer and use it in GitHub Desktop.
PHP7: nouveautés et modifications
This file contains 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 | |
declare(strict_types=1); // toujours en début de fichier et ne concerne que le fichier actuel. | |
function foo(int $paramInt, string $paramString): array { | |
return array($paramInt, $paramString); | |
} | |
foo(5, "toto"); // [5, "toto"] | |
foo("555 tt", "toto"); // Erreur car n'a pas le droit de cast la chaine en int |
This file contains 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 | |
function foo(int $paramInt, string $paramString): array { | |
return array($paramInt, $paramString); | |
} | |
foo(5, "toto"); // [5, "toto"] | |
foo("555 tt", "toto"); // [555, "toto"], cast automatique si possible |
This file contains 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 | |
// avant | |
use Namespace\Subnamespace\Class1; | |
use Namespace\Subnamespace\Class2; | |
use Namespace\Subnamespace\Class3 as BestClass; | |
// PHP7 | |
use Namespace\Subnamespace\{ Class1, Class2, Class3 as BestClass }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment