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

Static methods and properties accessed through a variable are not detected #213

Closed
jack126guy opened this issue Dec 3, 2015 · 5 comments
Assignees
Labels
Milestone

Comments

@jack126guy
Copy link

The following code is reported as requiring PHP 5.0.0. However, accessing static methods and properties through a variable with the class name was added in PHP 5.3.0.

<?php
class MyClass {
        public static $t = 't';
        public static function test() {
                //Do something
        }
}

$name = 'MyClass';

//Following lines are supported only in PHP 5.3+
$name::test();
echo $name::$t;
@jack126guy jack126guy changed the title Static methods and properties called through a variable are not detected Static methods and properties accessed through a variable are not detected Dec 3, 2015
@llaville llaville added the bug label Dec 3, 2015
@llaville llaville self-assigned this Dec 3, 2015
@llaville llaville added this to the 5.0.0 milestone Dec 3, 2015
@llaville
Copy link
Owner

llaville commented Dec 3, 2015

Backport to branch 4.5 is planned later. Major version 5.0 (stable) is planned for saturday (+2 days now)

@llaville llaville closed this as completed Dec 4, 2015
@jack126guy
Copy link
Author

👍

Unfortunately, the issue is only partly solved. The case of a static method is handled, but not a static property. Perhaps I should have split my test file into two:

<?php
class MyClass {
        public static function test() {
                //Do something
        }
}

$name = 'MyClass';

//Following line is supported only in PHP 5.3+
$name::test();
<?php
class MyClass {
        public static $t = 't';
}

$name = 'MyClass';

//Following line is supported only in PHP 5.3+
echo $name::$t;

@llaville llaville reopened this Mar 8, 2022
@llaville
Copy link
Owner

llaville commented Mar 8, 2022

Don't noticed your comment, when you wrote it ! Sorry, but better late than never ;-)

Will be fixed with upcoming release 6.4

@llaville
Copy link
Owner

llaville commented Mar 8, 2022

@jack126guy Now both use case are detected : see new specialized DynamicAccessSniff and unit tests Php53IssueTest.

@llaville llaville closed this as completed Mar 8, 2022
@llaville
Copy link
Owner

llaville commented Mar 8, 2022

Rule Reporter that is marked as experimental since previous release 6.3, give now expected results.

When invoking following command bin/phpcompatinfo analyser:run tests/fixtures/features/php53/ --output rule

gh213-rule-report

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

No branches or pull requests

2 participants