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
#!/usr/bin/php | |
<?php | |
/** @license WTFPL http://www.wtfpl.net/ 2020 tadsan */ | |
$base_dir = dirname(__DIR__) . '/'; | |
$new_argv = [__DIR__ . '/phpstan']; | |
array_shift($argv); | |
file_put_contents(__DIR__ . '/../phpstan.log', json_encode($argv, JSON_UNESCAPED_SLASHES) . PHP_EOL, FILE_APPEND); |
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 | |
$request = implode("\r\n", [ | |
'POST /post HTTP/1.1', | |
'Host: httpbin.org', | |
'Accept: application/json', | |
'Content-Type: application/json', | |
'Connection: close', | |
'', | |
json_encode(['foo' => 'bar']), |
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 | |
function fib(int $i) | |
{ | |
return [0, 1][$i] ?? fib($i - 1) + fib($i - 2); | |
} | |
var_dump(iterator_to_array(map(Closure::fromCallable('fib'), xrange(1, 24)))); |
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 | |
function fibonacci() | |
{ | |
$i = 0; | |
$j = 1; | |
while (true) { | |
yield $i; | |
[$i, $j] = [$j, $i + $j]; |
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 | |
function map(Closure $callback, iterable $iter): Generator | |
{ | |
foreach ($iter as $k => $v) { | |
yield $k => $callback($v); | |
} | |
} | |
function take(int $n, iterable $iter): Generator |
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 | |
namespace PixivTest\Util\RegexPattern; | |
/** | |
* 正規表現のためのDocTest | |
* | |
* {@see \Util_RegexPattern} クラスの定数定義ごとに正規表現をテストする。 | |
* | |
* ## 記法 |
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 | |
$code = <<<'EoPHP' | |
<?php | |
if (1 == 1) { | |
echo 'a'; | |
} else { | |
echo $b; | |
} | |
EoPHP; |