From f42be1981d61f788ed03da3f70852ad73e1dd761 Mon Sep 17 00:00:00 2001 From: KyleKatarn Date: Sat, 22 May 2021 18:53:58 +0200 Subject: [PATCH 1/6] Move compatibility TestCase files outside the autoload folder --- .../Phug}/Util/TestCaseTyped.php | 0 .../Phug}/Util/TestCaseUntyped.php | 0 src/Phug/Util/.travis.yml | 1 + src/Phug/Util/README.md | 2 +- src/Phug/Util/Util/TestCase.php | 19 +++++++++++++------ 5 files changed, 15 insertions(+), 7 deletions(-) rename {src/Phug/Util => compatibility/Phug}/Util/TestCaseTyped.php (100%) rename {src/Phug/Util => compatibility/Phug}/Util/TestCaseUntyped.php (100%) diff --git a/src/Phug/Util/Util/TestCaseTyped.php b/compatibility/Phug/Util/TestCaseTyped.php similarity index 100% rename from src/Phug/Util/Util/TestCaseTyped.php rename to compatibility/Phug/Util/TestCaseTyped.php diff --git a/src/Phug/Util/Util/TestCaseUntyped.php b/compatibility/Phug/Util/TestCaseUntyped.php similarity index 100% rename from src/Phug/Util/Util/TestCaseUntyped.php rename to compatibility/Phug/Util/TestCaseUntyped.php diff --git a/src/Phug/Util/.travis.yml b/src/Phug/Util/.travis.yml index f5c6bd7e..c7ce8389 100644 --- a/src/Phug/Util/.travis.yml +++ b/src/Phug/Util/.travis.yml @@ -21,6 +21,7 @@ install: if [[ "$STYLECHECK" != "on" ]]; then mkdir -p tests/Phug && \ vendor/bin/split copy https://github.com/phug-php/phug.git tests/Phug/ --filters=tests/Phug/Util; + vendor/bin/split copy https://github.com/phug-php/phug.git compatibility; fi; script: diff --git a/src/Phug/Util/README.md b/src/Phug/Util/README.md index 4d095270..e1fe1550 100644 --- a/src/Phug/Util/README.md +++ b/src/Phug/Util/README.md @@ -2,7 +2,7 @@ Phug Util ========= -What is Phug Lexer? +What is Phug Util? ------------------- The Phug Util repository contains several utilities to be used in conjunction with Phug libraries. diff --git a/src/Phug/Util/Util/TestCase.php b/src/Phug/Util/Util/TestCase.php index 3da92c3e..471a5ec3 100644 --- a/src/Phug/Util/Util/TestCase.php +++ b/src/Phug/Util/Util/TestCase.php @@ -5,14 +5,21 @@ use PHPUnit\Framework\TestCase as PHPUnitTestCase; use ReflectionMethod; -$setUp = @new ReflectionMethod(PHPUnitTestCase::class, 'setUp'); -$testCaseInitialization = true; +if (!class_exists(TestCaseTypeBase::class)) { + $setUp = @new ReflectionMethod(PHPUnitTestCase::class, 'setUp'); + $testCaseInitialization = true; + $compatibilityFolder = __DIR__.'/../../../../compatibility'; -require $setUp && method_exists($setUp, 'hasReturnType') && $setUp->hasReturnType() - ? __DIR__.'/TestCaseTyped.php' - : __DIR__.'/TestCaseUntyped.php'; + if (!file_exists($compatibilityFolder)) { + $compatibilityFolder = __DIR__.'/../compatibility'; + } + + require $setUp && method_exists($setUp, 'hasReturnType') && $setUp->hasReturnType() + ? "$compatibilityFolder/Phug/Util/TestCaseTyped.php" + : "$compatibilityFolder/Phug/Util/TestCaseUntyped.php"; -unset($testCaseInitialization); + unset($testCaseInitialization); +} class TestCase extends TestCaseTypeBase { From fc30357980c4feb0b5b445296ed8ce557690b747 Mon Sep 17 00:00:00 2001 From: KyleKatarn Date: Sat, 22 May 2021 19:48:29 +0200 Subject: [PATCH 2/6] Move compatibility TestCase files outside the autoload folder --- .../Phug/Util/CompatibilityUtil}/TestCaseTyped.php | 0 .../Phug/Util/CompatibilityUtil}/TestCaseUntyped.php | 2 +- src/Phug/Util/Util/TestCase.php | 9 ++------- 3 files changed, 3 insertions(+), 8 deletions(-) rename {compatibility/Phug/Util => src/Phug/Util/CompatibilityUtil}/TestCaseTyped.php (100%) rename {compatibility/Phug/Util => src/Phug/Util/CompatibilityUtil}/TestCaseUntyped.php (94%) diff --git a/compatibility/Phug/Util/TestCaseTyped.php b/src/Phug/Util/CompatibilityUtil/TestCaseTyped.php similarity index 100% rename from compatibility/Phug/Util/TestCaseTyped.php rename to src/Phug/Util/CompatibilityUtil/TestCaseTyped.php diff --git a/compatibility/Phug/Util/TestCaseUntyped.php b/src/Phug/Util/CompatibilityUtil/TestCaseUntyped.php similarity index 94% rename from compatibility/Phug/Util/TestCaseUntyped.php rename to src/Phug/Util/CompatibilityUtil/TestCaseUntyped.php index 54132eab..dcfcc170 100644 --- a/compatibility/Phug/Util/TestCaseUntyped.php +++ b/src/Phug/Util/CompatibilityUtil/TestCaseUntyped.php @@ -1,6 +1,6 @@ hasReturnType() - ? "$compatibilityFolder/Phug/Util/TestCaseTyped.php" - : "$compatibilityFolder/Phug/Util/TestCaseUntyped.php"; + ? __DIR__ . '/../CompatibilityUtil/TestCaseTyped.php' + : __DIR__ . '/../CompatibilityUtil/TestCaseUntyped.php'; unset($testCaseInitialization); } From d2ebde7baec350e8b7725ef712a8717bc998c613 Mon Sep 17 00:00:00 2001 From: KyleKatarn Date: Sat, 22 May 2021 19:54:04 +0200 Subject: [PATCH 3/6] Fix namespace --- src/Phug/Util/CompatibilityUtil/TestCaseTyped.php | 2 +- src/Phug/Util/Util/TestCase.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Phug/Util/CompatibilityUtil/TestCaseTyped.php b/src/Phug/Util/CompatibilityUtil/TestCaseTyped.php index efaef6a1..ff3b9868 100644 --- a/src/Phug/Util/CompatibilityUtil/TestCaseTyped.php +++ b/src/Phug/Util/CompatibilityUtil/TestCaseTyped.php @@ -1,6 +1,6 @@ Date: Sat, 22 May 2021 19:55:57 +0200 Subject: [PATCH 4/6] Fix code style --- src/Phug/Util/Util/TestCase.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Phug/Util/Util/TestCase.php b/src/Phug/Util/Util/TestCase.php index 6bbcaa2a..8f4b95d6 100644 --- a/src/Phug/Util/Util/TestCase.php +++ b/src/Phug/Util/Util/TestCase.php @@ -11,8 +11,8 @@ $testCaseInitialization = true; require $setUp && method_exists($setUp, 'hasReturnType') && $setUp->hasReturnType() - ? __DIR__ . '/../CompatibilityUtil/TestCaseTyped.php' - : __DIR__ . '/../CompatibilityUtil/TestCaseUntyped.php'; + ? __DIR__.'/../CompatibilityUtil/TestCaseTyped.php' + : __DIR__.'/../CompatibilityUtil/TestCaseUntyped.php'; unset($testCaseInitialization); } From 645793140df9a1c6dd36d4dcfced86f364c15297 Mon Sep 17 00:00:00 2001 From: KyleKatarn Date: Sat, 22 May 2021 22:26:10 +0200 Subject: [PATCH 5/6] Fix PHPCS exceptions --- phpcs.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpcs.xml b/phpcs.xml index c9bb5b43..ea311069 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -4,8 +4,8 @@ *.js */src/Phug/Renderer/Renderer/Adapter/Stream/Template.php */src/Phug/Util/Util/TestCase.php - */src/Phug/Util/Util/TestCaseTyped.php - */src/Phug/Util/Util/TestCaseUntyped.php + */src/Phug/Util/CompatibilityUtil/TestCaseTyped.php + */src/Phug/Util/CompatibilityUtil/TestCaseUntyped.php src \ No newline at end of file From 7c6ee98ad802274462fc17e1f5d10355bdf27bfa Mon Sep 17 00:00:00 2001 From: KyleKatarn Date: Sat, 22 May 2021 22:36:21 +0200 Subject: [PATCH 6/6] Restrict Util autoload to Phug\Util namespace --- composer.json | 6 +++--- src/Phug/Util/composer.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index ca80ee5d..1eb6a234 100644 --- a/composer.json +++ b/composer.json @@ -66,9 +66,9 @@ "./src/Phug/Lexer/", "./src/Phug/Parser/", "./src/Phug/Reader/", - "./src/Phug/Renderer/", - "./src/Phug/Util/" - ] + "./src/Phug/Renderer/" + ], + "Phug\\Util\\": "./src/Phug/Util/Util/" } }, "autoload-dev": { diff --git a/src/Phug/Util/composer.json b/src/Phug/Util/composer.json index 5b460de8..1ed8367f 100644 --- a/src/Phug/Util/composer.json +++ b/src/Phug/Util/composer.json @@ -29,7 +29,7 @@ }, "autoload": { "psr-4": { - "Phug\\": "" + "Phug\\Util\\": "Util/" } }, "extra": {