diff --git a/.github/workflows/rector-cs.yml b/.github/workflows/rector-cs.yml new file mode 100644 index 0000000..403e4d6 --- /dev/null +++ b/.github/workflows/rector-cs.yml @@ -0,0 +1,26 @@ +name: Rector + PHP CS Fixer + +on: + pull_request: + paths: + - 'src/**' + - 'tests/**' + - 'rector.php' + - '.php-cs-fixer.dist.php' + - 'composer.json' + - '.github/workflows/rector-cs.yml' + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + rector-cs: + permissions: + contents: write # Required to commit formatting fixes back to the PR + uses: yiisoft/actions/.github/workflows/rector-cs.yml@master + with: + php: '8.1' diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php new file mode 100644 index 0000000..0e03959 --- /dev/null +++ b/.php-cs-fixer.dist.php @@ -0,0 +1,22 @@ +in([ + __DIR__ . '/src', + __DIR__ . '/tests', +]); + +return ConfigBuilder::build() + ->setCacheFile(__DIR__ . '/runtime/.php-cs-fixer.cache') + ->setRiskyAllowed(true) + ->setParallelConfig(ParallelConfigFactory::detect()) + ->setRules([ + '@Yiisoft/Core' => true, + '@Yiisoft/Core:risky' => true, + ]) + ->setFinder($finder); diff --git a/.styleci.yml b/.styleci.yml deleted file mode 100644 index 373fa40..0000000 --- a/.styleci.yml +++ /dev/null @@ -1,86 +0,0 @@ -preset: psr12 -risky: true - -version: 8.1 - -finder: - exclude: - - docs - - tests/Stub - - vendor - -enabled: - - alpha_ordered_traits - - array_indentation - - array_push - - combine_consecutive_issets - - combine_consecutive_unsets - - combine_nested_dirname - - declare_strict_types - - dir_constant - - fully_qualified_strict_types - - function_to_constant - - hash_to_slash_comment - - is_null - - logical_operators - - magic_constant_casing - - magic_method_casing - - method_separation - - modernize_types_casting - - native_function_casing - - native_function_type_declaration_casing - - no_alias_functions - - no_empty_comment - - no_empty_phpdoc - - no_empty_statement - - no_extra_block_blank_lines - - no_short_bool_cast - - no_superfluous_elseif - - no_unneeded_control_parentheses - - no_unneeded_curly_braces - - no_unneeded_final_method - - no_unset_cast - - no_unused_imports - - no_unused_lambda_imports - - no_useless_else - - no_useless_return - - normalize_index_brace - - php_unit_dedicate_assert - - php_unit_dedicate_assert_internal_type - - php_unit_expectation - - php_unit_mock - - php_unit_mock_short_will_return - - php_unit_namespaced - - php_unit_no_expectation_annotation - - phpdoc_no_empty_return - - phpdoc_no_useless_inheritdoc - - phpdoc_order - - phpdoc_property - - phpdoc_scalar - - phpdoc_singular_inheritdoc - - phpdoc_trim - - phpdoc_trim_consecutive_blank_line_separation - - phpdoc_type_to_var - - phpdoc_types - - phpdoc_types_order - - print_to_echo - - regular_callable_call - - return_assignment - - self_accessor - - self_static_accessor - - set_type_to_cast - - short_array_syntax - - short_list_syntax - - simplified_if_return - - single_quote - - standardize_not_equals - - ternary_to_null_coalescing - - trailing_comma_in_multiline_array - - unalign_double_arrow - - unalign_equals - - empty_loop_body_braces - - integer_literal_case - - union_type_without_spaces - -disabled: - - function_declaration diff --git a/CHANGELOG.md b/CHANGELOG.md index c838952..02e48e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## 1.2.1 under development -- no changes in this release. +- Enh #85: Explicitly import functions and constants in "use" section (@vjik) ## 1.2.0 April 02, 2026 diff --git a/composer.json b/composer.json index f98ea15..85028d3 100644 --- a/composer.json +++ b/composer.json @@ -30,9 +30,12 @@ "yiisoft/files": "^1.0.2 || ^2.0.0" }, "require-dev": { + "friendsofphp/php-cs-fixer": "^3.95", "phpunit/phpunit": "^10.5.47", + "rector/rector": "^2.5", "roave/infection-static-analysis-plugin": "^1.35", - "vimeo/psalm": "^5.26.1 || ^6.12" + "vimeo/psalm": "^5.26.1 || ^6.12", + "yiisoft/code-style": "^1.1" }, "autoload": { "psr-4": { @@ -45,7 +48,9 @@ } }, "scripts": { + "cs-fix": "php-cs-fixer fix", "phan": "phan --progress-bar -o analysis.txt", + "rector": "rector", "test": "phpunit --testdox --no-interaction" }, "config": { diff --git a/rector.php b/rector.php new file mode 100644 index 0000000..3a21a43 --- /dev/null +++ b/rector.php @@ -0,0 +1,16 @@ +withPaths([ + __DIR__ . '/src', + __DIR__ . '/tests', + ]) + ->withPhpSets(php81: true) + ->withSets([ + SetList::YII_CORE, + ]); diff --git a/runtime/.gitignore b/runtime/.gitignore new file mode 100644 index 0000000..d6b7ef3 --- /dev/null +++ b/runtime/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/src/ClassCache.php b/src/ClassCache.php index 9997d89..490c156 100644 --- a/src/ClassCache.php +++ b/src/ClassCache.php @@ -8,6 +8,11 @@ use RuntimeException; use Yiisoft\Files\FileHelper; +use function count; + +use const DIRECTORY_SEPARATOR; +use const LOCK_EX; + /** * @internal * @@ -21,9 +26,8 @@ public function __construct( * @var string Base directory for working with cache. It will be created automatically if it does not exist * ({@see getClassPath()}). */ - private string $cachePath - ) { - } + private string $cachePath, + ) {} /** * Writes proxy class contents to a file in {@see getClassPath()}. diff --git a/src/ClassConfigFactory.php b/src/ClassConfigFactory.php index 48da3f7..f4b6e06 100644 --- a/src/ClassConfigFactory.php +++ b/src/ClassConfigFactory.php @@ -116,8 +116,8 @@ private function getMethodModifiers(ReflectionClass $class, ReflectionMethod $me return array_values( array_filter( $modifiers, - static fn (string $modifier) => $modifier !== 'abstract' - ) + static fn(string $modifier) => $modifier !== 'abstract', + ), ); } @@ -241,7 +241,7 @@ function (ReflectionNamedType|ReflectionIntersectionType $subType) use ($declari $name = $subType->getName(); return ($declaringClassName !== null && $name === $declaringClassName) ? 'self' : $name; }, - $type->getTypes() + $type->getTypes(), ); return implode('|', $types); @@ -258,7 +258,7 @@ function (ReflectionNamedType|ReflectionUnionType $subType) use ($declaringClass $name = $subType->getName(); return ($declaringClassName !== null && $name === $declaringClassName) ? 'self' : $name; }, - $type->getTypes() + $type->getTypes(), ); return implode('&', $types); diff --git a/src/Config/ClassConfig.php b/src/Config/ClassConfig.php index d4c6b8a..4f076cc 100644 --- a/src/Config/ClassConfig.php +++ b/src/Config/ClassConfig.php @@ -47,6 +47,5 @@ public function __construct( * @psalm-var array */ public array $methods, - ) { - } + ) {} } diff --git a/src/Config/MethodConfig.php b/src/Config/MethodConfig.php index 4594bad..08c57b9 100644 --- a/src/Config/MethodConfig.php +++ b/src/Config/MethodConfig.php @@ -31,8 +31,7 @@ public function __construct( * @var TypeConfig|null Return type config. `null` means no return type specified. */ public ?TypeConfig $returnType, - ) { - } + ) {} /** * Whether a method has return type. diff --git a/src/Config/ParameterConfig.php b/src/Config/ParameterConfig.php index efeda11..7db1d7b 100644 --- a/src/Config/ParameterConfig.php +++ b/src/Config/ParameterConfig.php @@ -47,8 +47,7 @@ public function __construct( * when {@see $isDefaultValueAvailable} is `false`). */ public mixed $defaultValue, - ) { - } + ) {} /** * Whether a parameter has type. diff --git a/src/Config/TypeConfig.php b/src/Config/TypeConfig.php index 71113c0..251111b 100644 --- a/src/Config/TypeConfig.php +++ b/src/Config/TypeConfig.php @@ -29,6 +29,5 @@ public function __construct( * @link https://www.php.net/manual/en/migration71.new-features.php#migration71.new-features.nullable-types */ public bool $allowsNull, - ) { - } + ) {} } diff --git a/src/ObjectProxy.php b/src/ObjectProxy.php index b2ba8aa..add3cf7 100644 --- a/src/ObjectProxy.php +++ b/src/ObjectProxy.php @@ -6,6 +6,8 @@ use Throwable; +use function is_object; + /** * Base proxy class for objects to use in {@see ProxyManager}. A concrete implementation can be provided too. * @psalm-suppress ClassMustBeFinal @@ -18,9 +20,8 @@ public function __construct( /** * @var object An instance of the class for proxying method calls. */ - private object $instance - ) { - } + private object $instance, + ) {} /** * Gets instance. @@ -76,7 +77,7 @@ protected function afterCall( string $methodName, array $arguments, mixed $result, - float $timeStart + float $timeStart, ): mixed { return $result; } @@ -120,7 +121,7 @@ private function callInternal(string $methodName, array $arguments): mixed */ private function processResult(mixed $result): mixed { - if (is_object($result) && get_class($result) === get_class($this->instance)) { + if (is_object($result) && $result::class === $this->instance::class) { $result = $this->getNewStaticInstance($result); } diff --git a/src/ProxyManager.php b/src/ProxyManager.php index 0377d61..d6548d0 100644 --- a/src/ProxyManager.php +++ b/src/ProxyManager.php @@ -9,6 +9,10 @@ final class ProxyManager { + /** + * A suffix appended to proxy class names / files. + */ + public const PROXY_SUFFIX = 'Proxy'; /** * @var ClassRenderer A class renderer dependency. */ @@ -22,11 +26,6 @@ final class ProxyManager */ private ?ClassCache $classCache; - /** - * A suffix appended to proxy class names / files. - */ - public const PROXY_SUFFIX = 'Proxy'; - /** * @param string|null $cachePath Cache path, optional, {@see ClassCache::$cachePath}. Pass `null` to disable * caching. @@ -56,7 +55,7 @@ public function __construct(?string $cachePath = null) public function createObjectProxy( string $baseStructure, string $parentProxyClass, - array $proxyConstructorArguments + array $proxyConstructorArguments, ): ObjectProxy { $className = $baseStructure . self::PROXY_SUFFIX; /** @psalm-var class-string $shortClassName */ diff --git a/tests/ClassCacheTest.php b/tests/ClassCacheTest.php index 69e7113..c16eca4 100644 --- a/tests/ClassCacheTest.php +++ b/tests/ClassCacheTest.php @@ -12,6 +12,8 @@ use function sys_get_temp_dir; +use const DIRECTORY_SEPARATOR; + class ClassCacheTest extends TestCase { public function tearDown(): void @@ -61,7 +63,7 @@ class Node $expectedClassPath = implode( DIRECTORY_SEPARATOR, - [sys_get_temp_dir(), 'Yiisoft', 'Proxy', 'Tests', 'Stub', 'Node.MyProxy.php'] + [sys_get_temp_dir(), 'Yiisoft', 'Proxy', 'Tests', 'Stub', 'Node.MyProxy.php'], ); $actualClassPath = $cache->getClassPath(Node::class, MyProxy::class); $this->assertEquals($expectedClassPath, $actualClassPath); diff --git a/tests/ClassConfigFactoryTest.php b/tests/ClassConfigFactoryTest.php index 9950fa6..0a54c1a 100644 --- a/tests/ClassConfigFactoryTest.php +++ b/tests/ClassConfigFactoryTest.php @@ -12,6 +12,12 @@ use Yiisoft\Proxy\Config\TypeConfig; use Yiisoft\Proxy\Tests\Stub\Graph; use Yiisoft\Proxy\Tests\Stub\NodeInterface; +use Yiisoft\Proxy\Tests\Stub\GraphInterface; +use Yiisoft\Proxy\Tests\Stub\Node; +use Yiisoft\Proxy\Tests\Stub\NodeGrandParentInterface; +use Yiisoft\Proxy\Tests\Stub\NodeParentInterface; + +use const PHP_VERSION_ID; class ClassConfigFactoryTest extends TestCase { @@ -31,13 +37,13 @@ public function testGetClassConfigForInterface(): void isInterface: true, namespace: 'Yiisoft\Proxy\Tests\Stub', modifiers: [], - name: 'Yiisoft\Proxy\Tests\Stub\NodeInterface', + name: NodeInterface::class, shortName: 'NodeInterface', parent: '', interfaces: [ 'Countable', - 'Yiisoft\Proxy\Tests\Stub\NodeParentInterface', - 'Yiisoft\Proxy\Tests\Stub\NodeGrandParentInterface', + NodeParentInterface::class, + NodeGrandParentInterface::class, ], methods: [ 'nodeInterfaceMethod1' => new MethodConfig( @@ -53,90 +59,90 @@ interfaces: [ isDefaultValueAvailable: false, isDefaultValueConstant: null, defaultValueConstantName: null, - defaultValue: null + defaultValue: null, ), 'param2' => new ParameterConfig( type: new TypeConfig( name: 'int', - allowsNull: false + allowsNull: false, ), name: 'param2', isDefaultValueAvailable: false, isDefaultValueConstant: null, defaultValueConstantName: null, - defaultValue: null + defaultValue: null, ), 'param3' => new ParameterConfig( type: new TypeConfig( name: 'ArrayIterator', - allowsNull: false + allowsNull: false, ), name: 'param3', isDefaultValueAvailable: false, isDefaultValueConstant: null, defaultValueConstantName: null, - defaultValue: null + defaultValue: null, ), 'param4' => new ParameterConfig( type: new TypeConfig( name: 'mixed', - allowsNull: true + allowsNull: true, ), name: 'param4', isDefaultValueAvailable: false, isDefaultValueConstant: null, defaultValueConstantName: null, - defaultValue: null + defaultValue: null, ), 'param5' => new ParameterConfig( type: new TypeConfig( name: 'bool', - allowsNull: true + allowsNull: true, ), name: 'param5', isDefaultValueAvailable: false, isDefaultValueConstant: null, defaultValueConstantName: null, - defaultValue: null + defaultValue: null, ), 'param6' => new ParameterConfig( type: new TypeConfig( name: 'float', - allowsNull: false + allowsNull: false, ), name: 'param6', isDefaultValueAvailable: true, isDefaultValueConstant: false, defaultValueConstantName: null, - defaultValue: 3.5 + defaultValue: 3.5, ), 'param7' => new ParameterConfig( type: new TypeConfig( name: 'array', - allowsNull: false + allowsNull: false, ), name: 'param7', isDefaultValueAvailable: true, isDefaultValueConstant: false, defaultValueConstantName: null, - defaultValue: [] + defaultValue: [], ), 'param8' => new ParameterConfig( type: new TypeConfig( name: 'string', - allowsNull: false + allowsNull: false, ), name: 'param8', isDefaultValueAvailable: true, isDefaultValueConstant: true, defaultValueConstantName: 'Yiisoft\Proxy\Tests\Stub\CONST1', - defaultValue: 'CONST1_VALUE' + defaultValue: 'CONST1_VALUE', ), ], returnType: new TypeConfig( name: 'int', - allowsNull: true - ) + allowsNull: true, + ), ), 'nodeInterfaceMethod2' => new MethodConfig( modifiers: [ @@ -144,7 +150,7 @@ interfaces: [ ], name: 'nodeInterfaceMethod2', parameters: [], - returnType: null + returnType: null, ), 'nodeInterfaceMethod3' => new MethodConfig( modifiers: [ @@ -155,74 +161,74 @@ interfaces: [ 'param1' => new ParameterConfig( type: new TypeConfig( name: 'bool', - allowsNull: false + allowsNull: false, ), name: 'param1', isDefaultValueAvailable: true, isDefaultValueConstant: false, defaultValueConstantName: null, - defaultValue: false + defaultValue: false, ), 'param2' => new ParameterConfig( type: new TypeConfig( name: 'bool', - allowsNull: false + allowsNull: false, ), name: 'param2', isDefaultValueAvailable: true, isDefaultValueConstant: false, defaultValueConstantName: null, - defaultValue: true + defaultValue: true, ), 'param3' => new ParameterConfig( type: new TypeConfig( name: 'string', - allowsNull: false + allowsNull: false, ), name: 'param3', isDefaultValueAvailable: true, isDefaultValueConstant: false, defaultValueConstantName: null, - defaultValue: 'string' + defaultValue: 'string', ), 'param4' => new ParameterConfig( type: new TypeConfig( name: 'string', - allowsNull: true + allowsNull: true, ), name: 'param4', isDefaultValueAvailable: true, isDefaultValueConstant: false, defaultValueConstantName: null, - defaultValue: null + defaultValue: null, ), 'param5' => new ParameterConfig( type: new TypeConfig( name: 'array', - allowsNull: false + allowsNull: false, ), name: 'param5', isDefaultValueAvailable: true, isDefaultValueConstant: false, defaultValueConstantName: null, - defaultValue: [1, 'value'] + defaultValue: [1, 'value'], ), 'param6' => new ParameterConfig( type: new TypeConfig( name: 'Stringable|string', - allowsNull: false + allowsNull: false, ), name: 'param6', isDefaultValueAvailable: true, isDefaultValueConstant: false, defaultValueConstantName: null, - defaultValue: 'stringable' + defaultValue: 'stringable', ), ], returnType: new TypeConfig( name: 'void', - allowsNull: false - ) + allowsNull: false, + ), ), 'count' => new MethodConfig( modifiers: [ @@ -233,9 +239,9 @@ interfaces: [ returnType: PHP_VERSION_ID >= 80100 ? new TypeConfig( name: 'int', - allowsNull: false + allowsNull: false, ) - : null + : null, ), 'parentMethod1' => new MethodConfig( modifiers: [ @@ -245,8 +251,8 @@ interfaces: [ parameters: [], returnType: new TypeConfig( name: 'self', - allowsNull: false - ) + allowsNull: false, + ), ), 'parentMethod2' => new MethodConfig( modifiers: [ @@ -254,7 +260,7 @@ interfaces: [ ], name: 'parentMethod2', parameters: [], - returnType: null + returnType: null, ), 'grandParentMethod1' => new MethodConfig( modifiers: [ @@ -264,8 +270,8 @@ interfaces: [ parameters: [], returnType: new TypeConfig( name: 'ArrayObject', - allowsNull: false - ) + allowsNull: false, + ), ), 'grandParentMethod2' => new MethodConfig( modifiers: [ @@ -275,8 +281,8 @@ interfaces: [ parameters: [], returnType: new TypeConfig( name: 'ArrayObject', - allowsNull: false - ) + allowsNull: false, + ), ), 'grandParentMethod3' => new MethodConfig( modifiers: [ @@ -285,9 +291,9 @@ interfaces: [ name: 'grandParentMethod3', parameters: [], returnType: new TypeConfig( - name: 'Yiisoft\Proxy\Tests\Stub\Node', - allowsNull: false - ) + name: Node::class, + allowsNull: false, + ), ), 'grandParentMethod4' => new MethodConfig( modifiers: [ @@ -296,11 +302,11 @@ interfaces: [ name: 'grandParentMethod4', parameters: [], returnType: new TypeConfig( - name: 'Yiisoft\Proxy\Tests\Stub\Node', - allowsNull: false - ) + name: Node::class, + allowsNull: false, + ), ), - ] + ], ); $this->assertEquals($expectedConfig, $config); @@ -314,10 +320,10 @@ public function testGetClassConfigForClass(): void isInterface: false, namespace: 'Yiisoft\Proxy\Tests\Stub', modifiers: [], - name: 'Yiisoft\Proxy\Tests\Stub\Graph', + name: Graph::class, shortName: 'Graph', parent: '', - interfaces: ['Yiisoft\Proxy\Tests\Stub\GraphInterface'], + interfaces: [GraphInterface::class], methods: [ 'nodesCount' => new MethodConfig( modifiers: ['public'], @@ -326,19 +332,19 @@ interfaces: ['Yiisoft\Proxy\Tests\Stub\GraphInterface'], 'previousNodesCount' => new ParameterConfig( type: new TypeConfig( name: 'int', - allowsNull: false + allowsNull: false, ), name: 'previousNodesCount', isDefaultValueAvailable: false, isDefaultValueConstant: null, defaultValueConstantName: null, - defaultValue: null + defaultValue: null, ), ], returnType: new TypeConfig( name: 'int', - allowsNull: false - ) + allowsNull: false, + ), ), 'getGraphInstance' => new MethodConfig( modifiers: ['public'], @@ -346,8 +352,8 @@ interfaces: ['Yiisoft\Proxy\Tests\Stub\GraphInterface'], parameters: [], returnType: new TypeConfig( name: 'self', - allowsNull: false - ) + allowsNull: false, + ), ), 'makeNewGraph' => new MethodConfig( modifiers: ['public'], @@ -355,8 +361,8 @@ interfaces: ['Yiisoft\Proxy\Tests\Stub\GraphInterface'], parameters: [], returnType: new TypeConfig( name: 'self', - allowsNull: false - ) + allowsNull: false, + ), ), 'edgesCount' => new MethodConfig( modifiers: ['public'], @@ -364,8 +370,8 @@ interfaces: ['Yiisoft\Proxy\Tests\Stub\GraphInterface'], parameters: [], returnType: new TypeConfig( name: 'int', - allowsNull: false - ) + allowsNull: false, + ), ), 'name' => new MethodConfig( modifiers: ['public'], @@ -373,10 +379,10 @@ interfaces: ['Yiisoft\Proxy\Tests\Stub\GraphInterface'], parameters: [], returnType: new TypeConfig( name: 'Stringable|string', - allowsNull: false - ) + allowsNull: false, + ), ), - ] + ], ); $this->assertEquals($expectedConfig, $config); diff --git a/tests/ProxyTest.php b/tests/ProxyTest.php index 5bf227d..735adf3 100644 --- a/tests/ProxyTest.php +++ b/tests/ProxyTest.php @@ -20,6 +20,8 @@ use Yiisoft\Proxy\Tests\Stub\MyProxy; use Yiisoft\Proxy\Tests\Stub\Square; +use const DIRECTORY_SEPARATOR; + /** * @see ProxyManager * @see ObjectProxy @@ -41,7 +43,7 @@ public function testCreateObjectProxyFromInterface(): void /** @var Graph|MyProxy $object */ $object = $manager->createObjectProxy(GraphInterface::class, MyProxy::class, [new Graph()]); $this->assertIsObject($object); - $this->assertSame('Yiisoft_Proxy_Tests_Stub_GraphInterfaceProxy', get_class($object)); + $this->assertSame('Yiisoft_Proxy_Tests_Stub_GraphInterfaceProxy', $object::class); $this->assertSame(2, $object->nodesCount(1)); $this->assertNull($object->getCurrentError()); @@ -170,7 +172,7 @@ public function testClassWithBuiltInInterface(): void /** @var Money|MyProxy $object */ $object = $manager->createObjectProxy(Countable::class, MyProxy::class, [new Money()]); - $this->assertSame('CountableProxy', get_class($object)); + $this->assertSame('CountableProxy', $object::class); $this->assertSame(1, $object->count()); $this->assertSame('Log', $object->getLog()); } diff --git a/tests/Stub/DisjunctiveNormalFormTypes.php b/tests/Stub/DisjunctiveNormalFormTypes.php index 7cf7ac1..27af648 100644 --- a/tests/Stub/DisjunctiveNormalFormTypes.php +++ b/tests/Stub/DisjunctiveNormalFormTypes.php @@ -9,11 +9,7 @@ final class DisjunctiveNormalFormTypes { - public function param(string|int|null|(Stringable&Countable) $param): void - { - } + public function param(string|int|(Stringable&Countable)|null $param): void {} - public function result(): CarInterface|(Line&Money)|null - { - } + public function result(): CarInterface|(Line&Money)|null {} } diff --git a/tests/Stub/IntersectionTypes.php b/tests/Stub/IntersectionTypes.php index 4e94805..3e651ff 100644 --- a/tests/Stub/IntersectionTypes.php +++ b/tests/Stub/IntersectionTypes.php @@ -9,11 +9,7 @@ final class IntersectionTypes { - public function param(Stringable&Countable $param): void - { - } + public function param(Stringable&Countable $param): void {} - public function result(): Stringable&Countable - { - } + public function result(): Stringable&Countable {} } diff --git a/tests/Stub/Line.php b/tests/Stub/Line.php index c462eed..b9eede8 100644 --- a/tests/Stub/Line.php +++ b/tests/Stub/Line.php @@ -4,6 +4,4 @@ namespace Yiisoft\Proxy\Tests\Stub; -class Line -{ -} +class Line {} diff --git a/tests/Stub/MyProxy.php b/tests/Stub/MyProxy.php index ac19e16..75bfb6e 100644 --- a/tests/Stub/MyProxy.php +++ b/tests/Stub/MyProxy.php @@ -6,10 +6,17 @@ use Yiisoft\Proxy\ObjectProxy; +use function in_array; + class MyProxy extends ObjectProxy { private string $log = ''; + public function getLog(): string + { + return $this->log; + } + protected function afterCall(string $methodName, array $arguments, mixed $result, float $timeStart): mixed { $result = parent::afterCall($methodName, $arguments, $result, $timeStart); @@ -20,9 +27,4 @@ protected function afterCall(string $methodName, array $arguments, mixed $result return $result; } - - public function getLog(): string - { - return $this->log; - } } diff --git a/tests/Stub/Node.php b/tests/Stub/Node.php index e5c139f..6823e0e 100644 --- a/tests/Stub/Node.php +++ b/tests/Stub/Node.php @@ -6,7 +6,5 @@ class Node { - public function someMethod(): void - { - } + public function someMethod(): void {} } diff --git a/tests/Stub/NodeInterface.php b/tests/Stub/NodeInterface.php index 45ef85d..4b296dd 100644 --- a/tests/Stub/NodeInterface.php +++ b/tests/Stub/NodeInterface.php @@ -20,7 +20,7 @@ public static function nodeInterfaceMethod1( ?bool $param5, float $param6 = 3.5, array $param7 = [], - string $param8 = CONST1 + string $param8 = CONST1, ): ?int; public function nodeInterfaceMethod2(); @@ -31,6 +31,6 @@ public function nodeInterfaceMethod3( string $param3 = 'string', ?string $param4 = null, array $param5 = [1, 'value'], - Stringable|string $param6 = 'stringable' + Stringable|string $param6 = 'stringable', ): void; } diff --git a/tests/Stub/Square.php b/tests/Stub/Square.php index ad5800f..5f2de9b 100644 --- a/tests/Stub/Square.php +++ b/tests/Stub/Square.php @@ -6,9 +6,7 @@ class Square { - public function __construct(private float $sideLength) - { - } + public function __construct(private float $sideLength) {} public function area(): float { diff --git a/tests/Stub/UnionTypes.php b/tests/Stub/UnionTypes.php index eceb8cf..d354223 100644 --- a/tests/Stub/UnionTypes.php +++ b/tests/Stub/UnionTypes.php @@ -6,11 +6,7 @@ final class UnionTypes { - public function param(string|int|null $param): void - { - } + public function param(string|int|null $param): void {} - public function result(): string|int|null - { - } + public function result(): string|int|null {} }