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

Usage of self within a closure #215

Closed
shadyvb opened this issue Feb 5, 2014 · 3 comments · Fixed by #216
Closed

Usage of self within a closure #215

shadyvb opened this issue Feb 5, 2014 · 3 comments · Fixed by #216
Labels

Comments

@shadyvb
Copy link
Contributor

shadyvb commented Feb 5, 2014

See http://wordpress.org/support/topic/temporary-fatal-error-after-upgrade-113?replies=2

Fatal error: Cannot access self:: when no class scope is active in /home/cbbtest/public_html/wp-content/plugins/stream/connectors/settings.php on line 317
@westonruter
Copy link
Contributor

@shadyvb another way that I get around this problem is to do this:

$self = __CLASS__;
$func = function () use ( $self ) {
    $self::foo();
};

But this is fixed in PHP 5.4 I believe.

@shadyvb
Copy link
Contributor Author

shadyvb commented Feb 5, 2014

I did it in two different ways, yours, and using $callback = array( __CLASS__, 'function' ); but ultimately thought that this is a fairly simple loop, why not foreach ? and i switched to that.

@westonruter
Copy link
Contributor

Exactly. Your solution is great.

@shadyvb shadyvb closed this as completed in be68090 Feb 6, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants