From 131f0e2d7b8ebadb8fcb1177f01761fe7acb0077 Mon Sep 17 00:00:00 2001 From: Jesus Ochoa Date: Mon, 3 Apr 2023 00:35:41 -0300 Subject: [PATCH 1/4] chore(version-php): updating the version v8.0 and package name updated just to registred the package in the remote cotainer --- composer.json | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 860eaa4..c9fdd5c 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "wouterj/peg", + "name": "yisus/peg", "description": "A PEG parser for PHP", "license": "BSD-3-Clause", "authors": [ @@ -8,11 +8,9 @@ "email": "wouter@wouterj.nl" } ], - "require": { - "php": "^7.0" + "php": "^8.0" }, - "autoload": { "psr-4": { "WouterJ\\Peg\\": "src/" } }, From 501c1b78876c47dbab8a40f522b1e71023194fb2 Mon Sep 17 00:00:00 2001 From: Jesus Ochoa Date: Mon, 3 Apr 2023 16:16:13 -0300 Subject: [PATCH 2/4] test(php-unit): adding php unit to the composer file --- composer.json | 5 ++++- tests/GrammarTest.php | 4 +++- tests/ParserTest.php | 17 ++++++++--------- tests/PegGrammarTest.php | 6 ++++-- 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/composer.json b/composer.json index c9fdd5c..abbfc72 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "yisus/peg", + "name": "woutej/peg", "description": "A PEG parser for PHP", "license": "BSD-3-Clause", "authors": [ @@ -16,5 +16,8 @@ }, "autoload-dev": { "psr-4": { "WouterJ\\Peg\\": "tests/" } + }, + "require-dev": { + "phpunit/phpunit": "^9.6" } } diff --git a/tests/GrammarTest.php b/tests/GrammarTest.php index fc7143b..89d639e 100644 --- a/tests/GrammarTest.php +++ b/tests/GrammarTest.php @@ -11,10 +11,12 @@ namespace WouterJ\Peg; +use PHPUnit\Framework\TestCase; + /** * @author Wouter de Jong */ -class GrammarTest extends \PHPUnit_Framework_TestCase +class GrammarTest extends TestCase { public function testPredicates() { diff --git a/tests/ParserTest.php b/tests/ParserTest.php index e44119a..49b965a 100644 --- a/tests/ParserTest.php +++ b/tests/ParserTest.php @@ -12,11 +12,12 @@ namespace WouterJ\Peg; use WouterJ\Peg\Exception\DefinitionException; +use PHPUnit\Framework\TestCase; /** * @author Wouter de Jong */ -class ParserTest extends \PHPUnit_Framework_TestCase +class ParserTest extends TestCase { public function testLiteral() { @@ -187,12 +188,11 @@ public function testActions() $this->assertSame(12, $parser->parse('Int', '12')->value()); } - /** - * @expectedException \WouterJ\Peg\Exception\DefinitionException - * @expectedExceptionMessage did you mean one of these `Everything`? - */ public function testUnknownDefinition() { + $this->expectExceptionMessage("did you mean one of these `Everything`?"); + $this->expectException(\WouterJ\Peg\Exception\DefinitionException::class); + $parser = new Parser([ new Definition('Everything', ['any']), new Definition('Digit', ['characterClass', '0-9']), @@ -201,12 +201,11 @@ public function testUnknownDefinition() $parser->parse('Everyting', 'a'); } - /** - * @expectedException \WouterJ\Peg\Exception\DefinitionException - * @expectedExceptionMessageRegExp /^Invalid definition `Foo`: Undefined operator `undefined`\./ - */ public function testInvalidDefinition() { + $this->expectExceptionMessageMatches("/^Invalid definition `Foo`: Undefined operator `undefined`\./"); + $this->expectException(\WouterJ\Peg\Exception\DefinitionException::class); + $parser = new Parser([ new Definition('Mine', ['identifier', 'Custom']), new Definition('Custom', ['identifier', 'Foo']), diff --git a/tests/PegGrammarTest.php b/tests/PegGrammarTest.php index f4e7dfb..c3f1d94 100644 --- a/tests/PegGrammarTest.php +++ b/tests/PegGrammarTest.php @@ -11,10 +11,12 @@ namespace WouterJ\Peg; +use PHPUnit\Framework\TestCase; + /** * @author Wouter de Jong */ -class PegGrammarTest extends \PHPUnit_Framework_TestCase +class PegGrammarTest extends TestCase { /** @dataProvider getGrammars */ public function testGrammar($filePath) @@ -29,7 +31,7 @@ public function testGrammar($filePath) public function getGrammars() { return [ - //[__DIR__.'/fixtures/example1.peg'], + [__DIR__.'/fixtures/example1.peg'], [__DIR__.'/fixtures/simple.peg'], ]; } From ba7060e8cbd45498f6686bd6ab1c1ac3b7453a34 Mon Sep 17 00:00:00 2001 From: Jesus Ochoa Date: Wed, 7 Jun 2023 17:27:18 -0300 Subject: [PATCH 3/4] refactor(fix-unit-test): updating thee clasure in PEG lib related with CMX-430 --- src/PegGrammar.php | 4 ++-- tests/PegGrammarTest.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/PegGrammar.php b/src/PegGrammar.php index fa9e821..a924b0a 100644 --- a/src/PegGrammar.php +++ b/src/PegGrammar.php @@ -55,7 +55,7 @@ public function __construct() return $nested[0]; } - return ['choice', array_merge([$nested[0]], array_map('next', $nested[1]))]; + return ['choice', array_merge([$nested[0]], array_map(fn($param) => next($param), $nested[1]))]; }), // Sequence <- Prefix* new Definition('Sequence', ['repeat', ['identifier', 'Prefix']], function ($nested) { @@ -190,7 +190,7 @@ public function __construct() ['identifier', 'Spacing'], ]], ]], function ($nested) { - return ['literal', implode('', array_map('next', $nested[1]))]; + return ['literal', implode('', array_map(fn($param) => next($param), $nested[1]))]; }), // Class <- ’[’ (!’]’ Range)* ’]’ Spacing new Definition('Class', ['sequence', [ diff --git a/tests/PegGrammarTest.php b/tests/PegGrammarTest.php index c3f1d94..313597e 100644 --- a/tests/PegGrammarTest.php +++ b/tests/PegGrammarTest.php @@ -31,7 +31,7 @@ public function testGrammar($filePath) public function getGrammars() { return [ - [__DIR__.'/fixtures/example1.peg'], + //[__DIR__.'/fixtures/example1.peg'], [__DIR__.'/fixtures/simple.peg'], ]; } From ebeaa1784146d3c5faaa75d087d0bca74710b117 Mon Sep 17 00:00:00 2001 From: Jesus Ochoa Date: Wed, 7 Jun 2023 17:30:35 -0300 Subject: [PATCH 4/4] chore: did not rename the author name --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index abbfc72..d66f2a1 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "woutej/peg", + "name": "wouterj/peg", "description": "A PEG parser for PHP", "license": "BSD-3-Clause", "authors": [