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

Fixes for newly introduced GH Actions #88

Merged
merged 3 commits into from
Jun 19, 2024
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
7 changes: 2 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ jobs:
matrix:
php: [ '7.3', '7.4', '8.0', '8.1', '8.2', '8.3' ]
dependency-version: [ '' ]
include:
- php: '7.3'
dependency-version: '--prefer-lowest'
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -30,7 +27,7 @@ jobs:
php-version: ${{ matrix.php }}
coverage: none
- name: Cache Composer dependencies
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.composer/cache
key: php-${{ matrix.php }}-composer-locked-${{ hashFiles('composer.lock') }}
Expand All @@ -53,7 +50,7 @@ jobs:
tools: cs2pr
coverage: none
- name: Cache Composer dependencies
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.composer/cache
key: php-composer-locked-${{ hashFiles('composer.lock') }}
Expand Down
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