Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Don't ignore files with use function #44

Merged
merged 1 commit into from
May 1, 2018

Conversation

weirdan
Copy link
Contributor

@weirdan weirdan commented May 1, 2018

Previously ClassFileLocator would enter a "function context" when it encountered T_FUNCTION token, causing it to ignore subsequent classes (thinking they are defined in a function), ultimately leading to the file being ignored because ClassFileLocator thought there's no (named) classes defined in the file.

Now it will additionally check that the T_FUNCTION token is not preceded by T_USE, fixing the bug.

Steps to reproduce:

  • Create a file, containing a class, and import a function in that class with use function (see ContainsUseFunction.php in the test asset folder).
  • Create a ClassFileLocator for a folder containing that file
  • Iterate over the locator

Expected

The file should be found, and contain the class

Actual

The file is ignored

Checklist

  • Are you fixing a bug?
    • Detail how the bug is invoked currently.
    • Detail the original, incorrect behavior.
    • Detail the new, expected behavior.
    • Base your feature on the master branch, and submit against that branch.
    • Add a regression test that demonstrates the bug, and proves the fix.
    • Add a CHANGELOG.md entry for the fix.

Previously `ClassFileLocator` would enter a "function context" when it
encountered `T_FUNCTION` token, causing it to ignore subsequent classes
(thinking they are defined in a function), ultimately leading to the
file being ignored because ``ClassFileLocator`` thought there's no
(named) classes defined in the file.

Now it will additionally check that the `T_FUNCTION` token is not
preceded by `T_USE`, fixing the bug.
@weierophinney weierophinney merged commit 0aa4d35 into zendframework:master May 1, 2018
weierophinney added a commit that referenced this pull request May 1, 2018
weierophinney added a commit that referenced this pull request May 1, 2018
weierophinney added a commit that referenced this pull request May 1, 2018
Forward port #44

Conflicts:
	CHANGELOG.md
@weierophinney
Copy link
Member

Thanks, @weirdan!

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

Successfully merging this pull request may close these issues.

2 participants