3v4l.org

run code in 500+ PHP versions simultaneously
<?php class PhpstanOptions { private array $options = []; public function memoryLimit(string $limit) { $this->options['memory-limit'] = $limit; return $this; } public function level(string $level) { $this->options['level'] = $level; return $this; } } $options = new PhpstanOptions()->memoryLimit('1G')->level('5'); var_dump($options);
Output for 8.4.4
object(PhpstanOptions)#1 (1) { ["options":"PhpstanOptions":private]=> array(2) { ["memory-limit"]=> string(2) "1G" ["level"]=> string(1) "5" } }
Output for 8.3.5
Parse error: syntax error, unexpected token "->" in /in/aZLVd on line 19
Process exited with code 255.

preferences:
37.83 ms | 493 KiB | 3 Q