https://wiki.php.net/rfc/namespaced_names_as_token
$ docker run --rm php:8.0.0beta2-cli-alpine php -r 'var_dump(token_get_all("<?php namespace new\Foo;"));'
array(5) {
[0]=>
array(3) {
[0]=>
int(390)
[1]=>| <?php | |
| $string = str_repeat(' ', 200000) . 'a'; | |
| $start = microtime(true); | |
| preg_replace('/\s+$/', '', $string); | |
| if (preg_last_error() !== 0) { | |
| var_dump(preg_last_error_msg()); | |
| } |
| <?php | |
| const LOOP = 50; | |
| $mesuare = function (string $title, callable $func): void { | |
| printf("<h2>%s</h2>", htmlspecialchars($title)); | |
| for ($i = 1; $i <= LOOP; $i++) { | |
| $start = microtime(true); | |
| $time = $func() - $start; |
| <?php | |
| enum Color: int { | |
| case Red = 1; | |
| case Blue = 2; | |
| case Green = 3; | |
| } | |
| function foo(Color $color) { | |
| var_dump($color); |
| <?php | |
| declare(strict_types=1); | |
| $i = random_int(1, 2); | |
| var_dump($i); | |
| // match expression | |
| $ret = match ($i % 2 === 0) { | |
| true => 'even', | |
| false => 'odd', |
| <?php | |
| declare(strict_types=1); | |
| for ($i = 0 ; $i < 4 ; $i++) { | |
| try { | |
| $no = match ($i) { | |
| 0 => '0', | |
| 1 => throw new RuntimeException(), | |
| // 2 => continue, Parse error: syntax error, unexpected token "continue" |
| hello-server: | |
| CGO_ENABLED=0 GOOS=linux GOARCH=amd64 docker run --rm -v `pwd`:/app -w /app golang:1.15-buster go build -o hello-server | |
| clean: | |
| -rm hello-server |
| <?php | |
| namespace Acme; | |
| use Attribute; | |
| @@Attribute | |
| final class Attr1 {} | |
| @@Attr1 | |
| final class Foo {} |
| <?php | |
| namespace Acme; | |
| @@Attribute | |
| final class Attr1 {} | |
| @@Attr1 | |
| final class Foo {} | |
| $reflectionClass = new \ReflectionClass(Foo::class); |
| <?php | |
| declare(strict_types=1); | |
| @@Attribute | |
| final class Attr1 { | |
| public function __construct(private string $value) {} | |
| } | |
| final class Attr2 { | |
| public function __construct() {} |
https://wiki.php.net/rfc/namespaced_names_as_token
$ docker run --rm php:8.0.0beta2-cli-alpine php -r 'var_dump(token_get_all("<?php namespace new\Foo;"));'
array(5) {
[0]=>
array(3) {
[0]=>
int(390)
[1]=>