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

Fix: Ignore method named after reserved keywords #41

Merged
merged 3 commits into from
Apr 25, 2018

Conversation

localheinz
Copy link
Member

@localheinz localheinz commented Sep 16, 2017

This PR

  • asserts that ClassFileLocator ignores methods named after reserved keywords when they have return type declarations
  • adjusts ClassFileLocator

💁‍♂️ Ran into a weird issue when ClassFileLocator inspected something like

final class Foo
{
    public function class() : string
    {
        return self::class;
    }
}

on PHP 7.1 and reported two classes

  • Foo
  • string

@localheinz localheinz added the bug label Sep 16, 2017
@localheinz localheinz self-assigned this Sep 16, 2017
@localheinz localheinz force-pushed the fix/reserved branch 3 times, most recently from 7460df2 to 21595e0 Compare October 9, 2017 16:44
Patch zendframework#41 originally was providing a unit test demonstrating a problem
in PHP 7.1 and up: the tokenizer is classifying method names such as
`class`, `interface`, and `trait` as their associated tokens, instead of
as literal strings.

The changes in this patch add some logic to test for `T_FUNCTION` token
and set a flag indicating we are in a function declaration. Once an
opening paren (`(`) is discovered, the flag is reset. This prevents
mis-identifying such function names as tokens.
@weierophinney weierophinney merged commit 45fe50d into zendframework:develop Apr 25, 2018
weierophinney added a commit that referenced this pull request Apr 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants