3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php trait DataCollector { static $collectionData = array(); final abstract private function setData( $data ) { self::$CollectionData[] = $data; return $this; } final abstract public function getCollectedData() { return self::$CollectionData; } } class Form {} class Field extends Form { use DataCollector; public function __construct( $type, $text = NULL ) { $this->setData( $type )->setData( $text ); } } $Field1 = new Field( 'text' ); var_dump( $Field1->getCollectedData() ); $Field2 = new Field( 'html', 'hello' ); var_dump( $Field2->getCollectedData() );
Output for 5.4.0 - 5.4.17
Fatal error: Cannot use the final modifier on an abstract class member in /in/Ei6He on line 5
Process exited with code 255.
Output for 5.3.0 - 5.3.27
Parse error: syntax error, unexpected T_STRING in /in/Ei6He on line 2
Process exited with code 255.