Skip to content

Commit

Permalink
Address all phpcs issues
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed Jun 19, 2024
1 parent bec2e8b commit 69f5e9e
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 14 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/vendor/
/composer.phar
/composer.lock
.phpcs-cache
27 changes: 27 additions & 0 deletions .phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0"?>
<ruleset>
<arg name="basepath" value="."/>
<arg name="extensions" value="php"/>
<arg name="cache" value=".phpcs-cache"/>
<!-- Show sniff names -->
<arg value="s"/>

<file>src</file>

<rule ref="HardMode"/>

<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingAnyTypeHint">
<exclude-pattern type="relative">src/CallableResolver.php</exclude-pattern>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingAnyTypeHint">
<exclude-pattern type="relative">src/CallableResolver.php</exclude-pattern>
</rule>

<rule ref="SlevomatCodingStandard.Classes.SuperfluousInterfaceNaming.SuperfluousSuffix">
<severity>0</severity>
</rule>
<rule ref="SlevomatCodingStandard.Classes.SuperfluousExceptionNaming.SuperfluousSuffix">
<severity>0</severity>
</rule>

</ruleset>
8 changes: 7 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@
},
"require-dev": {
"laminas/laminas-diactoros": "^2.1",
"phpunit/phpunit": ">= 7.0 < 10"
"phpunit/phpunit": ">= 7.0 < 10",
"mnapoli/hard-mode": "^0.3.0"
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}
8 changes: 4 additions & 4 deletions src/Bridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace DI\Bridge\Slim;

use DI\Container;
use Invoker\CallableResolver as InvokerCallableResolver;
use Invoker\Invoker;
use Invoker\ParameterResolver\AssociativeArrayResolver;
use Invoker\ParameterResolver\Container\TypeHintContainerResolver;
Expand All @@ -11,7 +12,6 @@
use Psr\Container\ContainerInterface;
use Slim\App;
use Slim\Factory\AppFactory;
use \Invoker\CallableResolver as InvokerCallableResolver;
use Slim\Interfaces\CallableResolverInterface;

/**
Expand All @@ -22,7 +22,7 @@
*/
class Bridge
{
public static function create(ContainerInterface $container = null): App
public static function create(?ContainerInterface $container = null): App
{
$container = $container ?: new Container;

Expand All @@ -43,11 +43,11 @@ private static function createControllerInvoker(ContainerInterface $container):
{
$resolvers = [
// Inject parameters by name first
new AssociativeArrayResolver(),
new AssociativeArrayResolver,
// Then inject services by type-hints for those that weren't resolved
new TypeHintContainerResolver($container),
// Then fall back on parameters default values for optional route parameters
new DefaultValueResolver(),
new DefaultValueResolver,
];

$invoker = new Invoker(new ResolverChain($resolvers), $container);
Expand Down
6 changes: 2 additions & 4 deletions src/CallableResolver.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);

namespace DI\Bridge\Slim;

Expand All @@ -12,9 +12,7 @@
*/
class CallableResolver implements AdvancedCallableResolverInterface
{
/**
* @var \Invoker\CallableResolver
*/
/** @var \Invoker\CallableResolver */
private $callableResolver;

public function __construct(\Invoker\CallableResolver $callableResolver)
Expand Down
8 changes: 3 additions & 5 deletions src/ControllerInvoker.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);

namespace DI\Bridge\Slim;

Expand All @@ -9,23 +9,21 @@

class ControllerInvoker implements InvocationStrategyInterface
{
/**
* @var InvokerInterface
*/
/** @var InvokerInterface */
private $invoker;

public function __construct(InvokerInterface $invoker)
{
$this->invoker = $invoker;
}

/**
* Invoke a route callable.
*
* @param callable $callable The callable to invoke using the strategy.
* @param ServerRequestInterface $request The request object.
* @param ResponseInterface $response The response object.
* @param array $routeArguments The route's placeholder arguments
*
* @return ResponseInterface|string The response from the callable.
*/
public function __invoke(
Expand Down

0 comments on commit 69f5e9e

Please sign in to comment.