Edit report at https://bugs.php.net/bug.php?id=64988&edit=1
ID: 64988 Updated by: larue...@php.net Reported by: RQuadling at GMail dot com Summary: Class loading order affects E_STRICT warning. -Status: Open +Status: Closed Type: Bug Package: *General Issues Operating System: Centos PHP Version: 5.4.16 Block user comment: N Private report: N New Comment: Automatic comment on behalf of laruence Revision: http://git.php.net/?p=php-src.git;a=commit;h=d8792d87cf978ef2a977362a7ef8f357820867c2 Log: Fixed bug #64988 (Class loading order affects E_STRICT warning) Previous Comments: ------------------------------------------------------------------------ [2013-06-07 14:37:06] RQuadling at GMail dot com Description: ------------ The load/compile order seems to affect the E_STRICT warning PHP Strict Standards: Declaration of class::method() should be compatible with class::method(array $data). The attached script simulates an autoloader to load three classes in the expected order for an autoloader (i.e. smooth1 => noisy1 => base1) as well as second set suitable for a non autoloader environment (i.e. base2, noisy2, smooth2). I only get the E_STRICT warning on the autoloaded loaded classes. Test script: --------------- <?php error_reporting(-1); function __autoload($s_Class) { switch ($s_Class) { case 'Smooth1' : class Smooth1 extends Noisy1 { public function insert(array $data) { return parent::insert($data, count($data)); } } break; case 'Noisy1' : class Noisy1 extends Base1 { public function insert(array $data, $option1 = Null) { if (!empty($option1)) { $data['option1'] = $option1; } return parent::insert($data); } } break; case 'Base1' : abstract class Base1 { public function insert(array $data){ return array_reverse($data); } } break; } } abstract class Base2 { public function insert(array $data) { return array_reverse($data); } } class Noisy2 extends Base2 { public function insert(array $data, $option1 = Null) { if (!empty($option1)) { $data['option1'] = $option1; } return parent::insert($data); } } class Smooth2 extends Noisy2 { public function insert(array $data) { return parent::insert($data, count($data)); } } $o = new Smooth1(); print_r($o->insert(array('a', 'b', 'c'))); $o = new Smooth2(); print_r($o->insert(array('a', 'b', 'c'))); $o = new Smooth1(); print_r($o->insert(array('a', 'b', 'c'))); $o = new Smooth2(); print_r($o->insert(array('a', 'b', 'c'))); Expected result: ---------------- Array ( [option1] => 3 [0] => c [1] => b [2] => a ) Array ( [option1] => 3 [0] => c [1] => b [2] => a ) Array ( [option1] => 3 [0] => c [1] => b [2] => a ) Array ( [option1] => 3 [0] => c [1] => b [2] => a ) Actual result: -------------- PHP Strict Standards: Declaration of Smooth1::insert() should be compatible with Base1::insert(array $data) in - on line 6 Strict Standards: Declaration of Smooth1::insert() should be compatible with Base1::insert(array $data) in - on line 6 Array ( [option1] => 3 [0] => c [1] => b [2] => a ) Array ( [option1] => 3 [0] => c [1] => b [2] => a ) Array ( [option1] => 3 [0] => c [1] => b [2] => a ) Array ( [option1] => 3 [0] => c [1] => b [2] => a ) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=64988&edit=1