Bug #7055

possible reflection problem.

Added by Falk Kühnel over 11 years ago. Updated about 11 years ago.

Status:
Closed
Priority:
Should have
Category:
Reflection
Target version:
-
Start date:
2010-04-07
Due date:
% Done:

0%

Estimated time:
PHP Version:
Has patch:
Complexity:

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.

#1

Updated by Karsten Dambekalns over 11 years ago

  • Category set to Reflection
  • Status changed from New to Closed
  • Assignee 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 11 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