Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
svycka committed Nov 21, 2022
2 parents 8f2bd20 + 4ff2460 commit 5d6e2b6
Show file tree
Hide file tree
Showing 16 changed files with 78 additions and 75 deletions.
32 changes: 16 additions & 16 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@ 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"
# - 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: "no"
- php-version: 8.0
dependencies: "--prefer-lowest --prefer-stable"
test_coverage: "no"
- php-version: 8.1
dependencies: "--prefer-stable"
test_coverage: "no"
- php-version: 8.1
dependencies: "--prefer-lowest --prefer-stable"
test_coverage: "no"

steps:
- name: Setup PHP
Expand All @@ -43,16 +43,16 @@ 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' }}
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
run: vendor/bin/php-coveralls
33 changes: 18 additions & 15 deletions .php_cs → .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,20 @@ public function __construct()
$this->setRiskyAllowed(true);
}

public function getRules()
public function getRules(): array
{
return [
'@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,
Expand All @@ -34,34 +36,33 @@ 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,
'no_alias_functions' => true,
'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,
'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,
Expand All @@ -76,8 +77,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,
Expand All @@ -92,7 +95,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,
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
12 changes: 5 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
}
],
"require": {
"php": "^7.2",
"php": "^7.2 || ~8.0.0 || ~8.1.0",
"ext-intl": "*",
"laminas/laminas-eventmanager": "^3.1",
"laminas/laminas-http": "^2.7",
Expand All @@ -30,13 +30,11 @@
"laminas/laminas-view": "^2.9.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.19.3",
"laminas/laminas-console": "^2.6",
"friendsofphp/php-cs-fixer": "^3.13.0",
"laminas/laminas-mvc": "^3.1",
"laminas/laminas-mvc-console": "^1.1.9",
"phpspec/prophecy": "^1.15",
"phpunit/phpunit": "^8.5.1",
"satooshi/php-coveralls": "^1.1.0"
"phpspec/prophecy-phpunit": "^2.0.1",
"phpunit/phpunit": "^9.5.26",
"php-coveralls/php-coveralls": "^2.4.3"
},
"suggest": {
"laminas/laminas-mvc": "For using the router in the UriPath strategy"
Expand Down
12 changes: 9 additions & 3 deletions src/SlmLocale/LocaleEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,20 @@

class LocaleEvent extends Event
{
const EVENT_DETECT = 'detect';
const EVENT_FOUND = 'found';
const EVENT_ASSEMBLE = 'assemble';
public const EVENT_DETECT = 'detect';

public const EVENT_FOUND = 'found';

public const EVENT_ASSEMBLE = 'assemble';

protected $request;

protected $response;

protected $supported;

protected $locale;

protected $uri;

public function getRequest()
Expand Down
2 changes: 1 addition & 1 deletion src/SlmLocale/Strategy/CookieStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

class CookieStrategy extends AbstractStrategy
{
const COOKIE_NAME = 'slm_locale';
public const COOKIE_NAME = 'slm_locale';

/**
* The name of the cookie.
Expand Down
13 changes: 9 additions & 4 deletions src/SlmLocale/Strategy/HostStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,14 @@

class HostStrategy extends AbstractStrategy
{
const LOCALE_KEY = ':locale';
const REDIRECT_STATUS_CODE = 302;
public const LOCALE_KEY = ':locale';

public const REDIRECT_STATUS_CODE = 302;

protected $domain;

protected $aliases;

protected $redirect_to_canonical;

public function setOptions(array $options = [])
Expand Down Expand Up @@ -99,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
));
}

Expand Down Expand Up @@ -172,7 +177,7 @@ protected function getAliasForLocale($locale)
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function assemble(LocaleEvent $event)
{
Expand Down
6 changes: 3 additions & 3 deletions src/SlmLocale/Strategy/QueryStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -75,7 +75,7 @@ protected function getQueryKey()
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function detect(LocaleEvent $event)
{
Expand All @@ -101,7 +101,7 @@ public function detect(LocaleEvent $event)
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function assemble(LocaleEvent $event)
{
Expand Down
4 changes: 2 additions & 2 deletions src/SlmLocale/Strategy/StrategyPluginManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class StrategyPluginManager extends AbstractPluginManager
protected $instanceOf = StrategyInterface::class;

/**
* {@inheritdoc}
* @inheritdoc
*/
protected $aliases = [
'cookie' => CookieStrategy::class,
Expand All @@ -61,7 +61,7 @@ class StrategyPluginManager extends AbstractPluginManager
];

/**
* {@inheritdoc}
* @inheritdoc
*/
protected $factories = [
CookieStrategy::class => InvokableFactory::class,
Expand Down
7 changes: 6 additions & 1 deletion src/SlmLocale/Strategy/UriPathStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,19 @@

class UriPathStrategy extends AbstractStrategy
{
const REDIRECT_STATUS_CODE = 302;
public 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
*/
Expand Down
3 changes: 3 additions & 0 deletions tests/SlmLocaleTest/ModuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
11 changes: 0 additions & 11 deletions tests/SlmLocaleTest/Strategy/AssetStrategyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
*/
Expand Down
1 change: 1 addition & 0 deletions tests/SlmLocaleTest/Strategy/CookieStrategyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
class CookieStrategyTest extends TestCase
{
protected $strategy;

protected $event;

public function setUp(): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
class HttpAcceptLanguageStrategyTest extends TestCase
{
protected $strategy;

protected $event;

public function setUp(): void
Expand Down
1 change: 1 addition & 0 deletions tests/SlmLocaleTest/Strategy/QueryStrategyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class QueryStrategyTest extends TestCase
* @var QueryStrategy $strategy
*/
protected $strategy;

/**
* @var LocaleEvent $event
*/
Expand Down
Loading

0 comments on commit 5d6e2b6

Please sign in to comment.