Skip to content

Commit

Permalink
Ci update (#32)
Browse files Browse the repository at this point in the history
* improve CI

* update CI

* add void

* drop php 7.2
  • Loading branch information
Nyholm authored Oct 8, 2024
1 parent b1857bc commit 0bf9a22
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 129 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@ jobs:
strategy:
max-parallel: 10
matrix:
php: [ '8.0', '8.1']
sf_version: [ '5.4.*', '6.0.*']
include:
- php: 7.2
sf_version: '5.4.*'
php: [ '8.1', '8.2', '8.3']
sf_version: [ '5.4.*', '6.4.*']

steps:
- name: Set up PHP
Expand Down Expand Up @@ -41,7 +38,7 @@ jobs:
- name: Set up PHP
uses: shivammathur/[email protected]
with:
php-version: 7.3
php-version: 8.1
coverage: none

- name: Checkout code
Expand Down
22 changes: 11 additions & 11 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name: Static analysis
jobs:
phpstan:
name: PHPStan
runs-on: ubuntu-20.04
runs-on: ubuntu-latest

steps:
- name: Checkout code
Expand All @@ -13,9 +13,9 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
php-version: 8.3
coverage: none
tools: phpstan:1.5.3, cs2pr
tools: phpstan:1.12, cs2pr

- name: Download dependencies
uses: ramsey/composer-install@v1
Expand All @@ -25,7 +25,7 @@ jobs:

php-cs-fixer:
name: PHP-CS-Fixer
runs-on: ubuntu-20.04
runs-on: ubuntu-latest

steps:
- name: Checkout code
Expand All @@ -34,26 +34,26 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
php-version: 8.3
coverage: none
tools: php-cs-fixer:3.8.0, cs2pr
tools: php-cs-fixer:3.64, cs2pr

- name: PHP-CS-Fixer
run: php-cs-fixer fix --dry-run --format=checkstyle | cs2pr

psalm:
name: Psalm
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
php-version: 8.3
coverage: none
tools: vimeo/psalm:4.22.0
tools: vimeo/psalm:5.26

- name: Download dependencies
uses: ramsey/composer-install@v1
Expand All @@ -63,13 +63,13 @@ jobs:

composer-normalize:
name: Composer Normalize
runs-on: ubuntu-20.04
runs-on: ubuntu-latest

steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.0
php-version: 8.3
coverage: none
tools: composer-normalize

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
}
],
"require": {
"php": ">=7.2",
"php": ">=8.1",
"friendsofphp/proxy-manager-lts": "^1.0",
"symfony/config": "^5.4 || ^6.0",
"symfony/dependency-injection": "^5.4 || ^6.0",
"symfony/http-kernel": "^5.4 || ^6.0"
},
"require-dev": {
"nyholm/symfony-bundle-test": "^2.0",
"symfony/phpunit-bridge": "^6.0"
"symfony/phpunit-bridge": "^6.4.11"
},
"minimum-stability": "dev",
"prefer-stable": true,
Expand Down
10 changes: 5 additions & 5 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ parameters:
count: 1
path: src/DependencyInjection/CompilerPass/ProxyServiceWithMockPass.php

-
message: "#^Parameter \\#1 \\$class of method Symfony\\\\Component\\\\DependencyInjection\\\\Definition\\:\\:setClass\\(\\) expects string\\|null, false given\\.$#"
count: 1
path: src/DependencyInjection/CompilerPass/ProxyServiceWithMockPass.php

-
message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\NodeDefinition\\:\\:children\\(\\)\\.$#"
count: 1
Expand All @@ -25,3 +20,8 @@ parameters:
count: 1
path: src/ServiceMock.php

-
message: "#^Parameter \\#1 \\$initializer of method ProxyManager\\\\Proxy\\\\LazyLoadingInterface\\<object\\>\\:\\:setProxyInitializer\\(\\) expects \\(Closure\\(object\\|null\\=, ProxyManager\\\\Proxy\\\\LazyLoadingInterface\\<object\\>\\=, string\\=, array\\<string, mixed\\>\\=, Closure\\|null\\=, array\\<string, mixed\\>\\=\\)\\: bool\\)\\|null, Closure\\(mixed, ProxyManager\\\\Proxy\\\\LazyLoadingInterface, mixed, array, mixed\\)\\: true given\\.$#"
count: 1
path: src/ServiceMock.php

