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

Reserved class method names are scrambled under certain conditions #11

Closed
mologie opened this issue Dec 22, 2015 · 3 comments
Closed

Reserved class method names are scrambled under certain conditions #11

mologie opened this issue Dec 22, 2015 · 3 comments

Comments

@mologie
Copy link

mologie commented Dec 22, 2015

When limiting the scope of predefined functions which are scanned, the scrambler catches some reserved function names such as __call because they do not appear in any of the scanned predefined classes.

The reason for this is that in scrambler.php, line 265, t_ignore is populated with a list of reserved functions, not methods. No fancy example this time ;).

@pk-fr
Copy link
Owner

pk-fr commented Dec 25, 2015

in scrambler.php, line 265, t_ignore is populated with a list of reserved functions, not methods.

As you can see in http://php.net/manual/en/reserved.keywords.php:
These words have special meaning in PHP. Some of them represent things which look like functions, some look like constants, and so on - but they're not, really: they are language constructs. You cannot use any of the following words as constants, class names, function or method names.

_call is processed differently, it is part of $t_reserved_method_names:
as you can see in http://php.net/manual/en/language.oop5.magic.php:
The function names __construct(), __destruct(), __call(), __callStatic(), __get(), __set(), __isset(), __unset(), __sleep(), __wakeup(), __toString(), __invoke(), __set_state(), __clone() and __debugInfo() are magical in PHP classes. You cannot have functions with these names in any of your classes unless you want the magic functionality associated with them.

@pk-fr pk-fr closed this as completed Dec 25, 2015
@mologie
Copy link
Author

mologie commented Dec 25, 2015

Hello, this issue is not resolved - please reopen. We may have misunderstood eachother.

The issue is that I do want the functionality of __call, but the scrambler replaces __call by something random. The resulting code is not equivalent to the input, so this is a bug.

Please check this line:

https://github.com/pk-fr/yakpro-po/blob/master/include/classes/scrambler.php#L265

The t_ignore array is only populated with reserved functions, which may in itself be correct like you described. (But take care: You do not ignore reserved functions in any other context either, and I do not see the advantage of doing so when dealing with function method names on the input side anyway.)

The ignore list should additionally be populated with $this->t_reserved_method_names so that magic method names like __call are not scrambled.

pk-fr added a commit that referenced this issue Dec 25, 2015
@pk-fr
Copy link
Owner

pk-fr commented Dec 25, 2015

Hi Oliver,
I misunderstood what you were trying to tell me (perhaps due to the lack of a small example ;o) )...
There is effectively a bug due to the new config file $conf->t_ignore_pre_defined_classes element introduced in 1.8.0 , replacing the old $conf->t_ignore_module_methods ...
The internal associated $t_reserved_method_names property had its structure changed... but the code near the line 265 was not changed accordingly...
additionally, there was a side effect of the $conf->t_ignore_pre_defined_classes with the default value 'all' was hiding the issue.
fixed in 1.8.5 (I hope so)
Happy Christmas...

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

No branches or pull requests

2 participants