Bug #7055

possible reflection problem.

Added by Falk Kühnel over 5 years ago. Updated almost 5 years ago.

Status:Closed Start date:2010-04-07
Priority:Should have Due date:
Assigned To:Karsten Dambekalns % Done:

0%

Category:Reflection
Target version:-
PHP Version: Complexity:
Has patch: Affected Flow version:

Description

I have not looked into it in very much detail, but in extbase a problem occured when calling fluid from a pibased franmework. #7053

Since it is a result of the reflected Class and the parameter checking based on the type hints for the constructors, the following code results in an exception:

/**
     * Constructor. Can take an array, and initializes the objects with it.
     *
     * @param array $objectArray
     * @author Sebastian Kurfürst <sebastian@typo3.org>
     * @api
     */
    public function __construct($objectArray = array()) {
        if (!is_array($objectArray)) throw new RuntimeException('Context has to be initialized with an array, ' . gettype($objectArray) . ' given.', 1224592343);
        $this->objects = $objectArray;
    }

The @param requests an array parameter and the constructor creates an array if the constructor is called without a param.
This should somehow be considered by the reflection mechanisms.

History

#1 Updated by Karsten Dambekalns over 5 years ago

  • Category set to Reflection
  • Status changed from New to Closed
  • Assigned To set to Karsten Dambekalns
  • Start date changed from 2010-03-29 to 2010-04-07

The issue you refer to does is caused by a NULL being given to the constructor. Well, either an array or nothing works in this case, but NULL is not allowed. This is a result of the type hint used and must be observed by the calling code. It has nothing to do with reflection, sorry...

#2 Updated by Falk Kühnel over 5 years ago

I dit not realize, that calling a function without paramter and with an unset paramter (NULL) is making a difference. This turns my supposed workaround for #7053 into a real patch :D

Also available in: Atom PDF