Skip to content

Commit 2c4ea17

Browse files
committed
fix: store some testing examples
1 parent 7a908b1 commit 2c4ea17

4 files changed

Lines changed: 47 additions & 0 deletions

File tree

playground/test.compile.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
var_dump(
4+
opcache_compile_file(__DIR__ . '/test.php')
5+
);

playground/test.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
$show_value = 123;
3+
echo 'sing_quote' . $show_value;
4+
function test()
5+
{
6+
return DateTimeImmutable::createFromFormat('123');
7+
}
8+
9+
throw E;
10+
echo "double_quote{$show_value}";
11+

playground/tokens_object.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
echo json_encode(
4+
array_map(
5+
function (PhpToken $token) {
6+
return [
7+
'line' => $token->line,
8+
'pos' => $token->pos,
9+
'name' => $token->getTokenName(),
10+
'value' => $token->text,
11+
];
12+
},
13+
\PhpToken::tokenize(file_get_contents($argv[1])),
14+
)
15+
);

playground/tokens_scalar.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
echo json_encode(
4+
array_map(
5+
function ($token) {
6+
return [
7+
'line' => $isArray = is_array($token) ? $token[2] : null,
8+
'name' => $isArray ? token_name($token[0]) : null,
9+
'value' => $isArray ? $token[1] : $token,
10+
];
11+
},
12+
token_get_all(
13+
file_get_contents($argv[1])
14+
),
15+
)
16+
);

0 commit comments

Comments
 (0)