ZF-7184: Zend_CodeGenerator_Php_File::fromReflection receives Warning: Illegal offset type in...

Description

When I call something like: require 'test.php'; $file = new Zend_Reflection_File('test.php'); $a = Zend_CodeGenerator_Php_File::fromReflection($file);

I'm receiving this message:

Warning: Illegal offset type in /usr/share/php/Zend/CodeGenerator/Php/Class.php on line 294

Call Stack: 0.0008 106028 1. {main}() /home/jayson/Projetos/PHP_Organizer/organizer.php:0 0.0279 948648 2. Zend_CodeGenerator_Php_File::fromReflection() /home/jayson/Projetos/PHP_Organizer/organizer.php:188 0.0319 1131984 3. Zend_CodeGenerator_Php_Class::fromReflection() /usr/share/php/Zend/CodeGenerator/Php/File.php:153 0.0323 1134216 4. Zend_CodeGenerator_Php_Class->setProperties() /usr/share/php/Zend/CodeGenerator/Php/Class.php:127 0.0323 1134288 5. Zend_CodeGenerator_Php_Class->setProperty() /usr/share/php/Zend/CodeGenerator/Php/Class.php:270

Warning: Illegal offset type in /usr/share/php/Zend/CodeGenerator/Php/Class.php on line 294

Call Stack: 0.0008 106028 1. {main}() /home/jayson/Projetos/PHP_Organizer/organizer.php:0 0.0279 948648 2. Zend_CodeGenerator_Php_File::fromReflection() /home/jayson/Projetos/PHP_Organizer/organizer.php:188 0.0319 1131984 3. Zend_CodeGenerator_Php_Class::fromReflection() /usr/share/php/Zend/CodeGenerator/Php/File.php:153 0.0323 1134216 4. Zend_CodeGenerator_Php_Class->setProperties() /usr/share/php/Zend/CodeGenerator/Php/Class.php:127 0.0324 1134360 5. Zend_CodeGenerator_Php_Class->setProperty() /usr/share/php/Zend/CodeGenerator/Php/Class.php:270

Warning: Illegal offset type in /usr/share/php/Zend/CodeGenerator/Php/Class.php on line 294

Call Stack: 0.0008 106028 1. {main}() /home/jayson/Projetos/PHP_Organizer/organizer.php:0 0.0279 948648 2. Zend_CodeGenerator_Php_File::fromReflection() /home/jayson/Projetos/PHP_Organizer/organizer.php:188 0.0319 1131984 3. Zend_CodeGenerator_Php_Class::fromReflection() /usr/share/php/Zend/CodeGenerator/Php/File.php:153 0.0323 1134216 4. Zend_CodeGenerator_Php_Class->setProperties() /usr/share/php/Zend/CodeGenerator/Php/Class.php:127 0.0325 1134360 5. Zend_CodeGenerator_Php_Class->setProperty() /usr/share/php/Zend/CodeGenerator/Php/Class.php:270

I tried others PHP files and that error occurs in all that.

Best Regards Jayson Reis

Comments

I cannot reproduce this, are you running against trunk?

can you tell me what your test.php looks like?

my files look like this:

codegen.php


<?php
error_reporting(E_ALL | E_STRICT);
set_include_path('/Users/ralphschindler/Projects/ZFStandardTrunk/library');
require_once 'Zend/Reflection/File.php';
require_once 'Zend/CodeGenerator/Php/File.php';

require 'test.php';
$file = new Zend_Reflection_File('test.php');
$a = Zend_CodeGenerator_Php_File::fromReflection($file);

echo $a->getClass()->getProperty('bar')->getDefaultValue()->getValue();

test.php


~/tmp/test-codegenerator$ cat test.php 
<?php


class Foo
{

   public $bar = 5;

}

Hello Ralph. I'm running against version 1.8.4. This is the code.

test.php <?php class Test { public $foo;

public function foo2($bar, $baz)
{
    return $bar + $baz;
}

}

testReflection.php <?php require_once 'test.php'; require_once 'Zend/Reflection/File.php'; require_once 'Zend/CodeGenerator/Php/File.php'; Zend_CodeGenerator_Php_File::fromReflectedFileName('test.php');

Can you try running against trunk? There have been new features over the past few weeks.

Hello Ralph, running against trunk that work's fine. Do you know when that trunk will be release as stable ? Best Regards Jayson Reis

This seems to be fixed in 1.9