3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace Yiisoft\EventDispatcher\Provider; abstract class AbstractProviderConfigurator { protected function attach(callable $listener, string $eventClassName = ''): void { throw new \RuntimeException("Method 'attach' does not exist."); } } class Provider extends AbstractProviderConfigurator { private $providers = []; protected function attach(callable $listener, string $eventClassName = ''): void { $this->providers[$eventClassName] = $listener; } public function getProviders(): array { return $this->providers; } } class MyProvider extends Provider { public function attach(callable $listener, string $eventClassName = ''): void { parent::attach($listener, $eventClassName); } } $provider = new MyProvider(); $provider->attach(function () { return true; }, 'MyEvent'); var_dump($provider->getProviders());
Output for 8.4.1 - 8.4.14, 8.5.0 - 8.5.1
array(1) { ["MyEvent"]=> object(Closure)#2 (3) { ["name"]=> string(22) "{closure:/in/HCcHQ:39}" ["file"]=> string(9) "/in/HCcHQ" ["line"]=> int(39) } }
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.28
array(1) { ["MyEvent"]=> object(Closure)#2 (0) { } }

preferences:
185.84 ms | 410 KiB | 5 Q