Skip to content

Commit

Permalink
Deps updated + Rector + ECS + PHPSTan (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
Spomky authored Nov 16, 2023
1 parent b7f2a7c commit ddbf9e1
Show file tree
Hide file tree
Showing 60 changed files with 478 additions and 533 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
/Makefile export-ignore
/phpbench.json export-ignore
/phpstan.neon export-ignore
/phpstan-baseline.neon export-ignore
/phpunit.xml.dist export-ignore
/rector.php export-ignore
2 changes: 1 addition & 1 deletion .github/workflows/merge-me.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Merge me!
uses: ridedott/[email protected].45
uses: ridedott/[email protected].50
with:
# Depending on branch protection rules, a manually populated
# `GITHUB_TOKEN_WORKAROUND` environment variable with permissions to
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.PHONY: mu
mu: vendor ## Mutation tests
vendor/bin/infection -s --threads=$$(nproc) --min-msi=87 --min-covered-msi=89
vendor/bin/infection -s --threads=$$(nproc) --min-msi=80 --min-covered-msi=80

.PHONY: tests
tests: vendor ## Run all tests
Expand Down Expand Up @@ -36,7 +36,7 @@ st: vendor ## Run static analyse

.PHONY: ci-mu
ci-mu: vendor ## Mutation tests (for CI/CD only)
vendor/bin/infection --logger-github -s --threads=$$(nproc) --min-msi=87 --min-covered-msi=89
vendor/bin/infection --logger-github -s --threads=$$(nproc) --min-msi=80 --min-covered-msi=80

.PHONY: ci-cc
ci-cc: vendor ## Show test coverage rates (for CI/CD only)
Expand Down
42 changes: 20 additions & 22 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,42 +17,39 @@
"psr/cache": "^1.0|^2.0|^3.0",
"psr/clock": "^1.0",
"psr/log": "^1.1|^2.0|^3.0",
"symfony/config": "^6.2",
"symfony/dependency-injection": "^6.2",
"symfony/framework-bundle": "^6.2",
"symfony/http-kernel": "^6.2"
"symfony/config": "^6.3|^7.0",
"symfony/dependency-injection": "^6.3|^7.0",
"symfony/framework-bundle": "^6.3|^7.0",
"symfony/http-kernel": "^6.3|^7.0"
},
"require-dev": {
"doctrine/dbal": "^3.0",
"doctrine/doctrine-bundle": "^2.0",
"doctrine/doctrine-fixtures-bundle": "^3.4",
"doctrine/orm": "^2.6",
"ekino/phpstan-banned-code": "^1.0",
"infection/infection": "^0.26",
"infection/infection": "^0.27",
"lcobucci/jwt": "^4.3|^5.0",
"matthiasnoback/symfony-config-test": "^4.2",
"matthiasnoback/symfony-dependency-injection-test": "^4.2",
"php-http/client-common": "^2.0",
"php-http/discovery": "^1.13",
"php-http/mock-client": "^1.4",
"matthiasnoback/symfony-config-test": "^4.2|^5.0",
"matthiasnoback/symfony-dependency-injection-test": "^4.2|^5.0",
"php-parallel-lint/php-parallel-lint": "^1.3",
"phpbench/phpbench": "^1.0",
"phpstan/phpstan": "^1.0",
"phpstan/phpstan-beberlei-assert": "^1.0",
"phpstan/extension-installer": "^1.3",
"phpstan/phpstan": "^1.8",
"phpstan/phpstan-deprecation-rules": "^1.0",
"phpstan/phpstan-phpunit": "^1.0",
"phpstan/phpstan-strict-rules": "^1.0",
"phpstan/phpstan-phpunit": "^1.1",
"phpstan/phpstan-strict-rules": "^1.4",
"phpunit/phpunit": "^10.1",
"qossmic/deptrac-shim": "^1.0",
"rector/rector": "^0.16",
"rector/rector": "^0.18",
"roave/security-advisories": "dev-latest",
"symfony/cache": "^6.2",
"symfony/clock": "^6.2",
"symfony/http-client": "^6.2",
"symfony/cache": "^6.3|^7.0",
"symfony/clock": "^6.3|^7.0",
"symfony/http-client": "^6.3|^7.0",
"symfony/monolog-bundle": "^3.5",
"symfony/var-dumper": "^6.2",
"symfony/yaml": "^6.2",
"symplify/easy-coding-standard": "^11.0",
"symfony/var-dumper": "^6.3|^7.0",
"symfony/yaml": "^6.3|^7.0",
"symplify/easy-coding-standard": "^12.0",
"web-token/jwt-signature-algorithm-ecdsa": "^3.0"
},
"autoload": {
Expand All @@ -69,7 +66,8 @@
"config": {
"sort-packages": true,
"allow-plugins": {
"infection/extension-installer": false,
"infection/extension-installer": true,
"phpstan/extension-installer": true,
"php-http/discovery": true
}
},
Expand Down
5 changes: 3 additions & 2 deletions ecs.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,9 @@
'import_functions' => true,
]);

$config->services()
->remove(PhpUnitTestClassRequiresCoversFixer::class);
$config->skip([
PhpUnitTestClassRequiresCoversFixer::class
]);

$config->parallel();
$config->paths([
Expand Down
16 changes: 16 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
parameters:
ignoreErrors:
-
message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\NodeDefinition\\:\\:addDefaultsIfNotSet\\(\\)\\.$#"
count: 1
path: src/bundle/DependencyInjection/Configuration.php

-
message: "#^Parameter \\#1 \\$contentEncodings of method WebPush\\\\Subscription\\:\\:withContentEncodings\\(\\) expects array\\<string\\>, array given\\.$#"
count: 1
path: src/library/Subscription.php

-
message: "#^Parameter \\#1 \\$input of static method WebPush\\\\Subscription\\:\\:createFromAssociativeArray\\(\\) expects array\\<string, mixed\\>, array given\\.$#"
count: 1
path: src/library/Subscription.php
25 changes: 5 additions & 20 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,11 @@ parameters:
- src
excludePaths:
- src/bundle/DependencyInjection/WebPushExtension.php
checkMissingIterableValueType: true
checkGenericClassInNonGenericObjectType: true
checkUninitializedProperties: true
treatPhpDocTypesAsCertain: false
checkMissingIterableValueType: false
ignoreErrors:
-
message: '#Call to an undefined method Symfony\\Component\\Config\\Definition\\Builder\\NodeDefinition::addDefaultsIfNotSet\(\)\.#'
count: 1
path: src/bundle/DependencyInjection/Configuration.php
-
message: '#Parameter \#1 \$contentEncodings of method WebPush\\Subscription\:\:withContentEncodings\(\) expects array\<string\>\, array given\.#'
count: 1
path: src/library/Subscription.php
-
message: '#Parameter \#1 \$input of static method WebPush\\Subscription\:\:createFromAssociativeArray\(\) expects array\<string, mixed\>\, array given\.#'
count: 1
path: src/library/Subscription.php
includes:
- vendor/phpstan/phpstan-strict-rules/rules.neon
- vendor/phpstan/phpstan-phpunit/extension.neon
- vendor/phpstan/phpstan-phpunit/rules.neon
- vendor/phpstan/phpstan-deprecation-rules/rules.neon
- vendor/phpstan/phpstan-beberlei-assert/extension.neon
- vendor/phpstan/phpstan/conf/bleedingEdge.neon
- vendor/ekino/phpstan-banned-code/extension.neon
- phpstan-baseline.neon

33 changes: 17 additions & 16 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Rector\Config\RectorConfig;
use Rector\Core\ValueObject\PhpVersion;
use Rector\Doctrine\Set\DoctrineSetList;
use Rector\PHPUnit\CodeQuality\Rector\Class_\PreferPHPUnitThisCallRector;
use Rector\PHPUnit\Set\PHPUnitLevelSetList;
use Rector\PHPUnit\Set\PHPUnitSetList;
use Rector\Set\ValueObject\LevelSetList;
Expand All @@ -13,24 +14,24 @@
use Rector\Symfony\Set\SymfonySetList;

return static function (RectorConfig $config): void {
$config->sets([
SetList::DEAD_CODE,
LevelSetList::UP_TO_PHP_82,
SymfonyLevelSetList::UP_TO_SYMFONY_62,
SymfonySetList::SYMFONY_CODE_QUALITY,
SymfonySetList::SYMFONY_CONSTRUCTOR_INJECTION,
DoctrineSetList::DOCTRINE_CODE_QUALITY,
DoctrineSetList::ANNOTATIONS_TO_ATTRIBUTES,
PHPUnitSetList::PHPUNIT_SPECIFIC_METHOD,
PHPUnitLevelSetList::UP_TO_PHPUNIT_100,
PHPUnitSetList::PHPUNIT_CODE_QUALITY,
PHPUnitSetList::PHPUNIT_EXCEPTION,
PHPUnitSetList::REMOVE_MOCKS,
PHPUnitSetList::PHPUNIT_YIELD_DATA_PROVIDER,
]);
$config->import(SetList::DEAD_CODE);
$config->import(LevelSetList::UP_TO_PHP_82);
$config->import(SymfonyLevelSetList::UP_TO_SYMFONY_62);
$config->import(SymfonySetList::SYMFONY_50_TYPES);
$config->import(SymfonySetList::SYMFONY_52_VALIDATOR_ATTRIBUTES);
$config->import(SymfonySetList::SYMFONY_CODE_QUALITY);
$config->import(SymfonySetList::SYMFONY_CONSTRUCTOR_INJECTION);
$config->import(SymfonySetList::ANNOTATIONS_TO_ATTRIBUTES);
$config->import(DoctrineSetList::DOCTRINE_CODE_QUALITY);
$config->import(DoctrineSetList::ANNOTATIONS_TO_ATTRIBUTES);
$config->import(PHPUnitSetList::PHPUNIT_CODE_QUALITY);
$config->import(PHPUnitSetList::ANNOTATIONS_TO_ATTRIBUTES);
$config->import(PHPUnitLevelSetList::UP_TO_PHPUNIT_100);

$config->paths([__DIR__ . '/src', __DIR__ . '/tests']);

$config->skip([
PreferPHPUnitThisCallRector::class,
]);
$config->phpVersion(PhpVersion::PHP_82);
$config->parallel();
$config->importNames();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ final class ExtensionCompilerPass implements CompilerPassInterface
{
public const TAG = 'webpush_extension';

/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container): void
{
if (! $container->hasDefinition(ExtensionManager::class)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ final class LoggerSetterCompilerPass implements CompilerPassInterface

public const SERVICE = 'webpush.logger';

/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container): void
{
if (! $container->hasAlias(self::SERVICE)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@

final class PayloadCacheCompilerPass implements CompilerPassInterface
{
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container): void
{
$this->processForService(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ final class PayloadContentEncodingCompilerPass implements CompilerPassInterface
{
public const TAG = 'webpush_payload_content_encoding';

/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container): void
{
if (! $container->hasDefinition(PayloadExtension::class)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,14 @@

namespace WebPush\Bundle\DependencyInjection\Compiler;

use function is_int;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use WebPush\Payload\AES128GCM;
use WebPush\Payload\AESGCM;
use function is_int;

final class PayloadPaddingCompilerPass implements CompilerPassInterface
{
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container): void
{
$this->processForService($container, AES128GCM::class, 'webpush.payload.aes128gcm.padding');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@

final class SymfonyServiceCompilerPass implements CompilerPassInterface
{
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container): void
{
if (! $container->hasDefinition('http_client')) {

Check warning on line 18 in src/bundle/DependencyInjection/Compiler/SymfonyServiceCompilerPass.php

View workflow job for this annotation

GitHub Actions / 5️⃣ Mutation Testing

Escaped Mutant for Mutator "LogicalNot": --- Original +++ New @@ @@ { public function process(ContainerBuilder $container) : void { - if (!$container->hasDefinition('http_client')) { + if ($container->hasDefinition('http_client')) { return; } $definition = new Definition(WebPush::class, [new Reference('http_client'), new Reference(ExtensionManager::class)]);
Expand Down
9 changes: 3 additions & 6 deletions src/bundle/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

namespace WebPush\Bundle\DependencyInjection;

use function in_array;
use function is_int;
use function sprintf;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
use Symfony\Contracts\HttpClient\HttpClientInterface;
use WebPush\Payload\AES128GCM;
use WebPush\Payload\AESGCM;
use function in_array;
use function is_int;
use function sprintf;

final readonly class Configuration implements ConfigurationInterface
{
Expand All @@ -20,9 +20,6 @@ public function __construct(
) {
}

/**
* {@inheritdoc}
*/
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder($this->alias);
Expand Down
2 changes: 1 addition & 1 deletion src/bundle/Resources/config/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
declare(strict_types=1);

use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use function Symfony\Component\DependencyInjection\Loader\Configurator\service;
use WebPush\ExtensionManager;
use WebPush\Payload\AES128GCM;
use WebPush\Payload\AESGCM;
Expand All @@ -13,6 +12,7 @@
use WebPush\TTLExtension;
use WebPush\UrgencyExtension;
use WebPush\WebPush;
use function Symfony\Component\DependencyInjection\Loader\Configurator\service;

return static function (ContainerConfigurator $container): void {
$container = $container->services()
Expand Down
2 changes: 1 addition & 1 deletion src/bundle/Resources/config/vapid.lcobucci.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
declare(strict_types=1);

use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use function Symfony\Component\DependencyInjection\Loader\Configurator\param;
use WebPush\VAPID\JWSProvider;
use WebPush\VAPID\LcobucciProvider;
use function Symfony\Component\DependencyInjection\Loader\Configurator\param;

return static function (ContainerConfigurator $container): void {
$container = $container->services()
Expand Down
4 changes: 2 additions & 2 deletions src/bundle/Resources/config/vapid.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
declare(strict_types=1);

use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use function Symfony\Component\DependencyInjection\Loader\Configurator\param;
use function Symfony\Component\DependencyInjection\Loader\Configurator\service;
use WebPush\VAPID\JWSProvider;
use WebPush\VAPID\VAPIDExtension;
use function Symfony\Component\DependencyInjection\Loader\Configurator\param;
use function Symfony\Component\DependencyInjection\Loader\Configurator\service;

return static function (ContainerConfigurator $container): void {
$container = $container->services()
Expand Down
2 changes: 1 addition & 1 deletion src/bundle/Resources/config/vapid.web_token.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
declare(strict_types=1);

use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use function Symfony\Component\DependencyInjection\Loader\Configurator\param;
use WebPush\VAPID\JWSProvider;
use WebPush\VAPID\WebTokenProvider;
use function Symfony\Component\DependencyInjection\Loader\Configurator\param;

return static function (ContainerConfigurator $container): void {
$container = $container->services()
Expand Down
6 changes: 0 additions & 6 deletions src/bundle/WebPushBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,11 @@

final class WebPushBundle extends Bundle
{
/**
* {@inheritdoc}
*/
public function getContainerExtension(): ExtensionInterface
{
return new WebPushExtension('webpush');
}

/**
* {@inheritdoc}
*/
public function build(ContainerBuilder $container): void
{
parent::build($container);
Expand Down
2 changes: 1 addition & 1 deletion src/library/Action.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

namespace WebPush;

use JsonSerializable;
use function json_encode;
use const JSON_THROW_ON_ERROR;
use const JSON_UNESCAPED_SLASHES;
use const JSON_UNESCAPED_UNICODE;
use JsonSerializable;

/**
* @see https://notifications.spec.whatwg.org/#actions
Expand Down
Loading

0 comments on commit ddbf9e1

Please sign in to comment.