Skip to content

Commit

Permalink
Merge pull request #27 from BrandEmbassy/upgrade_libraries
Browse files Browse the repository at this point in the history
Upgrade libraries, normalize code style and PHP stan
  • Loading branch information
Petr Hejna committed Mar 16, 2019
2 parents 08fdfd9 + da07d4d commit c3e3a8f
Show file tree
Hide file tree
Showing 29 changed files with 331 additions and 284 deletions.
1 change: 1 addition & 0 deletions .circleci/config.yml
Expand Up @@ -22,6 +22,7 @@ jobs:
- ./vendor
key: v1-dependencies-{{ checksum "composer.json" }}

- run: composer lint
- run: composer phpcs
- run: composer phpstan
- run: composer test
1 change: 1 addition & 0 deletions .gitignore
@@ -1,2 +1,3 @@
composer.lock
vendor
.phpunit.result.cache
31 changes: 18 additions & 13 deletions composer.json
Expand Up @@ -13,24 +13,29 @@
},
"require": {
"php": ">=7.2",
"nette/neon": "^2.4",
"slim/slim": "^3.9",
"nette/utils": "^2.5",
"nette/di": "^2.4",
"nette/neon": "^3.0",
"slim/slim": "^3.12",
"nette/utils": "^3.0",
"nette/di": "^3.0",
"psr/http-message": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "^7",
"phpunit/phpunit": "^8",
"roave/security-advisories": "dev-master",
"phpstan/phpstan": "^0.10",
"mockery/mockery": "dev-master",
"slevomat/coding-standard": "^4.8",
"phpstan/phpstan-phpunit": "^0.10.0"
"mockery/mockery": "^1.2",
"brandembassy/coding-standard": "^5.3"
},
"scripts": {
"test": "vendor/bin/phpunit tests",
"phpcs": "vendor/bin/phpcs --standard=ruleset.xml src tests --ignore=tests/temp",
"phpcbf": "./vendor/bin/phpcbf --standard=ruleset.xml src tests --ignore=tests/temp",
"phpstan": "vendor/bin/phpstan analyse src tests -l max -c phpstan.neon"
"lint": " find src tests -name \"*.php\" -print0 | xargs -0 -n1 -P8 php -l",
"phpcs": "./vendor/bin/phpcs --ignore=\"tests/temp/*\" --standard=ruleset.xml src tests",
"phpcbf": "./vendor/bin/phpcbf --standard=ruleset.xml src tests",
"phpstan": "./vendor/bin/phpstan analyse src tests",
"test": "./vendor/bin/phpunit tests"
},
"minimum-stability": "dev",
"prefer-stable": true,
"config": {
"sort-packages": true,
"process-timeout": 600
}
}
6 changes: 2 additions & 4 deletions phpstan.neon
Expand Up @@ -2,8 +2,6 @@ parameters:
excludes_analyse:
- %rootDir%/../../../tests/temp/*

ignoreErrors:
- '#Call to an undefined method Mockery\\ExpectationInterface|Mockery\\HigherOrderMessage::andReturn().#'

includes:
- vendor/phpstan/phpstan-phpunit/extension.neon
- vendor/brandembassy/coding-standard/default-phpstan.neon

76 changes: 2 additions & 74 deletions ruleset.xml
@@ -1,78 +1,6 @@
<?xml version="1.0"?>
<ruleset name="BrandEmbassyCodingStandard">
<rule ref="vendor/slevomat/coding-standard/SlevomatCodingStandard/ruleset.xml">
<exclude name="SlevomatCodingStandard.Files.TypeNameMatchesFileName"/>
<exclude name="SlevomatCodingStandard.Namespaces.FullyQualifiedClassNameAfterKeyword"/>
<exclude name="SlevomatCodingStandard.Namespaces.FullyQualifiedClassNameInAnnotation"/>
<exclude name="SlevomatCodingStandard.Namespaces.FullyQualifiedExceptions"/>
<exclude name="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly"/>
<exclude name="SlevomatCodingStandard.Namespaces.UseOnlyWhitelistedNamespaces"/>
<exclude name="SlevomatCodingStandard.ControlStructures.RequireYodaComparison"/>
<exclude name="SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingTraversableParameterTypeHintSpecification"/>
<exclude name="SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingTraversablePropertyTypeHintSpecification"/>
<exclude name="SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingTraversableReturnTypeHintSpecification"/>
<exclude name="SlevomatCodingStandard.Classes.SuperfluousExceptionNaming"/>
<exclude name="SlevomatCodingStandard.Commenting.RequireOneLinePropertyDocComment"/>
<exclude name="SlevomatCodingStandard.Classes.SuperfluousExceptionNaming"/>
<exclude name="SlevomatCodingStandard.ControlStructures.EarlyExit"/>
<exclude name="SlevomatCodingStandard.Classes.SuperfluousInterfaceNaming"/>
<exclude name="SlevomatCodingStandard.Functions.UnusedParameter"/>
<exclude name="SlevomatCodingStandard.ControlStructures.NewWithoutParentheses"/>

<rule ref="vendor/brandembassy/coding-standard/src/BrandEmbassyCodingStandard/ruleset.xml">
<exclude name="SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint"/>
</rule>
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses">
<properties>
<property name="searchAnnotations" type="bool" value="true"/>
</properties>
</rule>

<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
<rule ref="Generic.CodeAnalysis.JumbledIncrementer"/>
<rule ref="Generic.CodeAnalysis.UnconditionalIfStatement"/>
<rule ref="Generic.CodeAnalysis.UnnecessaryFinalModifier"/>
<rule ref="Generic.CodeAnalysis.UselessOverridingMethod"/>
<rule ref="Generic.Commenting.Todo"/>
<rule ref="Generic.Files.ByteOrderMark"/>
<rule ref="Generic.Files.EndFileNewline"/>
<rule ref="Generic.Files.LineLength">
<properties>
<property name="lineLimit" value="120"/>
<property name="absoluteLineLimit" value="120"/>
</properties>
</rule>
<rule ref="Generic.PHP.CharacterBeforePHPOpeningTag"/>
<rule ref="Generic.PHP.DeprecatedFunctions"/>
<rule ref="Generic.PHP.ForbiddenFunctions"/>
<rule ref="PSR2.ControlStructures.ElseIfDeclaration"/>
<rule ref="PSR2.Files.ClosingTag"/>
<rule ref="PSR2.Methods.MethodDeclaration"/>
<rule ref="PSR2.Namespaces.NamespaceDeclaration"/>
<rule ref="Squiz.PHP.GlobalKeyword"/>
<rule ref="Squiz.PHP.InnerFunctions"/>
<rule ref="Squiz.PHP.LowercasePHPFunctions"/>
<rule ref="Squiz.WhiteSpace.CastSpacing"/>
<rule ref="Squiz.WhiteSpace.LogicalOperatorSpacing"/>
<rule ref="Squiz.WhiteSpace.MemberVarSpacing"/>
<rule ref="Squiz.WhiteSpace.ObjectOperatorSpacing">
<properties>
<property name="ignoreNewlines" value="true"/>
</properties>
</rule>
<rule ref="Squiz.WhiteSpace.OperatorSpacing">
<properties>
<property name="ignoreNewlines" value="true"/>
</properties>
</rule>
<rule ref="Squiz.WhiteSpace.SemicolonSpacing"/>
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing">
<properties>
<property name="spacesCountBeforeColon" value="0"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.TypeHintDeclaration">
<properties>
<property name="usefulAnnotations" type="array" value="@dataProvider,@internal"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Commenting.DisallowOneLinePropertyDocComment"/>
</ruleset>
6 changes: 2 additions & 4 deletions src/ActionHandler.php
Expand Up @@ -7,17 +7,15 @@

interface ActionHandler
{

/**
* @param RequestInterface $request
* @param RequestInterface $request
* @param ResponseInterface $response
* @param array $arguments
* @param mixed[] $arguments
* @return ResponseInterface
*/
public function __invoke(
RequestInterface $request,
ResponseInterface $response,
array $arguments = []
): ResponseInterface;

}
4 changes: 2 additions & 2 deletions src/Controller.php
Expand Up @@ -12,17 +12,18 @@
*/
abstract class Controller extends Container
{

public function beforeAction(RequestInterface $request, ResponseInterface $response): void
{
// intentionally - this method is empty in default
}


public function afterAction(RequestInterface $request, ResponseInterface $response): void
{
// intentionally - this method is empty in default
}


public function middleware(RequestInterface $request, ResponseInterface $response, Route $next): ResponseInterface
{
$this->beforeAction($request, $response);
Expand All @@ -32,5 +33,4 @@ public function middleware(RequestInterface $request, ResponseInterface $respons

return $response;
}

}
7 changes: 3 additions & 4 deletions src/DI/SlimApiExtension.php
Expand Up @@ -7,21 +7,20 @@

final class SlimApiExtension extends CompilerExtension
{

/**
* @var array
* @var mixed[]
*/
private $defaults = [
'apiDefinitionKey' => 'api',
'apiDefinitionKey' => 'api',
'slimConfiguration' => [],
];


public function loadConfiguration(): void
{
$this->validateConfig($this->defaults);
$builder = $this->getContainerBuilder();
$builder->addDefinition($this->prefix('slimApi.factory'))
->setFactory(SlimApplicationFactory::class, [$this->config]);
}

}
2 changes: 0 additions & 2 deletions src/ErrorHandler.php
Expand Up @@ -8,11 +8,9 @@

interface ErrorHandler
{

public function __invoke(
RequestInterface $request,
ResponseInterface $response,
?Throwable $e = null
): ResponseInterface;

}
2 changes: 0 additions & 2 deletions src/Middleware.php
Expand Up @@ -7,7 +7,5 @@

interface Middleware
{

public function __invoke(RequestInterface $request, ResponseInterface $response, callable $next): ResponseInterface;

}
1 change: 0 additions & 1 deletion src/MissingApiArgumentException.php
Expand Up @@ -6,5 +6,4 @@

final class MissingApiArgumentException extends Exception implements RequestException
{

}

0 comments on commit c3e3a8f

Please sign in to comment.