Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Fixing "Undefined offset" error in ReflectionMethod::isEmpty() #102

Merged
merged 1 commit into from Oct 3, 2012

Conversation

Projects
None yet
3 participants
Contributor

iteman commented Sep 27, 2012

Since the path element is not always the second element of the array, an error Undefined offset: 2 will be raised in the ReflectionMethod::isEmpty() method.

Fixed a defect that caused an error "Undefined offset: 2" to be raise…
…d in the ReflectionMethod::isEmpty() method.
Owner

MarcelloDuarte commented Oct 2, 2012

@iteman does that actually fixes the issue? I see the new line character being used "\n" in your fix. Since you are on it can you please replace the "\n" with PHP_EOL and re-submit? thanks.

Contributor

iteman commented Oct 3, 2012

The \n has existed since f9ed1b6.

Since \n is always linefeed (LF, 0x0a) and the return value of ReflectionMethod::__toString() is always concatenated with linefeed regardless of platform, this code will work on any platform. And PHP_EOL will not work on Windows and Mac.

Owner

MarcelloDuarte commented Oct 3, 2012

@iteman ok...
@adrianmoya can you please check @iteman PR for us under Windows? thanks both.

Contributor

adrianmoya commented Oct 3, 2012

@iteman @MarcelloDuarte sure, is there a specific test you want me to try? under what condition the error was rised?

Owner

MarcelloDuarte commented Oct 3, 2012

@adrianmoya try leave an example empty. This is the use case in which this reflection call happens. Thanks.

Contributor

adrianmoya commented Oct 3, 2012

@MarcelloDuarte Leaving an example empty doesn't fail in the current stable version (1.4.2.) on windows. Any other case that could trigger this error?

Owner

MarcelloDuarte commented Oct 3, 2012

@iteman can you please provide an example of a case where this error is produced? Whatever context you can give is much appreciated. Thanks.

Contributor

iteman commented Oct 3, 2012

@adrianmoya @MarcelloDuarte Any PHPDoc tag will produce this error as the following:

    /**
     * @since Method available since Release 3.0.0
     */
    public function itShouldFail()
    {
        $this->spec(false)->should->beTrue();
    }
Contributor

adrianmoya commented Oct 3, 2012

Ok, I was able to reproduce the error in windows, and the fix works fine.

Owner

MarcelloDuarte commented Oct 3, 2012

Thanks all!

MarcelloDuarte added a commit that referenced this pull request Oct 3, 2012

Merge pull request #102 from iteman/fixing-reflectionmethod-isempty-e…
…rror

Fixing "Undefined offset" error in ReflectionMethod::isEmpty()

@MarcelloDuarte MarcelloDuarte merged commit cb54c94 into phpspec:master Oct 3, 2012

Contributor

iteman commented Oct 3, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment