note 85779 deleted from language.oop5.autoload by crell
| From: | crell@php.net | Date: | Mon, 04 Apr 2022 16:06:25 +0000 |
| Subject: | note 85779 deleted from language.oop5.autoload by crell | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-218015@lists.php.net to get a copy of this message | ||
Note Submitter: jbarker at erepublic dot com
----
In a subclass, I was trying to call an overridden parent method with an arbitrary number of
arguments:
<?php
call_user_func_array(array('parent', 'someNonStaticMethod'), $args);
?>
It turns out this triggers an E_STRICT level warning. So I changed to this:
<?php
call_user_func_array(array($this, 'parent::someNonStaticMethod'), $args);
?>
This doesn't trigger any warnings, but it has the undesirable (if not downright buggy) effect
of calling my __autoload() function with the argument 'parent'. I had to modify
__autoload() to handle this special situation:
<?php
function __autoload($cls)
{
if ('parent' != $cls)
{
require("class.$cls.php");
}
}
?>
Tested on Linux with PHP 5.1.6 and 5.2.5.