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

False positive on php4 constructors #28

Closed
pylebecq opened this issue Jun 1, 2018 · 5 comments
Closed

False positive on php4 constructors #28

pylebecq opened this issue Jun 1, 2018 · 5 comments

Comments

@pylebecq
Copy link

pylebecq commented Jun 1, 2018

Hi,

I tried running PhpCodeFixer on the Elastica library (https://github.com/ruflin/Elastica).
There are a lot of false positive related to usage of php4 constructors.

This library already uses php5 constructors but, in addition, some classes also have a method having the same name.

I think the detection of php4 could be improved by using the same rules written in the RFC that deprecated php4 constructors:

PHP 7 will emit E_DEPRECATED whenever a PHP 4 constructor is defined. When the method name matches the class name, the class is not in a namespace, and a PHP 5 constructor (__construct) is not present then an E_DEPRECATED will be emitted. PHP 8 will stop emitting E_DEPRECATED and the methods will not be recognized as constructors.

PHP 7 will also stop emitting E_STRICT when a method with the same name as the class is present as well as __construct.

Source: https://wiki.php.net/rfc/remove_php4_constructors

@wapmorgan
Copy link
Owner

Hello. Which version of Elastica you tried?

@pylebecq
Copy link
Author

pylebecq commented Jun 1, 2018

The last one, 6.0.2.

Max file size set to: 1.000 MiB
Scanning /project/Elastica-6.0.2 ...

Folder /project/Elastica-6.0.2
PHP | File:Line | Type | Issue
7.0 | /lib/Elastica/Log.php:46 | method_name | Method name log:Log (@php4_constructors) is deprecated.
7.0 | /lib/Elas../M../Search.php:140 | method_name | Method name search:Search (@php4_constructors) is deprecated.
7.0 | /lib/Elastica/Search.php:441 | method_name | Method name search:Search (@php4_constructors) is deprecated.

Total problems: 3
Peak memory usage: 2.859 MB

@wapmorgan
Copy link
Owner

wapmorgan commented Jun 1, 2018

Oh, I see. Really, phpcf is syntax-level checker with few improvements. It does not check other methods or class namespace right now. May be I'll find time to rewrite and make it more intelligent, but this requires a lot of changes in internal structure.

@fwolfsjaeger
Copy link
Contributor

I'm having the same issue, so if you don't mind I'd fix this.

@wapmorgan
Copy link
Owner

Try phpcf dev-master version now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants