diff --git a/bin/phpstan b/bin/phpstan index ade9dab..04bd637 100755 --- a/bin/phpstan +++ b/bin/phpstan @@ -2,5 +2,5 @@ cd $(dirname $0) -../vendor/bin/phpstan analyze --level=5 ../lib $@ +../vendor/bin/phpstan analyze -c ../phpstan.neon $@ diff --git a/composer.json b/composer.json index ec2ff35..304321d 100644 --- a/composer.json +++ b/composer.json @@ -34,7 +34,7 @@ } ], "require": { - "php": ">=7.4" + "php": ">=8.0" }, "autoload": { "psr-0": { diff --git a/composer.lock b/composer.lock index b4d377b..fa8e7fc 100644 --- a/composer.lock +++ b/composer.lock @@ -9,20 +9,20 @@ "packages-dev": [ { "name": "nette/tester", - "version": "v2.4.2", + "version": "v2.5.3", "source": { "type": "git", "url": "https://github.com/nette/tester.git", - "reference": "2e788e243bb17a6889aac5411f3fabc48cc5b23a" + "reference": "ee0a4b8402a8c1831db547ec0a56d18196906b51" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/tester/zipball/2e788e243bb17a6889aac5411f3fabc48cc5b23a", - "reference": "2e788e243bb17a6889aac5411f3fabc48cc5b23a", + "url": "https://api.github.com/repos/nette/tester/zipball/ee0a4b8402a8c1831db547ec0a56d18196906b51", + "reference": "ee0a4b8402a8c1831db547ec0a56d18196906b51", "shasum": "" }, "require": { - "php": ">=7.2 <8.2" + "php": "8.0 - 8.3" }, "require-dev": { "ext-simplexml": "*", @@ -34,7 +34,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.4-dev" + "dev-master": "2.5-dev" } }, "autoload": { @@ -78,22 +78,22 @@ ], "support": { "issues": "https://github.com/nette/tester/issues", - "source": "https://github.com/nette/tester/tree/v2.4.2" + "source": "https://github.com/nette/tester/tree/v2.5.3" }, - "time": "2022-03-24T19:02:37+00:00" + "time": "2024-06-18T18:44:12+00:00" }, { "name": "phpstan/phpstan", - "version": "1.5.7", + "version": "1.12.6", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "7fb7e2e1e9f3d59a26a413b2d3d5e47f0edb75ac" + "reference": "dc4d2f145a88ea7141ae698effd64d9df46527ae" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/7fb7e2e1e9f3d59a26a413b2d3d5e47f0edb75ac", - "reference": "7fb7e2e1e9f3d59a26a413b2d3d5e47f0edb75ac", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/dc4d2f145a88ea7141ae698effd64d9df46527ae", + "reference": "dc4d2f145a88ea7141ae698effd64d9df46527ae", "shasum": "" }, "require": { @@ -117,9 +117,16 @@ "MIT" ], "description": "PHPStan - PHP Static Analysis Tool", + "keywords": [ + "dev", + "static analysis" + ], "support": { + "docs": "https://phpstan.org/user-guide/getting-started", + "forum": "https://github.com/phpstan/phpstan/discussions", "issues": "https://github.com/phpstan/phpstan/issues", - "source": "https://github.com/phpstan/phpstan/tree/1.5.7" + "security": "https://github.com/phpstan/phpstan/security/policy", + "source": "https://github.com/phpstan/phpstan-src" }, "funding": [ { @@ -129,17 +136,9 @@ { "url": "https://github.com/phpstan", "type": "github" - }, - { - "url": "https://www.patreon.com/phpstan", - "type": "patreon" - }, - { - "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", - "type": "tidelift" } ], - "time": "2022-04-20T12:20:27+00:00" + "time": "2024-10-06T15:03:59+00:00" } ], "aliases": [], @@ -151,5 +150,5 @@ "php": ">=7.4" }, "platform-dev": [], - "plugin-api-version": "2.1.0" + "plugin-api-version": "2.3.0" } diff --git a/lib/hafriedlander/Peg/Compiler/Rule.php b/lib/hafriedlander/Peg/Compiler/Rule.php index 5ffa30f..353eb84 100644 --- a/lib/hafriedlander/Peg/Compiler/Rule.php +++ b/lib/hafriedlander/Peg/Compiler/Rule.php @@ -171,7 +171,7 @@ public function tokenize($str, &$tokens, $o = 0) { } /* Handle expression labels */ elseif (\preg_match('/\G(\w*):/', $str, $match, 0, $o)) { - $pending->set('tag', $match[1] ?? ''); + $pending->set('tag', $match[1] ?: ''); $o += \strlen($match[0]); } /* Handle descent token */ diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..2379ae3 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,5 @@ +parameters: + level: 5 + paths: + - ./lib + - ./tests diff --git a/tests/CachedRegexp.phpt b/tests/CachedRegexp.phpt index 7bd39fb..3354139 100644 --- a/tests/CachedRegexp.phpt +++ b/tests/CachedRegexp.phpt @@ -1,9 +1,11 @@ assertMatches('Expression', '1 + 2 * 3 + 4 + 4 + 4 + 4 + 4 / 5 - 6 + 7 * 8 - 9'); $parser->assertDoesntMatch('Expression', 'variables + do + not + exist'); diff --git a/tests/ParserSyntax.phpt b/tests/ParserSyntax.phpt index 6b85555..7d43c8e 100644 --- a/tests/ParserSyntax.phpt +++ b/tests/ParserSyntax.phpt @@ -1,5 +1,7 @@ buildParser(' - /*!* RecurseOnVariablesParser - A: "a" - B: "b" - Foo: $Template - Bar: Foo - function __construct(&$res){ $res["Template"] = "A"; } - Baz: Foo - function __construct(&$res){ $res["Template"] = "B"; } - */ + /*!* RecurseOnVariablesParser + A: "a" + B: "b" + Foo: $Template + Bar: Foo + function __construct(&$res){ $res["Template"] = "A"; } + Baz: Foo + function __construct(&$res){ $res["Template"] = "B"; } + */ '); $parser->assertMatches('Bar', 'a'); diff --git a/tests/bootstrap.php b/tests/bootstrap.php index f9f5275..1c4f485 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -1,5 +1,7 @@ + */ + private string $parserClass; + function __construct(string $parserClass) { $this->parserClass = $parserClass; } @@ -59,11 +67,14 @@ function assertDoesntMatch($method, $string, $message = null) { class ParserTestBase extends TestCase { - function buildParser($grammar, $baseClass = 'Basic') { + function buildParser( + string $grammar, + string $baseClass = Basic::class, + ): ParserTestWrapper { $class = 'Parser_' . md5(uniqid()); eval(Peg\Compiler::compile(" - class $class extends hafriedlander\Peg\Parser\\$baseClass { + class $class extends $baseClass { $grammar } "));