Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update coding standard #226

Merged
merged 2 commits into from
Feb 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,7 @@ categories:
#- title: '**📦 new Useragents:**'
# labels:
# - 'new useragents'

commitish: master
target_commitish: master
filter-by-commitish: true
8 changes: 4 additions & 4 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* This file is part of the mimmi20/laminas-router-hostname package.
*
* Copyright (c) 2021, Thomas Mueller <mimmi20@live.de>
* Copyright (c) 2021-2023, Thomas Mueller <mimmi20@live.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand All @@ -13,7 +13,7 @@
$header = <<<'EOF'
This file is part of the mimmi20/laminas-router-hostname package.

Copyright (c) 2021, Thomas Mueller <mimmi20@live.de>
Copyright (c) 2021-2023, Thomas Mueller <mimmi20@live.de>

For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
Expand Down Expand Up @@ -42,8 +42,8 @@
'location' => 'after_open',
'separate' => 'bottom',
],
]
)
],
),
)
->setUsingCache(true)
->setFinder($finder);
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"infection/infection": "^0.26.19",
"laminas/laminas-modulemanager": "^2.14.0",
"laminas/laminas-servicemanager": "^3.20.0",
"mimmi20/coding-standard": "^3.0.27",
"mimmi20/coding-standard": "4.0.0-beta.6",
"nikic/php-parser": "^v4.15.3",
"phpstan/extension-installer": "^1.2.0",
"phpstan/phpstan": "^1.10.2",
Expand Down
6 changes: 5 additions & 1 deletion phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
<arg name="encoding" value="utf-8"/>

<!-- inherit rules from: -->
<rule ref="mimmi20-cs"/>
<rule ref="Mimmi20CodingStandard">
<exclude name="SlevomatCodingStandard.Functions.FunctionLength.FunctionLength"/>
<exclude name="SlevomatCodingStandard.Classes.ClassLength.ClassTooLong"/>
<exclude name="SlevomatCodingStandard.Complexity.Cognitive.ComplexityTooHigh"/>
</rule>

<!-- Paths to check -->
<file>src</file>
Expand Down
32 changes: 31 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,18 +1,45 @@
parameters:
level: max

parallel:
maximumNumberOfProcesses: 1
processTimeout: 200.0

paths:
- src
- tests

scanFiles:
- %currentWorkingDirectory%/vendor/autoload.php
- %currentWorkingDirectory%/vendor/squizlabs/php_codesniffer/autoload.php
- %currentWorkingDirectory%/vendor/squizlabs/php_codesniffer/src/Util/Tokens.php

checkAlwaysTrueCheckTypeFunctionCall: true
checkAlwaysTrueInstanceof: true
checkAlwaysTrueStrictComparison: true
checkBenevolentUnionTypes: true
checkDynamicProperties: true
checkExplicitMixedMissingReturn: true
checkFunctionNameCase: true
checkGenericClassInNonGenericObjectType: false
checkMissingIterableValueType: false
checkImplicitMixed: true
checkInternalClassCaseSensitivity: true
checkMissingCallableSignature: true
checkMissingIterableValueType: true
checkTooWideReturnTypesInProtectedAndPublicMethods: true
checkUninitializedProperties: true
inferPrivatePropertyTypeFromConstructor: true
polluteScopeWithAlwaysIterableForeach: false
polluteScopeWithLoopInitialAssignments: false
# reportAlwaysTrueInLastCondition: true
reportMaybesInMethodSignatures: false
reportMaybesInPropertyPhpDocTypes: true
reportStaticMethodSignatures: true
# reportWrongPhpDocTypeInVarTag: true
treatPhpDocTypesAsCertain: false

tipsOfTheDay: false

exceptions:
implicitThrows: false
checkedExceptionRegexes:
Expand All @@ -21,6 +48,9 @@ parameters:
check:
missingCheckedExceptionInThrows: true
tooWideThrowType: true

