|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits              [2013-06-10 13:36 UTC] laruence@php.net
  [2013-06-10 13:36 UTC] laruence@php.net
 
-Status: Open
+Status: Closed
  [2014-10-07 23:18 UTC] stas@php.net
  [2014-10-07 23:30 UTC] stas@php.net
 | |||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 13:00:01 2025 UTC | 
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 )