65 changes: 8 additions & 57 deletions psalm.baseline.xml
Original file line number Diff line number Diff line change
@@ -1,62 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="4.22.0@fc2c6ab4d5fa5d644d8617089f012f3bb84b8703">
<files psalm-version="5.26.1@d747f6500b38ac4f7dfc5edbcae6e4b637d7add0">
<file src="src/DependencyInjection/Configuration.php">
<UndefinedMethod>
<code><![CDATA[children]]></code>
</UndefinedMethod>
</file>
<file src="src/ServiceMock.php">
<UndefinedInterfaceMethod occurrences="1">
<code>getWrappedValueHolderValue</code>
<UndefinedInterfaceMethod>
<code><![CDATA[getWrappedValueHolderValue]]></code>
</UndefinedInterfaceMethod>
</file>
<file src="vendor/laminas/laminas-code/src/Generator/ClassGenerator.php">
<ParseError occurrences="6">
<code>$interface</code>
<code>$interface</code>
<code>)</code>
<code>)</code>
<code>fn</code>
<code>fn</code>
</ParseError>
</file>
<file src="vendor/laminas/laminas-code/src/Generator/FileGenerator.php">
<ParseError occurrences="4">
<code>,</code>
<code>,</code>
<code>=&gt;</code>
<code>fn</code>
</ParseError>
</file>
<file src="vendor/laminas/laminas-code/src/Generator/MethodGenerator.php">
<ParseError occurrences="3">
<code>$item1</code>
<code>)</code>
<code>fn</code>
</ParseError>
</file>
<file src="vendor/laminas/laminas-code/src/Generator/TypeGenerator.php">
<ParseError occurrences="15">
<code>$left</code>
<code>$type</code>
<code>$type</code>
<code>$type</code>
<code>)</code>
<code>)</code>
<code>)</code>
<code>)</code>
<code>,</code>
<code>,</code>
<code>,</code>
<code>fn</code>
<code>fn</code>
<code>fn</code>
<code>fn</code>
</ParseError>
</file>
<file src="vendor/laminas/laminas-code/src/Generator/TypeGenerator/AtomicType.php">
<ParseError occurrences="6">
<code>$type</code>
<code>$type</code>
<code>)</code>
<code>)</code>
<code>fn</code>
<code>fn</code>
</ParseError>
</file>
</files>
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

class ProxyServiceWithMockPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container)
public function process(ContainerBuilder $container): void
{
/** @var array $serviceIds */
$serviceIds = $container->getParameter('happyr_service_mock.services');
Expand Down
3 changes: 0 additions & 3 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@

class Configuration implements ConfigurationInterface
{
/**
* {@inheritdoc}
*/
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('happyr_service_mocking');
Expand Down
5 changes: 1 addition & 4 deletions src/DependencyInjection/HappyrServiceMockingExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@

class HappyrServiceMockingExtension extends Extension
{
/**
* {@inheritdoc}
*/
public function load(array $configs, ContainerBuilder $container)
public function load(array $configs, ContainerBuilder $container): void
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
Expand Down
29 changes: 11 additions & 18 deletions src/Generator/Constructor.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,13 @@

namespace Happyr\ServiceMocking\Generator;

use function array_filter;
use function array_map;
use function implode;
use Laminas\Code\Generator\Exception\InvalidArgumentException;
use Laminas\Code\Generator\PropertyGenerator;
use Laminas\Code\Reflection\MethodReflection;
use Laminas\Code\Reflection\ParameterReflection;
use ProxyManager\Generator\MethodGenerator;
use ProxyManager\ProxyGenerator\Util\Properties;
use ProxyManager\ProxyGenerator\Util\UnsetPropertiesGenerator;
use ReflectionClass;
use ReflectionMethod;
use function reset;
use function var_export;

/**
* The `__construct` implementation for lazy loading proxies.
Expand All @@ -29,7 +22,7 @@ class Constructor extends MethodGenerator
/**
* @throws InvalidArgumentException
*/
public static function generateMethod(ReflectionClass $originalClass, PropertyGenerator $valueHolder): self
public static function generateMethod(\ReflectionClass $originalClass, PropertyGenerator $valueHolder): self
{
$originalConstructor = self::getConstructor($originalClass);

Expand All @@ -41,7 +34,7 @@ public static function generateMethod(ReflectionClass $originalClass, PropertyGe
'static $reflection;'."\n\n"
.'if (! $this->'.$valueHolder->getName().') {'."\n"
.' $reflection = $reflection ?? new \ReflectionClass('
.var_export($originalClass->getName(), true)
.\var_export($originalClass->getName(), true)
.");\n"
.' $this->'.$valueHolder->getName().' = $reflection->newInstanceWithoutConstructor();'."\n"
.UnsetPropertiesGenerator::generateSnippet(Properties::fromReflectionClass($originalClass), 'this')
Expand All @@ -56,13 +49,13 @@ public static function generateMethod(ReflectionClass $originalClass, PropertyGe

private static function generateOriginalConstructorCall(
MethodReflection $originalConstructor,
PropertyGenerator $valueHolder
PropertyGenerator $valueHolder,
): string {
return "\n\n"
.'$this->'.$valueHolder->getName().'->'.$originalConstructor->getName().'('
.implode(
.\implode(
', ',
array_map(
\array_map(
static function (ParameterReflection $parameter): string {
return ($parameter->isVariadic() ? '...' : '').'$'.$parameter->getName();
},
Expand All @@ -72,23 +65,23 @@ static function (ParameterReflection $parameter): string {
.');';
}

private static function getConstructor(ReflectionClass $class): ?MethodReflection
private static function getConstructor(\ReflectionClass $class): ?MethodReflection
{
$constructors = array_map(
static function (ReflectionMethod $method): MethodReflection {
$constructors = \array_map(
static function (\ReflectionMethod $method): MethodReflection {
return new MethodReflection(
$method->getDeclaringClass()->getName(),
$method->getName()
);
},
array_filter(
\array_filter(
$class->getMethods(),
static function (ReflectionMethod $method): bool {
static function (\ReflectionMethod $method): bool {
return $method->isConstructor();
}
)
);

return reset($constructors) ?: null;
return \reset($constructors) ?: null;
}
}
Loading

0 comments on commit 0bf9a22

Please sign in to comment.