3v4l.org

run code in 300+ PHP versions simultaneously
<?php abstract class BaseLib { abstract protected function process( $a ); } class MyLib extends BaseLib { //protected $a; protected string $a; public function run( string $a ) { $this->process( $a ); } protected function process( $a ) { $this->a = $a; } } class ThirdParty extends MyLib { public function run( string $a = null ) { $this->process( $a ); } } $third_party_code = new ThirdParty(); $third_party_code->run();
Output for 8.4.18, 8.5.3
Deprecated: ThirdParty::run(): Implicitly marking parameter $a as nullable is deprecated, the explicit nullable type must be used instead in /in/0orf9 on line 21 Fatal error: Uncaught TypeError: Cannot assign null to property MyLib::$a of type string in /in/0orf9:16 Stack trace: #0 /in/0orf9(22): MyLib->process(NULL) #1 /in/0orf9(28): ThirdParty->run() #2 {main} thrown in /in/0orf9 on line 16
Process exited with code 255.

preferences:
50.88 ms | 497 KiB | 4 Q