ignoreErrors:
- '~Parameter #1 \$options of static method Mimmi20\\Routing\\Router\\HostName::factory\(\) expects array{host\?: string, hosts\?: array<int\|string, string>, defaults\?: array<int\|string, mixed>}\|bool\|Traversable<string, mixed>, ~'
- '~is not subtype of Throwable~'
- '~Call to static method PHPUnit\\Framework\\Assert::assert.*\(\) with .* will always evaluate to true~'
- '~Parameter #1 \$hosts of class Mimmi20\\Routing\\Router\\HostName constructor expects array<int\|string, string>, array given~'
6 changes: 5 additions & 1 deletion src/ConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* This file is part of the mimmi20/laminas-router-hostname package.
*
* Copyright (c) 2021, Thomas Mueller <mimmi20@live.de>
* Copyright (c) 2021-2023, Thomas Mueller <mimmi20@live.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand All @@ -22,6 +22,8 @@ final class ConfigProvider
*
* @return array<string, array<string, array<string, string>>>
* @phpstan-return array{route_manager: array{factories: array<class-string, class-string>}, router: array{routes: array<mixed>}}
*
* @throws void
*/
public function __invoke(): array
{
Expand All @@ -36,6 +38,8 @@ public function __invoke(): array
*
* @return array<string, array<string, string>>
* @phpstan-return array{factories: array<class-string, class-string>}
*
* @throws void
*/
public function getRouteManagerConfig(): array
{
Expand Down
6 changes: 5 additions & 1 deletion src/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* This file is part of the mimmi20/laminas-router-hostname package.
*
* Copyright (c) 2021, Thomas Mueller <mimmi20@live.de>
* Copyright (c) 2021-2023, Thomas Mueller <mimmi20@live.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand All @@ -20,6 +20,8 @@ final class Module implements ConfigProviderInterface, DependencyIndicatorInterf
/**
* @return array<string, array<string, array<string, string>>>
* @phpstan-return array{route_manager: array{factories: array<class-string, class-string>}, router: array{routes: array<mixed>}}
*
* @throws void
*/
public function getConfig(): array
{
Expand All @@ -35,6 +37,8 @@ public function getConfig(): array
* Expected to return an array of modules on which the current one depends on
*
* @return array<int, string>
*
* @throws void
*/
public function getModuleDependencies(): array
{
Expand Down
6 changes: 3 additions & 3 deletions src/Router/HostName.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* This file is part of the mimmi20/laminas-router-hostname package.
*
* Copyright (c) 2021, Thomas Mueller <mimmi20@live.de>
* Copyright (c) 2021-2023, Thomas Mueller <mimmi20@live.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down Expand Up @@ -54,8 +54,8 @@ final class HostName implements RouteInterface
/**
* Create a new hostname route.
*
* @param array<string> $hosts
* @param array<int|string, mixed> $defaults
* @param array<int|string, string> $hosts
* @param array<int|string, mixed> $defaults
*
* @throws void
*/
Expand Down
9 changes: 6 additions & 3 deletions src/Router/HostNameFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* This file is part of the mimmi20/laminas-router-hostname package.
*
* Copyright (c) 2021, Thomas Mueller <mimmi20@live.de>
* Copyright (c) 2021-2023, Thomas Mueller <mimmi20@live.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down Expand Up @@ -31,8 +31,11 @@ final class HostNameFactory implements FactoryInterface
* @phpcsSuppress SlevomatCodingStandard.Functions.UnusedParameter.UnusedParameter
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint
*/
public function __invoke(ContainerInterface $container, $requestedName, array | null $options = null): HostName
{
public function __invoke(
ContainerInterface $container,
$requestedName,
array | null $options = null,
): HostName {
if (!is_array($options)) {
throw new ServiceNotCreatedException('Options must be an Array');
}
Expand Down
2 changes: 1 addition & 1 deletion tests/ConfigProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* This file is part of the mimmi20/laminas-router-hostname package.
*
* Copyright (c) 2021, Thomas Mueller <mimmi20@live.de>
* Copyright (c) 2021-2023, Thomas Mueller <mimmi20@live.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down
2 changes: 1 addition & 1 deletion tests/ModuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* This file is part of the mimmi20/laminas-router-hostname package.
*
* Copyright (c) 2021, Thomas Mueller <mimmi20@live.de>
* Copyright (c) 2021-2023, Thomas Mueller <mimmi20@live.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down
8 changes: 2 additions & 6 deletions tests/Router/HostNameFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* This file is part of the mimmi20/laminas-router-hostname package.
*
* Copyright (c) 2021, Thomas Mueller <mimmi20@live.de>
* Copyright (c) 2021-2023, Thomas Mueller <mimmi20@live.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand All @@ -18,17 +18,14 @@
use Mimmi20\Routing\Router\HostNameFactory;
use PHPUnit\Framework\Exception;
use PHPUnit\Framework\TestCase;
use SebastianBergmann\RecursionContext\InvalidArgumentException;

use function assert;

final class HostNameFactoryTest extends TestCase
{
private HostNameFactory $object;

/**
* Erstellt alle notwendigen Objekte
*/
/** @throws void */
protected function setUp(): void
{
$this->object = new HostNameFactory();
Expand Down Expand Up @@ -62,7 +59,6 @@ public function testInvokeFailed(): void

/**
* @throws Exception
* @throws InvalidArgumentException
* @throws ServiceNotCreatedException
*/
public function testInvoke(): void
Expand Down
Loading