diff --git a/.php_cs b/.php_cs deleted file mode 100644 index d192a9f..0000000 --- a/.php_cs +++ /dev/null @@ -1,130 +0,0 @@ -setRiskyAllowed(true) - ->setRules(array( - '@PSR2' => true, - 'header_comment' => ['header' => $header, 'commentType' => 'PHPDoc', 'separate' => 'none'], - 'array_syntax' => ['syntax' => 'short'], - 'binary_operator_spaces' => ['align_equals' => false, 'align_double_arrow' => false], - 'blank_line_after_opening_tag' => false, - 'blank_line_after_namespace' => false, - 'blank_line_before_return' => true, - 'cast_spaces' => true, -// 'class_keyword_remove' => true, - 'combine_consecutive_unsets' => true, - 'concat_space' => ['spacing' => 'one'], - 'declare_equal_normalize' => true, - 'declare_strict_types' => false, - 'dir_constant' => true, - 'ereg_to_preg' => true, - 'function_typehint_space' => true, - 'general_phpdoc_annotation_remove' => true, - 'hash_to_slash_comment' => true, - 'heredoc_to_nowdoc' => true, - 'include' => true, - 'indentation_type' => true, - 'is_null' => ['use_yoda_style' => false], - 'linebreak_after_opening_tag' => false, - 'lowercase_cast' => true, -// 'mb_str_functions' => true, - 'method_separation' => true, - 'modernize_types_casting' => true, - 'native_function_casing' => true, - 'native_function_invocation' => true, - 'new_with_braces' => false, // - 'no_alias_functions' => true, - 'no_blank_lines_after_class_opening' => true, - 'no_blank_lines_after_phpdoc' => true, - 'no_blank_lines_before_namespace' => true, - 'no_empty_comment' => true, - 'no_empty_phpdoc' => true, - 'no_empty_statement' => true, - 'no_extra_consecutive_blank_lines' => ['break', 'continue', 'curly_brace_block', 'extra', 'parenthesis_brace_block', 'return', 'square_brace_block', 'throw', 'use', 'useTrait'], - 'no_leading_import_slash' => true, - 'no_leading_namespace_whitespace' => true, - 'no_mixed_echo_print' => ['use' => 'echo'], - 'no_multiline_whitespace_around_double_arrow' => true, - 'no_multiline_whitespace_before_semicolons' => true, - 'no_php4_constructor' => false, - 'no_short_bool_cast' => true, - 'no_short_echo_tag' => false, - '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_whitespace' => true, - 'no_trailing_whitespace_in_comment' => true, - 'no_unneeded_control_parentheses' => true, - 'no_unreachable_default_argument_value' => true, - 'no_unused_imports' => true, - 'no_useless_else' => true, - 'no_useless_return' => true, - 'no_whitespace_before_comma_in_array' => true, - 'no_whitespace_in_blank_line' => true, - 'normalize_index_brace' => true, - 'not_operator_with_space' => false, - 'not_operator_with_successor_space' => true, - 'object_operator_without_whitespace' => true, - 'ordered_class_elements' => true, - 'ordered_imports' => true, - 'php_unit_construct' => true, - 'php_unit_dedicate_assert' => true, - 'php_unit_fqcn_annotation' => true, - 'php_unit_strict' => true, - 'phpdoc_add_missing_param_annotation' => true, - 'phpdoc_align' => true, - 'phpdoc_annotation_without_dot' => true, - 'phpdoc_indent' => true, - 'phpdoc_inline_tag' => true, - 'phpdoc_no_access' => true, - 'phpdoc_no_alias_tag' => ['property-read' => 'property', 'property-write' => 'property', 'type' => 'var'], - 'phpdoc_no_empty_return' => true, - 'phpdoc_no_package' => true, - 'phpdoc_no_useless_inheritdoc' => true, - 'phpdoc_order' => true, - 'phpdoc_return_self_reference' => true, - 'phpdoc_scalar' => true, - 'phpdoc_separation' => true, - 'phpdoc_single_line_var_spacing' => true, -// 'phpdoc_summary' => true, - 'phpdoc_to_comment' => true, - 'phpdoc_trim' => true, - 'phpdoc_types' => true, - 'phpdoc_var_without_name' => true, - 'pow_to_exponentiation' => true, -// 'pre_increment' => true, - 'protected_to_private' => true, - 'psr0' => true, - 'psr4' => true, - 'random_api_migration' => true, - 'return_type_declaration' => ['space_before' => 'one'], - 'self_accessor' => true, - 'short_scalar_cast' => true, -// 'silenced_deprecation_error' => true, - 'simplified_null_return' => true, -// 'single_blank_line_before_namespace' => true, - 'single_quote' => true, - 'space_after_semicolon' => true, - 'standardize_not_equals' => true, -// 'strict_comparison' => true, - 'ternary_operator_spaces' => true, - 'strict_param' => true, - 'ternary_to_null_coalescing' => true, -// 'trailing_comma_in_multiline_array' => true, - 'trim_array_spaces' => true, - 'unary_operator_spaces' => true, - 'whitespace_after_comma_in_array' => true - )) - ->setFinder( - PhpCsFixer\Finder::create() - ->exclude('tests/Fake') - ->exclude('fake-app/var') - ->in(__DIR__) - )->setLineEnding("\n"); diff --git a/.php_cs.dist b/.php_cs.dist new file mode 100644 index 0000000..5dafec7 --- /dev/null +++ b/.php_cs.dist @@ -0,0 +1,195 @@ +exclude(['tests/Fake', 'tests/tmp']) + ->notPath('tests/Provide/Router/aura.route.php') + ->in(__DIR__); + +return \PhpCsFixer\Config::create() + ->setRiskyAllowed(true) + ->setRules([ + '@PSR2' => true, + '@PHP70Migration:risky' => true, + 'align_multiline_comment' => true, + 'array_indentation' => true, + 'array_syntax' => ['syntax' => 'short'], + 'backtick_to_shell_exec' => true, + 'binary_operator_spaces' => true, // @Symfony + 'blank_line_after_opening_tag' => true, // @Symfony + 'blank_line_before_return' => true, + 'blank_line_before_statement' => ['statements' => ['break', 'continue', 'declare', 'return', 'throw']], // @Symfony + 'braces' => true, + 'cast_spaces' => true, // @Symfony + 'class_attributes_separation' => ['elements' => ['const', 'method']], // @Symfony +// 'class_keyword_remove' => true, + 'combine_consecutive_issets' => true, + 'combine_consecutive_unsets' => true, + 'combine_nested_dirname' => true, +// 'comment_to_phpdoc' => true, + 'compact_nullable_typehint' => true, + 'concat_space' => ['spacing' => 'one'], // @Symfony + 'date_time_immutable' => true, + 'declare_equal_normalize' => true, // @Symfony +// 'declare_strict_types' => true + 'dir_constant' => true, // @Symfony:risky + 'ereg_to_preg' => true, // @Symfony:risky + 'error_suppression' => true, // @Symfony:risky + 'escape_implicit_backslashes' => true, + 'explicit_indirect_variable' => true, + 'explicit_string_variable' => true, +// 'final_class' => true, +// 'final_internal_class' => true, + 'fully_qualified_strict_types' => true, +// 'final_public_method_for_abstract_class' => true, + 'function_to_constant' => true, // @Symfony:risky + 'function_typehint_space' => true, // @Symfony + 'general_phpdoc_annotation_remove' => ['author', 'category', 'package', 'copyright', 'version'], + 'global_namespace_import' => ['import_classes' => true, 'import_functions' => true, 'import_constants' => true], + 'header_comment' => ['header' => ''], + 'heredoc_to_nowdoc' => true, + 'include' => true, // @Symfony +// 'increment_style' => 'pre', // @Symfony + 'indentation_type' => true, + 'is_null' => ['use_yoda_style' => false], // @Symfony:risky + 'linebreak_after_opening_tag' => true, +// 'list_syntax' => true, +// 'logical_operators' => true, + 'lowercase_cast' => true, // @Symfony + 'lowercase_static_reference' => true, // @Symfony + 'magic_constant_casing' => true, +// 'mb_str_functions' => true, + 'method_chaining_indentation' => true, + 'method_separation' => true, + 'modernize_types_casting' => true, // @Symfony:risky + 'multiline_comment_opening_closing' => true, + 'multiline_whitespace_before_semicolons' => true, +// 'native_constant_invocation' => true, + 'native_function_casing' => true, // @Symfony +// 'native_function_invocation' => true, +// 'new_with_braces' => true, // @Symfony + 'no_alias_functions' => true, // @Symfony:risky + 'no_alternative_syntax' => true, + 'no_binary_string' => true, + 'no_blank_lines_after_class_opening' => true, // @Symfony + 'no_blank_lines_after_phpdoc' => true, // @Symfony +// 'no_blank_lines_before_namespace' => true, + 'no_empty_comment' => true, // @Symfony + 'no_empty_phpdoc' => true, // @Symfony + 'no_empty_statement' => true, // @Symfony + 'no_extra_blank_lines' => true, + 'no_homoglyph_names' => true, // @Symfony:risky + 'no_leading_import_slash' => true, // @Symfony + 'no_leading_namespace_whitespace' => true, // @Symfony + 'no_mixed_echo_print' => true, // @Symfony + 'no_multiline_whitespace_around_double_arrow' => true, // @Symfony + 'no_null_property_initialization' => true, + 'no_php4_constructor' => true, + 'no_short_bool_cast' => true, // @Symfony + 'no_short_echo_tag' => false, + 'no_singleline_whitespace_before_semicolons' => true, // @Symfony + 'no_spaces_around_offset' => true, // @Symfony + 'no_superfluous_elseif' => true, + 'no_superfluous_phpdoc_tags' => ['allow_mixed' => true], + 'no_trailing_comma_in_list_call' => true, // @Symfony + 'no_trailing_comma_in_singleline_array' => true, // @Symfony + 'no_trailing_whitespace' => true, + 'no_trailing_whitespace_in_comment' => true, + 'no_unneeded_control_parentheses' => true, // @Symfony + 'no_unneeded_curly_braces' => true, // @Symfony + 'no_unneeded_final_method' => true, // @Symfony + 'no_unreachable_default_argument_value' => true, + 'no_unset_on_property' => false, + 'no_unused_imports' => true, + 'no_useless_else' => true, + 'no_useless_return' => true, + 'no_whitespace_before_comma_in_array' => true, // @Symfony + 'no_whitespace_in_blank_line' => true, // @Symfony + 'non_printable_character' => true, // @Symfony + 'normalize_index_brace' => true, // @Symfony + 'not_operator_with_space' => false, + 'not_operator_with_successor_space' => true, + 'object_operator_without_whitespace' => true, // @Symfony + 'ordered_class_elements' => true, + 'ordered_imports' => true, + 'php_unit_construct' => true, // @Symfony:risky + 'php_unit_dedicate_assert' => true, + 'php_unit_dedicate_assert_internal_type' => true, + 'php_unit_expectation' => true, + 'php_unit_fqcn_annotation' => true, // @Symfony +// 'php_unit_internal_class' => true, // @Symfony] +// 'php_unit_mock' => true, + 'php_unit_namespaced' => true, + 'php_unit_no_expectation_annotation' => true, + 'php_unit_ordered_covers' => true, + 'php_unit_set_up_tear_down_visibility' => true, + 'php_unit_strict' => true, +// 'php_unit_test_annotation' => true, +// 'php_unit_test_case_static_method_calls' => true, +// 'php_unit_test_class_requires_covers' => true, +// 'phpdoc_add_missing_param_annotation' => true, + 'phpdoc_align' => ['tags' => ['param', 'return', 'throws', 'type', 'var', 'property-read', 'property-write']], // @Symfony] + 'phpdoc_annotation_without_dot' => true, // @Symfony] + 'phpdoc_var_annotation_correct_order' => true, + 'phpdoc_indent' => true, // @Symfony] + 'phpdoc_inline_tag' => true, // @Symfony] + 'phpdoc_no_access' => true, // @Symfony] + 'phpdoc_no_alias_tag' => ['type' => 'var', 'link' => 'see'], // @Symfony +// 'phpdoc_no_empty_return' => true, // @Symfony + 'phpdoc_no_package' => true, // @Symfony +// 'phpdoc_no_useless_inheritdoc' => true, // @Symfony + 'phpdoc_order' => true, + 'phpdoc_return_self_reference' => true, // @Symfony + 'phpdoc_scalar' => true, // @Symfony + 'phpdoc_separation' => true, // @Symfony + 'phpdoc_single_line_var_spacing' => true, // @Symfony +// 'phpdoc_summary' => true, // @Symfony +// 'phpdoc_to_comment' => true, // @Symfony + 'phpdoc_trim' => true, // @Symfony + 'phpdoc_trim_consecutive_blank_line_separation' => true, + 'phpdoc_types' => true, // @Symfony + 'phpdoc_types_order' => true, // @Symfony + 'phpdoc_var_without_name' => true, // @Symfony + 'protected_to_private' => true, + 'psr0' => true, + 'psr4' => true, // @Symfony:risky + 'return_assignment' => false, + 'return_type_declaration' => ['space_before' => 'one'], + 'self_accessor' => true, // @Symfony:risky + 'semicolon_after_instruction' => true, // @Symfony + 'set_type_to_cast' => true, // @Symfony:risky + 'short_scalar_cast' => true, // @Symfony:risky +// 'simplified_null_return' => true, + 'simple_to_complex_string_variable' => true, // @Symfony + 'single_blank_line_at_eof' => true, // @Symfony + 'single_blank_line_before_namespace' => true, // @Symfony +// 'single_line_comment_style' => true, // @Symfony + 'single_class_element_per_statement' => true, + 'single_import_per_statement' => true, // @Symfony + 'single_line_after_imports' => true, + 'single_quote' => true, // @Symfony + 'space_after_semicolon' => true, // @Symfony + 'standardize_increment' => true, // @Symfony + 'standardize_not_equals' => true, // @Symfony +// 'static_lambda' => true, +// 'strict_comparison' => true, + 'strict_param' => true, +// 'string_line_ending' => true, + 'switch_case_semicolon_to_colon' => true, + 'switch_case_space' => true, + 'ternary_operator_spaces' => true, +// 'trailing_comma_in_multiline_array' => true, // @Symfony + 'trim_array_spaces' => true, // @Symfony + 'unary_operator_spaces' => true, // @Symfony + 'visibility_required' => ['property', 'method', 'const'], +// 'void_return' => true, // @PHP71Migration:risky + 'whitespace_after_comma_in_array' => true, // @Symfony +// 'yoda_style' => true + ]) + ->setFinder($finder); diff --git a/.travis.yml b/.travis.yml index 366be24..fe40315 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,11 +7,12 @@ php: cache: directories: - - vendor + - ./vendor - $HOME/.composer/cache before_install: - mv ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini{,.disabled} || echo "xdebug not available" + - composer validate - composer self-update install: @@ -21,34 +22,37 @@ script: - ./vendor/bin/phpunit; jobs: + fast_finish: true include: - - stage: Test - name: Lowest dependencies - php: 7.2 - install: composer update --prefer-dist --prefer-lowest - - - stage: Test - name: Code coverage - php: 7.2 - before_script: - - mv ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini{.disabled,} - - if [[ ! $(php -m | grep -si xdebug) ]]; then echo "xdebug required for coverage"; exit 1; fi - script: - - ./vendor/bin/phpunit -v --coverage-clover ./build/logs/clover.xml - after_script: - - wget https://scrutinizer-ci.com/ocular.phar && php ocular.phar code-coverage:upload --format=php-clover coverage.clover; - - - stage: Code Quality - name: Static analysis - php: 7.2 - install: composer require --dev phpstan/phpstan ^0.11 vimeo/psalm ^3.8; - script: - - ./vendor/bin/phpstan analyse -c phpstan.neon --no-progress --no-interaction; - - ./vendor/bin/psalm --shepherd --stats; - - - stage: Code Quality - name: Coding standards - php: 7.2 - install: composer require --dev friendsofphp/php-cs-fixer ^2.0; - script: - - ./vendor/bin/php-cs-fixer --dry-run -v fix; + - stage: Test + name: Lowest dependencies + php: 7.2 + install: composer update --prefer-dist --prefer-lowest + + - stage: Code Quality + name: Code coverage + php: 7.2 + before_script: + - mv ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini{.disabled,} + - if [[ ! $(php -m | grep -si xdebug) ]]; then echo "xdebug required for coverage"; exit 1; fi + script: + - ./vendor/bin/phpunit -v --coverage-clover ./build/logs/clover.xml + after_script: + - wget https://scrutinizer-ci.com/ocular.phar && php ocular.phar code-coverage:upload --format=php-clover coverage.clover; + + - stage: Code Quality + name: Static analysis + php: 7.2 + install: + - composer global require --dev phpstan/phpstan ^0.12 vimeo/psalm ^3.12 phpmetrics/phpmetrics ^2.6; + script: + - ~/.composer/vendor/bin/phpstan analyse -c phpstan.neon --no-progress --no-interaction; + - ~/.composer/vendor/bin/psalm --show-info=false + - ~/.composer/vendor/bin/phpmetrics --exclude=Exception src + + - stage: Code Quality + name: Coding standards + php: 7.2 + install: composer global require --dev friendsofphp/php-cs-fixer ^2.0; + script: + - ~/.composer/vendor/bin/php-cs-fixer --dry-run -v fix; diff --git a/composer.json b/composer.json index 3880186..e72869d 100644 --- a/composer.json +++ b/composer.json @@ -17,11 +17,11 @@ "php": ">=7.2", "aura/router": "^3.1", "laminas/laminas-diactoros": "^1.7", - "bear/package": "^1.9.7", "doctrine/annotations": "^1.7", "laminas/laminas-dependency-plugin": "^1.0" }, "require-dev": { + "bear/package": "1.x-dev", "phpunit/phpunit": "^8.5" }, "autoload": { diff --git a/phpstan.neon b/phpstan.neon index 8430748..3f90949 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -3,5 +3,8 @@ parameters: paths: - src - tests - ignoreErrors: - - '#Undefined variable#' + excludes_analyse: + - tests/Fake/* + - tests/Provide/Router/aura.route.php +# ignoreErrors: +# - '#Undefined variable#' diff --git a/psalm.xml b/psalm.xml index 42f355b..3240886 100644 --- a/psalm.xml +++ b/psalm.xml @@ -1,6 +1,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Provide/Router/AuraRouter.php b/src/Provide/Router/AuraRouter.php index 34fdfba..02ad993 100644 --- a/src/Provide/Router/AuraRouter.php +++ b/src/Provide/Router/AuraRouter.php @@ -1,9 +1,7 @@ - $globals + * @phpstan-param array{REQUEST_METHOD: string} $server */ private function getRouterMatch(array $globals, array $server, Route $route) : RouterMatch { @@ -110,7 +119,8 @@ private function getRouterMatch(array $globals, array $server, Route $route) : R // path $request->path = $this->schemeHost . $route->name; // method, query - list($request->method, $query) = $this->httpMethodParams->get($server, $globals['_GET'], $globals['_POST']); + [$request->method, $query] = $this->httpMethodParams->get($server, $globals['_GET'], $globals['_POST']); + /** @var array $route->attributes */ $request->query = $route->attributes + $query; return $request; diff --git a/src/Provide/Router/AuraRouterModule.php b/src/Provide/Router/AuraRouterModule.php index 137aec9..6f062e0 100644 --- a/src/Provide/Router/AuraRouterModule.php +++ b/src/Provide/Router/AuraRouterModule.php @@ -1,9 +1,7 @@ -routerContainer = new RouterContainer; $routerFile = ($routerFile === '') ? $appMeta->appDir . '/var/conf/aura.route.php' : $routerFile; $map = $this->routerContainer->getMap(); - if (! \file_exists($routerFile)) { + if (! file_exists($routerFile)) { throw new InvalidRouterFilePathException($routerFile); } require $routerFile; diff --git a/tests/Fake/fake-app/src/Module/AppModule.php b/tests/Fake/fake-app/src/Module/AppModule.php index 4b6538d..0960a63 100644 --- a/tests/Fake/fake-app/src/Module/AppModule.php +++ b/tests/Fake/fake-app/src/Module/AppModule.php @@ -12,7 +12,7 @@ class AppModule extends AbstractModule /** * {@inheritdoc} */ - protected function configure() + protected function configure() : void { self::$modules[] = get_class($this); $this->install(new PackageModule); diff --git a/tests/Provide/Router/AuraRouterModuleTest.php b/tests/Provide/Router/AuraRouterModuleTest.php index 4a91583..71804e2 100644 --- a/tests/Provide/Router/AuraRouterModuleTest.php +++ b/tests/Provide/Router/AuraRouterModuleTest.php @@ -1,12 +1,10 @@ -install(new AppMetaModule(new AppMeta('FakeVendor\HelloWorld'))); + $module->install(new AppMetaModule(new Meta('FakeVendor\HelloWorld'))); $injector = new Injector($module); $auraRouter = $injector->getInstance(RouterInterface::class, 'primary_router'); $this->assertInstanceOf(AuraRouter::class, $auraRouter); @@ -33,7 +29,7 @@ public function testGetInstance() /** * @depends testGetInstance */ - public function testRoute(AuraRouter $auraRouter) + public function testRoute(AuraRouter $auraRouter) : void { $globals = [ '_GET' => [], @@ -52,7 +48,7 @@ public function testRoute(AuraRouter $auraRouter) /** * @depends testGetInstance */ - public function testRouteWithTokenSuccess(AuraRouter $auraRouter) + public function testRouteWithTokenSuccess(AuraRouter $auraRouter) : void { $globals = [ '_GET' => [], @@ -69,7 +65,7 @@ public function testRouteWithTokenSuccess(AuraRouter $auraRouter) /** * @depends testGetInstance */ - public function testRouteWithTokenFailure(AuraRouter $auraRouter) + public function testRouteWithTokenFailure(AuraRouter $auraRouter) : void { $globals = [ '_GET' => [], @@ -83,19 +79,19 @@ public function testRouteWithTokenFailure(AuraRouter $auraRouter) $this->assertInstanceOf(NullMatch::class, $request); } - public function testRouterFileNotExsits() + public function testRouterFileNotExsits() : void { $this->expectException(InvalidRouterFilePathException::class); $module = (new AuraRouterModule('__INVALID', new AppModule)); - $module->install(new AppMetaModule(new AppMeta('FakeVendor\HelloWorld'))); + $module->install(new AppMetaModule(new Meta('FakeVendor\HelloWorld'))); $injector = new Injector($module); $injector->getInstance(RouterInterface::class); } - public function testRouterFileExsits() + public function testRouterFileExsits() : void { $module = (new AuraRouterModule(__DIR__ . '/aura.route.php', new AppModule)); - $module->install(new AppMetaModule(new AppMeta('FakeVendor\HelloWorld'))); + $module->install(new AppMetaModule(new Meta('FakeVendor\HelloWorld'))); $injector = new Injector($module); $router = $injector->getInstance(RouterInterface::class); $this->assertInstanceOf(RouterCollection::class, $router); diff --git a/tests/Provide/Router/AuraRouterTest.php b/tests/Provide/Router/AuraRouterTest.php index c4eef8a..878e143 100644 --- a/tests/Provide/Router/AuraRouterTest.php +++ b/tests/Provide/Router/AuraRouterTest.php @@ -1,20 +1,21 @@ - */ private $map; @@ -23,18 +24,18 @@ class AuraRouterTest extends TestCase */ private $auraRouter; - public function setUp() : void + protected function setUp() : void { parent::setUp(); $routerContainer = new RouterContainer; $map = $routerContainer->getMap(); $this->map = $map; - $routerFile = \dirname(__DIR__, 2) . '/Fake/fake-app/var/conf/aura.route.php'; + $routerFile = dirname(__DIR__, 2) . '/Fake/fake-app/var/conf/aura.route.php'; require $routerFile; $this->auraRouter = new AuraRouter($routerContainer, new HttpMethodParams); } - public function testMatch() + public function testMatch() : void { $this->map->route('/blog', '/blog/{id}'); $globals = [ @@ -51,7 +52,7 @@ public function testMatch() $this->assertSame(['id' => 'PC6001', 'title' => 'hello'], $request->query); } - public function testMatchInvalidToken() + public function testMatchInvalidToken() : void { $this->map->route('/blog', '/blog/{id}')->tokens(['id' => '\d+']); $globals = [ @@ -66,7 +67,7 @@ public function testMatchInvalidToken() $this->assertInstanceOf(NullMatch::class, $request); } - public function testMatchValidToken() + public function testMatchValidToken() : void { $this->map->route('/blog', '/blog/{id}')->tokens(['id' => '\d+']); $globals = [ @@ -82,7 +83,7 @@ public function testMatchValidToken() $this->assertSame(['id' => '1', 'title' => 'hello'], $request->query); } - public function testMethodOverrideField() + public function testMethodOverrideField() : void { $this->map->route('/blog', '/blog/{id}'); $globals = [ @@ -98,7 +99,7 @@ public function testMethodOverrideField() $this->assertSame(['id' => 'PC6001', 'title' => 'hello'], $request->query); } - public function testMethodOverrideHeader() + public function testMethodOverrideHeader() : void { $this->map->route('/blog', '/blog/{id}'); $globals = [ @@ -115,7 +116,7 @@ public function testMethodOverrideHeader() $this->assertSame(['id' => 'PC6001'], $request->query); } - public function testNotMatch() + public function testNotMatch() : void { $this->map->route('/blog', '/blog/{id}'); $globals = [ @@ -130,7 +131,7 @@ public function testNotMatch() $this->assertInstanceOf(NullMatch::class, $match); } - public function testInvalidPath() + public function testInvalidPath() : void { $globals = [ '_POST' => [], @@ -138,29 +139,29 @@ public function testInvalidPath() ]; $server = [ 'REQUEST_METHOD' => 'GET', - 'REQUEST_URI' => null + 'REQUEST_URI' => '' ]; $match = $this->auraRouter->match($globals, $server); $this->assertInstanceOf(NullMatch::class, $match); } - public function testGenerate() + public function testGenerate() : void { $this->map->route('/calendar', '/calendar/{year}/{month}'); $uri = $this->auraRouter->generate('/calendar', ['year' => '8', 'month' => '1']); $this->assertSame('/calendar/8/1', $uri); } - public function testGenerateFailed() + public function testGenerateFailed() : void { $uri = $this->auraRouter->generate('/_invalid_', ['year' => '8', 'month' => '1']); $this->assertFalse((bool) $uri); } - public function testSerialize() + public function testSerialize() : void { /** @var AuraRouter $router */ - $router = \unserialize(\serialize($this->auraRouter)); + $router = unserialize(serialize($this->auraRouter)); $globals = [ '_GET' => [], '_POST' => [] diff --git a/tests/Provide/Router/aura.route.php b/tests/Provide/Router/aura.route.php index 08f90b5..13d5d6b 100644 --- a/tests/Provide/Router/aura.route.php +++ b/tests/Provide/Router/aura.route.php @@ -1,10 +1,6 @@ -route('/user', '/user/{id}');