From d216972d00a205dfe068ce8532dc2c7a94277a89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Borys=20=C5=BBmuda?= Date: Tue, 8 Oct 2024 07:32:46 +0200 Subject: [PATCH 01/18] chore: Update dependencies --- composer.json | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 0e46261..cbb273d 100644 --- a/composer.json +++ b/composer.json @@ -16,15 +16,14 @@ } ], "require": { - "php": ">=8.1" + "php": ">=8.2" }, "require-dev": { "friendsofphp/php-cs-fixer": "^3.0", - "nunomaduro/phpinsights": "^2.0", - "pestphp/pest": "^2.0", + "pestphp/pest": "^3.0", "phpstan/phpstan": "^1.0", "rector/rector": "^1.0", - "symfony/var-dumper": "^6.0" + "symfony/var-dumper": "^7.0" }, "autoload": { "psr-4": { @@ -51,7 +50,6 @@ "test:arch": "pest --filter=arch", "test:unit": "pest --testsuite=unit", "test:integration": "pest --testsuite=integration", - "insights": "phpinsights analyse", "test": [ "@test:pint", "@test:refactor", From e47524c1a3aa91cb80ff5a8ff09afb4cbdbd7984 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Borys=20=C5=BBmuda?= Date: Tue, 8 Oct 2024 07:33:29 +0200 Subject: [PATCH 02/18] refactor: Make classes readonly --- src/Token.php | 6 +++--- src/Tokens/Group.php | 4 ++-- src/Tokens/Letter.php | 8 ++++---- src/Tokens/NegativeGroup.php | 6 +++--- src/Tokens/Number.php | 6 +++--- src/Tokens/PositiveGroup.php | 6 +++--- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/Token.php b/src/Token.php index d23a30d..0204d44 100644 --- a/src/Token.php +++ b/src/Token.php @@ -9,11 +9,11 @@ use Rudashi\Tokens\Letter; use Rudashi\Tokens\Number; -final class Token +final readonly class Token { public function __construct( - private readonly FluentBuilder $builder, - private readonly bool $sub = false, + private FluentBuilder $builder, + private bool $sub = false, ) { } diff --git a/src/Tokens/Group.php b/src/Tokens/Group.php index b34fe53..f2561f1 100644 --- a/src/Tokens/Group.php +++ b/src/Tokens/Group.php @@ -7,10 +7,10 @@ use LogicException; use Rudashi\Contracts\TokenContract; -final class Group implements TokenContract +final readonly class Group implements TokenContract { public function __construct( - private readonly TokenContract $group, + private TokenContract $group, ) { } diff --git a/src/Tokens/Letter.php b/src/Tokens/Letter.php index 355743b..eebc470 100644 --- a/src/Tokens/Letter.php +++ b/src/Tokens/Letter.php @@ -7,15 +7,15 @@ use LogicException; use Rudashi\Contracts\TokenContract; -final class Letter implements TokenContract +final readonly class Letter implements TokenContract { private const FIRST = 'a'; private const LAST = 'z'; public function __construct( - private readonly string $first, - private readonly string $last, - private readonly bool $onlyLower = false, + private string $first, + private string $last, + private bool $onlyLower = false, ) { if (! in_array($this->first, range('a', 'y'), true)) { $this->throwLogicException('The first letter must be between [a-y].'); diff --git a/src/Tokens/NegativeGroup.php b/src/Tokens/NegativeGroup.php index 86ae8d1..b0277f1 100644 --- a/src/Tokens/NegativeGroup.php +++ b/src/Tokens/NegativeGroup.php @@ -6,11 +6,11 @@ use Rudashi\Contracts\TokenContract; -final class NegativeGroup implements TokenContract +final readonly class NegativeGroup implements TokenContract { public function __construct( - private readonly bool $lookbehind = false, - private readonly bool $lookahead = false, + private bool $lookbehind = false, + private bool $lookahead = false, ) { } diff --git a/src/Tokens/Number.php b/src/Tokens/Number.php index 2d7aa57..174dc43 100644 --- a/src/Tokens/Number.php +++ b/src/Tokens/Number.php @@ -7,14 +7,14 @@ use LogicException; use Rudashi\Contracts\TokenContract; -final class Number implements TokenContract +final readonly class Number implements TokenContract { private const MIN = 0; private const MAX = 9; public function __construct( - private readonly int $min, - private readonly int $max, + private int $min, + private int $max, ) { if ($this->min < self::MIN || $this->min > self::MAX - 1) { $this->throwLogicException(); diff --git a/src/Tokens/PositiveGroup.php b/src/Tokens/PositiveGroup.php index 1fb172b..dca7f9c 100644 --- a/src/Tokens/PositiveGroup.php +++ b/src/Tokens/PositiveGroup.php @@ -6,11 +6,11 @@ use Rudashi\Contracts\TokenContract; -final class PositiveGroup implements TokenContract +final readonly class PositiveGroup implements TokenContract { public function __construct( - private readonly bool $lookbehind = false, - private readonly bool $lookahead = false, + private bool $lookbehind = false, + private bool $lookahead = false, ) { } From fb60a7b1f51fc632f0cdaa9266ac35a9d4a38ad0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Borys=20=C5=BBmuda?= Date: Tue, 8 Oct 2024 08:17:06 +0200 Subject: [PATCH 03/18] chore: Bump phpstan level --- phpstan.neon | 10 ++++++---- tests/Unit/DumpableTest.php | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/phpstan.neon b/phpstan.neon index 52e3f77..2ea812c 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,13 +1,15 @@ +includes: + - vendor/pestphp/pest/extension.neon + parameters: paths: - src - tests - level: 9 + level: max ignoreErrors: - '#Call to an undefined method Pest\\Mixins\\Expectation#' - - - message: '#Undefined variable: \$this.*#' - path: tests/** + universalObjectCratesClasses: + - PHPUnit\Framework\TestCase earlyTerminatingMethodCalls: Rudashi\FluentBuilder: - throwBadMethodException \ No newline at end of file diff --git a/tests/Unit/DumpableTest.php b/tests/Unit/DumpableTest.php index 01ff5e3..a5e3515 100644 --- a/tests/Unit/DumpableTest.php +++ b/tests/Unit/DumpableTest.php @@ -37,12 +37,12 @@ it('can use `dump`', function () { ob_start(); - $result = $this->builder->dump(); + $this->builder->dump(); $dump = ob_get_clean(); - expect($result) - ->toBeInstanceOf(FluentBuilder::class) - ->and($this->getDump($dump)) + // @phpstan-ignore-next-line + expect($this->getDump($dump)) + ->toBeString() ->toContain(...EXPECTED_DUMP); }); @@ -53,6 +53,7 @@ $this->builder->dump($var1); $dump = ob_get_clean(); + // @phpstan-ignore-next-line expect($this->getDump($dump)) ->toContain( '}\n @@ -71,6 +72,7 @@ $this->builder->dump($var1, $var2, $var3); $dump = ob_get_clean(); + // @phpstan-ignore-next-line expect($this->getDump($dump)) ->toContain( '}\n From e3295188995de07ae4a0dc689950ee1429cc1a26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Borys=20=C5=BBmuda?= Date: Tue, 8 Oct 2024 08:18:08 +0200 Subject: [PATCH 04/18] tests: Added new Arch tests --- tests/ArchTest.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/ArchTest.php b/tests/ArchTest.php index 5435e8c..f98c6fe 100644 --- a/tests/ArchTest.php +++ b/tests/ArchTest.php @@ -8,11 +8,20 @@ use Rudashi\Contracts\PatternContract; use Rudashi\Flag; +arch()->preset()->security(); + +arch()->preset()->php()->ignoring(Dumpable::class); + arch('strict types are everywhere', function () { expect('Rudashi') ->toUseStrictTypes(); }); +arch('strict equality', function () { + expect('Rudashi\JavaScript') + ->toUseStrictEquality(); +}); + arch('globals', function () { expect(['dd', 'dump', 'die', 'var_dump', 'sleep']) ->not->toBeUsed() From d2bc0bee2b3fb158c85030d84dfad4bbadb5f663 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Borys=20=C5=BBmuda?= Date: Tue, 8 Oct 2024 08:28:24 +0200 Subject: [PATCH 05/18] chore: Update docker --- Dockerfile | 5 +++-- docker-compose.yml | 8 ++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4b1b798..3d8dc2a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,9 @@ FROM php:8.2-fpm RUN pecl install xdebug \ - && docker-php-ext-enable xdebug + && docker-php-ext-enable xdebug \ + && curl -sLS https://getcomposer.org/installer | php -- --install-dir=/usr/bin/ --filename=composer # Configure Xdebug -RUN echo "xdebug.mode=develop,debug" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ +RUN echo "xdebug.mode=develop,debug,coverage" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ && echo "xdebug.client_host=host.docker.internal" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index e2d765a..25b3399 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,9 +2,17 @@ services: php: build: dockerfile: Dockerfile + extra_hosts: + - "host.docker.internal:host-gateway" + environment: + VAR_DUMPER_FORMAT: server volumes: - '.:/var/www/html' composer: image: composer + extra_hosts: + - "host.docker.internal:host-gateway" + environment: + VAR_DUMPER_SERVER: host.docker.internal:9912 volumes: - '.:/var/www/html' \ No newline at end of file From 0658092829304a460f5ef0958e9c65164999f2ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Borys=20=C5=BBmuda?= Date: Tue, 8 Oct 2024 08:28:36 +0200 Subject: [PATCH 06/18] chore: Update phpunit configuration --- phpunit.xml | 3 --- 1 file changed, 3 deletions(-) diff --git a/phpunit.xml b/phpunit.xml index 226f5fe..ae3804b 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -6,9 +6,6 @@ failOnRisky="true" > - - ./tests - ./tests/Unit From ef9a0fbcc935d831844d62a8292fcf69c0a80fa1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Borys=20=C5=BBmuda?= Date: Sat, 12 Oct 2024 20:36:20 +0200 Subject: [PATCH 07/18] chore: Removed php 8.1 support --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e48854f..1261de5 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -19,7 +19,7 @@ jobs: strategy: fail-fast: true matrix: - php: [8.1, 8.2, 8.3] + php: [8.2, 8.3] name: PHP ${{ matrix.php }} From 8a901f6ee7b71fa3c1d6bbea86daf24cea591a79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Borys=20=C5=BBmuda?= Date: Sat, 12 Oct 2024 21:13:45 +0200 Subject: [PATCH 08/18] chore: Bump composer version --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 2d6a9d8..289702c 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "rudashi/fluent-regex", "description": "Elegant way for PHP regex", - "version": "1.0.0", + "version": "2.0.0", "license": "MIT", "keywords": [ "php", From f2447c1b2f44bcaa34a56b840e71bf3e1cc3eef3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Borys=20=C5=BBmuda?= Date: Sun, 13 Oct 2024 08:20:40 +0200 Subject: [PATCH 09/18] chore: Update phpstan config --- phpstan.neon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpstan.neon b/phpstan.neon index 2ea812c..5e739f2 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -7,7 +7,7 @@ parameters: - tests level: max ignoreErrors: - - '#Call to an undefined method Pest\\Mixins\\Expectation#' + - '#Call to an undefined method Pest#' universalObjectCratesClasses: - PHPUnit\Framework\TestCase earlyTerminatingMethodCalls: From 52571fc705a5fd57536dede82171cfa00b8d4e7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Borys=20=C5=BBmuda?= Date: Sun, 13 Oct 2024 10:35:17 +0200 Subject: [PATCH 10/18] test: Adds test for quantifier times equal zero --- tests/Unit/QuantifiersTest.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/Unit/QuantifiersTest.php b/tests/Unit/QuantifiersTest.php index bbc96b6..0cdc84b 100644 --- a/tests/Unit/QuantifiersTest.php +++ b/tests/Unit/QuantifiersTest.php @@ -23,6 +23,13 @@ ->toBe('/\w+/'); }); +it('can add zero `times` quantifier causes token to be ignored', function () { + $regex = fluentBuilder()->word()->times(0); + + expect($regex->get()) + ->toBe('/\w{0}/'); +}); + it('can add `times` quantifier', function () { $regex = fluentBuilder()->word()->times(1); From aa64f10c468f604bbdcbe49706fd14660acda35b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Borys=20=C5=BBmuda?= Date: Mon, 14 Oct 2024 07:08:24 +0200 Subject: [PATCH 11/18] chore: Adds mutate tests to composer scripts --- composer.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 289702c..e8b51ae 100644 --- a/composer.json +++ b/composer.json @@ -51,13 +51,15 @@ "test:arch": "pest --filter=arch", "test:unit": "pest --testsuite=unit", "test:integration": "pest --testsuite=integration", + "test:mutate": "pest --mutate", "test": [ "@test:pint", "@test:refactor", "@test:types", "@test:arch", "@test:unit", - "@test:integration" + "@test:integration", + "@test:mutate" ] } } \ No newline at end of file From 7b92a7e6711cd08fa5de373e4377271f72fb12b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Borys=20=C5=BBmuda?= Date: Mon, 14 Oct 2024 07:34:38 +0200 Subject: [PATCH 12/18] tests: Grouped `Quantifiers::between()` tests --- tests/Unit/QuantifiersTest.php | 68 +++++++++++++++++----------------- 1 file changed, 35 insertions(+), 33 deletions(-) diff --git a/tests/Unit/QuantifiersTest.php b/tests/Unit/QuantifiersTest.php index 0cdc84b..daaa913 100644 --- a/tests/Unit/QuantifiersTest.php +++ b/tests/Unit/QuantifiersTest.php @@ -44,18 +44,44 @@ ->toBe('/\w{2,}/'); }); -it('can add `between` quantifier', function () { - $regex = fluentBuilder()->word()->between(1, 3); +describe('between', function () { + it('can add `between` quantifier', function () { + $regex = fluentBuilder()->word()->between(1, 3); - expect($regex->get()) - ->toBe('/\w{1,3}/'); -}); + expect($regex->get()) + ->toBe('/\w{1,3}/'); + }); -it('can add the quantifier `between` to act like `min`', function () { - $regex = fluentBuilder()->word()->between(1); + it('can add the quantifier `between` to act like `min`', function () { + $regex = fluentBuilder()->word()->between(1); - expect($regex->get()) - ->toBe('/\w{1,}/'); + expect($regex->get()) + ->toBe('/\w{1,}/'); + }); + + it('threw an exception when the parameters are a negative number for the `between` quantifier', function () { + expect(fn () => fluentBuilder()->word()->between(-1, -3)) + ->toThrow( + exception: LogicException::class, + exceptionMessage: 'The "min" parameter must be a positive integer.' + ); + }); + + it('threw an exception when the first parameter is a negative number for the `between` quantifier', function () { + expect(fn () => fluentBuilder()->word()->between(-1)) + ->toThrow( + exception: LogicException::class, + exceptionMessage: 'The "min" parameter must be a positive integer.' + ); + }); + + it('threw an exception when the second parameter is a negative number for the `between` quantifier', function () { + expect(fn () => fluentBuilder()->word()->between(1, -2)) + ->toThrow( + exception: LogicException::class, + exceptionMessage: 'The "max" parameter must be a positive integer.' + ); + }); }); it('threw an exception when the parameter is a negative number for the `times` quantifier', function () { @@ -74,30 +100,6 @@ ); }); -it('threw an exception when the parameters are a negative number for the `between` quantifier', function () { - expect(fn () => fluentBuilder()->word()->between(-1, -3)) - ->toThrow( - exception: LogicException::class, - exceptionMessage: 'The "min" parameter must be a positive integer.' - ); -}); - -it('threw an exception when the first parameter is a negative number for the `between` quantifier', function () { - expect(fn () => fluentBuilder()->word()->between(-1)) - ->toThrow( - exception: LogicException::class, - exceptionMessage: 'The "min" parameter must be a positive integer.' - ); -}); - -it('threw an exception when the second parameter is a negative number for the `between` quantifier', function () { - expect(fn () => fluentBuilder()->word()->between(1, -2)) - ->toThrow( - exception: LogicException::class, - exceptionMessage: 'The "max" parameter must be a positive integer.' - ); -}); - it('thrown an exception when trying to negate the quantifier', function (string $method) { expect(fn () => fluentBuilder()->not->{$method}()) ->toThrow( From 9e541aa7d9085d121b7bb93d39f11a7a0660d58e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Borys=20=C5=BBmuda?= Date: Mon, 14 Oct 2024 07:45:37 +0200 Subject: [PATCH 13/18] tests: Adds extra tests for `Quantifiers` --- tests/Unit/QuantifiersTest.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/Unit/QuantifiersTest.php b/tests/Unit/QuantifiersTest.php index daaa913..e794a9a 100644 --- a/tests/Unit/QuantifiersTest.php +++ b/tests/Unit/QuantifiersTest.php @@ -52,6 +52,13 @@ ->toBe('/\w{1,3}/'); }); + test('the same value in the `between` quantifier causes the token to behave like `times(n)`', function () { + $regex = fluentBuilder()->word()->between(1, 1); + + expect($regex->get()) + ->toBe('/\w{1,1}/'); + }); + it('can add the quantifier `between` to act like `min`', function () { $regex = fluentBuilder()->word()->between(1); @@ -59,6 +66,13 @@ ->toBe('/\w{1,}/'); }); + test('a [0] value in the `between` quantifier causes the token to behave like `zeroOrMore`', function () { + $regex = fluentBuilder()->word()->between(0); + + expect($regex->get()) + ->toBe('/\w{0,}/'); + }); + it('threw an exception when the parameters are a negative number for the `between` quantifier', function () { expect(fn () => fluentBuilder()->word()->between(-1, -3)) ->toThrow( From ed062e6c390ab7a1c0baf9926c3739e42db5defd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Borys=20=C5=BBmuda?= Date: Mon, 14 Oct 2024 07:47:43 +0200 Subject: [PATCH 14/18] pint --- tests/Unit/QuantifiersTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Unit/QuantifiersTest.php b/tests/Unit/QuantifiersTest.php index e794a9a..24f7e56 100644 --- a/tests/Unit/QuantifiersTest.php +++ b/tests/Unit/QuantifiersTest.php @@ -90,7 +90,7 @@ }); it('threw an exception when the second parameter is a negative number for the `between` quantifier', function () { - expect(fn () => fluentBuilder()->word()->between(1, -2)) + expect(fn () => fluentBuilder()->word()->between(1, -1)) ->toThrow( exception: LogicException::class, exceptionMessage: 'The "max" parameter must be a positive integer.' From bb0ebb46d10a9ff102f45707b838eaf133b9a229 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Borys=20=C5=BBmuda?= Date: Mon, 14 Oct 2024 07:53:44 +0200 Subject: [PATCH 15/18] tests: Adds mutation coverage --- tests/Unit/AnchorsTest.php | 4 ++++ tests/Unit/FlagsTest.php | 4 ++++ tests/Unit/QuantifiersTest.php | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/tests/Unit/AnchorsTest.php b/tests/Unit/AnchorsTest.php index 34ffc2e..5f796ba 100644 --- a/tests/Unit/AnchorsTest.php +++ b/tests/Unit/AnchorsTest.php @@ -2,6 +2,10 @@ declare(strict_types=1); +use Rudashi\Anchors; + +mutates(Anchors::class); + it('can add `start of a string` anchor', function () { $regex = fluentBuilder()->start(); diff --git a/tests/Unit/FlagsTest.php b/tests/Unit/FlagsTest.php index 56762a8..7850c3f 100644 --- a/tests/Unit/FlagsTest.php +++ b/tests/Unit/FlagsTest.php @@ -2,6 +2,10 @@ declare(strict_types=1); +use Rudashi\Concerns\Flags; + +mutates(Flags::class); + it('can add `insensitive` flag', function () { $regex = fluentBuilder()->ignoreCase(); diff --git a/tests/Unit/QuantifiersTest.php b/tests/Unit/QuantifiersTest.php index 24f7e56..3bbe42a 100644 --- a/tests/Unit/QuantifiersTest.php +++ b/tests/Unit/QuantifiersTest.php @@ -2,6 +2,10 @@ declare(strict_types=1); +use Rudashi\Concerns\Quantifiers; + +mutates(Quantifiers::class); + it('can add `zeroOrOne` quantifier', function () { $regex = fluentBuilder()->word()->zeroOrOne(); From 4e628b7745e29a8fc3b68d435198af72000587d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Borys=20=C5=BBmuda?= Date: Sun, 20 Oct 2024 18:47:16 +0200 Subject: [PATCH 16/18] tests: Renamed `Features` to `Patterns` --- phpunit.xml | 2 +- tests/{Feature => Patterns}/CreditCardTest.php | 0 tests/{Feature => Patterns}/DateTest.php | 0 tests/{Feature => Patterns}/EmailTest.php | 0 tests/{Feature => Patterns}/ExamplesTest.php | 0 tests/{Feature => Patterns}/IPAddressTest.php | 0 tests/{Feature => Patterns}/IPv6AddressTest.php | 0 tests/{Feature => Patterns}/MACAddressTest.php | 0 tests/{Feature => Patterns}/TimeTest.php | 0 tests/{Feature => Patterns}/UrlTest.php | 0 10 files changed, 1 insertion(+), 1 deletion(-) rename tests/{Feature => Patterns}/CreditCardTest.php (100%) rename tests/{Feature => Patterns}/DateTest.php (100%) rename tests/{Feature => Patterns}/EmailTest.php (100%) rename tests/{Feature => Patterns}/ExamplesTest.php (100%) rename tests/{Feature => Patterns}/IPAddressTest.php (100%) rename tests/{Feature => Patterns}/IPv6AddressTest.php (100%) rename tests/{Feature => Patterns}/MACAddressTest.php (100%) rename tests/{Feature => Patterns}/TimeTest.php (100%) rename tests/{Feature => Patterns}/UrlTest.php (100%) diff --git a/phpunit.xml b/phpunit.xml index ae3804b..b353e2b 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -10,7 +10,7 @@ ./tests/Unit - ./tests/Feature + ./tests/Patterns diff --git a/tests/Feature/CreditCardTest.php b/tests/Patterns/CreditCardTest.php similarity index 100% rename from tests/Feature/CreditCardTest.php rename to tests/Patterns/CreditCardTest.php diff --git a/tests/Feature/DateTest.php b/tests/Patterns/DateTest.php similarity index 100% rename from tests/Feature/DateTest.php rename to tests/Patterns/DateTest.php diff --git a/tests/Feature/EmailTest.php b/tests/Patterns/EmailTest.php similarity index 100% rename from tests/Feature/EmailTest.php rename to tests/Patterns/EmailTest.php diff --git a/tests/Feature/ExamplesTest.php b/tests/Patterns/ExamplesTest.php similarity index 100% rename from tests/Feature/ExamplesTest.php rename to tests/Patterns/ExamplesTest.php diff --git a/tests/Feature/IPAddressTest.php b/tests/Patterns/IPAddressTest.php similarity index 100% rename from tests/Feature/IPAddressTest.php rename to tests/Patterns/IPAddressTest.php diff --git a/tests/Feature/IPv6AddressTest.php b/tests/Patterns/IPv6AddressTest.php similarity index 100% rename from tests/Feature/IPv6AddressTest.php rename to tests/Patterns/IPv6AddressTest.php diff --git a/tests/Feature/MACAddressTest.php b/tests/Patterns/MACAddressTest.php similarity index 100% rename from tests/Feature/MACAddressTest.php rename to tests/Patterns/MACAddressTest.php diff --git a/tests/Feature/TimeTest.php b/tests/Patterns/TimeTest.php similarity index 100% rename from tests/Feature/TimeTest.php rename to tests/Patterns/TimeTest.php diff --git a/tests/Feature/UrlTest.php b/tests/Patterns/UrlTest.php similarity index 100% rename from tests/Feature/UrlTest.php rename to tests/Patterns/UrlTest.php From f03a2fdc834b70ba15408479c6f87d320bc32033 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Borys=20=C5=BBmuda?= Date: Sun, 20 Oct 2024 18:52:31 +0200 Subject: [PATCH 17/18] chore: Updated README.md --- README.md | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 0b9c37e..4ca892a 100644 --- a/README.md +++ b/README.md @@ -12,9 +12,9 @@ This package provides a simple way to create regular expression in a fluent way. -**Fluent Regex** is a library in PHP that simplifies the creation and management of regular expressions through -the use of fluent syntax. Traditional regular expressions can be difficult to read and understand, especially when -they become complex. **Fluent Regex** solves this problem by allowing you to build regular expressions using +**Fluent Regex** is a library in PHP that simplifies the creation and management of regular expressions through +the use of fluent syntax. Traditional regular expressions can be difficult to read and understand, especially when +they become complex. **Fluent Regex** solves this problem by allowing you to build regular expressions using a readable and intuitive object-oriented interface. > If you thought that finding a `needle` in a `haystack` was impossible, this repository is for you. @@ -29,10 +29,10 @@ composer require rudashi/fluent-regex ## Version Guidance -| Version | Branch | PHP Version | -|---------|---------------------------------------------------------|-------------| -| v1.x | [1.x](https://github.com/rudashi/fluent-regex/tree/1.x) | ^8.1 | -| v2.x | [2.x](https://github.com/rudashi/fluent-regex/tree/2.x) | ^8.2 | +| Version | Branch | PHP Version | Composer Install | +|---------|---------------------------------------------------------|-------------|----------------------------------------------| +| v2.x | [2.x](https://github.com/rudashi/fluent-regex/tree/2.x) | ^8.2 | `composer require rudashi/fluent-regex:^2.0` | +| v1.x | [1.x](https://github.com/rudashi/fluent-regex/tree/1.x) | ^8.1 | `composer require rudashi/fluent-regex:^1.0` | ## Usage @@ -52,11 +52,13 @@ $match = Regex::for('https://100commitow.pl/')->find('100commitow')->check(); ## Documentation -The [Fluent Regex documentation](https://rudashi.github.io/fluent-regex/) is extensive and complete, making getting started with regular expression syntax a breeze. +The [Fluent Regex documentation](https://rudashi.github.io/fluent-regex/) is extensive and complete, making getting +started with regular expression syntax a breeze. ## Changelog -Detailed changes for each release are documented in the [CHANGELOG.md](https://github.com/rudashi/fluent-regex/blob/master/CHANGELOG.md). +Detailed changes for each release are documented in +the [CHANGELOG.md](https://github.com/rudashi/fluent-regex/blob/master/CHANGELOG.md). ## Credits From 234fb9e07f3bb9e839dbfd6ec6efdd040698e44b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Borys=20=C5=BBmuda?= Date: Mon, 21 Oct 2024 09:04:42 +0200 Subject: [PATCH 18/18] chore: Extract `fakePattern` function to Pest.php --- tests/Pest.php | 14 ++++++++++++++ tests/Unit/PatternTest.php | 15 --------------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/tests/Pest.php b/tests/Pest.php index 1a8cddb..f3f6645 100644 --- a/tests/Pest.php +++ b/tests/Pest.php @@ -2,8 +2,10 @@ declare(strict_types=1); +use Rudashi\Contracts\PatternContract; use Rudashi\FluentBuilder; use Rudashi\Negate; +use Rudashi\Pattern; use Rudashi\Token; /* @@ -63,3 +65,15 @@ function token(bool $asSub = false): Token { return new Token(fluentBuilder(), $asSub); } + +function fakePattern(): Pattern +{ + return new class() extends Pattern implements PatternContract { + protected static string $name = 'fake-pattern'; + + public function getName(): string + { + return 'diff-name'; + } + }; +} diff --git a/tests/Unit/PatternTest.php b/tests/Unit/PatternTest.php index c5997eb..1e6dc62 100644 --- a/tests/Unit/PatternTest.php +++ b/tests/Unit/PatternTest.php @@ -2,21 +2,6 @@ declare(strict_types=1); -use Rudashi\Contracts\PatternContract; -use Rudashi\Pattern; - -function fakePattern(): Pattern -{ - return new class() extends Pattern implements PatternContract { - protected static string $name = 'fake-pattern'; - - public function getName(): string - { - return 'diff-name'; - } - }; -} - it('can return static name', function () { $pattern = fakePattern();