From a46c7a858d0e8c2119c4a8e05f13fd062370f948 Mon Sep 17 00:00:00 2001 From: Daniil Tkachev Date: Mon, 30 Oct 2023 16:08:16 +0100 Subject: [PATCH 1/5] OXDEV-7525 Upgrade phpunit from 9 to 10 --- CHANGELOG.md | 6 +++ .../Filters/PhpFunctionsExtensionTest.php | 2 +- .../Filters/RegexReplaceExtensionTest.php | 3 +- .../Filters/TranslateExtensionTest.php | 35 ++++--------- .../TranslateSalutationExtensionTest.php | 4 +- .../Filters/TruncateExtensionTest.php | 10 ++-- .../Filters/WordwrapExtensionTest.php | 12 ++--- .../Extensions/FormatPriceExtensionTest.php | 2 +- .../GetRequestVariablesExtensionTest.php | 2 +- .../IncludeContentExtensionTest.php | 2 +- .../Extensions/InputHelpExtensionTest.php | 4 +- .../Extensions/MailtoExtensionTest.php | 3 +- .../Extensions/PhpFunctionsExtensionTest.php | 2 +- .../Extensions/ScriptExtensionTest.php | 4 +- .../Extensions/SmartyCycleExtensionTest.php | 2 +- .../Extensions/TranslateExtensionTest.php | 2 +- .../Extensions/UrlExtensionTest.php | 4 +- .../Resolver/TemplateFileResolverTest.php | 2 +- .../src/Contoller/ModuleController.php | 2 +- .../ModuleControllerMissingTemplate.php | 1 + .../ModulesTemplateChainSortingTest.php | 8 +-- tests/Unit/Escaper/DecEntityEscaperTest.php | 4 +- tests/Unit/Escaper/HexEntityEscaperTest.php | 4 +- tests/Unit/Escaper/HexEscaperTest.php | 2 +- tests/Unit/Escaper/HtmlAllEscaperTest.php | 2 +- tests/Unit/Escaper/MailEscaperTest.php | 2 +- tests/Unit/Escaper/NonStdEscaperTest.php | 9 ++-- tests/Unit/Escaper/QuotesEscaperTest.php | 2 +- tests/Unit/Escaper/UrlPathInfoEscaperTest.php | 2 +- .../Filters/DateFormatExtensionTest.php | 2 +- .../Filters/FileSizeExtensionTest.php | 2 +- .../Filters/FormatTimeExtensionTest.php | 2 +- .../Filters/SmartWordwrapExtensionTest.php | 3 +- .../Unit/Extensions/IncludeExtensionTest.php | 5 +- tests/Unit/Extensions/StyleExtensionTest.php | 2 +- tests/Unit/Loader/CmsLoaderTest.php | 10 ++-- .../Unit/Loader/CmsTemplateNameParserTest.php | 4 +- tests/Unit/Node/AbstractOxidTwigTestCase.php | 29 +++++++++++ tests/Unit/Node/CaptureNodeTest.php | 50 ++++++++++--------- tests/Unit/Node/HasRightsNodeTest.php | 14 +++--- tests/Unit/Node/IfContentNodeTest.php | 5 +- tests/Unit/Node/IncludeDynamicNodeTest.php | 23 +++++++-- .../ModulesTemplateDirectoryResolverTest.php | 25 +++++++--- .../TokenParser/CaptureTokenParserTest.php | 4 +- .../TokenParser/HasRightsTokenParserTest.php | 6 ++- 45 files changed, 188 insertions(+), 137 deletions(-) create mode 100644 tests/Unit/Node/AbstractOxidTwigTestCase.php diff --git a/CHANGELOG.md b/CHANGELOG.md index ceba714..b57ff01 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ ## v2.2.0 - unreleased +### Added +- PHPUnit v10 support + +### Removed +- PHPUnit v9 support + ### Deprecated - `SmartyCycleExtension` will be removed diff --git a/tests/Integration/Extensions/Filters/PhpFunctionsExtensionTest.php b/tests/Integration/Extensions/Filters/PhpFunctionsExtensionTest.php index 08126c3..8b6bad5 100644 --- a/tests/Integration/Extensions/Filters/PhpFunctionsExtensionTest.php +++ b/tests/Integration/Extensions/Filters/PhpFunctionsExtensionTest.php @@ -25,7 +25,7 @@ protected function setUp(): void $this->extension = new PhpFunctionsExtension(); } - public function dummyTemplateProvider(): array + public static function dummyTemplateProvider(): array { return [ ["{% set foo = 'bar'|parse_url %}{{ foo['path'] }}", 'bar'], diff --git a/tests/Integration/Extensions/Filters/RegexReplaceExtensionTest.php b/tests/Integration/Extensions/Filters/RegexReplaceExtensionTest.php index 941a59e..1de76ae 100644 --- a/tests/Integration/Extensions/Filters/RegexReplaceExtensionTest.php +++ b/tests/Integration/Extensions/Filters/RegexReplaceExtensionTest.php @@ -24,7 +24,7 @@ protected function setUp(): void $this->extension = new RegexReplaceExtension(); } - public function dummyTemplateProvider(): array + public static function dummyTemplateProvider(): array { return [ ["{{ '1-foo-2'|regex_replace('/[0-9]/', 'bar') }}", "bar-foo-bar"], @@ -32,7 +32,6 @@ public function dummyTemplateProvider(): array } /** - * * @dataProvider dummyTemplateProvider */ public function testIfPhpFunctionsAreCallable(string $template, string $expected) diff --git a/tests/Integration/Extensions/Filters/TranslateExtensionTest.php b/tests/Integration/Extensions/Filters/TranslateExtensionTest.php index fe8adb8..82ec35a 100644 --- a/tests/Integration/Extensions/Filters/TranslateExtensionTest.php +++ b/tests/Integration/Extensions/Filters/TranslateExtensionTest.php @@ -1,4 +1,4 @@ -extension = $this->get(TranslateExtension::class); } - /** - * Provides data to testSimpleTranslating - */ - public function simpleTranslatingProvider(): array + public static function simpleTranslatingProvider(): array { return [ ["{{ 'FIRST_NAME'|translate }}", 0, 'Vorname'], @@ -41,9 +38,6 @@ public function simpleTranslatingProvider(): array } /** - * Tests simple translating, where only translation is fetched - * - * * @dataProvider simpleTranslatingProvider */ public function testSimpleTranslating(string $template, int $languageId, string $expected): void @@ -52,10 +46,7 @@ public function testSimpleTranslating(string $template, int $languageId, string $this->assertEquals($expected, $this->getTemplate($template)->render([])); } - /** - * Provides data to testTranslatingWithArguments - */ - public function withArgumentsProvider(): array + public static function withArgumentsProvider(): array { return [ ["{{ 'MANUFACTURER_S'|translate('Opel') }}", 0, '| Hersteller: Opel'], @@ -66,8 +57,6 @@ public function withArgumentsProvider(): array } /** - * Tests value translating when translating strings containing %s - * * @dataProvider withArgumentsProvider */ public function testTranslatingWithArguments(string $template, int $languageId, string $expected): void @@ -76,21 +65,22 @@ public function testTranslatingWithArguments(string $template, int $languageId, $this->assertEquals($expected, $this->getTemplate($template)->render([])); } - /** - * Provides data to testTranslateFrontend_isMissingTranslation - */ - public function missingTranslationProviderFrontend(): array + public static function missingTranslationProviderFrontend(): array { return [ [true, "{{ 'MY_MISING_TRANSLATION'|translate }}", 'MY_MISING_TRANSLATION'], - [false, "{{ 'MY_MISING_TRANSLATION'|translate }}", 'ERROR: Translation for MY_MISING_TRANSLATION not found!'], + [false, "{{ 'MY_MISING_TRANSLATION'|translate }}", 'ERROR: Translation for MY_MISING_TRANSLATION not found!'], //phpcs:disable ]; } /** * @dataProvider missingTranslationProviderFrontend */ - public function testTranslateFrontendIsMissingTranslation(bool $isProductiveMode, string $template, string $expected): void + public function testTranslateFrontendIsMissingTranslation( + bool $isProductiveMode, + string $template, + string $expected + ): void { $this->setAdminMode(false); $this->setLanguage(1); @@ -102,10 +92,7 @@ public function testTranslateFrontendIsMissingTranslation(bool $isProductiveMode $this->assertStringContainsString($expected, $this->getTemplate($template)->render([])); } - /** - * Provides data to testTranslateAdmin_isMissingTranslation - */ - public function missingTranslationProviderAdmin(): array + public static function missingTranslationProviderAdmin(): array { return [ ["{{ 'MY_MISING_TRANSLATION'|translate }}", 'ERROR: Translation for MY_MISING_TRANSLATION not found!'], diff --git a/tests/Integration/Extensions/Filters/TranslateSalutationExtensionTest.php b/tests/Integration/Extensions/Filters/TranslateSalutationExtensionTest.php index c91ebeb..1eadd5f 100644 --- a/tests/Integration/Extensions/Filters/TranslateSalutationExtensionTest.php +++ b/tests/Integration/Extensions/Filters/TranslateSalutationExtensionTest.php @@ -24,7 +24,7 @@ protected function setUp(): void $this->setLanguage(0); } - public function translateSalutationProvider(): array + public static function translateSalutationProvider(): array { return [ ["{{ 'MR'|translate_salutation }}", 'Herr'], @@ -39,7 +39,7 @@ public function testTranslateSalutation(string $template, string $expected): voi { $translateSalutationLogic = $this->getMockBuilder(TranslateSalutationLogic::class) ->disableOriginalConstructor() - ->setMethods(['translateSalutation'])->getMock(); + ->onlyMethods(['translateSalutation'])->getMock(); $translateSalutationLogic->expects($this->once())->method('translateSalutation')->willReturn( $expected diff --git a/tests/Integration/Extensions/Filters/TruncateExtensionTest.php b/tests/Integration/Extensions/Filters/TruncateExtensionTest.php index fce8a77..a0135ff 100644 --- a/tests/Integration/Extensions/Filters/TruncateExtensionTest.php +++ b/tests/Integration/Extensions/Filters/TruncateExtensionTest.php @@ -1,4 +1,4 @@ -assertEquals($expected, $this->getTemplate($template)->render([])); } - public function truncateProvider(): array + public static function truncateProvider(): array { return [ [ @@ -54,7 +54,7 @@ public function testTruncateWithLength(string $template, string $expected): void $this->assertEquals($expected, $this->getTemplate($template)->render([])); } - public function truncateProviderWithLength(): array + public static function truncateProviderWithLength(): array { return [ [ @@ -80,7 +80,7 @@ public function testTruncateWithSuffix(string $template, string $expected): void $this->assertEquals($expected, $this->getTemplate($template)->render([])); } - public function truncateProviderWithSuffix(): array + public static function truncateProviderWithSuffix(): array { return [ [ @@ -98,7 +98,7 @@ public function testTruncateWithBreakWords(string $template, string $expected): $this->assertEquals($expected, $this->getTemplate($template)->render([])); } - public function truncateProviderWithBreakWords(): array + public static function truncateProviderWithBreakWords(): array { return [ [ diff --git a/tests/Integration/Extensions/Filters/WordwrapExtensionTest.php b/tests/Integration/Extensions/Filters/WordwrapExtensionTest.php index 3901677..71ded35 100644 --- a/tests/Integration/Extensions/Filters/WordwrapExtensionTest.php +++ b/tests/Integration/Extensions/Filters/WordwrapExtensionTest.php @@ -24,10 +24,7 @@ protected function setUp(): void $this->extension = new WordwrapExtension(new WordwrapLogic()); } - /** - * Provides data for testWordWrapWithNonAscii - */ - public function nonAsciiProvider(): array + public static function nonAsciiProvider(): array { return [ ['{{ "HÖ HÖ"|wordwrap(2) }}', "HÖ\nHÖ"], @@ -45,10 +42,8 @@ public function testWordWrapWithNonAscii(string $template, string $expected): vo $this->assertEquals($expected, $this->getTemplate($template)->render([])); } - /** - * Provides data for testWordWrapAscii - */ - public function asciiProvider(): array + //phpcs:disable + public static function asciiProvider(): array { return [ ['{{ "aaa aaa"|wordwrap(2) }}', "aaa\naaa"], @@ -65,6 +60,7 @@ public function asciiProvider(): array ] ]; } + //phpcs:enable /** * @dataProvider asciiProvider diff --git a/tests/Integration/Extensions/FormatPriceExtensionTest.php b/tests/Integration/Extensions/FormatPriceExtensionTest.php index 35d3482..801a519 100644 --- a/tests/Integration/Extensions/FormatPriceExtensionTest.php +++ b/tests/Integration/Extensions/FormatPriceExtensionTest.php @@ -21,7 +21,7 @@ protected function setUp(): void $this->extension = new FormatPriceExtension($formatPriceLogic); } - public function priceProvider(): array + public static function priceProvider(): array { return [ ['{{ format_price(100) }}', '100,00 €'], diff --git a/tests/Integration/Extensions/GetRequestVariablesExtensionTest.php b/tests/Integration/Extensions/GetRequestVariablesExtensionTest.php index b585480..b23d4e3 100644 --- a/tests/Integration/Extensions/GetRequestVariablesExtensionTest.php +++ b/tests/Integration/Extensions/GetRequestVariablesExtensionTest.php @@ -31,7 +31,7 @@ protected function tearDown(): void unset($_GET['foo']); } - public function dummyTemplateProvider(): array + public static function dummyTemplateProvider(): array { return [ ['{{ get_global_cookie("foo") }}', 'bar'], diff --git a/tests/Integration/Extensions/IncludeContentExtensionTest.php b/tests/Integration/Extensions/IncludeContentExtensionTest.php index 892a4e0..6df404a 100644 --- a/tests/Integration/Extensions/IncludeContentExtensionTest.php +++ b/tests/Integration/Extensions/IncludeContentExtensionTest.php @@ -78,7 +78,7 @@ public function testContent(string $template, string $expected): void $this->assertEquals($expected, $this->getTemplate($template)->render([])); } - public function contentProvider(): array + public static function contentProvider(): array { return [ [ diff --git a/tests/Integration/Extensions/InputHelpExtensionTest.php b/tests/Integration/Extensions/InputHelpExtensionTest.php index 1b0efb7..a8a99a5 100644 --- a/tests/Integration/Extensions/InputHelpExtensionTest.php +++ b/tests/Integration/Extensions/InputHelpExtensionTest.php @@ -24,7 +24,7 @@ protected function setUp(): void $this->inputHelpExtension = new InputHelpExtension($inputHelpLogic); } - public function getIdentProvider(): array + public static function getIdentProvider(): array { return [ [null, 1, false, null], @@ -48,7 +48,7 @@ public function testGetIdent($params, $iLang, $blAdmin, $expected): void $this->assertEquals($expected, $this->inputHelpExtension->getHelpId($params)); } - public function getHelpTextProvider(): array + public static function getHelpTextProvider(): array { return [ [null, 1, false, null], diff --git a/tests/Integration/Extensions/MailtoExtensionTest.php b/tests/Integration/Extensions/MailtoExtensionTest.php index f36ddf0..7c2e03b 100644 --- a/tests/Integration/Extensions/MailtoExtensionTest.php +++ b/tests/Integration/Extensions/MailtoExtensionTest.php @@ -30,7 +30,8 @@ public function testMailto(string $template, string $expected, array $variables $this->assertEquals($expected, $this->getTemplate($template)->render($variables)); } - public function getMailtoTests(): array + //phpcs:disable + public static function getMailtoTests(): array { return [ [ diff --git a/tests/Integration/Extensions/PhpFunctionsExtensionTest.php b/tests/Integration/Extensions/PhpFunctionsExtensionTest.php index 2da94ba..06cecdb 100644 --- a/tests/Integration/Extensions/PhpFunctionsExtensionTest.php +++ b/tests/Integration/Extensions/PhpFunctionsExtensionTest.php @@ -22,7 +22,7 @@ protected function setUp(): void $this->extension = new PhpFunctionsExtension(); } - public function dummyTemplateProvider(): array + public static function dummyTemplateProvider(): array { return [ ["{{ count({0:0, 1:1, 2:2}) }}", 3], diff --git a/tests/Integration/Extensions/ScriptExtensionTest.php b/tests/Integration/Extensions/ScriptExtensionTest.php index fda1dd2..c38d0a1 100644 --- a/tests/Integration/Extensions/ScriptExtensionTest.php +++ b/tests/Integration/Extensions/ScriptExtensionTest.php @@ -32,10 +32,10 @@ public function testScript(string $template, string $expected): void $this->assertEquals($expected, $this->getTemplate($template)->render([])); } - public function getScriptTests(): array + //phpcs:disable + public static function getScriptTests(): array { return [ - // Empty buffer [ "{{ script() }}", "" diff --git a/tests/Integration/Extensions/SmartyCycleExtensionTest.php b/tests/Integration/Extensions/SmartyCycleExtensionTest.php index 63a1eb5..9c66249 100644 --- a/tests/Integration/Extensions/SmartyCycleExtensionTest.php +++ b/tests/Integration/Extensions/SmartyCycleExtensionTest.php @@ -27,7 +27,7 @@ public function testStaticCycle(string $template, string $expected, array $varia $this->assertEquals($expected, $this->getTemplate($template)->render($variables)); } - public function getStaticCycle(): array + public static function getStaticCycle(): array { return [ [ diff --git a/tests/Integration/Extensions/TranslateExtensionTest.php b/tests/Integration/Extensions/TranslateExtensionTest.php index 8c9de71..5273451 100644 --- a/tests/Integration/Extensions/TranslateExtensionTest.php +++ b/tests/Integration/Extensions/TranslateExtensionTest.php @@ -26,7 +26,7 @@ protected function setUp(): void $this->translateExtension = $this->get(TranslateExtension::class); } - public function dataProvider(): array + public static function dataProvider(): array { return [ [['ident' => 'foobar'], 'ERROR: Translation for foobar not found!'], diff --git a/tests/Integration/Extensions/UrlExtensionTest.php b/tests/Integration/Extensions/UrlExtensionTest.php index f8e03c5..b351fd2 100644 --- a/tests/Integration/Extensions/UrlExtensionTest.php +++ b/tests/Integration/Extensions/UrlExtensionTest.php @@ -38,7 +38,7 @@ public function testAddUrlParameters(string $template, string $expected, array $ $this->assertEquals($expected, $this->getTemplate($template)->render($variables)); } - public function getSeoUrlTests(): array + public static function getSeoUrlTests(): array { return [ [ @@ -48,7 +48,7 @@ public function getSeoUrlTests(): array ]; } - public function getAddUrlParametersTests(): array + public static function getAddUrlParametersTests(): array { return [ [ diff --git a/tests/Integration/Resolver/TemplateFileResolverTest.php b/tests/Integration/Resolver/TemplateFileResolverTest.php index 7233846..c7436a5 100644 --- a/tests/Integration/Resolver/TemplateFileResolverTest.php +++ b/tests/Integration/Resolver/TemplateFileResolverTest.php @@ -27,7 +27,7 @@ public function testResolveSmartyTemplate(string $templateName, string $expected $this->assertEquals($expectedFilename, $filename); } - public function templateNameFileDataProvider(): array + public static function templateNameFileDataProvider(): array { return [ [ diff --git a/tests/Integration/TwigEngine/ControllerRender/Fixtures/module1/src/Contoller/ModuleController.php b/tests/Integration/TwigEngine/ControllerRender/Fixtures/module1/src/Contoller/ModuleController.php index 49d0a54..2ed8c30 100644 --- a/tests/Integration/TwigEngine/ControllerRender/Fixtures/module1/src/Contoller/ModuleController.php +++ b/tests/Integration/TwigEngine/ControllerRender/Fixtures/module1/src/Contoller/ModuleController.php @@ -13,5 +13,5 @@ class ModuleController extends FrontendController { - protected $_sThisTemplate = '@module1/module_controller'; + protected $_sThisTemplate = '@module1/module_controller'; //phpcs:disable } diff --git a/tests/Integration/TwigEngine/ControllerRender/Fixtures/module1/src/Contoller/ModuleControllerMissingTemplate.php b/tests/Integration/TwigEngine/ControllerRender/Fixtures/module1/src/Contoller/ModuleControllerMissingTemplate.php index f1aa8ed..5d94b83 100644 --- a/tests/Integration/TwigEngine/ControllerRender/Fixtures/module1/src/Contoller/ModuleControllerMissingTemplate.php +++ b/tests/Integration/TwigEngine/ControllerRender/Fixtures/module1/src/Contoller/ModuleControllerMissingTemplate.php @@ -11,6 +11,7 @@ use OxidEsales\Eshop\Application\Controller\FrontendController; +//phpcs:disable class ModuleControllerMissingTemplate extends FrontendController { protected $_sThisTemplate = '@module1/module_controller_missing_template'; diff --git a/tests/Integration/TwigEngine/TemplateChainSorting/ModulesTemplateChainSortingTest.php b/tests/Integration/TwigEngine/TemplateChainSorting/ModulesTemplateChainSortingTest.php index b8a935d..2e99f2c 100644 --- a/tests/Integration/TwigEngine/TemplateChainSorting/ModulesTemplateChainSortingTest.php +++ b/tests/Integration/TwigEngine/TemplateChainSorting/ModulesTemplateChainSortingTest.php @@ -68,7 +68,7 @@ public function testRenderWithShopTemplateAndSorting(string $sorting, string $ex $this->assertStringContainsString($expectedResult, $actual); } - public function renderShopTemplateDataProvider(): array + public static function renderShopTemplateDataProvider(): array { return [ [ @@ -124,7 +124,7 @@ public function testRenderWithModuleTemplateAndSorting(string $sorting, string $ $this->assertStringContainsString($expectedResult, $actual); } - public function renderModuleTemplateDataProvider(): array + public static function renderModuleTemplateDataProvider(): array { return [ [ @@ -176,7 +176,7 @@ public function testRenderWithShopTemplateAmdFaultySortingConfiguration( $this->assertStringContainsString($expectedResult, $actual); } - public function renderWithShopTemplateAndFaultySortingConfigDataProvider(): array + public static function renderWithShopTemplateAndFaultySortingConfigDataProvider(): array { return [ [ @@ -223,7 +223,7 @@ public function testRenderWithModuleTemplateAndFaultySortingConfiguration( $this->assertStringContainsString($expectedResult, $actual); } - public function renderWithModuleTemplateAndFaultySortingConfigDataProvider(): array + public static function renderWithModuleTemplateAndFaultySortingConfigDataProvider(): array { return [ [ diff --git a/tests/Unit/Escaper/DecEntityEscaperTest.php b/tests/Unit/Escaper/DecEntityEscaperTest.php index c9066b2..bcc19e5 100644 --- a/tests/Unit/Escaper/DecEntityEscaperTest.php +++ b/tests/Unit/Escaper/DecEntityEscaperTest.php @@ -27,12 +27,12 @@ protected function setUp(): void $this->environment = $this->createMock(Environment::class); } - public function escapeProvider(): array + public static function escapeProvider(): array { return [ [ "A 'quote' is bold", - "A 'quote' is <b>bold</b>" + "A 'quote' is <b>bold</b>" //phpcs:disable ] ]; } diff --git a/tests/Unit/Escaper/HexEntityEscaperTest.php b/tests/Unit/Escaper/HexEntityEscaperTest.php index 3c653e1..2f6d839 100644 --- a/tests/Unit/Escaper/HexEntityEscaperTest.php +++ b/tests/Unit/Escaper/HexEntityEscaperTest.php @@ -27,12 +27,12 @@ protected function setUp(): void $this->environment = $this->createMock(Environment::class); } - public function escapeProvider(): array + public static function escapeProvider(): array { return [ [ "A 'quote' is bold", - "A 'quote' is <b>bold</b>" + "A 'quote' is <b>bold</b>" //phpcs:disable ] ]; } diff --git a/tests/Unit/Escaper/HexEscaperTest.php b/tests/Unit/Escaper/HexEscaperTest.php index b0eb5ce..df73a12 100644 --- a/tests/Unit/Escaper/HexEscaperTest.php +++ b/tests/Unit/Escaper/HexEscaperTest.php @@ -27,7 +27,7 @@ protected function setUp(): void $this->environment = $this->createMock(Environment::class); } - public function escapeProvider(): array + public static function escapeProvider(): array { return [ ["A 'quote' is bold", "%41%20%27%71%75%6f%74%65%27%20%69%73%20%3c%62%3e%62%6f%6c%64%3c%2f%62%3e"] diff --git a/tests/Unit/Escaper/HtmlAllEscaperTest.php b/tests/Unit/Escaper/HtmlAllEscaperTest.php index dd2cbef..827f982 100644 --- a/tests/Unit/Escaper/HtmlAllEscaperTest.php +++ b/tests/Unit/Escaper/HtmlAllEscaperTest.php @@ -27,7 +27,7 @@ protected function setUp(): void $this->environment = $this->createMock(Environment::class); } - public function escapeProvider(): array + public static function escapeProvider(): array { return [ ["A 'quote' is bold", "A 'quote' is <b>bold</b>"] diff --git a/tests/Unit/Escaper/MailEscaperTest.php b/tests/Unit/Escaper/MailEscaperTest.php index ce2bd47..2a56e45 100644 --- a/tests/Unit/Escaper/MailEscaperTest.php +++ b/tests/Unit/Escaper/MailEscaperTest.php @@ -27,7 +27,7 @@ protected function setUp(): void $this->environment = $this->createMock(Environment::class); } - public function escapeProvider(): array + public static function escapeProvider(): array { return [ [ diff --git a/tests/Unit/Escaper/NonStdEscaperTest.php b/tests/Unit/Escaper/NonStdEscaperTest.php index 692fb74..5fd5a2d 100644 --- a/tests/Unit/Escaper/NonStdEscaperTest.php +++ b/tests/Unit/Escaper/NonStdEscaperTest.php @@ -27,23 +27,20 @@ protected function setUp(): void $this->environment = $this->createMock(Environment::class); } - public function escapeProvider(): array + public static function escapeProvider(): array { return [ [ "Zażółć 'gęślą' jaźń", - "Zażółć 'gęślÄ…' jaźń" + "Zażółć 'gęślÄ…' jaźń" //phpcs:disable ] ]; } /** - * @param string $string - * @param string $expected - * * @dataProvider escapeProvider */ - public function testEscape($string, $expected) + public function testEscape(string $string, string $expected) { $this->assertEquals($expected, $this->escaper->escape($this->environment, $string, 'UTF-8')); } diff --git a/tests/Unit/Escaper/QuotesEscaperTest.php b/tests/Unit/Escaper/QuotesEscaperTest.php index 891d75e..942fab4 100644 --- a/tests/Unit/Escaper/QuotesEscaperTest.php +++ b/tests/Unit/Escaper/QuotesEscaperTest.php @@ -27,7 +27,7 @@ protected function setUp(): void $this->environment = $this->createMock(Environment::class); } - public function escapeProvider(): array + public static function escapeProvider(): array { return [ ["A 'quote' is bold", "A \'quote\' is bold"] diff --git a/tests/Unit/Escaper/UrlPathInfoEscaperTest.php b/tests/Unit/Escaper/UrlPathInfoEscaperTest.php index 5dac148..085e0f2 100644 --- a/tests/Unit/Escaper/UrlPathInfoEscaperTest.php +++ b/tests/Unit/Escaper/UrlPathInfoEscaperTest.php @@ -27,7 +27,7 @@ protected function setUp(): void $this->environment = $this->createMock(Environment::class); } - public function escapeProvider(): array + public static function escapeProvider(): array { return [ [ diff --git a/tests/Unit/Extensions/Filters/DateFormatExtensionTest.php b/tests/Unit/Extensions/Filters/DateFormatExtensionTest.php index d7c3c01..7f82aff 100644 --- a/tests/Unit/Extensions/Filters/DateFormatExtensionTest.php +++ b/tests/Unit/Extensions/Filters/DateFormatExtensionTest.php @@ -24,7 +24,7 @@ protected function setUp(): void $this->dateFormatExtension = new DateFormatExtension($dateFormatHelper); } - public function provider(): array + public static function provider(): array { return [ diff --git a/tests/Unit/Extensions/Filters/FileSizeExtensionTest.php b/tests/Unit/Extensions/Filters/FileSizeExtensionTest.php index e19ab03..db69e58 100644 --- a/tests/Unit/Extensions/Filters/FileSizeExtensionTest.php +++ b/tests/Unit/Extensions/Filters/FileSizeExtensionTest.php @@ -15,7 +15,7 @@ final class FileSizeExtensionTest extends TestCase { - public function provider() + public static function provider() { return [ [1023, '1023 B'], diff --git a/tests/Unit/Extensions/Filters/FormatTimeExtensionTest.php b/tests/Unit/Extensions/Filters/FormatTimeExtensionTest.php index 4d8c00e..c021ac3 100644 --- a/tests/Unit/Extensions/Filters/FormatTimeExtensionTest.php +++ b/tests/Unit/Extensions/Filters/FormatTimeExtensionTest.php @@ -15,7 +15,7 @@ final class FormatTimeExtensionTest extends TestCase { - public function provider(): array + public static function provider(): array { return [ [0, '00:00:00'], diff --git a/tests/Unit/Extensions/Filters/SmartWordwrapExtensionTest.php b/tests/Unit/Extensions/Filters/SmartWordwrapExtensionTest.php index 8599740..0368029 100644 --- a/tests/Unit/Extensions/Filters/SmartWordwrapExtensionTest.php +++ b/tests/Unit/Extensions/Filters/SmartWordwrapExtensionTest.php @@ -14,9 +14,10 @@ use OxidEsales\EshopCommunity\Tests\Unit\Application\Controller\contentTest_oxUtilsView; use PHPUnit\Framework\TestCase; +//phpcs:disable final class SmartWordwrapExtensionTest extends TestCase { - public function provider() + public static function provider() { return [ [ diff --git a/tests/Unit/Extensions/IncludeExtensionTest.php b/tests/Unit/Extensions/IncludeExtensionTest.php index 503d1ab..7476acf 100644 --- a/tests/Unit/Extensions/IncludeExtensionTest.php +++ b/tests/Unit/Extensions/IncludeExtensionTest.php @@ -19,7 +19,6 @@ final class IncludeExtensionTest extends TestCase { use ProphecyTrait; - /** @var IncludeExtension */ private IncludeExtension $includeExtension; public function setUp(): void @@ -39,7 +38,7 @@ public function testIncludeDynamicPrefix(array $parameters, array $expected): vo $this->assertEquals($this->includeExtension->includeDynamicPrefix($parameters), $expected); } - public function dataProviderTestIncludeDynamicPrefix(): array + public static function dataProviderTestIncludeDynamicPrefix(): array { return [ [[], []], @@ -63,7 +62,7 @@ public function testRenderForCache(array $parameters, string $expected): void $this->assertEquals($this->includeExtension->renderForCache($parameters), $expected); } - public function dataProviderTestRenderForCache(): array + public static function dataProviderTestRenderForCache(): array { return [ [[], ''], diff --git a/tests/Unit/Extensions/StyleExtensionTest.php b/tests/Unit/Extensions/StyleExtensionTest.php index c001e80..b0ad5f6 100644 --- a/tests/Unit/Extensions/StyleExtensionTest.php +++ b/tests/Unit/Extensions/StyleExtensionTest.php @@ -31,7 +31,7 @@ public function testCollectStyleSheets($params, $isDynamic): void $styleExtension->style($env, $params); } - public function dataProvider(): array + public static function dataProvider(): array { return [ [['foo' => 'bar', '__oxid_include_dynamic' => true], true], diff --git a/tests/Unit/Loader/CmsLoaderTest.php b/tests/Unit/Loader/CmsLoaderTest.php index b92d74c..f4a3536 100644 --- a/tests/Unit/Loader/CmsLoaderTest.php +++ b/tests/Unit/Loader/CmsLoaderTest.php @@ -26,7 +26,7 @@ final class CmsLoaderTest extends TestCase public function setUp(): void { parent::setUp(); - $this->contentMockBuilder = $this->getMockBuilder(Content::class)->setMethods(['getLanguage']); + $this->contentMockBuilder = $this->getMockBuilder(Content::class)->onlyMethods(['getLanguage']); $validContentMock = $this->prepareContentMock( 0, @@ -40,7 +40,11 @@ public function setUp(): void $fieldContentMock = $this->prepareContentMock( 0, - ['oxactive' => true, 'customfield' => "Template code (custom field)", 'oxtimestamp' => '2018-10-09 09:32:06'] + [ + 'oxactive' => true, + 'customfield' => "Template code (custom field)", + 'oxtimestamp' => '2018-10-09 09:32:06' + ] ); $notFreshContentMock = $this->prepareContentMock( @@ -52,7 +56,7 @@ public function setUp(): void $contentFactoryMock = $this ->getMockBuilder(ContentFactory::class) - ->setMethods(['getContent']) + ->onlyMethods(['getContent']) ->getMock(); $contentFactoryMock diff --git a/tests/Unit/Loader/CmsTemplateNameParserTest.php b/tests/Unit/Loader/CmsTemplateNameParserTest.php index 86210c0..46c8676 100644 --- a/tests/Unit/Loader/CmsTemplateNameParserTest.php +++ b/tests/Unit/Loader/CmsTemplateNameParserTest.php @@ -72,7 +72,7 @@ public function testGetKey(string $name, array $expected): void $this->assertEquals($this->cmsTemplateNameParser->getKey($name), $expected['key']); } - public function getInvalidNameTests(): array + public static function getInvalidNameTests(): array { $invalidNames = [ '', @@ -93,7 +93,7 @@ public function getInvalidNameTests(): array ); } - public function getValidNameTests(): array + public static function getValidNameTests(): array { return [ [ diff --git a/tests/Unit/Node/AbstractOxidTwigTestCase.php b/tests/Unit/Node/AbstractOxidTwigTestCase.php new file mode 100644 index 0000000..6bc4e38 --- /dev/null +++ b/tests/Unit/Node/AbstractOxidTwigTestCase.php @@ -0,0 +1,29 @@ +assertNodeCompilation($source, $node, $environment, $isPattern); + } +} diff --git a/tests/Unit/Node/CaptureNodeTest.php b/tests/Unit/Node/CaptureNodeTest.php index 2c42b39..09d0903 100644 --- a/tests/Unit/Node/CaptureNodeTest.php +++ b/tests/Unit/Node/CaptureNodeTest.php @@ -5,35 +5,28 @@ * See LICENSE file for license details. */ +declare(strict_types=1); + namespace OxidEsales\Twig\Tests\Unit\Node; use OxidEsales\Twig\Node\CaptureNode; use Twig\Node\TextNode; -use Twig\Test\NodeTestCase; -final class CaptureNodeTest extends NodeTestCase +final class CaptureNodeTest extends AbstractOxidTwigTestCase { - private string $variableName = 'foo'; - private int $line = 1; - private string $tag = 'capture'; - private $body; - - public function __construct($name = null, array $data = [], $dataName = '') - { - parent::__construct($name, $data, $dataName); - $this->body = new TextNode("Lorem Ipsum", 1); - } - - public function getTests() + public static function getOxidTwigTests(): array { - return array_merge($this->getTestForCaptureWithAttributeName(), $this->getTestForCaptureWithAttributeAssign(), $this->getTestForCaptureWithAttributeAppend()); + return array_merge( + self::getTestForCaptureWithAttributeName(), + self::getTestForCaptureWithAttributeAssign(), + self::getTestForCaptureWithAttributeAppend() + ); } - private function getTestForCaptureWithAttributeName() + private static function getTestForCaptureWithAttributeName(): array { $tests = []; - $nodeForCaptureName = new CaptureNode('name', $this->variableName, $this->body, $this->line, $this->tag); - + $nodeForCaptureName = self::getCaptureNode('name'); $tests[] = [$nodeForCaptureName, <<variableName, $this->body, $this->line, $this->tag); + $nodeForCaptureAssign = self::getCaptureNode('assign'); $tests[] = [$nodeForCaptureAssign, <<variableName, $this->body, $this->line, $this->tag); - $tests[] = [$nodeForCaptureAssign, <<assertEquals($parametersNode, $node->getNode('parameters')); } - public function getTests(): array + public static function getOxidTwigTests(): array { - return array_merge($this->getNonNestedBlocksTests(), $this->getNestedBlocksTests()); + return array_merge( + self::getNonNestedBlocksTests(), + self::getNestedBlocksTests() + ); } - private function getNonNestedBlocksTests(): array + private static function getNonNestedBlocksTests(): array { $tests = []; @@ -57,7 +59,7 @@ private function getNonNestedBlocksTests(): array return $tests; } - private function getNestedBlocksTests(): array + private static function getNestedBlocksTests(): array { $tests = []; diff --git a/tests/Unit/Node/IfContentNodeTest.php b/tests/Unit/Node/IfContentNodeTest.php index 9f56ea6..f960aaa 100644 --- a/tests/Unit/Node/IfContentNodeTest.php +++ b/tests/Unit/Node/IfContentNodeTest.php @@ -14,9 +14,8 @@ use Twig\Node\Expression\AssignNameExpression; use Twig\Node\Expression\ConstantExpression; use Twig\Node\TextNode; -use Twig\Test\NodeTestCase; -final class IfContentNodeTest extends NodeTestCase +final class IfContentNodeTest extends AbstractOxidTwigTestCase { public function testConstructor(): void { @@ -38,7 +37,7 @@ public function testConstructor(): void $this->assertFalse($node->hasNode('ident')); } - public function getTests(): array + public static function getOxidTwigTests(): array { $ifContentExtensionClass = IfContentExtension::class; diff --git a/tests/Unit/Node/IncludeDynamicNodeTest.php b/tests/Unit/Node/IncludeDynamicNodeTest.php index e43cbb0..598099b 100644 --- a/tests/Unit/Node/IncludeDynamicNodeTest.php +++ b/tests/Unit/Node/IncludeDynamicNodeTest.php @@ -13,9 +13,8 @@ use OxidEsales\Twig\Node\IncludeDynamicNode; use Twig\Node\Expression\ArrayExpression; use Twig\Node\Expression\ConstantExpression; -use Twig\Test\NodeTestCase; -final class IncludeDynamicNodeTest extends NodeTestCase +final class IncludeDynamicNodeTest extends AbstractOxidTwigTestCase { public function testConstructor(): void { @@ -26,13 +25,21 @@ public function testConstructor(): void $this->assertEquals($expr, $node->getNode('expr')); $this->assertFalse($node->getAttribute('only')); - $vars = new ArrayExpression([new ConstantExpression('foo', 1), new ConstantExpression(true, 1)], 1); + $vars = new ArrayExpression( + [ + new ConstantExpression('foo', 1), + new ConstantExpression(true, 1) + ], + 1 + ); + $node = new IncludeDynamicNode($expr, $vars, true, false, 1); $this->assertEquals($vars, $node->getNode('variables')); $this->assertTrue($node->getAttribute('only')); } - public function getTests(): array + //phpcs:disable + public static function getOxidTwigTests(): array { $includeExtensionClass = IncludeExtension::class; @@ -51,7 +58,13 @@ public function getTests(): array ]; $expr = new ConstantExpression('foo.twig', 1); - $vars = new ArrayExpression([new ConstantExpression('foo', 1), new ConstantExpression(true, 1)], 1); + $vars = new ArrayExpression( + [ + new ConstantExpression('foo', 1), + new ConstantExpression(true, 1) + ], + 1 + ); $node = new IncludeDynamicNode($expr, $vars, false, false, 1); $tests[] = [$node, <<modulePathResolver->getFullModulePathFromConfiguration($moduleId1, $this->shopId)->willReturn($modulePath1); + $this->modulePathResolver + ->getFullModulePathFromConfiguration($moduleId1, $this->shopId) + ->willReturn($modulePath1); $this->activeModulesDataProvider->getModuleIds()->willReturn([$moduleId1]); @@ -66,7 +68,9 @@ public function testGetTemplateDirectoriesWith1ModuleAnd1ExistingTemplate(): voi $modulePath1 = 'module-path-1'; $moduleTemplateDirectory1 = "$modulePath1/views/twig"; - $this->modulePathResolver->getFullModulePathFromConfiguration($moduleId1, $this->shopId)->willReturn($modulePath1); + $this->modulePathResolver + ->getFullModulePathFromConfiguration($moduleId1, $this->shopId) + ->willReturn($modulePath1); $this->activeModulesDataProvider->getModuleIds()->willReturn([$moduleId1]); @@ -86,8 +90,12 @@ public function testGetTemplateDirectoriesWith2ModulesAnd2ExistingTemplates(): v $moduleTemplateDirectory1 = "$modulePath1/views/twig"; $moduleTemplateDirectory2 = "$modulePath2/views/twig"; - $this->modulePathResolver->getFullModulePathFromConfiguration($moduleId1, $this->shopId)->willReturn($modulePath1); - $this->modulePathResolver->getFullModulePathFromConfiguration($moduleId2, $this->shopId)->willReturn($modulePath2); + $this->modulePathResolver + ->getFullModulePathFromConfiguration($moduleId1, $this->shopId) + ->willReturn($modulePath1); + $this->modulePathResolver + ->getFullModulePathFromConfiguration($moduleId2, $this->shopId) + ->willReturn($modulePath2); $this->activeModulesDataProvider->getModuleIds()->willReturn([$moduleId1, $moduleId2]); @@ -111,9 +119,12 @@ public function testGetTemplateDirectoriesWith3ModulesAnd1ExistingTemplate(): vo $moduleTemplateDirectory2 = "$modulePath2/views/twig"; $moduleTemplateDirectory3 = "$modulePath3/views/twig"; - $this->modulePathResolver->getFullModulePathFromConfiguration($moduleId1, $this->shopId)->willReturn($modulePath1); - $this->modulePathResolver->getFullModulePathFromConfiguration($moduleId2, $this->shopId)->willReturn($modulePath2); - $this->modulePathResolver->getFullModulePathFromConfiguration($moduleId3, $this->shopId)->willReturn($modulePath3); + $this->modulePathResolver + ->getFullModulePathFromConfiguration($moduleId1, $this->shopId)->willReturn($modulePath1); + $this->modulePathResolver + ->getFullModulePathFromConfiguration($moduleId2, $this->shopId)->willReturn($modulePath2); + $this->modulePathResolver + ->getFullModulePathFromConfiguration($moduleId3, $this->shopId)->willReturn($modulePath3); $this->activeModulesDataProvider->getModuleIds()->willReturn([$moduleId1, $moduleId2, $moduleId3]); diff --git a/tests/Unit/TokenParser/CaptureTokenParserTest.php b/tests/Unit/TokenParser/CaptureTokenParserTest.php index 90b2dc9..c8fdb8c 100644 --- a/tests/Unit/TokenParser/CaptureTokenParserTest.php +++ b/tests/Unit/TokenParser/CaptureTokenParserTest.php @@ -80,7 +80,7 @@ public function testParse($source): void $this->assertTrue($ifContentNode->hasNode('body')); } - public function templateSourceCodeProvider(): array + public static function templateSourceCodeProvider(): array { return [ ["{% capture name = \"foo\" %}Lorem Ipsum{% endcapture %}"], @@ -110,7 +110,7 @@ public function testParseException(): void $stream = $this->environment->tokenize(new Source($source, 'index')); $this->expectException(SyntaxError::class); - $this->expectExceptionMessage("Incorrect attribute name. Possible attribute names are: 'name', 'assign' and 'append'"); + $this->expectExceptionMessage("Incorrect attribute name. Possible attribute names are: 'name', 'assign' and 'append'"); //phpcs:disable $this->parser->parse($stream); } } diff --git a/tests/Unit/TokenParser/HasRightsTokenParserTest.php b/tests/Unit/TokenParser/HasRightsTokenParserTest.php index 4bbca3e..0f48343 100644 --- a/tests/Unit/TokenParser/HasRightsTokenParserTest.php +++ b/tests/Unit/TokenParser/HasRightsTokenParserTest.php @@ -71,7 +71,9 @@ public function testParse(): void $env = new Environment($loader, array('cache' => false, 'autoescape' => false)); $env->addExtension(new HasRightsExtension(new HasRightsTokenParser(HasRightsNode::class))); - $stream = $env->parse($env->tokenize(new Source('{% hasrights {\'id\' : \'1\'} %}{% endhasrights %}', 'index'))); + $stream = $env->parse( + $env->tokenize(new Source('{% hasrights {\'id\' : \'1\'} %}{% endhasrights %}', 'index')) + ); $stream->compile(new Compiler($env)); $tags = []; @@ -95,7 +97,7 @@ public function testParseException(): void $env->addExtension(new HasRightsExtension(new HasRightsTokenParser(HasRightsNode::class))); $this->expectException(SyntaxError::class); - $this->expectExceptionMessage('Unexpected "foo" tag (expecting closing tag for the "hasrights" tag defined near line 1) in "index" at line 1.'); + $this->expectExceptionMessage('Unexpected "foo" tag (expecting closing tag for the "hasrights" tag defined near line 1) in "index" at line 1.'); //phpcs:disable $env->parse($env->tokenize(new Source('{% hasrights {\'id\' : \'1\'} %}{% foo %}', 'index'))); } From 9c0d40bd6134cfa99071db3fe55bf6043cf51221 Mon Sep 17 00:00:00 2001 From: Vasyl Liulka Date: Mon, 18 Dec 2023 11:23:00 +0100 Subject: [PATCH 2/5] OXDEV-7525 Remove phpcs comments --- .../Integration/Extensions/Filters/TranslateExtensionTest.php | 4 ++-- .../Integration/Extensions/Filters/TruncateExtensionTest.php | 2 +- .../Integration/Extensions/Filters/WordwrapExtensionTest.php | 2 -- tests/Integration/Extensions/MailtoExtensionTest.php | 1 - tests/Integration/Extensions/ScriptExtensionTest.php | 1 - .../Fixtures/module1/src/Contoller/ModuleController.php | 2 +- .../module1/src/Contoller/ModuleControllerMissingTemplate.php | 1 - tests/Unit/Escaper/DecEntityEscaperTest.php | 2 +- tests/Unit/Escaper/HexEntityEscaperTest.php | 2 +- tests/Unit/Escaper/NonStdEscaperTest.php | 2 +- tests/Unit/Extensions/Filters/SmartWordwrapExtensionTest.php | 1 - tests/Unit/Node/IncludeDynamicNodeTest.php | 1 - tests/Unit/TokenParser/CaptureTokenParserTest.php | 2 +- tests/Unit/TokenParser/HasRightsTokenParserTest.php | 2 +- 14 files changed, 9 insertions(+), 16 deletions(-) diff --git a/tests/Integration/Extensions/Filters/TranslateExtensionTest.php b/tests/Integration/Extensions/Filters/TranslateExtensionTest.php index 82ec35a..059b7f6 100644 --- a/tests/Integration/Extensions/Filters/TranslateExtensionTest.php +++ b/tests/Integration/Extensions/Filters/TranslateExtensionTest.php @@ -1,4 +1,4 @@ -assertEquals($expected, $this->getTemplate($template)->render([])); } - //phpcs:disable public static function asciiProvider(): array { return [ @@ -60,7 +59,6 @@ public static function asciiProvider(): array ] ]; } - //phpcs:enable /** * @dataProvider asciiProvider diff --git a/tests/Integration/Extensions/MailtoExtensionTest.php b/tests/Integration/Extensions/MailtoExtensionTest.php index 7c2e03b..80d1fed 100644 --- a/tests/Integration/Extensions/MailtoExtensionTest.php +++ b/tests/Integration/Extensions/MailtoExtensionTest.php @@ -30,7 +30,6 @@ public function testMailto(string $template, string $expected, array $variables $this->assertEquals($expected, $this->getTemplate($template)->render($variables)); } - //phpcs:disable public static function getMailtoTests(): array { return [ diff --git a/tests/Integration/Extensions/ScriptExtensionTest.php b/tests/Integration/Extensions/ScriptExtensionTest.php index c38d0a1..381ce60 100644 --- a/tests/Integration/Extensions/ScriptExtensionTest.php +++ b/tests/Integration/Extensions/ScriptExtensionTest.php @@ -32,7 +32,6 @@ public function testScript(string $template, string $expected): void $this->assertEquals($expected, $this->getTemplate($template)->render([])); } - //phpcs:disable public static function getScriptTests(): array { return [ diff --git a/tests/Integration/TwigEngine/ControllerRender/Fixtures/module1/src/Contoller/ModuleController.php b/tests/Integration/TwigEngine/ControllerRender/Fixtures/module1/src/Contoller/ModuleController.php index 2ed8c30..49d0a54 100644 --- a/tests/Integration/TwigEngine/ControllerRender/Fixtures/module1/src/Contoller/ModuleController.php +++ b/tests/Integration/TwigEngine/ControllerRender/Fixtures/module1/src/Contoller/ModuleController.php @@ -13,5 +13,5 @@ class ModuleController extends FrontendController { - protected $_sThisTemplate = '@module1/module_controller'; //phpcs:disable + protected $_sThisTemplate = '@module1/module_controller'; } diff --git a/tests/Integration/TwigEngine/ControllerRender/Fixtures/module1/src/Contoller/ModuleControllerMissingTemplate.php b/tests/Integration/TwigEngine/ControllerRender/Fixtures/module1/src/Contoller/ModuleControllerMissingTemplate.php index 5d94b83..f1aa8ed 100644 --- a/tests/Integration/TwigEngine/ControllerRender/Fixtures/module1/src/Contoller/ModuleControllerMissingTemplate.php +++ b/tests/Integration/TwigEngine/ControllerRender/Fixtures/module1/src/Contoller/ModuleControllerMissingTemplate.php @@ -11,7 +11,6 @@ use OxidEsales\Eshop\Application\Controller\FrontendController; -//phpcs:disable class ModuleControllerMissingTemplate extends FrontendController { protected $_sThisTemplate = '@module1/module_controller_missing_template'; diff --git a/tests/Unit/Escaper/DecEntityEscaperTest.php b/tests/Unit/Escaper/DecEntityEscaperTest.php index bcc19e5..7cfc8c8 100644 --- a/tests/Unit/Escaper/DecEntityEscaperTest.php +++ b/tests/Unit/Escaper/DecEntityEscaperTest.php @@ -32,7 +32,7 @@ public static function escapeProvider(): array return [ [ "A 'quote' is bold", - "A 'quote' is <b>bold</b>" //phpcs:disable + "A 'quote' is <b>bold</b>" ] ]; } diff --git a/tests/Unit/Escaper/HexEntityEscaperTest.php b/tests/Unit/Escaper/HexEntityEscaperTest.php index 2f6d839..ac6b024 100644 --- a/tests/Unit/Escaper/HexEntityEscaperTest.php +++ b/tests/Unit/Escaper/HexEntityEscaperTest.php @@ -32,7 +32,7 @@ public static function escapeProvider(): array return [ [ "A 'quote' is bold", - "A 'quote' is <b>bold</b>" //phpcs:disable + "A 'quote' is <b>bold</b>" ] ]; } diff --git a/tests/Unit/Escaper/NonStdEscaperTest.php b/tests/Unit/Escaper/NonStdEscaperTest.php index 5fd5a2d..8bdc26b 100644 --- a/tests/Unit/Escaper/NonStdEscaperTest.php +++ b/tests/Unit/Escaper/NonStdEscaperTest.php @@ -32,7 +32,7 @@ public static function escapeProvider(): array return [ [ "Zażółć 'gęślą' jaźń", - "Zażółć 'gęślÄ…' jaźń" //phpcs:disable + "Zażółć 'gęślÄ…' jaźń" ] ]; } diff --git a/tests/Unit/Extensions/Filters/SmartWordwrapExtensionTest.php b/tests/Unit/Extensions/Filters/SmartWordwrapExtensionTest.php index 0368029..c314fb6 100644 --- a/tests/Unit/Extensions/Filters/SmartWordwrapExtensionTest.php +++ b/tests/Unit/Extensions/Filters/SmartWordwrapExtensionTest.php @@ -14,7 +14,6 @@ use OxidEsales\EshopCommunity\Tests\Unit\Application\Controller\contentTest_oxUtilsView; use PHPUnit\Framework\TestCase; -//phpcs:disable final class SmartWordwrapExtensionTest extends TestCase { public static function provider() diff --git a/tests/Unit/Node/IncludeDynamicNodeTest.php b/tests/Unit/Node/IncludeDynamicNodeTest.php index 598099b..709dec6 100644 --- a/tests/Unit/Node/IncludeDynamicNodeTest.php +++ b/tests/Unit/Node/IncludeDynamicNodeTest.php @@ -38,7 +38,6 @@ public function testConstructor(): void $this->assertTrue($node->getAttribute('only')); } - //phpcs:disable public static function getOxidTwigTests(): array { $includeExtensionClass = IncludeExtension::class; diff --git a/tests/Unit/TokenParser/CaptureTokenParserTest.php b/tests/Unit/TokenParser/CaptureTokenParserTest.php index c8fdb8c..fd10e1e 100644 --- a/tests/Unit/TokenParser/CaptureTokenParserTest.php +++ b/tests/Unit/TokenParser/CaptureTokenParserTest.php @@ -110,7 +110,7 @@ public function testParseException(): void $stream = $this->environment->tokenize(new Source($source, 'index')); $this->expectException(SyntaxError::class); - $this->expectExceptionMessage("Incorrect attribute name. Possible attribute names are: 'name', 'assign' and 'append'"); //phpcs:disable + $this->expectExceptionMessage("Incorrect attribute name. Possible attribute names are: 'name', 'assign' and 'append'"); $this->parser->parse($stream); } } diff --git a/tests/Unit/TokenParser/HasRightsTokenParserTest.php b/tests/Unit/TokenParser/HasRightsTokenParserTest.php index 0f48343..f891bee 100644 --- a/tests/Unit/TokenParser/HasRightsTokenParserTest.php +++ b/tests/Unit/TokenParser/HasRightsTokenParserTest.php @@ -97,7 +97,7 @@ public function testParseException(): void $env->addExtension(new HasRightsExtension(new HasRightsTokenParser(HasRightsNode::class))); $this->expectException(SyntaxError::class); - $this->expectExceptionMessage('Unexpected "foo" tag (expecting closing tag for the "hasrights" tag defined near line 1) in "index" at line 1.'); //phpcs:disable + $this->expectExceptionMessage('Unexpected "foo" tag (expecting closing tag for the "hasrights" tag defined near line 1) in "index" at line 1.'); $env->parse($env->tokenize(new Source('{% hasrights {\'id\' : \'1\'} %}{% foo %}', 'index'))); } From 19fcd464be77340149f6297a950ee3a58fb71f96 Mon Sep 17 00:00:00 2001 From: Vasyl Liulka Date: Mon, 18 Dec 2023 12:03:31 +0100 Subject: [PATCH 3/5] OXDEV-7525 Ignore PHPCS warnings --- .github/workflows/build.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2f715f5..5972d8f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -99,7 +99,12 @@ jobs: perl -pi -e "s#^#$TWIG_ROOT/#" changed-files.txt if [[ -f "changed-files.txt" && -s "changed-files.txt" ]]; then cd ../../../../../ - $RUN_PHP php vendor/bin/phpcs --standard=psr12 --file-list=$TWIG_ROOT/changed-files.txt 2>&1 \ + $RUN_PHP \ + vendor/bin/phpcs \ + --standard=psr12 \ + --ignore=tests/*/Fixtures/* \ + --exclude=Generic.Files.LineLength \ + --file-list=$TWIG_ROOT/changed-files.txt 2>&1 \ | tee php_codesniff_log.txt || true rm source/eshop_ce/vendor/oxid-esales/twig-component/changed-files.txt if grep -q -Ei 'fail|\\.\\=\\=|Warning|Notice|Deprecated|Fatal|Error' php_codesniff_log.txt; From 3999d33d50968b12b7568ebef819ee0b0aaedcc7 Mon Sep 17 00:00:00 2001 From: Vasyl Liulka Date: Mon, 18 Dec 2023 12:33:04 +0100 Subject: [PATCH 4/5] OXDEV-7525 Fix PSR errors --- src/Resolver/TemplateChain/DataObject/TemplateChain.php | 1 + src/Resolver/TemplateChain/TemplateChainBuilderAggregate.php | 4 ++-- .../Integration/Extensions/Filters/TranslateExtensionTest.php | 3 +-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Resolver/TemplateChain/DataObject/TemplateChain.php b/src/Resolver/TemplateChain/DataObject/TemplateChain.php index ee8a28c..5972fec 100644 --- a/src/Resolver/TemplateChain/DataObject/TemplateChain.php +++ b/src/Resolver/TemplateChain/DataObject/TemplateChain.php @@ -13,6 +13,7 @@ use IteratorAggregate; use OxidEsales\Twig\Resolver\TemplateChain\TemplateType\DataObject\TemplateTypeInterface; use Traversable; + use function array_keys; use function array_search; use function count; diff --git a/src/Resolver/TemplateChain/TemplateChainBuilderAggregate.php b/src/Resolver/TemplateChain/TemplateChainBuilderAggregate.php index 4376d9b..f401f99 100644 --- a/src/Resolver/TemplateChain/TemplateChainBuilderAggregate.php +++ b/src/Resolver/TemplateChain/TemplateChainBuilderAggregate.php @@ -21,8 +21,8 @@ public function __construct( private TemplateChainValidatorInterface $templateChainValidator, private InitialTemplateResolverInterface $initialTemplateResolver, private TemplateChainSorterInterface $templateChainSorter, - ) - {} + ) { + } /** * @inheritDoc diff --git a/tests/Integration/Extensions/Filters/TranslateExtensionTest.php b/tests/Integration/Extensions/Filters/TranslateExtensionTest.php index 059b7f6..7b10a37 100644 --- a/tests/Integration/Extensions/Filters/TranslateExtensionTest.php +++ b/tests/Integration/Extensions/Filters/TranslateExtensionTest.php @@ -80,8 +80,7 @@ public function testTranslateFrontendIsMissingTranslation( bool $isProductiveMode, string $template, string $expected - ): void - { + ): void { $this->setAdminMode(false); $this->setLanguage(1); From ae8860c652d570e26372509f49c0f97818e6b8f8 Mon Sep 17 00:00:00 2001 From: Vasyl Liulka Date: Mon, 18 Dec 2023 12:52:52 +0100 Subject: [PATCH 5/5] OXDEV-7525 Fix PSR line length warnings --- .../Compiler/TwigEnvironmentPass.php | 6 ++++-- src/Extensions/Filters/TruncateExtension.php | 18 +++++++----------- .../InsertNewBasketItemExtension.php | 4 +++- src/Node/CaptureNode.php | 9 +++++++-- .../TemplateHandler/ChainAppender.php | 13 +++++++++---- .../TemplateHandler/ChainAppenderInterface.php | 6 +++++- .../ModuleExtensionTemplateHandler.php | 15 ++++++++++----- .../ModuleExtensions/ModuleTemplateHandler.php | 15 ++++++++++----- .../ShopExtensionTemplateHandler.php | 9 ++++++--- .../ShopTemplateChainAppender.php | 16 +++++++++++----- .../ModuleExtensions/ShopTemplateHandler.php | 9 ++++++--- .../TemplateHandler/ModuleTemplateHandler.php | 7 +++++-- .../TemplateHandler/ShopTemplateHandler.php | 7 +++++-- src/TokenParser/CaptureTokenParser.php | 4 +++- src/TokenParser/HasRightsTokenParser.php | 9 ++++++++- 15 files changed, 99 insertions(+), 48 deletions(-) diff --git a/src/DependencyInjection/Compiler/TwigEnvironmentPass.php b/src/DependencyInjection/Compiler/TwigEnvironmentPass.php index b8e13e9..9b49dbe 100644 --- a/src/DependencyInjection/Compiler/TwigEnvironmentPass.php +++ b/src/DependencyInjection/Compiler/TwigEnvironmentPass.php @@ -46,7 +46,7 @@ class TwigEnvironmentPass implements CompilerPassInterface */ public function process(ContainerBuilder $container): void { - if (false === $container->hasDefinition('twig')) { + if ($container->hasDefinition('twig') === false) { return; } @@ -71,7 +71,9 @@ public function process(ContainerBuilder $container): void } if (!empty($twigBridgeExtensionsMethodCalls) || !empty($othersExtensionsMethodCalls)) { - $definition->setMethodCalls(array_merge($twigBridgeExtensionsMethodCalls, $othersExtensionsMethodCalls, $currentMethodCalls)); + $definition->setMethodCalls( + array_merge($twigBridgeExtensionsMethodCalls, $othersExtensionsMethodCalls, $currentMethodCalls) + ); } } } diff --git a/src/Extensions/Filters/TruncateExtension.php b/src/Extensions/Filters/TruncateExtension.php index 8a514a4..b1e210e 100644 --- a/src/Extensions/Filters/TruncateExtension.php +++ b/src/Extensions/Filters/TruncateExtension.php @@ -32,17 +32,13 @@ public function getFilters(): array ]; } - /** - * @param string|null $string $string - * @param int $length - * @param string $suffix - * @param bool $breakWords - * @param bool $middle - * - * @return string - */ - public function truncate(string $string = null, int $length = 80, string $suffix = '...', bool $breakWords = false, bool $middle = false): string - { + public function truncate( + string $string = null, + int $length = 80, + string $suffix = '...', + bool $breakWords = false, + bool $middle = false + ): string { return $this->truncateLogic->truncate($string, $length, $suffix, $breakWords, $middle); } } diff --git a/src/Extensions/InsertNewBasketItemExtension.php b/src/Extensions/InsertNewBasketItemExtension.php index 6f903eb..7a79855 100644 --- a/src/Extensions/InsertNewBasketItemExtension.php +++ b/src/Extensions/InsertNewBasketItemExtension.php @@ -26,7 +26,9 @@ public function __construct(private InsertNewBasketItemLogicTwig $newBasketItemL */ public function getFunctions(): array { - return [new TwigFunction('insert_new_basket_item', [$this, 'insertNewBasketItem'], ['needs_environment' => true])]; + return [ + new TwigFunction('insert_new_basket_item', [$this, 'insertNewBasketItem'], ['needs_environment' => true]) + ]; } /** diff --git a/src/Node/CaptureNode.php b/src/Node/CaptureNode.php index 0d7c1d1..c6fe0f9 100644 --- a/src/Node/CaptureNode.php +++ b/src/Node/CaptureNode.php @@ -9,8 +9,8 @@ namespace OxidEsales\Twig\Node; -use Twig\Node\Node; use Twig\Compiler; +use Twig\Node\Node; class CaptureNode extends Node { @@ -32,7 +32,12 @@ class CaptureNode extends Node public function __construct(string $attributeName, string $variableName, Node $body, int $line, string $tag = null) { - parent::__construct(['body' => $body], ['attributeName' => $attributeName, 'variableName' => $variableName], $line, $tag); + parent::__construct( + ['body' => $body], + ['attributeName' => $attributeName, 'variableName' => $variableName], + $line, + $tag + ); } /** diff --git a/src/Resolver/TemplateChain/TemplateHandler/ChainAppender.php b/src/Resolver/TemplateChain/TemplateHandler/ChainAppender.php index 492cc2f..fd5d63b 100644 --- a/src/Resolver/TemplateChain/TemplateHandler/ChainAppender.php +++ b/src/Resolver/TemplateChain/TemplateHandler/ChainAppender.php @@ -22,16 +22,21 @@ public function __construct( ) { } - public function addToChain(TemplateChain $templateChain, TemplateTypeInterface $templateType, NamespacedDirectory $directory): TemplateChain - { + public function addToChain( + TemplateChain $templateChain, + TemplateTypeInterface $templateType, + NamespacedDirectory $directory + ): TemplateChain { if ($this->directoryContainsTemplateFile($directory, $templateType)) { $templateChain->append($templateType); } return $templateChain; } - private function directoryContainsTemplateFile(NamespacedDirectory $directory, TemplateTypeInterface $template): bool - { + private function directoryContainsTemplateFile( + NamespacedDirectory $directory, + TemplateTypeInterface $template + ): bool { return $this->filesystem->exists( Path::join($directory->getDirectory(), $template->getRelativeFilePath()) ); diff --git a/src/Resolver/TemplateChain/TemplateHandler/ChainAppenderInterface.php b/src/Resolver/TemplateChain/TemplateHandler/ChainAppenderInterface.php index 1431ec6..44c5b7d 100644 --- a/src/Resolver/TemplateChain/TemplateHandler/ChainAppenderInterface.php +++ b/src/Resolver/TemplateChain/TemplateHandler/ChainAppenderInterface.php @@ -13,5 +13,9 @@ interface ChainAppenderInterface { - public function addToChain(TemplateChain $templateChain, TemplateTypeInterface $templateType, NamespacedDirectory $directory): TemplateChain; + public function addToChain( + TemplateChain $templateChain, + TemplateTypeInterface $templateType, + NamespacedDirectory $directory + ): TemplateChain; } diff --git a/src/Resolver/TemplateChain/TemplateHandler/ModuleExtensions/ModuleExtensionTemplateHandler.php b/src/Resolver/TemplateChain/TemplateHandler/ModuleExtensions/ModuleExtensionTemplateHandler.php index 41513a8..916f47a 100644 --- a/src/Resolver/TemplateChain/TemplateHandler/ModuleExtensions/ModuleExtensionTemplateHandler.php +++ b/src/Resolver/TemplateChain/TemplateHandler/ModuleExtensions/ModuleExtensionTemplateHandler.php @@ -10,9 +10,9 @@ namespace OxidEsales\Twig\Resolver\TemplateChain\TemplateHandler\ModuleExtensions; use OxidEsales\Twig\Resolver\DataObject\NamespacedDirectory; +use OxidEsales\Twig\Resolver\TemplateChain\DataObject\TemplateChain; use OxidEsales\Twig\Resolver\TemplateChain\TemplateHandler\ChainAppenderInterface; use OxidEsales\Twig\Resolver\TemplateChain\TemplateHandler\TemplateTypeCheckerInterface; -use OxidEsales\Twig\Resolver\TemplateChain\DataObject\TemplateChain; use OxidEsales\Twig\Resolver\TemplateChain\TemplateType\DataObject\ModuleExtensionTemplateType; use OxidEsales\Twig\Resolver\TemplateChain\TemplateType\DataObject\TemplateTypeInterface; @@ -23,8 +23,11 @@ public function __construct( ) { } - public function addToChain(TemplateChain $templateChain, TemplateTypeInterface $templateType, NamespacedDirectory $directory): TemplateChain - { + public function addToChain( + TemplateChain $templateChain, + TemplateTypeInterface $templateType, + NamespacedDirectory $directory + ): TemplateChain { if (!$this->canHandle($templateType)) { return $templateChain; } @@ -37,8 +40,10 @@ public function canHandle(TemplateTypeInterface $templateType): bool return $templateType->isModuleExtensionTemplate(); } - private function getExtension(TemplateTypeInterface $template, NamespacedDirectory $directory): ModuleExtensionTemplateType - { + private function getExtension( + TemplateTypeInterface $template, + NamespacedDirectory $directory + ): ModuleExtensionTemplateType { return new ModuleExtensionTemplateType( $template->getName(), $directory->getNamespace(), diff --git a/src/Resolver/TemplateChain/TemplateHandler/ModuleExtensions/ModuleTemplateHandler.php b/src/Resolver/TemplateChain/TemplateHandler/ModuleExtensions/ModuleTemplateHandler.php index a2137bf..1972903 100644 --- a/src/Resolver/TemplateChain/TemplateHandler/ModuleExtensions/ModuleTemplateHandler.php +++ b/src/Resolver/TemplateChain/TemplateHandler/ModuleExtensions/ModuleTemplateHandler.php @@ -10,9 +10,9 @@ namespace OxidEsales\Twig\Resolver\TemplateChain\TemplateHandler\ModuleExtensions; use OxidEsales\Twig\Resolver\DataObject\NamespacedDirectory; +use OxidEsales\Twig\Resolver\TemplateChain\DataObject\TemplateChain; use OxidEsales\Twig\Resolver\TemplateChain\TemplateHandler\ChainAppenderInterface; use OxidEsales\Twig\Resolver\TemplateChain\TemplateHandler\TemplateTypeCheckerInterface; -use OxidEsales\Twig\Resolver\TemplateChain\DataObject\TemplateChain; use OxidEsales\Twig\Resolver\TemplateChain\TemplateType\DataObject\ModuleExtensionTemplateType; use OxidEsales\Twig\Resolver\TemplateChain\TemplateType\DataObject\TemplateTypeInterface; @@ -23,8 +23,11 @@ public function __construct( ) { } - public function addToChain(TemplateChain $templateChain, TemplateTypeInterface $templateType, NamespacedDirectory $directory): TemplateChain - { + public function addToChain( + TemplateChain $templateChain, + TemplateTypeInterface $templateType, + NamespacedDirectory $directory + ): TemplateChain { if (!$this->canHandle($templateType)) { return $templateChain; } @@ -37,8 +40,10 @@ public function canHandle(TemplateTypeInterface $templateType): bool return $templateType->isModuleTemplate(); } - private function getExtension(TemplateTypeInterface $templateType, NamespacedDirectory $directory): ModuleExtensionTemplateType - { + private function getExtension( + TemplateTypeInterface $templateType, + NamespacedDirectory $directory + ): ModuleExtensionTemplateType { return new ModuleExtensionTemplateType( $templateType->getName(), $directory->getNamespace(), diff --git a/src/Resolver/TemplateChain/TemplateHandler/ModuleExtensions/ShopExtensionTemplateHandler.php b/src/Resolver/TemplateChain/TemplateHandler/ModuleExtensions/ShopExtensionTemplateHandler.php index 80c448d..b7d8f34 100644 --- a/src/Resolver/TemplateChain/TemplateHandler/ModuleExtensions/ShopExtensionTemplateHandler.php +++ b/src/Resolver/TemplateChain/TemplateHandler/ModuleExtensions/ShopExtensionTemplateHandler.php @@ -10,9 +10,9 @@ namespace OxidEsales\Twig\Resolver\TemplateChain\TemplateHandler\ModuleExtensions; use OxidEsales\Twig\Resolver\DataObject\NamespacedDirectory; +use OxidEsales\Twig\Resolver\TemplateChain\DataObject\TemplateChain; use OxidEsales\Twig\Resolver\TemplateChain\TemplateHandler\ChainAppenderInterface; use OxidEsales\Twig\Resolver\TemplateChain\TemplateHandler\TemplateTypeCheckerInterface; -use OxidEsales\Twig\Resolver\TemplateChain\DataObject\TemplateChain; use OxidEsales\Twig\Resolver\TemplateChain\TemplateType\DataObject\TemplateTypeInterface; class ShopExtensionTemplateHandler implements ChainAppenderInterface, TemplateTypeCheckerInterface @@ -22,8 +22,11 @@ public function __construct( ) { } - public function addToChain(TemplateChain $templateChain, TemplateTypeInterface $templateType, NamespacedDirectory $directory): TemplateChain - { + public function addToChain( + TemplateChain $templateChain, + TemplateTypeInterface $templateType, + NamespacedDirectory $directory + ): TemplateChain { if (!$this->canHandle($templateType)) { return $templateChain; } diff --git a/src/Resolver/TemplateChain/TemplateHandler/ModuleExtensions/ShopTemplateChainAppender.php b/src/Resolver/TemplateChain/TemplateHandler/ModuleExtensions/ShopTemplateChainAppender.php index b102b3a..2e6927d 100644 --- a/src/Resolver/TemplateChain/TemplateHandler/ModuleExtensions/ShopTemplateChainAppender.php +++ b/src/Resolver/TemplateChain/TemplateHandler/ModuleExtensions/ShopTemplateChainAppender.php @@ -10,8 +10,8 @@ namespace OxidEsales\Twig\Resolver\TemplateChain\TemplateHandler\ModuleExtensions; use OxidEsales\Twig\Resolver\DataObject\NamespacedDirectory; -use OxidEsales\Twig\Resolver\TemplateChain\TemplateHandler\ChainAppenderInterface; use OxidEsales\Twig\Resolver\TemplateChain\DataObject\TemplateChain; +use OxidEsales\Twig\Resolver\TemplateChain\TemplateHandler\ChainAppenderInterface; use OxidEsales\Twig\Resolver\TemplateChain\TemplateType\DataObject\ShopExtensionTemplateType; use OxidEsales\Twig\Resolver\TemplateChain\TemplateType\DataObject\TemplateTypeInterface; use OxidEsales\Twig\TwigContextInterface; @@ -24,8 +24,11 @@ public function __construct( ) { } - public function addToChain(TemplateChain $templateChain, TemplateTypeInterface $templateType, NamespacedDirectory $directory): TemplateChain - { + public function addToChain( + TemplateChain $templateChain, + TemplateTypeInterface $templateType, + NamespacedDirectory $directory + ): TemplateChain { foreach ($this->getThemeIdsOrderedByLoadPriority() as $theme) { $countBefore = $templateChain->count(); $extension = $this->getExtension($templateType, $directory, $theme); @@ -50,8 +53,11 @@ private function getFallbackThemeId(): string return 'default'; } - private function getExtension(TemplateTypeInterface $template, NamespacedDirectory $directory, string $theme): ShopExtensionTemplateType - { + private function getExtension( + TemplateTypeInterface $template, + NamespacedDirectory $directory, + string $theme + ): ShopExtensionTemplateType { return new ShopExtensionTemplateType( $template->getName(), $directory->getNamespace(), diff --git a/src/Resolver/TemplateChain/TemplateHandler/ModuleExtensions/ShopTemplateHandler.php b/src/Resolver/TemplateChain/TemplateHandler/ModuleExtensions/ShopTemplateHandler.php index d4d31d5..a7c75da 100644 --- a/src/Resolver/TemplateChain/TemplateHandler/ModuleExtensions/ShopTemplateHandler.php +++ b/src/Resolver/TemplateChain/TemplateHandler/ModuleExtensions/ShopTemplateHandler.php @@ -10,9 +10,9 @@ namespace OxidEsales\Twig\Resolver\TemplateChain\TemplateHandler\ModuleExtensions; use OxidEsales\Twig\Resolver\DataObject\NamespacedDirectory; +use OxidEsales\Twig\Resolver\TemplateChain\DataObject\TemplateChain; use OxidEsales\Twig\Resolver\TemplateChain\TemplateHandler\ChainAppenderInterface; use OxidEsales\Twig\Resolver\TemplateChain\TemplateHandler\TemplateTypeCheckerInterface; -use OxidEsales\Twig\Resolver\TemplateChain\DataObject\TemplateChain; use OxidEsales\Twig\Resolver\TemplateChain\TemplateType\DataObject\TemplateTypeInterface; class ShopTemplateHandler implements ChainAppenderInterface, TemplateTypeCheckerInterface @@ -22,8 +22,11 @@ public function __construct( ) { } - public function addToChain(TemplateChain $templateChain, TemplateTypeInterface $templateType, NamespacedDirectory $directory): TemplateChain - { + public function addToChain( + TemplateChain $templateChain, + TemplateTypeInterface $templateType, + NamespacedDirectory $directory + ): TemplateChain { if (!$this->canHandle($templateType)) { return $templateChain; } diff --git a/src/Resolver/TemplateChain/TemplateHandler/ModuleTemplateHandler.php b/src/Resolver/TemplateChain/TemplateHandler/ModuleTemplateHandler.php index 511e926..a597f95 100644 --- a/src/Resolver/TemplateChain/TemplateHandler/ModuleTemplateHandler.php +++ b/src/Resolver/TemplateChain/TemplateHandler/ModuleTemplateHandler.php @@ -20,8 +20,11 @@ public function __construct( ) { } - public function addToChain(TemplateChain $templateChain, TemplateTypeInterface $templateType, NamespacedDirectory $directory): TemplateChain - { + public function addToChain( + TemplateChain $templateChain, + TemplateTypeInterface $templateType, + NamespacedDirectory $directory + ): TemplateChain { if (!$this->canHandle($templateType)) { return $templateChain; } diff --git a/src/Resolver/TemplateChain/TemplateHandler/ShopTemplateHandler.php b/src/Resolver/TemplateChain/TemplateHandler/ShopTemplateHandler.php index 549eda2..4a1bf19 100644 --- a/src/Resolver/TemplateChain/TemplateHandler/ShopTemplateHandler.php +++ b/src/Resolver/TemplateChain/TemplateHandler/ShopTemplateHandler.php @@ -20,8 +20,11 @@ public function __construct( ) { } - public function addToChain(TemplateChain $templateChain, TemplateTypeInterface $templateType, NamespacedDirectory $directory): TemplateChain - { + public function addToChain( + TemplateChain $templateChain, + TemplateTypeInterface $templateType, + NamespacedDirectory $directory + ): TemplateChain { if (!$this->canHandle($templateType)) { return $templateChain; } diff --git a/src/TokenParser/CaptureTokenParser.php b/src/TokenParser/CaptureTokenParser.php index 01effad..80b6157 100644 --- a/src/TokenParser/CaptureTokenParser.php +++ b/src/TokenParser/CaptureTokenParser.php @@ -51,7 +51,9 @@ private function getAttributeName(TokenStream $stream): string { $attributeName = $stream->expect(Token::NAME_TYPE)->getValue(); if (!in_array($attributeName, $this->possibleAttributes)) { - throw new SyntaxError("Incorrect attribute name. Possible attribute names are: 'name', 'assign' and 'append'"); + throw new SyntaxError( + "Incorrect attribute name. Possible attribute names are: 'name', 'assign' and 'append'" + ); } return $attributeName; diff --git a/src/TokenParser/HasRightsTokenParser.php b/src/TokenParser/HasRightsTokenParser.php index 40996b5..4cbb45a 100644 --- a/src/TokenParser/HasRightsTokenParser.php +++ b/src/TokenParser/HasRightsTokenParser.php @@ -43,7 +43,14 @@ public function parse(Token $token) if ($stream->next()->getValue() === 'endhasrights') { $continue = false; } else { - throw new SyntaxError(sprintf('Unexpected end of template. Twig was looking for the following tags "endhasrights" to close the "hasrights" block started at line %d)', $lineno), -1); + throw new SyntaxError( + sprintf( + 'Unexpected end of template. Twig was looking for the following tags "endhasrights" to close ' + . 'the "hasrights" block started at line %d)', + $lineno + ), + -1 + ); } $stream->expect(Token::BLOCK_END_TYPE);