Skip to content
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

Fatal error on version 3.0: Argument 1 passed to Parser::unexpectedSyntaxError() must be of the type array, null given #124

Closed
emodric opened this issue Mar 7, 2018 · 6 comments
Labels

Comments

@emodric
Copy link

emodric commented Mar 7, 2018

Hi, I'm using PHP Matcher 3.0 on PHP 7.2.

The following script:

<?php

require 'vendor/autoload.php';

use Coduo\PHPMatcher\Factory\SimpleFactory;

$matcher = (new SimpleFactory)->createMatcher();

$a = '{"foo": "","bar": "baz"}';
$b = '{"foo": "","bar": "bazz"}';

$match = $matcher->match($a, $b);

results in the following exception:

PHP Fatal error:  Uncaught TypeError: Argument 1 passed to Coduo\PHPMatcher\Parser::unexpectedSyntaxError() must be of the type array, null given, called in vendor/coduo/php-matcher/src/Parser.php on line 62 and defined in vendor/coduo/php-matcher/src/Parser.php:248
Stack trace:
#0 vendor/coduo/php-matcher/src/Parser.php(62): Coduo\PHPMatcher\Parser->unexpectedSyntaxError(NULL, '@type@ pattern')
#1 vendor/coduo/php-matcher/src/Parser.php(50): Coduo\PHPMatcher\Parser->getPattern()
#2 vendor/coduo/php-matcher/src/Parser.php(29): Coduo\PHPMatcher\Parser->getAST('')
#3 vendor/coduo/php-matcher/src/Matcher/StringMatcher.php(43): Coduo\PHPMatcher\Parser->hasValidSyntax('')
#4 vendor/coduo/php-matcher/src/Matcher/ChainMatcher.php(32): Coduo\PHPMatcher\Matcher\StringMatcher->canMatch('')
#5  in vendor/coduo/php-matcher/src/Parser.php on line 248

With PHP Matcher 2.4 works as expected, returning false.

@emodric
Copy link
Author

emodric commented Mar 7, 2018

git bisect says that this is the culprit: #104, mainly, introducing typeints to Coduo\PHPMatcher\Parser::unexpectedSyntaxError.

Indeed, rolling back to a commit before that PR makes everything work again.

However, it may be possible that introducing type hints to Coduo\PHPMatcher\Parser::unexpectedSyntaxError revealed a deeper issue somewhere else in the code.

@emodric
Copy link
Author

emodric commented Mar 7, 2018

Seems that it's already fixed by #119.

@norzechowicz Can we get a 3.0.1 tag with the fix? :)

@norberttech
Copy link
Member

norberttech commented Mar 7, 2018

@emodric sure, I will first need to cherry pick #119 to 3.0 branch and then I can tag 3.0.1.
I will do my best to make it available asap
Thanks for reporting and investigation 🍻

@emodric
Copy link
Author

emodric commented Mar 7, 2018

Thank you @norzechowicz! 🍻

@norberttech
Copy link
Member

https://github.com/coduo/php-matcher/releases/tag/3.0.1 here you go, please let me know if it works now!

@emodric
Copy link
Author

emodric commented Mar 9, 2018

Thanks @norzechowicz, it works fine 🎉

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

No branches or pull requests

2 participants