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 | |
| /** | |
| * Run this code with: "php -n <file.php>" to make sure no configuration will be used | |
| * so xdebug will not be used either. | |
| */ | |
| declare(strict_types=1); | |
| function primesGenerator(Iterator $iterator): 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 | |
| /** | |
| * Run this code with: "php -n <file.php>" to make sure no configuration will be used | |
| * so xdebug will not be used either. | |
| */ | |
| declare(strict_types=1); | |
| namespace App; |
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 | |
| declare(strict_types=1); | |
| namespace App; | |
| use drupol\launcher\Launcher; | |
| use loophp\phptree\Builder\Random; | |
| use loophp\phptree\Exporter\Gv; | |
| use loophp\phptree\Exporter\Image; |
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 | |
| // Programmation imperative | |
| $factorial = static function(int $x): int { | |
| $factorial = 1; | |
| for ($i = 2; $i <= $x; $i++) { | |
| $factorial *= $i; | |
| } |
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 | |
| declare(strict_types=1); | |
| namespace App; | |
| use ArrayObject; | |
| use Closure; | |
| use 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 | |
| declare(strict_types=1); | |
| namespace App; | |
| use Generator; | |
| use Iterator; | |
| class ClosureIterator implements \Iterator |
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 | |
| /** | |
| * Wallis formula | |
| * | |
| * 2 2 4 4 6 6 8 8 | |
| * pi = 2 x --- x --- x --- x --- x --- x --- x --- x --- x ... | |
| * 1 3 3 5 5 7 7 9 | |
| */ |
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 | |
| declare(strict_types=1); | |
| include __DIR__ . '/../vendor/autoload.php'; | |
| use loophp\collection\Collection; | |
| $integers = Collection::unfold(static fn (int $n = 1): int => $n + 1); |
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 App; | |
| use Facile\JoseVerifier\JWK\JwksProviderBuilder; | |
| use Facile\JoseVerifier\JWTVerifier; | |
| use Symfony\Component\HttpClient\HttpClient; | |
| use Symfony\Component\HttpClient\Psr18Client; | |
| include __DIR__ . '/vendor/autoload.php'; |
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 | |
| // Factorial of a number | |
| printf("\nype a number: ") | |
| && ($g = (int) trim(fgets(STDIN))) && (fn(int $g, $y) => | |
| printf($y(static fn (callable $function) => static fn ($n = 1) => (1 >= $n) ? 1 : $n * $function($n - 1))($g)) | |
| )( | |
| $g, | |
| static fn (callable $g): callable => (static fn ($f): callable => $f($f))(static fn ($f): callable => $g(static fn ($x) => $f($f)($x))) | |
| ); |