Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Zephir: read static property

As i see the zephir for the current time not supports the Late Static Bindings for static properties. So i try to use inject C-macros to zephir... and got exception.

namespace Igor;

class Abc
   public static myproperty = "Hello ABC";

   public static function printer()
        var className, value = null;
        let className = get_called_class();

            zephir_read_static_property(&value, Z_STRVAL_P(className), Z_STRLEN_P(className), SS("myproperty") TSRMLS_CC);

        echo value;

then i try to direct read static property from php. It's OK.

echo Igor\Abc::$myproperty; // OK

when i call printer... i get error.

 Igor\Abc::printer(); // FAIL


*PHP Fatal error:  Access to undeclared static property: Igor\Abc::$myproperty in ....*

So i can't Late Static Bindings for properties with C-injections TOO. :(

my extended class:

class SomeTest extends \Igor\Abc
    public static $myproperty = "Hello TEST";

\Igor\Abc::printer(); // Hello ABC
SomeTest::printer(); // Hello TEST

Have ideas?


Hello, you can better post this question in the Zephir forum:

In my tool php-to-c-ext, i find a way to make it work, not in zephir level,but in php level.

For me, late static binding, trait... all are suggars feature but not too hard to fullfil.