Skip to content

Conversation

jrfnl
Copy link
Collaborator

@jrfnl jrfnl commented Jan 18, 2020

While $this can be used freely within classes, traits and closures, if a nested closed scope is defined within any of these, $this is not inherited and should be considered undefined.

As things were, the sniff would not throw a warning for this (false negative).
This commit fixes this.

Includes unit tests.

Includes removing an outdated comment. T_CLOSURE works perfectly fine with the conditions array (and has for quite a few years).

Fixes #109

While `$this` can be used freely within classes, traits and closures, if a nested closed scope is defined within any of these, `$this` is not inherited and should be considered undefined.

As things were, the sniff would not throw a warning for this (false negative).
This commit fixes this.

Includes unit tests.

Includes removing an outdated comment. `T_CLOSURE` works perfectly fine with the conditions array (and has for quite a few years).

Fixes 109
@sirbrillig
Copy link
Owner

👍 Thanks!

@sirbrillig sirbrillig merged commit 49b2d8b into sirbrillig:master Jan 20, 2020
@jrfnl jrfnl deleted the feature/109-bugfix-this-in-nested-function branch January 20, 2020 18:32
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.

False negative: $this in nested function declarations
2 participants