Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NFR] Support for self/parent/static scopes in static properties #943

Merged
merged 1 commit into from Jul 27, 2013
Merged

[NFR] Support for self/parent/static scopes in static properties #943

merged 1 commit into from Jul 27, 2013

Conversation

ghost
Copy link

@ghost ghost commented Jul 27, 2013

This will allow to handle the situations like this:

class A
{
    static $prop = 1;

    public static function get()
    {
            return static::$prop;
    }
}

class B extends A
{
    static $prop = 2;
}

echo B::get(), "\n";

This can be useful if a child class wants to override parent's static property.

Supported types:

  • self::$property;
  • parent::$property;
  • static::$property (late static binding).

Added functions:

  • phalcon_fetch_self_class(): fetches zend_class_entry* corresponding to self;
  • phalcon_fetch_parent_class(): fetches zend_class_entry* corresponding to parent;
  • phalcon_fetch_static_class(): fetches zend_class_entry* corresponding to static;
  • phalcon_read_static_property_ce(): same as phalcon_read_static_property() but uses zend_class_entry* instead of class_name;
  • phalcon_update_static_property_ce(): same as phalcon_update_static_property() but uses zend_class_entry* instead of class_name;
  • phalcon_read_class_property(): phalcon_fetch_XXX_class() and phalcon_read_static_property_ce() combined

phalcon pushed a commit that referenced this pull request Jul 27, 2013
[NFR] Support for self/parent/static scopes in static properties
@phalcon phalcon merged commit 01fc115 into phalcon:1.3.0 Jul 27, 2013
@ghost ghost deleted the read_class_property branch July 27, 2013 23:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants