3v4l.org

run code in 300+ PHP versions simultaneously
<?php // native PHPStan class AbstractClass { public $attributes; public function getAttribute(string $name) { return $this->attributes[$name] ?? null; } public function setAttribute(string $name, $value): void { $this->attributes[$name] = $value; } } // Rector faking trait AttributesTrait { public $attributes; public function getAttribute(string $name) { return $this->attributes[$name] ?? null; } public function setAttribute(string $name, $value): void { $this->attributes[$name] = $value; } } final class SomeNode extends AbstractClass { use AttributesTrait; } $someNode = new SomeNode(); $someNode->setAttribute('test', 'yes'); var_dump($someNode->getAttribute('test'));

preferences:
27.61 ms | 404 KiB | 5 Q