3v4l.org

run code in 500+ PHP versions simultaneously
<?php class PhpstanOptions { private array $options = []; public function memoryLimit(string $limit): self { $this->options['memory-limit'] = $limit; return $this; } public function level(string $level): self { $this->options['level'] = $level; return $this; } public function noProgress(bool $progress): self { $this->options['no-progress'] = $progress; return $this; } public function debug(string $debug): self { $this->options['debug'] = $debug; return $this; } public function buildCliCommand(): string { $cmd = ''; foreach($this->options as $option => $val) { $cmd .= sprintf('--%s=%s ', $option, $val); } return $cmd; } } $options = new PhpstanOptions()->memoryLimit('1G')->level('5'); var_dump($options); echo $options->buildCliCommand();
Output for 8.4.4
object(PhpstanOptions)#1 (1) { ["options":"PhpstanOptions":private]=> array(2) { ["memory-limit"]=> string(2) "1G" ["level"]=> string(1) "5" } } --memory-limit=1G --level=5
Output for 8.3.5
Parse error: syntax error, unexpected token "->" in /in/8V3II on line 44
Process exited with code 255.

preferences:
45.62 ms | 493 KiB | 3 Q