<?php
namespace DummyTest\Lib {
class TObject {
public function __construct() {
}
}
class TComponent extends \DummyTest\Lib\TObject {
public function __construct() {
parent::__construct();
}
}
class TSingletonComponent extends \DummyTest\Lib\TComponent {
public function __construct() {
parent::__construct();
}
}
class TDatabase extends \DummyTest\Lib\TSingletonComponent {
public function __construct() {
parent::__construct();
}
public static function Init() {
$db = new \DummyTest\Lib\Database\TPDO();
}
}
}
namespace DummyTest\Lib\Database {
class TDatabase extends \DummyTest\Lib\TComponent {
public function __construct() {
parent::__construct();
}
}
class TPDO extends \DummyTest\Lib\Database\TDatabase {
protected $pdo;
public function __construct() {
parent::__construct();
echo serialize(\DummyTest\SystemConfig::Get('xxx')); // Fails in PHP
}
}
}
namespace DummyTest {
class SystemConfig {
protected static $config = array();
public function Get($name) {
echo get_called_class().PHP_EOL;
if(isset(static::$config[$name])) {
return static::$config[$name];
}
return null;
}
public function Set($name, $value) {
static::$config[$name] = $value;
}
}
SystemConfig::Set('xxx', 'yyy');
\DummyTest\Lib\TDatabase::Init();
}
Fatal error: Uncaught Error: Non-static method DummyTest\SystemConfig::Set() cannot be called statically in /in/1r5Um:61
Stack trace:
#0 {main}
thrown in /in/1r5Um on line 61
Process exited with code 255.
Deprecated: Non-static method DummyTest\SystemConfig::Set() should not be called statically in /in/1r5Um on line 61
Deprecated: Non-static method DummyTest\SystemConfig::Get() should not be called statically in /in/1r5Um on line 39
DummyTest\SystemConfig
s:3:"yyy";
Output for 7.3.32 - 7.3.33
DummyTest\SystemConfig
s:3:"yyy";
Output for 5.6.7 - 5.6.28
Strict Standards: Non-static method DummyTest\SystemConfig::Set() should not be called statically in /in/1r5Um on line 61
Deprecated: Non-static method DummyTest\SystemConfig::Get() should not be called statically, assuming $this from incompatible context in /in/1r5Um on line 39
DummyTest\Lib\Database\TPDO
Fatal error: Access to undeclared static property: DummyTest\Lib\Database\TPDO::$config in /in/1r5Um on line 50
Process exited with code 255.
Strict Standards: Non-static method DummyTest\SystemConfig::Set() should not be called statically in /in/1r5Um on line 61
Strict Standards: Non-static method DummyTest\SystemConfig::Get() should not be called statically, assuming $this from incompatible context in /in/1r5Um on line 39
DummyTest\Lib\Database\TPDO
Fatal error: Access to undeclared static property: DummyTest\Lib\Database\TPDO::$config in /in/1r5Um on line 50
Process exited with code 255.