Skip to content

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

@emodric

Description

@emodric

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions