Skip to content
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
28 changes: 20 additions & 8 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,23 @@ on:
jobs:
test:

name: Test PHP ${{ matrix.php-versions }}
name: Test PHP ${{ matrix.php.version }} ${{ matrix.php.composer_flags }}
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: ['8.0', '8.1', '8.2']
php:
- version: '8.2'
composer_flags: --prefer-lowest
- version: '8.3'
composer_flags: --prefer-lowest
- version: '8.4'
composer_flags: --prefer-lowest
- version: '8.2'
composer_flags: --prefer-stable
- version: '8.3'
composer_flags: --prefer-stable
- version: '8.4'
composer_flags: --prefer-stable

steps:
- uses: actions/checkout@v3
Expand All @@ -27,7 +39,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
php-version: ${{ matrix.php.version }}
extensions: curl, mbstring, intl, libxml, simplexml
coverage: xdebug

Expand All @@ -40,17 +52,17 @@ jobs:
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache-dir.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-
key: ${{ runner.os }}-composer-${{ matrix.php.composer_flags }}-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-${{ matrix.php.composer_flags }}-

- name: Install dependencies
run: (test -d vendor && echo vendor directory exists) || composer install --prefer-dist --no-progress --no-suggest
run: (test -d vendor && echo vendor directory exists) || composer update ${{ matrix.php.composer_flags }} --no-progress --no-suggest

- name: Run PHPUnit
run: ./bin/phpunit --coverage-text --coverage-clover clover.xml

