• With strict warnings enabled in PHP 5.3., AVH First Defence Against Spam version 3.6.5 generates:

    Strict standards: Only variables should be passed by reference in /Library/WebServer/Documents/wp-3.8.1/wp-content/plugins/avh-first-defense-against-spam/libs/avh-registry.php on line 93

    Line 93 is in AVH_Class_Registry::load_class():

    $object = $this->instantiate_class(new $name());

    The declaration for AVH_Class_Registry::instantiate_class() specifies that its argument is passed by reference, hence the warning:

    protected function instantiate_class (&$class_object)

    Also, the doc for AVH_Class_Registry::instantiate_class() states that it “Returns a new class object by reference”, but the method isn’t declared to return by reference. Other than “mak[ing] PHP 5.3 cry”, what is this method supposed to do? Is it supposed to somehow deal with PHP 4’s assignment semantics? It seems that removing the call to instantiate_class() on line 93, assigning directly (by reference, for PHP 4) to $object, would work just as well, and would prevent the warning.

    $object =& new $name();

  • The topic ‘Strict standards warning: Only variables should be passed by reference’ is closed to new replies.