Skip to content

Conversation

@reeze
Copy link
Contributor

@reeze reeze commented Mar 6, 2013

See bug https://bugs.php.net/bug.php?id=61025

This patch make __invoke() visibility consist with other magic methods.

reeze added 3 commits March 6, 2013 23:37
- check visibility of __invoke when calling
- make is_callable consist
- Add the ZEND_ACC_CLOSURE flag to the closure created with: zend_create_closure()
Related to bug #61025
Consist with similar magic methods which will raise warning
when modified with improper modifiers
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don’t we miss a return 0 here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I only see four conditions, they are closure function and other three possible ZEND_ACC_PPP* flags.
or else it's common function, but that wouldn't happen when get the function with get_closure

@laruence
Copy link
Member

laruence commented Mar 7, 2013

I don't think this need to be fixed in this way, like __call:

<?php

class Bar {
    private function __call($name, $value) {
        return __CLASS__;
    }
}

$b = new Bar;
$b->__call("name", NULL);

works well, but with an warning:

Warning: The magic method __call() must have public visibility and cannot be static 

I am not sure whether this is a bug, or just need document.

@jpauli
Copy link
Member

jpauli commented Mar 7, 2013

This patch is inconsistent with what actually exist.
Actually, __magics() signature are checked at compile time, not at run-time. This patch adds runtime checks for __invoke() , which IMO is wrong.

I think it's better to stay consistent and add the checks in the zend_compile.c cases.
Visibility is never checked at runtime for __magics() (but used to be).

@php-pulls
Copy link

Comment on behalf of laruence at php.net:

wrong fix, closed

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.

5 participants