From 784dc2855eb72d7e42c03b7a9bcf752ce41cfde7 Mon Sep 17 00:00:00 2001 From: KoKsPfLaNzE Date: Fri, 24 Sep 2021 20:20:49 +0200 Subject: [PATCH 01/12] added php80 in composer and travis removed deprecated laminas-console --- .travis.yml | 9 ++++++++- composer.json | 8 +++----- tests/SlmLocaleTest/Strategy/AssetStrategyTest.php | 11 ----------- tests/SlmLocaleTest/Strategy/UriPathStrategyTest.php | 9 --------- 4 files changed, 11 insertions(+), 26 deletions(-) diff --git a/.travis.yml b/.travis.yml index 84a7020..045f8b7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,11 +24,18 @@ matrix: - php: 7.4 env: - DEPENDENCIES="--prefer-stable" - - TEST_COVERAGE=true - php: 7.4 env: - DEPENDENCIES="--prefer-lowest --prefer-stable" + - php: 8.0 + env: + - DEPENDENCIES="--prefer-stable" + - TEST_COVERAGE=true + - php: 8.0 + env: + - DEPENDENCIES="--prefer-lowest --prefer-stable" + before_script: - phpenv config-rm xdebug.ini - composer self-update diff --git a/composer.json b/composer.json index a059ca1..39fc9cc 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ } ], "require": { - "php": "^7.2", + "php": "^7.2 || ~8.0.0", "ext-intl": "*", "laminas/laminas-eventmanager": "^3.1", "laminas/laminas-http": "^2.7", @@ -32,10 +32,8 @@ "require-dev": { "friendsofphp/php-cs-fixer": "^2.16.1", "phpunit/phpunit": "^8.5.1", - "satooshi/php-coveralls": "^1.1.0", - "laminas/laminas-console": "^2.6", - "laminas/laminas-mvc": "^3.1", - "laminas/laminas-mvc-console": "^1.1.9" + "php-coveralls/php-coveralls": "^2.4.3", + "laminas/laminas-mvc": "^3.1" }, "suggest": { "laminas/laminas-mvc": "For using the router in the UriPath strategy" diff --git a/tests/SlmLocaleTest/Strategy/AssetStrategyTest.php b/tests/SlmLocaleTest/Strategy/AssetStrategyTest.php index a6d5fb6..ddb8d23 100644 --- a/tests/SlmLocaleTest/Strategy/AssetStrategyTest.php +++ b/tests/SlmLocaleTest/Strategy/AssetStrategyTest.php @@ -2,8 +2,6 @@ namespace SlmLocaleTest\Strategy; -use Laminas\Console\Request as ConsoleRequest; -use Laminas\Console\Response as ConsoleResponse; use Laminas\EventManager\EventManager; use Laminas\Http\PhpEnvironment\Request as HttpRequest; use Laminas\Http\PhpEnvironment\Response as HttpResponse; @@ -38,15 +36,6 @@ public function testDetectReturnsNullByDefault() $this->assertNull($locale); } - public function testDetectWithConsoleRequestReturnsNull() - { - $this->event->setRequest(new ConsoleRequest()); - $this->event->setResponse(new ConsoleResponse()); - - $locale = $this->strategy->detect($this->event); - $this->assertNull($locale); - } - /** * @dataProvider uriProvider */ diff --git a/tests/SlmLocaleTest/Strategy/UriPathStrategyTest.php b/tests/SlmLocaleTest/Strategy/UriPathStrategyTest.php index 4446087..a2c4932 100644 --- a/tests/SlmLocaleTest/Strategy/UriPathStrategyTest.php +++ b/tests/SlmLocaleTest/Strategy/UriPathStrategyTest.php @@ -71,15 +71,6 @@ public function setUp(): void $this->event->setSupported(['nl', 'de', 'en']); } - public function testDetectWithConsoleRequestReturnsNull() - { - $this->event->setRequest(new ConsoleRequest()); - $this->event->setResponse(new ConsoleResponse()); - - $locale = $this->strategy->detect($this->event); - $this->assertNull($locale); - } - public function testDetectReturnsNullByDefault() { $this->event->setRequest(new HttpRequest()); From eebc7797203384a0c929541c003d0ac77b9a8ac0 Mon Sep 17 00:00:00 2001 From: Oliver Date: Thu, 9 Jun 2022 21:45:01 +0200 Subject: [PATCH 02/12] php81 added --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 39fc9cc..5d397f1 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ } ], "require": { - "php": "^7.2 || ~8.0.0", + "php": "^7.2 || ~8.0.0 || ~8.1.0", "ext-intl": "*", "laminas/laminas-eventmanager": "^3.1", "laminas/laminas-http": "^2.7", From 0fa4fab30c321d8ba26553a23a30d21dd4e90f8f Mon Sep 17 00:00:00 2001 From: Demian Katz Date: Thu, 17 Nov 2022 14:56:16 -0500 Subject: [PATCH 03/12] Switch from Travis to GitHub Actions. --- .github/workflows/ci.yaml | 58 +++++++++++++++++++++++++++++++++++++++ .travis.yml | 49 --------------------------------- composer.json | 8 ++++-- 3 files changed, 63 insertions(+), 52 deletions(-) create mode 100644 .github/workflows/ci.yaml delete mode 100644 .travis.yml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..dd16d72 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,58 @@ +name: CI + +on: [push, pull_request] + +jobs: + run-tests: + name: Tests with PHP ${{ matrix.php-version }} (Composer ${{ matrix.dependencies }}) + runs-on: ubuntu-latest + strategy: + matrix: + include: + - php-version: 7.4 + dependencies: "--prefer-stable" + test_coverage: "yes" + - php-version: 7.4 + dependencies: "--prefer-lowest --prefer-stable" + test_coverage: "no" +# - php-version: 8.0 +# dependencies: "--prefer-stable" +# test_coverage: false +# - php-version: 8.0 +# dependencies: "--prefer-lowest --prefer-stable" +# test_coverage: false +# - php-version: 8.1 +# dependencies: "--prefer-stable" +# test_coverage: false +# - php-version: 8.1 +# dependencies: "--prefer-lowest --prefer-stable" +# test_coverage: false + + steps: + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + extensions: xdebug + tools: composer:2.4.4 + + - name: Checkout + uses: actions/checkout@v3 + + - name: Install composer dependencies + run: composer update --prefer-source ${{ matrix.dependencies }} + + - name: Run php-cs-fixer + run: vendor/bin/php-cs-fixer fix -v --diff --dry-run + + - name: Run tests (without coverage) + if: ${{ matrix.test_coverage == 'no' }} + run: vendor/bin/phpunit + + - name: Run tests (with coverage) + if: ${{ matrix.test_coverage == 'yes' }} + run: php -dzend_extension=xdebug.so ./vendor/bin/phpunit --coverage-text --coverage-clover ./build/logs/clover.xml + + - name: Run coveralls + if: ${{ matrix.test_coverage == 'yes' }} + run: vendor/bin/coveralls diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 045f8b7..0000000 --- a/.travis.yml +++ /dev/null @@ -1,49 +0,0 @@ -language: php - -cache: - directories: - - $HOME/.composer/cache - - $HOME/.php-cs-fixer - -matrix: - include: - - php: 7.2 - env: - - DEPENDENCIES="--prefer-stable" - - php: 7.2 - env: - - DEPENDENCIES="--prefer-lowest --prefer-stable" - - - php: 7.3 - env: - - DEPENDENCIES="--prefer-stable" - - php: 7.3 - env: - - DEPENDENCIES="--prefer-lowest --prefer-stable" - - - php: 7.4 - env: - - DEPENDENCIES="--prefer-stable" - - php: 7.4 - env: - - DEPENDENCIES="--prefer-lowest --prefer-stable" - - - php: 8.0 - env: - - DEPENDENCIES="--prefer-stable" - - TEST_COVERAGE=true - - php: 8.0 - env: - - DEPENDENCIES="--prefer-lowest --prefer-stable" - -before_script: - - phpenv config-rm xdebug.ini - - composer self-update - - composer update --prefer-source $DEPENDENCIES - -script: - - vendor/bin/php-cs-fixer fix -v --diff --dry-run - - if [[ $TEST_COVERAGE == 'true' ]]; then php -dzend_extension=xdebug.so ./vendor/bin/phpunit --coverage-text --coverage-clover ./build/logs/clover.xml; else ./vendor/bin/phpunit; fi - -after_success: - - if [[ $TEST_COVERAGE == 'true' ]]; then php vendor/bin/coveralls -v; fi diff --git a/composer.json b/composer.json index 5d397f1..24d5fed 100644 --- a/composer.json +++ b/composer.json @@ -30,10 +30,12 @@ "laminas/laminas-view": "^2.9.0" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^2.16.1", + "friendsofphp/php-cs-fixer": "^2.19.3", + "laminas/laminas-console": "^2.6", + "laminas/laminas-mvc": "^3.1", + "phpspec/prophecy": "^1.15", "phpunit/phpunit": "^8.5.1", - "php-coveralls/php-coveralls": "^2.4.3", - "laminas/laminas-mvc": "^3.1" + "satooshi/php-coveralls": "^2.4.3" }, "suggest": { "laminas/laminas-mvc": "For using the router in the UriPath strategy" From 5fb673bc84b247d8b85695274a2da07ef09e2a43 Mon Sep 17 00:00:00 2001 From: KoKsPfLaNzE Date: Fri, 18 Nov 2022 15:54:46 +0100 Subject: [PATCH 04/12] enabled php80 and php81 --- .github/workflows/ci.yaml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index dd16d72..c2511bb 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -15,18 +15,18 @@ jobs: - php-version: 7.4 dependencies: "--prefer-lowest --prefer-stable" test_coverage: "no" -# - php-version: 8.0 -# dependencies: "--prefer-stable" -# test_coverage: false -# - php-version: 8.0 -# dependencies: "--prefer-lowest --prefer-stable" -# test_coverage: false -# - php-version: 8.1 -# dependencies: "--prefer-stable" -# test_coverage: false -# - php-version: 8.1 -# dependencies: "--prefer-lowest --prefer-stable" -# test_coverage: false + - php-version: 8.0 + dependencies: "--prefer-stable" + test_coverage: false + - php-version: 8.0 + dependencies: "--prefer-lowest --prefer-stable" + test_coverage: false + - php-version: 8.1 + dependencies: "--prefer-stable" + test_coverage: false + - php-version: 8.1 + dependencies: "--prefer-lowest --prefer-stable" + test_coverage: false steps: - name: Setup PHP From d9e48954313b9002901cd5939cb25e1333305a11 Mon Sep 17 00:00:00 2001 From: KoKsPfLaNzE Date: Fri, 18 Nov 2022 16:02:44 +0100 Subject: [PATCH 05/12] removed old dependencies --- composer.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 24d5fed..4eda9a4 100644 --- a/composer.json +++ b/composer.json @@ -31,11 +31,10 @@ }, "require-dev": { "friendsofphp/php-cs-fixer": "^2.19.3", - "laminas/laminas-console": "^2.6", "laminas/laminas-mvc": "^3.1", "phpspec/prophecy": "^1.15", "phpunit/phpunit": "^8.5.1", - "satooshi/php-coveralls": "^2.4.3" + "php-coveralls/php-coveralls": "^2.4.3" }, "suggest": { "laminas/laminas-mvc": "For using the router in the UriPath strategy" From a59e1ed736ceadbaddc9cf4b77fb6bc130d92dc8 Mon Sep 17 00:00:00 2001 From: KoKsPfLaNzE Date: Fri, 18 Nov 2022 16:19:37 +0100 Subject: [PATCH 06/12] PHP-CS-Fixer config update and run --- .php_cs => .php-cs-fixer.php | 28 +++++++++++-------- src/SlmLocale/LocaleEvent.php | 6 ++++ src/SlmLocale/Strategy/HostStrategy.php | 5 +++- src/SlmLocale/Strategy/QueryStrategy.php | 4 +-- .../Strategy/StrategyPluginManager.php | 4 +-- src/SlmLocale/Strategy/UriPathStrategy.php | 5 ++++ .../Strategy/CookieStrategyTest.php | 1 + .../HttpAcceptLanguageStrategyTest.php | 1 + .../Strategy/QueryStrategyTest.php | 1 + .../Strategy/UriPathStrategyTest.php | 4 +-- 10 files changed, 40 insertions(+), 19 deletions(-) rename .php_cs => .php-cs-fixer.php (84%) diff --git a/.php_cs b/.php-cs-fixer.php similarity index 84% rename from .php_cs rename to .php-cs-fixer.php index c5bd692..9cce88e 100644 --- a/.php_cs +++ b/.php-cs-fixer.php @@ -17,12 +17,14 @@ public function getRules() '@PSR2' => true, 'array_syntax' => ['syntax' => 'short'], 'binary_operator_spaces' => [ - 'align_double_arrow' => true, - 'align_equals' => true, + 'operators' => [ + '=>' => 'align', + '=' => 'align', + ], ], 'blank_line_after_opening_tag' => true, 'blank_line_after_namespace' => true, - 'blank_line_before_return' => true, + 'blank_line_before_statement' => true, 'braces' => true, 'cast_spaces' => true, 'class_definition' => true, @@ -34,16 +36,16 @@ public function getRules() 'full_opening_tag' => true, 'function_declaration' => true, 'function_typehint_space' => true, - 'hash_to_slash_comment' => true, + 'single_line_comment_style' => true, 'header_comment' => false, 'include' => true, 'indentation_type' => true, 'linebreak_after_opening_tag' => true, 'line_ending' => true, - 'lowercase_constants' => true, + 'constant_case' => true, 'lowercase_keywords' => true, 'method_argument_space' => true, - 'method_separation' => true, + 'class_attributes_separation' => true, 'modernize_types_casting' => true, 'native_function_casing' => true, 'new_with_braces' => true, @@ -51,13 +53,13 @@ public function getRules() 'no_blank_lines_after_class_opening' => true, 'no_closing_tag' => true, 'no_empty_statement' => true, - 'no_extra_consecutive_blank_lines' => true, + 'no_extra_blank_lines' => true, 'no_leading_import_slash' => true, 'no_leading_namespace_whitespace' => true, 'no_multiline_whitespace_around_double_arrow' => true, - 'no_multiline_whitespace_before_semicolons' => true, + 'multiline_whitespace_before_semicolons' => true, 'no_short_bool_cast' => true, - 'no_short_echo_tag' => true, + 'echo_tag_syntax' => true, 'no_singleline_whitespace_before_semicolons' => true, 'no_spaces_around_offset' => true, 'no_trailing_comma_in_list_call' => true, @@ -76,8 +78,10 @@ public function getRules() 'object_operator_without_whitespace' => true, 'ordered_imports' => true, 'phpdoc_indent' => true, - 'phpdoc_inline_tag' => true, - 'psr4' => true, + 'general_phpdoc_tag_rename' => true, + 'phpdoc_inline_tag_normalizer' => true, + 'phpdoc_tag_type' => true, + 'psr_autoloading' => true, 'return_type_declaration' => false, 'semicolon_after_instruction' => true, 'short_scalar_cast' => true, @@ -92,7 +96,7 @@ public function getRules() 'switch_case_semicolon_to_colon' => true, 'switch_case_space' => true, 'ternary_operator_spaces' => true, - 'trailing_comma_in_multiline_array' => true, + 'trailing_comma_in_multiline' => true, 'trim_array_spaces' => true, 'unary_operator_spaces' => true, 'visibility_required' => true, diff --git a/src/SlmLocale/LocaleEvent.php b/src/SlmLocale/LocaleEvent.php index 4ebb3ce..e25a26c 100644 --- a/src/SlmLocale/LocaleEvent.php +++ b/src/SlmLocale/LocaleEvent.php @@ -48,13 +48,19 @@ class LocaleEvent extends Event { const EVENT_DETECT = 'detect'; + const EVENT_FOUND = 'found'; + const EVENT_ASSEMBLE = 'assemble'; protected $request; + protected $response; + protected $supported; + protected $locale; + protected $uri; public function getRequest() diff --git a/src/SlmLocale/Strategy/HostStrategy.php b/src/SlmLocale/Strategy/HostStrategy.php index 96bef6f..ec673ce 100644 --- a/src/SlmLocale/Strategy/HostStrategy.php +++ b/src/SlmLocale/Strategy/HostStrategy.php @@ -46,10 +46,13 @@ class HostStrategy extends AbstractStrategy { const LOCALE_KEY = ':locale'; + const REDIRECT_STATUS_CODE = 302; protected $domain; + protected $aliases; + protected $redirect_to_canonical; public function setOptions(array $options = []) @@ -172,7 +175,7 @@ protected function getAliasForLocale($locale) } /** - * {@inheritdoc} + * @inheritdoc */ public function assemble(LocaleEvent $event) { diff --git a/src/SlmLocale/Strategy/QueryStrategy.php b/src/SlmLocale/Strategy/QueryStrategy.php index f9e1eba..fed1427 100644 --- a/src/SlmLocale/Strategy/QueryStrategy.php +++ b/src/SlmLocale/Strategy/QueryStrategy.php @@ -75,7 +75,7 @@ protected function getQueryKey() } /** - * {@inheritdoc} + * @inheritdoc */ public function detect(LocaleEvent $event) { @@ -101,7 +101,7 @@ public function detect(LocaleEvent $event) } /** - * {@inheritdoc} + * @inheritdoc */ public function assemble(LocaleEvent $event) { diff --git a/src/SlmLocale/Strategy/StrategyPluginManager.php b/src/SlmLocale/Strategy/StrategyPluginManager.php index 21599bb..3c27a20 100644 --- a/src/SlmLocale/Strategy/StrategyPluginManager.php +++ b/src/SlmLocale/Strategy/StrategyPluginManager.php @@ -49,7 +49,7 @@ class StrategyPluginManager extends AbstractPluginManager protected $instanceOf = StrategyInterface::class; /** - * {@inheritdoc} + * @inheritdoc */ protected $aliases = [ 'cookie' => CookieStrategy::class, @@ -61,7 +61,7 @@ class StrategyPluginManager extends AbstractPluginManager ]; /** - * {@inheritdoc} + * @inheritdoc */ protected $factories = [ CookieStrategy::class => InvokableFactory::class, diff --git a/src/SlmLocale/Strategy/UriPathStrategy.php b/src/SlmLocale/Strategy/UriPathStrategy.php index f9a37ee..78e4fe1 100644 --- a/src/SlmLocale/Strategy/UriPathStrategy.php +++ b/src/SlmLocale/Strategy/UriPathStrategy.php @@ -51,11 +51,16 @@ class UriPathStrategy extends AbstractStrategy const REDIRECT_STATUS_CODE = 302; protected $redirect_when_found = true; + protected $aliases; + protected $redirect_to_canonical; + protected $sl; + /** @var string|null */ protected $default; + /** * @var SimpleRouteStack */ diff --git a/tests/SlmLocaleTest/Strategy/CookieStrategyTest.php b/tests/SlmLocaleTest/Strategy/CookieStrategyTest.php index ca54f34..84bc9d6 100644 --- a/tests/SlmLocaleTest/Strategy/CookieStrategyTest.php +++ b/tests/SlmLocaleTest/Strategy/CookieStrategyTest.php @@ -50,6 +50,7 @@ class CookieStrategyTest extends TestCase { protected $strategy; + protected $event; public function setUp(): void diff --git a/tests/SlmLocaleTest/Strategy/HttpAcceptLanguageStrategyTest.php b/tests/SlmLocaleTest/Strategy/HttpAcceptLanguageStrategyTest.php index 01d3166..1e31e11 100644 --- a/tests/SlmLocaleTest/Strategy/HttpAcceptLanguageStrategyTest.php +++ b/tests/SlmLocaleTest/Strategy/HttpAcceptLanguageStrategyTest.php @@ -48,6 +48,7 @@ class HttpAcceptLanguageStrategyTest extends TestCase { protected $strategy; + protected $event; public function setUp(): void diff --git a/tests/SlmLocaleTest/Strategy/QueryStrategyTest.php b/tests/SlmLocaleTest/Strategy/QueryStrategyTest.php index 9f80b47..38ed1c6 100644 --- a/tests/SlmLocaleTest/Strategy/QueryStrategyTest.php +++ b/tests/SlmLocaleTest/Strategy/QueryStrategyTest.php @@ -52,6 +52,7 @@ class QueryStrategyTest extends TestCase * @var QueryStrategy $strategy */ protected $strategy; + /** * @var LocaleEvent $event */ diff --git a/tests/SlmLocaleTest/Strategy/UriPathStrategyTest.php b/tests/SlmLocaleTest/Strategy/UriPathStrategyTest.php index a2c4932..47ed309 100644 --- a/tests/SlmLocaleTest/Strategy/UriPathStrategyTest.php +++ b/tests/SlmLocaleTest/Strategy/UriPathStrategyTest.php @@ -39,8 +39,6 @@ */ namespace SlmLocaleTest\Locale; -use Laminas\Console\Request as ConsoleRequest; -use Laminas\Console\Response as ConsoleResponse; use Laminas\Http\PhpEnvironment\Request as HttpRequest; use Laminas\Http\PhpEnvironment\Response as HttpResponse; use Laminas\Mvc\Console\Router\SimpleRouteStack as ConsoleRouter; @@ -56,8 +54,10 @@ class UriPathStrategyTest extends TestCase { /** @var UriPathStrategy */ private $strategy; + /** @var LocaleEvent */ private $event; + /** @var HttpRouter */ private $router; From 817c0719081c611a70388af71671c86598481427 Mon Sep 17 00:00:00 2001 From: KoKsPfLaNzE Date: Fri, 18 Nov 2022 16:24:57 +0100 Subject: [PATCH 07/12] workflow update --- .github/workflows/ci.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index c2511bb..fcde218 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -43,11 +43,11 @@ jobs: run: composer update --prefer-source ${{ matrix.dependencies }} - name: Run php-cs-fixer - run: vendor/bin/php-cs-fixer fix -v --diff --dry-run + run: composer cs-check - name: Run tests (without coverage) if: ${{ matrix.test_coverage == 'no' }} - run: vendor/bin/phpunit + run: composer test - name: Run tests (with coverage) if: ${{ matrix.test_coverage == 'yes' }} @@ -55,4 +55,4 @@ jobs: - name: Run coveralls if: ${{ matrix.test_coverage == 'yes' }} - run: vendor/bin/coveralls + run: vendor/bin/php-coveralls From 7ada9eb2cc6476947c52948e150975b2da1bfd6a Mon Sep 17 00:00:00 2001 From: KoKsPfLaNzE Date: Fri, 18 Nov 2022 16:36:46 +0100 Subject: [PATCH 08/12] fix test_coverage in workflow --- .github/workflows/ci.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index fcde218..1325cb7 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -17,16 +17,16 @@ jobs: test_coverage: "no" - php-version: 8.0 dependencies: "--prefer-stable" - test_coverage: false + test_coverage: "no" - php-version: 8.0 dependencies: "--prefer-lowest --prefer-stable" - test_coverage: false + test_coverage: "no" - php-version: 8.1 dependencies: "--prefer-stable" - test_coverage: false + test_coverage: "no" - php-version: 8.1 dependencies: "--prefer-lowest --prefer-stable" - test_coverage: false + test_coverage: "no" steps: - name: Setup PHP From 6fef49290a80e8ff90c3d7cea0c6b701a6359956 Mon Sep 17 00:00:00 2001 From: KoKsPfLaNzE Date: Fri, 18 Nov 2022 16:49:11 +0100 Subject: [PATCH 09/12] phpunit update php-cs-fixer update --- .php-cs-fixer.php | 5 ++--- composer.json | 6 +++--- tests/SlmLocaleTest/ModuleTest.php | 3 +++ 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php index 9cce88e..ae7d32c 100644 --- a/.php-cs-fixer.php +++ b/.php-cs-fixer.php @@ -11,7 +11,7 @@ public function __construct() $this->setRiskyAllowed(true); } - public function getRules() + public function getRules(): array { return [ '@PSR2' => true, @@ -62,8 +62,7 @@ public function getRules() 'echo_tag_syntax' => true, 'no_singleline_whitespace_before_semicolons' => true, 'no_spaces_around_offset' => true, - 'no_trailing_comma_in_list_call' => true, - 'no_trailing_comma_in_singleline_array' => true, + 'no_trailing_comma_in_singleline' => true, 'no_unneeded_control_parentheses' => true, 'no_unreachable_default_argument_value' => true, 'no_unused_imports' => true, diff --git a/composer.json b/composer.json index 4eda9a4..0e9a0ae 100644 --- a/composer.json +++ b/composer.json @@ -30,10 +30,10 @@ "laminas/laminas-view": "^2.9.0" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^2.19.3", + "friendsofphp/php-cs-fixer": "^3.13.0", "laminas/laminas-mvc": "^3.1", - "phpspec/prophecy": "^1.15", - "phpunit/phpunit": "^8.5.1", + "phpspec/prophecy-phpunit": "^2.0.1", + "phpunit/phpunit": "^9.5.26", "php-coveralls/php-coveralls": "^2.4.3" }, "suggest": { diff --git a/tests/SlmLocaleTest/ModuleTest.php b/tests/SlmLocaleTest/ModuleTest.php index 1894792..f705ee7 100644 --- a/tests/SlmLocaleTest/ModuleTest.php +++ b/tests/SlmLocaleTest/ModuleTest.php @@ -9,11 +9,14 @@ use Laminas\Stdlib\Request; use Laminas\Stdlib\Response; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; use SlmLocale\Locale\Detector; use SlmLocale\Module; class ModuleTest extends TestCase { + use ProphecyTrait; + public function testCanGetConfig() { $module = new Module(); From c2c931cecdf1558d0f85650549c44a6cc4758b3a Mon Sep 17 00:00:00 2001 From: KoKsPfLaNzE Date: Fri, 18 Nov 2022 16:56:13 +0100 Subject: [PATCH 10/12] phpunit update php-cs-fixer update --- src/SlmLocale/LocaleEvent.php | 6 +++--- src/SlmLocale/Strategy/CookieStrategy.php | 2 +- src/SlmLocale/Strategy/HostStrategy.php | 8 +++++--- src/SlmLocale/Strategy/QueryStrategy.php | 2 +- src/SlmLocale/Strategy/UriPathStrategy.php | 2 +- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/SlmLocale/LocaleEvent.php b/src/SlmLocale/LocaleEvent.php index e25a26c..cdc7bab 100644 --- a/src/SlmLocale/LocaleEvent.php +++ b/src/SlmLocale/LocaleEvent.php @@ -47,11 +47,11 @@ class LocaleEvent extends Event { - const EVENT_DETECT = 'detect'; + public const EVENT_DETECT = 'detect'; - const EVENT_FOUND = 'found'; + public const EVENT_FOUND = 'found'; - const EVENT_ASSEMBLE = 'assemble'; + public const EVENT_ASSEMBLE = 'assemble'; protected $request; diff --git a/src/SlmLocale/Strategy/CookieStrategy.php b/src/SlmLocale/Strategy/CookieStrategy.php index 1f6dddf..8a970d3 100644 --- a/src/SlmLocale/Strategy/CookieStrategy.php +++ b/src/SlmLocale/Strategy/CookieStrategy.php @@ -47,7 +47,7 @@ class CookieStrategy extends AbstractStrategy { - const COOKIE_NAME = 'slm_locale'; + public const COOKIE_NAME = 'slm_locale'; /** * The name of the cookie. diff --git a/src/SlmLocale/Strategy/HostStrategy.php b/src/SlmLocale/Strategy/HostStrategy.php index ec673ce..2a4ab0e 100644 --- a/src/SlmLocale/Strategy/HostStrategy.php +++ b/src/SlmLocale/Strategy/HostStrategy.php @@ -45,9 +45,9 @@ class HostStrategy extends AbstractStrategy { - const LOCALE_KEY = ':locale'; + public const LOCALE_KEY = ':locale'; - const REDIRECT_STATUS_CODE = 302; + public const REDIRECT_STATUS_CODE = 302; protected $domain; @@ -102,7 +102,9 @@ public function detect(LocaleEvent $event) } if (strpos($domain, self::LOCALE_KEY) === false) { throw new Exception\InvalidArgumentException(sprintf( - 'The domain %s must contain a locale key part "%s"', $domain, self::LOCALE_KEY + 'The domain %s must contain a locale key part "%s"', + $domain, + self::LOCALE_KEY )); } diff --git a/src/SlmLocale/Strategy/QueryStrategy.php b/src/SlmLocale/Strategy/QueryStrategy.php index fed1427..9c421c3 100644 --- a/src/SlmLocale/Strategy/QueryStrategy.php +++ b/src/SlmLocale/Strategy/QueryStrategy.php @@ -49,7 +49,7 @@ class QueryStrategy extends AbstractStrategy * * @var string */ - const QUERY_KEY = 'lang'; + public const QUERY_KEY = 'lang'; /** * Query key to use for request diff --git a/src/SlmLocale/Strategy/UriPathStrategy.php b/src/SlmLocale/Strategy/UriPathStrategy.php index 78e4fe1..5dbd33a 100644 --- a/src/SlmLocale/Strategy/UriPathStrategy.php +++ b/src/SlmLocale/Strategy/UriPathStrategy.php @@ -48,7 +48,7 @@ class UriPathStrategy extends AbstractStrategy { - const REDIRECT_STATUS_CODE = 302; + public const REDIRECT_STATUS_CODE = 302; protected $redirect_when_found = true; From af8882aa3fe6b658e246f967bdd5860b4b35c57e Mon Sep 17 00:00:00 2001 From: KoKsPfLaNzE Date: Fri, 18 Nov 2022 18:07:25 +0100 Subject: [PATCH 11/12] test_coverage disabled --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 1325cb7..000de73 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -11,7 +11,7 @@ jobs: include: - php-version: 7.4 dependencies: "--prefer-stable" - test_coverage: "yes" + test_coverage: "no" - php-version: 7.4 dependencies: "--prefer-lowest --prefer-stable" test_coverage: "no" From 4ff24603da192ca6ce612965411b0e0f63157385 Mon Sep 17 00:00:00 2001 From: Vytautas Stankus Date: Mon, 21 Nov 2022 10:06:36 +0200 Subject: [PATCH 12/12] Update CI badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 15dcbad..453a212 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ SlmLocale === -[![Build Status](https://travis-ci.org/basz/SlmLocale.svg?branch=master)](https://travis-ci.org/basz/SlmLocale) +[![CI](https://github.com/basz/SlmLocale/actions/workflows/ci.yaml/badge.svg?branch=master)](https://github.com/basz/SlmLocale/actions/workflows/ci.yaml) [![Latest Stable Version](https://poser.pugx.org/slm/locale/v/stable.png)](https://packagist.org/packages/slm/locale) [![Coverage Status](https://coveralls.io/repos/github/basz/SlmLocale/badge.svg?branch=master)](https://coveralls.io/github/basz/SlmLocale?branch=master)