Skip to content

SELF is not recognised as T_SELF token in: return new self #1245

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

Closed
michalbundyra opened this issue Dec 15, 2016 · 1 comment
Closed

SELF is not recognised as T_SELF token in: return new self #1245

michalbundyra opened this issue Dec 15, 2016 · 1 comment

Comments

@michalbundyra
Copy link
Contributor

class MyClass {
  public static function getInstance() {
    return new self;
  }
}

In above, self is recognised as T_STRING token, not as T_SELF token.

michalbundyra added a commit to zendframework/zend-coding-standard that referenced this issue Dec 15, 2016
@gsherwood gsherwood changed the title "self" is not recognised as T_SELF token in "return new self" SELF is not recognised as T_SELF token in: return new self Dec 21, 2016
@gsherwood
Copy link
Member

I've fixed the tokenizer for this specific case. Thanks for the report.

jrfnl added a commit to jrfnl/PHPCompatibility that referenced this issue Dec 22, 2016
Fixes failing unit tests caused by changed behaviour of PHPCS > 2.7.1.
See:
* squizlabs/PHP_CodeSniffer@79cd3dc
* squizlabs/PHP_CodeSniffer#1245
jrfnl added a commit to PHPCSStandards/PHPCSUtils that referenced this issue May 17, 2024
….8.0

In PHPCS < 2.8.0, the `self` in `return new self` would be tokenized as `T_STRING`, not `T_SELF`.

This commit adds a work-around to the utility method to handle the situation correctly.

Includes a unit test covering the issue.

Ref: squizlabs/PHP_CodeSniffer#1245
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

2 participants