- name: Upload Scrutinizer coverage
if: matrix.php-versions == '8.0'
if: matrix.php.version == '8.2' && matrix.php.composer_flags == '--prefer-stable'
uses: sudo-bot/action-scrutinizer@latest
with:
cli-args: "--format=php-clover clover.xml"
cli-args: "--format=php-clover clover.xml --revision=${{ github.event.pull_request.head.sha || github.sha }}"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ composer.lock
/.coveralls.yml
/clover.xml
/coveralls-upload.json
/rector.php
3 changes: 1 addition & 2 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
'no_singleline_whitespace_before_semicolons' => true,
'no_spaces_after_function_name' => true,
'no_spaces_around_offset' => true,
'no_superfluous_phpdoc_tags' => false,
'no_superfluous_phpdoc_tags' => ['allow_mixed' => true, 'remove_inheritdoc' => false, 'allow_unused_params' => true],
'no_unused_imports' => true,
'no_useless_else' => true,
'no_whitespace_before_comma_in_array' => true,
Expand All @@ -38,7 +38,6 @@
'phpdoc_types_order' => ['null_adjustment' => 'always_first'],
'protected_to_private' => true,
'single_blank_line_at_eof' => true,
'single_blank_line_before_namespace' => true,
'single_line_comment_style' => false,
'single_line_throw' => false,
'single_quote' => false,
Expand Down
1 change: 1 addition & 0 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
build:
image: default-bionic
nodes:
analysis:
project_setup:
Expand Down
24 changes: 12 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@
"description": "A library to manage patch requests",
"keywords": ["rest", "patch", "api", "symfony", "bundle"],
"require": {
"php": "^8.0",
"php": "^8.2",
"ext-json": "*",
"symfony/property-access": "^4.0 || ^5.0 || ^6.0",
"symfony/http-foundation": "^4.0 || ^5.0 || ^6.0",
"symfony/options-resolver": "^4.0 || ^5.0 || ^6.0",
"symfony/dependency-injection": "^4.0 || ^5.0 || ^6.0",
"symfony/http-kernel": "^4.0 || ^5.0 || ^6.0",
"symfony/config": "^4.0 || ^5.0 || ^6.0",
"symfony/event-dispatcher": "^4.0 || ^5.0 || ^6.0",
"mattiabasone/phpcollection": "^0.7.0"
"symfony/property-access": "^6.0 || ^7.0",
"symfony/http-foundation": "^6.0 || ^7.0",
"symfony/options-resolver": "^6.0 || ^7.0",
"symfony/dependency-injection": "^6.0 || ^7.0",
"symfony/http-kernel": "^6.0 || ^7.0",
"symfony/config": "^6.0 || ^7.0",
"symfony/event-dispatcher": "^6.0 || ^7.0",
"mattiabasone/phpcollection": "^1.0.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.1",
"phpunit/phpunit": "^9.5",
"friendsofphp/php-cs-fixer": "^3.70",
"phpunit/phpunit": "^11.5",
"mockery/mockery": "^1.4",
"yohang/finite": "^1.2",
"doctrine/orm": "^2.9",
"phpspec/prophecy-phpunit": "^2.0",
"phpspec/prophecy-phpunit": "^2.3",
"phpstan/phpstan": "^1.0",
"phpstan/phpstan-doctrine": "^1.0",
"phpstan/phpstan-mockery": "^1.0"
Expand Down
5 changes: 1 addition & 4 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@ parameters:
level: 6 #https://phpstan.org/user-guide/rule-levels
paths:
- src
- tests
checkGenericClassInNonGenericObjectType: false
ignoreErrors:
- '#no value type specified in iterable type#'
- '#Call to an undefined method Symfony\\Component\\Config\\Definition\\Builder\\NodeDefinition::children\(\)#'
- '#Call to an undefined method Prophecy\\Prophecy#'
- '#Method Cypress\\PatchManager\\OperationMatcher::getUnmatchedOperations\(\) should return PhpCollection\\Sequence but returns PhpCollection\\AbstractSequence#'
- '#Property Cypress\\PatchManager\\Tests\\FakeObjects\\Subject(A|B)::\$a is never read, only written#'
- '#Property Cypress\\PatchManager\\Exception\\InvalidJsonRequestContent::\$message has no type specified#'
27 changes: 13 additions & 14 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- http://www.phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
backupGlobals = "false"
backupStaticAttributes = "false"
colors = "true"
convertErrorsToExceptions = "true"
convertNoticesToExceptions = "true"
convertWarningsToExceptions = "true"
processIsolation = "false"
stopOnFailure = "false" >

<coverage>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.5/phpunit.xsd"
backupGlobals="false"
colors= "true"
displayDetailsOnTestsThatTriggerDeprecations="true"
displayDetailsOnTestsThatTriggerErrors="true"
displayDetailsOnTestsThatTriggerNotices="true"
displayDetailsOnTestsThatTriggerWarnings="true"
displayDetailsOnPhpunitDeprecations="true"
processIsolation="false"
stopOnFailure= "false"
>
<source>
<include>
<directory>./src</directory>
</include>
<exclude>
<directory>src/*Bundle/Resources</directory>
<directory>src/DataFixtures</directory>
</exclude>
</coverage>
</source>

<testsuites>
<testsuite name="PatchManager Test Suite">
Expand Down
2 changes: 2 additions & 0 deletions src/PatchManager/Bundle/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Cypress\PatchManager\Bundle\DependencyInjection;

use Symfony\Component\Config\Definition\Builder\TreeBuilder;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Cypress\PatchManager\Bundle\DependencyInjection;

use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
Expand All @@ -13,8 +15,6 @@ class PatchManagerCompilerPass implements CompilerPassInterface
/**
* You can modify the container here before it is dumped to PHP code.
*
* @param ContainerBuilder $container
*
* @api
*/
public function process(ContainerBuilder $container): void
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Cypress\PatchManager\Bundle\DependencyInjection;

use Symfony\Component\Config\FileLocator;
Expand All @@ -17,6 +19,7 @@ class PatchManagerExtension extends Extension
* @param ContainerBuilder $container A ContainerBuilder instance
*
* @throws \InvalidArgumentException When provided tag is not defined in this extension
* @throws \Exception
*
* @api
*/
Expand All @@ -34,11 +37,6 @@ public function load(array $configs, ContainerBuilder $container): void
$this->handleGenericConfig($config, $container, $loaderHandlers);
}

