Skip to content

Fixed Bug #61025 __invoke() visibility not honored - #298

Closed
reeze wants to merge 3 commits into
php:PHP-5.5from
reeze:bug-61025-invoke-visibility
Closed

reeze wants to merge 3 commits into
php:PHP-5.5from
reeze:bug-61025-invoke-visibility

Conversation

@reeze

@reeze reeze commented Mar 6, 2013

Copy link
Copy Markdown
Contributor

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
Comment thread Zend/zend_API.c

Copy link
Copy Markdown
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
Copy Markdown
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

laruence commented Mar 7, 2013

Copy link
Copy Markdown
Member

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

jpauli commented Mar 7, 2013

Copy link
Copy Markdown
Member

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
Copy Markdown

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