/**
* @param array $config
* @param ContainerBuilder $container
* @param Loader\XmlFileLoader $loaderHandlers
*/
private function handleGenericConfig(
array $config,
ContainerBuilder $container,
Expand All @@ -60,10 +58,6 @@ private function handleGenericConfig(
$container->setParameter('patch_manager.strict_mode', $config['strict_mode']);
}

/**
* @param Loader\XmlFileLoader $loaderHandlers
* @param ContainerBuilder $container
*/
private function handleStateMachine(Loader\XmlFileLoader $loaderHandlers, ContainerBuilder $container): void
{
if (!interface_exists('Finite\Factory\FactoryInterface')) {
Expand Down
2 changes: 2 additions & 0 deletions src/PatchManager/Bundle/PatchManagerBundle.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Cypress\PatchManager\Bundle;

use Cypress\PatchManager\Bundle\DependencyInjection\PatchManagerCompilerPass;
Expand Down
11 changes: 2 additions & 9 deletions src/PatchManager/Bundle/RequestAdapter/RequestStackAdapter.php
Original file line number Diff line number Diff line change
@@ -1,28 +1,21 @@
<?php

declare(strict_types=1);

namespace Cypress\PatchManager\Bundle\RequestAdapter;

use Cypress\PatchManager\Request\Adapter;
use Symfony\Component\HttpFoundation\RequestStack;

class RequestStackAdapter implements Adapter
{
/**
* @var RequestStack
*/
private RequestStack $requestStack;

/**
* @param RequestStack $requestStack
*/
public function __construct(RequestStack $requestStack)
{
$this->requestStack = $requestStack;
}

/**
* @return null|string
*/
public function getRequestBody(): ?string
{
$request = $this->requestStack->getCurrentRequest();
Expand Down
18 changes: 2 additions & 16 deletions src/PatchManager/Event/PatchManagerEvent.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Cypress\PatchManager\Event;

use Cypress\PatchManager\MatchedPatchOperation;
Expand All @@ -8,37 +10,21 @@

class PatchManagerEvent extends Event
{
/**
* @var MatchedPatchOperation
*/
private MatchedPatchOperation $matchedPatchOperation;

/**
* @var Patchable
*/
private Patchable $subject;

/**
* @param MatchedPatchOperation $matchedPatchOperation
* @param Patchable $subject
*/
public function __construct(MatchedPatchOperation $matchedPatchOperation, Patchable $subject)
{
$this->matchedPatchOperation = $matchedPatchOperation;
$this->subject = $subject;
}

/**
* @return MatchedPatchOperation
*/
public function getMatchedPatchOperation(): MatchedPatchOperation
{
return $this->matchedPatchOperation;
}

/**
* @return Patchable
*/
public function getSubject(): Patchable
{
return $this->subject;
Expand Down
2 changes: 2 additions & 0 deletions src/PatchManager/Event/PatchManagerEvents.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Cypress\PatchManager\Event;

final class PatchManagerEvents
Expand Down
2 changes: 2 additions & 0 deletions src/PatchManager/Exception/HandlerNotFoundException.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Cypress\PatchManager\Exception;

use PhpCollection\Sequence;
Expand Down
5 changes: 2 additions & 3 deletions src/PatchManager/Exception/InvalidJsonRequestContent.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<?php

declare(strict_types=1);

namespace Cypress\PatchManager\Exception;

class InvalidJsonRequestContent extends PatchManagerException
{
/**
* @var string
*/
protected $message = "The Request passed to the PatchManagerHandler contains invalid json data";
}
2 changes: 2 additions & 0 deletions src/PatchManager/Exception/MissingOperationNameRequest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Cypress\PatchManager\Exception;

class MissingOperationNameRequest extends PatchManagerException
Expand Down
2 changes: 2 additions & 0 deletions src/PatchManager/Exception/MissingOperationRequest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Cypress\PatchManager\Exception;

class MissingOperationRequest extends PatchManagerException
Expand Down
2 changes: 2 additions & 0 deletions src/PatchManager/Exception/NonExistentOperationException.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Cypress\PatchManager\Exception;

class NonExistentOperationException extends PatchManagerException
Expand Down
2 changes: 2 additions & 0 deletions src/PatchManager/Exception/PatchManagerException.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Cypress\PatchManager\Exception;

class PatchManagerException extends \Exception
Expand Down
Loading