From 8cbccfe6614dea6da79a7a7a33c27122d62c15e9 Mon Sep 17 00:00:00 2001 From: TomasVotruba Date: Wed, 18 Dec 2019 10:44:56 +0100 Subject: [PATCH 1/4] [TypeDeclaration] Add AddParamTypeDeclarationRector --- .../AddParamTypeDeclarationRector.php | 175 ++++++++++++++++++ .../AddParamTypeDeclarationRectorTest.php | 39 ++++ .../Fixture/fixture.php.inc | 29 +++ .../ParentInterfaceWithChangeType.php | 8 + 4 files changed, 251 insertions(+) create mode 100644 packages/TypeDeclaration/src/Rector/ClassMethod/AddParamTypeDeclarationRector.php create mode 100644 packages/TypeDeclaration/tests/Rector/ClassMethod/AddParamTypeDeclarationRector/AddParamTypeDeclarationRectorTest.php create mode 100644 packages/TypeDeclaration/tests/Rector/ClassMethod/AddParamTypeDeclarationRector/Fixture/fixture.php.inc create mode 100644 packages/TypeDeclaration/tests/Rector/ClassMethod/AddParamTypeDeclarationRector/ParentInterfaceWithChangeType.php diff --git a/packages/TypeDeclaration/src/Rector/ClassMethod/AddParamTypeDeclarationRector.php b/packages/TypeDeclaration/src/Rector/ClassMethod/AddParamTypeDeclarationRector.php new file mode 100644 index 000000000000..85396be25ff6 --- /dev/null +++ b/packages/TypeDeclaration/src/Rector/ClassMethod/AddParamTypeDeclarationRector.php @@ -0,0 +1,175 @@ +typehintForParameterByMethodByClass = $typehintForParameterByMethodByClass; + } + + public function getDefinition(): RectorDefinition + { + return new RectorDefinition('Add param types where needed', [ + new ConfiguredCodeSample( + <<<'PHP' +class SomeClass +{ + public function process($name) + { + } +} +PHP +, + <<<'PHP' +class SomeClass +{ + public function process(string $name) + { + } +} +PHP + + , [ + '$typehintForParameterByMethodByClass' => [ + 'SomeClass' => [ + 'process' => [ + 0 => 'string' + ] + ] + ] + ]) + ]); + } + + /** + * @return string[] + */ + public function getNodeTypes(): array + { + return [ClassMethod::class]; + } + + /** + * @param ClassMethod $node + */ + public function refactor(Node $node): ?Node + { + if ($this->shouldSkip($node)) { + return null; + } + + /** @var ClassLike $class */ + $class = $node->getAttribute(AttributeKey::CLASS_NODE); + + foreach ($this->typehintForParameterByMethodByClass as $objectType => $typehintForParameterByMethod) { + if (! $this->isObjectType($class, $objectType)) { + continue; + } + + foreach ($typehintForParameterByMethod as $methodName => $typehintByParameterPosition) { + if (! $this->isName($node, $methodName)) { + continue; + } + + $this->refactorClassMethodWithTypehintByParameterPosition($node, $typehintByParameterPosition); + } + } + + return $node; + } + + private function shouldSkip(ClassMethod $classMethod): bool + { + // skip class methods without args + if (count((array) $classMethod->params) === 0) { + return true; + } + + /** @var ClassLike|null $class */ + $class = $classMethod->getAttribute(AttributeKey::CLASS_NODE); + if ($class === null) { + return true; + } + + // skip traits + if ($class instanceof Trait_) { + return true; + } + + // skip class without parents/interfaces + if ($class instanceof Class_) { + if ($class->implements) { + return false; + } + + if ($class->extends) { + return false; + } + + return true; + } + + // skip interface without parents + return ! (bool) $class->extends; + } + + private function refactorParameter(Param $param, string $newType): void + { + // already set → no change + if ($param->type && $this->isName($param->type, $newType)) { + return; + } + + // remove it + if ($newType === '') { + $param->type = null; + return; + } + + $returnTypeNode = $this->staticTypeMapper->mapStringToPhpParserNode($newType); + if ($returnTypeNode === null) { + return; + } + + $param->type = $returnTypeNode; + } + + private function refactorClassMethodWithTypehintByParameterPosition(Node $node, $typehintByParameterPosition): void + { + foreach ($typehintByParameterPosition as $parameterPosition => $type) { + if (!isset($node->params[$parameterPosition])) { + continue; + } + + $parameter = $node->params[$parameterPosition]; + $this->refactorParameter($parameter, $type); + } + } +} diff --git a/packages/TypeDeclaration/tests/Rector/ClassMethod/AddParamTypeDeclarationRector/AddParamTypeDeclarationRectorTest.php b/packages/TypeDeclaration/tests/Rector/ClassMethod/AddParamTypeDeclarationRector/AddParamTypeDeclarationRectorTest.php new file mode 100644 index 000000000000..ac7255fb9a4b --- /dev/null +++ b/packages/TypeDeclaration/tests/Rector/ClassMethod/AddParamTypeDeclarationRector/AddParamTypeDeclarationRectorTest.php @@ -0,0 +1,39 @@ +doTestFile($file); + } + + public function provideDataForTest(): \Iterator + { + return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); + } + + protected function getRectorsWithConfiguration(): array + { + return [ + AddParamTypeDeclarationRector::class => [ + '$typehintForParameterByMethodByClass' => [ + ParentInterfaceWithChangeType::class => [ + 'process' => [ + 0 => 'string' + ] + ] + ] + ] + ]; + } +} diff --git a/packages/TypeDeclaration/tests/Rector/ClassMethod/AddParamTypeDeclarationRector/Fixture/fixture.php.inc b/packages/TypeDeclaration/tests/Rector/ClassMethod/AddParamTypeDeclarationRector/Fixture/fixture.php.inc new file mode 100644 index 000000000000..5385f7eee21a --- /dev/null +++ b/packages/TypeDeclaration/tests/Rector/ClassMethod/AddParamTypeDeclarationRector/Fixture/fixture.php.inc @@ -0,0 +1,29 @@ + +----- + diff --git a/packages/TypeDeclaration/tests/Rector/ClassMethod/AddParamTypeDeclarationRector/ParentInterfaceWithChangeType.php b/packages/TypeDeclaration/tests/Rector/ClassMethod/AddParamTypeDeclarationRector/ParentInterfaceWithChangeType.php new file mode 100644 index 000000000000..460e3d37c5ff --- /dev/null +++ b/packages/TypeDeclaration/tests/Rector/ClassMethod/AddParamTypeDeclarationRector/ParentInterfaceWithChangeType.php @@ -0,0 +1,8 @@ + Date: Wed, 18 Dec 2019 10:53:46 +0100 Subject: [PATCH 2/4] update docs --- docs/AllRectorsOverview.md | 152 +++++++++++++++--- .../AddParamTypeDeclarationRector.php | 2 +- .../AddParamTypeDeclarationRectorTest.php | 3 +- 3 files changed, 134 insertions(+), 23 deletions(-) diff --git a/docs/AllRectorsOverview.md b/docs/AllRectorsOverview.md index 8d44409e22c7..1355c7dd0c26 100644 --- a/docs/AllRectorsOverview.md +++ b/docs/AllRectorsOverview.md @@ -1,4 +1,4 @@ -# All 395 Rectors Overview +# All 400 Rectors Overview - [Projects](#projects) - [General](#general) @@ -27,6 +27,7 @@ - [PHPUnit](#phpunit) - [PHPUnitSymfony](#phpunitsymfony) - [PSR4](#psr4) +- [Phalcon](#phalcon) - [Php52](#php52) - [Php53](#php53) - [Php54](#php54) @@ -3523,23 +3524,8 @@ Turns vague php-only method in PHPUnit TestCase to more specific ``` ```diff --$this->assertSame($value, {function}($anything), "message"); -+$this->assert{function}($value, $anything, "message"); -``` - -```diff --$this->assertEquals($value, {function}($anything), "message"); -+$this->assert{function}($value, $anything, "message"); -``` - -```diff --$this->assertNotSame($value, {function}($anything), "message"); -+$this->assertNot{function}($value, $anything, "message") -``` - -```diff --$this->assertNotEquals($value, {function}($anything), "message"); -+$this->assertNot{function}($value, $anything, "message") +-$this->assertNotEquals(get_class($value), stdClass::class); ++$this->assertNotInstanceOf(stdClass::class, $value); ```
@@ -4204,6 +4190,70 @@ Changes namespace and class names to match PSR-4 in composer.json autoload secti
+## Phalcon + +### `AddRequestToHandleMethodCallRector` + +- class: `Rector\Phalcon\Rector\MethodCall\AddRequestToHandleMethodCallRector` + +Add $_SERVER REQUEST_URI to method call + +```diff + class SomeClass { + public function run($di) + { + $application = new \Phalcon\Mvc\Application(); +- $response = $application->handle(); ++ $response = $application->handle($_SERVER["REQUEST_URI"]); + } + } +``` + +
+ +### `FlashWithCssClassesToExtraCallRector` + +- class: `Rector\Phalcon\Rector\Assign\FlashWithCssClassesToExtraCallRector` + +Add $cssClasses in Flash to separated method call + +```diff + class SomeClass { + public function run() + { + $cssClasses = []; +- $flash = new Phalcon\Flash($cssClasses); ++ $flash = new Phalcon\Flash(); ++ $flash->setCssClasses($cssClasses); + } + } +``` + +
+ +### `NewApplicationToToFactoryWithDefaultContainerRector` + +- class: `Rector\Phalcon\Rector\Assign\NewApplicationToToFactoryWithDefaultContainerRector` + +Change new application to default factory with application + +```diff + class SomeClass + { + public function run($di) + { +- $application = new \Phalcon\Mvc\Application($di); ++ $container = new \Phalcon\Di\FactoryDefault(); ++ $application = new \Phalcon\Mvc\Application($container); + +- $response = $application->handle(); ++ $response = $application->handle($_SERVER["REQUEST_URI"]); + } + } +``` + +
+ ## Php52 ### `ContinueToBreakInSwitchRector` @@ -7231,6 +7281,35 @@ Change param type of passed getId() to UuidInterface type declaration
+### `AddParamTypeDeclarationRector` + +- class: `Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector` + +Add param types where needed + +```yaml +services: + Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector: + $typehintForParameterByMethodByClass: + SomeClass: + process: + - string +``` + +↓ + +```diff + class SomeClass + { +- public function process($name) ++ public function process(string $name) + { + } + } +``` + +
+ ### `CompleteVarDocTypePropertyRector` - class: `Rector\TypeDeclaration\Rector\Property\CompleteVarDocTypePropertyRector` @@ -8116,9 +8195,8 @@ Change new Object to static call services: Rector\Rector\New_\NewToStaticCallRector: Cookie: - - - - Cookie - - create + - Cookie + - create ``` ↓ @@ -8631,6 +8709,38 @@ services:
+### `SwapClassMethodArgumentsRector` + +- class: `Rector\Rector\StaticCall\SwapClassMethodArgumentsRector` + +Reorder class method arguments, including their calls + +```yaml +services: + Rector\Rector\StaticCall\SwapClassMethodArgumentsRector: + $newArgumentPositionsByMethodAndClass: + SomeClass: + run: + - 1 + - 0 +``` + +↓ + +```diff + class SomeClass + { +- public static function run($first, $second) ++ public static function run($second, $first) + { +- self::run($first, $second); ++ self::run($second, $first); + } + } +``` + +
+ ### `SwapFuncCallArgumentsRector` - class: `Rector\Rector\Argument\SwapFuncCallArgumentsRector` diff --git a/packages/TypeDeclaration/src/Rector/ClassMethod/AddParamTypeDeclarationRector.php b/packages/TypeDeclaration/src/Rector/ClassMethod/AddParamTypeDeclarationRector.php index 85396be25ff6..8c98326f1e0e 100644 --- a/packages/TypeDeclaration/src/Rector/ClassMethod/AddParamTypeDeclarationRector.php +++ b/packages/TypeDeclaration/src/Rector/ClassMethod/AddParamTypeDeclarationRector.php @@ -129,7 +129,7 @@ private function shouldSkip(ClassMethod $classMethod): bool return false; } - if ($class->extends) { + if ($class->extends !== null) { return false; } diff --git a/packages/TypeDeclaration/tests/Rector/ClassMethod/AddParamTypeDeclarationRector/AddParamTypeDeclarationRectorTest.php b/packages/TypeDeclaration/tests/Rector/ClassMethod/AddParamTypeDeclarationRector/AddParamTypeDeclarationRectorTest.php index ac7255fb9a4b..7c038277eb73 100644 --- a/packages/TypeDeclaration/tests/Rector/ClassMethod/AddParamTypeDeclarationRector/AddParamTypeDeclarationRectorTest.php +++ b/packages/TypeDeclaration/tests/Rector/ClassMethod/AddParamTypeDeclarationRector/AddParamTypeDeclarationRectorTest.php @@ -4,6 +4,7 @@ namespace Rector\TypeDeclaration\Tests\Rector\ClassMethod\AddParamTypeDeclarationRector; +use Iterator; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector; @@ -17,7 +18,7 @@ public function test(string $file): void $this->doTestFile($file); } - public function provideDataForTest(): \Iterator + public function provideDataForTest(): Iterator { return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } From 9b8a32da6bde2a9fdf215bff9019cb851f1d8456 Mon Sep 17 00:00:00 2001 From: TomasVotruba Date: Wed, 18 Dec 2019 11:03:41 +0100 Subject: [PATCH 3/4] [Nette 3.0] Add param types --- .../nette-application-param-types.yaml | 5 ++ .../nette-component-model-param-types.yaml | 34 +++++++++ .../nette-30/nette-security-param-types.yaml | 72 +++++++++++++++++++ .../AddParamTypeDeclarationRector.php | 1 + phpstan.neon | 1 + 5 files changed, 113 insertions(+) create mode 100644 config/set/nette/nette-30/nette-application-param-types.yaml create mode 100644 config/set/nette/nette-30/nette-component-model-param-types.yaml create mode 100644 config/set/nette/nette-30/nette-security-param-types.yaml diff --git a/config/set/nette/nette-30/nette-application-param-types.yaml b/config/set/nette/nette-30/nette-application-param-types.yaml new file mode 100644 index 000000000000..28ba03e7d6d0 --- /dev/null +++ b/config/set/nette/nette-30/nette-application-param-types.yaml @@ -0,0 +1,5 @@ +services: + # scalar type hints, see https://github.com/nette/application/commit/b71d69c507f90b48fbc1e40447d451b4b5c6f063 + Rector\Rector\ClassMethod\AddReturnTypeDeclarationRector: + Nette\Application\UI\Control: + 0: 'Nette\ComponentModel\IComponent' diff --git a/config/set/nette/nette-30/nette-component-model-param-types.yaml b/config/set/nette/nette-30/nette-component-model-param-types.yaml new file mode 100644 index 000000000000..40f4627727f2 --- /dev/null +++ b/config/set/nette/nette-30/nette-component-model-param-types.yaml @@ -0,0 +1,34 @@ +services: + # scalar type hints, see https://github.com/nette/component-model/commit/f69df2ca224cad7b07f1c8835679393263ea6771 + Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector: + Nette\ComponentModel\Component: + lookup: + 0: '?string' + 1: 'bool' + lookupPath: + 0: 'string' + 1: 'bool' + monitor: + 0: 'string' + unmonitor: + 0: 'string' + attached: + 0: 'Nette\ComponentModel\IComponent' + detached: + 0: 'Nette\ComponentModel\IComponent' + + Nette\ComponentModel\Container: + getComponent: + 1: 'bool' + createComponent: + 0: 'string' + + Nette\ComponentModel\IComponent: + setParent: + 0: '?Nette\ComponentModel\IContainer' + 1: 'string' + + Nette\ComponentModel\IContainer: + getComponents: + 0: 'bool' + 1: 'string' diff --git a/config/set/nette/nette-30/nette-security-param-types.yaml b/config/set/nette/nette-30/nette-security-param-types.yaml new file mode 100644 index 000000000000..4e5c845c0b78 --- /dev/null +++ b/config/set/nette/nette-30/nette-security-param-types.yaml @@ -0,0 +1,72 @@ +services: + # scalar param types https://github.com/nette/security/commit/84024f612fb3f55f5d6e3e3e28eef1ad0388fa56 + Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector: + Nette\Bridges\SecurityDI\SecurityExtension: + __construct: + 0: bool + + Nette\Security\IUserStorage: + setAuthenticated: + 0: bool + setIdentity: + 0: ?Nette\Security\IIdentity + setExpiration: + 1: int + + Nette\Security\Identity: + __construct: + 2: iterable + __set: + 0: 'string' + '&__get': + 0: 'string' + __isset: + 0: 'string' + + Nette\Security\Passwords: + hash: + 0: 'string' + verify: + 0: 'string' + 1: 'string' + needsRehash: + 0: 'string' + + Nette\Security\Permission: + addRole: + 0: 'string' + hasRole: + 0: 'string' + getRoleParents: + 0: 'string' + removeRole: + 0: 'string' + addResource: + 0: 'string' + 1: 'string' + hasResource: + 0: 'string' + resourceInheritsFrom: + 0: 'string' + 1: 'string' + 2: 'bool' + removeResource: + 0: 'string' + allow: + 3: 'callable' + deny: + 3: 'callable' + setRule: + 0: 'bool' + 1: 'bool' + 5: 'callable' + + Nette\Security\User: + logout: + 0: 'bool' + getAuthenticator: + 0: 'bool' + isInRole: + 0: 'string' + getAuthorizator: + 0: 'bool' diff --git a/packages/TypeDeclaration/src/Rector/ClassMethod/AddParamTypeDeclarationRector.php b/packages/TypeDeclaration/src/Rector/ClassMethod/AddParamTypeDeclarationRector.php index 8c98326f1e0e..47f66625defd 100644 --- a/packages/TypeDeclaration/src/Rector/ClassMethod/AddParamTypeDeclarationRector.php +++ b/packages/TypeDeclaration/src/Rector/ClassMethod/AddParamTypeDeclarationRector.php @@ -137,6 +137,7 @@ private function shouldSkip(ClassMethod $classMethod): bool } // skip interface without parents + /** @var $class Interface_ */ return ! (bool) $class->extends; } diff --git a/phpstan.neon b/phpstan.neon index 7c810e0a38cc..3bbf63b0f1e8 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -42,6 +42,7 @@ parameters: # false positive # - '#Call to function method_exists\(\) with string and (.*?) will always evaluate to false#' - '#PHPDoc tag \@param for parameter \$node with type float is incompatible with native type PhpParser\\Node#' + - '#Access to an undefined property PhpParser\\Node\\Stmt\\ClassLike\:\:\$extends#' # misuse of interface and class - '#Parameter \#1 (.*?) expects Symfony\\Component\\DependencyInjection\\ContainerBuilder, Symfony\\Component\\DependencyInjection\\ContainerInterface given#' From 0303d9e064679a960b17dd4305f94e59f05e61c4 Mon Sep 17 00:00:00 2001 From: TomasVotruba Date: Wed, 18 Dec 2019 11:30:44 +0100 Subject: [PATCH 4/4] merge configs fix config laod bug --- .../nette-application-param-types.yaml | 5 -- .../nette-component-model-param-types.yaml | 34 ----------- .../nette-component-model-return-types.yaml | 28 --------- ...aram-types.yaml => nette-param-types.yaml} | 35 ++++++++++- ...urn-types.yaml => nette-return-types.yaml} | 60 ++++++++++++++++++- .../nette-30/nette-security-return-types.yaml | 33 ---------- 6 files changed, 93 insertions(+), 102 deletions(-) delete mode 100644 config/set/nette/nette-30/nette-application-param-types.yaml delete mode 100644 config/set/nette/nette-30/nette-component-model-param-types.yaml delete mode 100644 config/set/nette/nette-30/nette-component-model-return-types.yaml rename config/set/nette/nette-30/{nette-security-param-types.yaml => nette-param-types.yaml} (62%) rename config/set/nette/nette-30/{nette-application-return-types.yaml => nette-return-types.yaml} (78%) delete mode 100644 config/set/nette/nette-30/nette-security-return-types.yaml diff --git a/config/set/nette/nette-30/nette-application-param-types.yaml b/config/set/nette/nette-30/nette-application-param-types.yaml deleted file mode 100644 index 28ba03e7d6d0..000000000000 --- a/config/set/nette/nette-30/nette-application-param-types.yaml +++ /dev/null @@ -1,5 +0,0 @@ -services: - # scalar type hints, see https://github.com/nette/application/commit/b71d69c507f90b48fbc1e40447d451b4b5c6f063 - Rector\Rector\ClassMethod\AddReturnTypeDeclarationRector: - Nette\Application\UI\Control: - 0: 'Nette\ComponentModel\IComponent' diff --git a/config/set/nette/nette-30/nette-component-model-param-types.yaml b/config/set/nette/nette-30/nette-component-model-param-types.yaml deleted file mode 100644 index 40f4627727f2..000000000000 --- a/config/set/nette/nette-30/nette-component-model-param-types.yaml +++ /dev/null @@ -1,34 +0,0 @@ -services: - # scalar type hints, see https://github.com/nette/component-model/commit/f69df2ca224cad7b07f1c8835679393263ea6771 - Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector: - Nette\ComponentModel\Component: - lookup: - 0: '?string' - 1: 'bool' - lookupPath: - 0: 'string' - 1: 'bool' - monitor: - 0: 'string' - unmonitor: - 0: 'string' - attached: - 0: 'Nette\ComponentModel\IComponent' - detached: - 0: 'Nette\ComponentModel\IComponent' - - Nette\ComponentModel\Container: - getComponent: - 1: 'bool' - createComponent: - 0: 'string' - - Nette\ComponentModel\IComponent: - setParent: - 0: '?Nette\ComponentModel\IContainer' - 1: 'string' - - Nette\ComponentModel\IContainer: - getComponents: - 0: 'bool' - 1: 'string' diff --git a/config/set/nette/nette-30/nette-component-model-return-types.yaml b/config/set/nette/nette-30/nette-component-model-return-types.yaml deleted file mode 100644 index a62f04428e3d..000000000000 --- a/config/set/nette/nette-30/nette-component-model-return-types.yaml +++ /dev/null @@ -1,28 +0,0 @@ -services: - # scalar type hints, see https://github.com/nette/component-model/commit/f69df2ca224cad7b07f1c8835679393263ea6771 - Rector\Rector\ClassMethod\AddReturnTypeDeclarationRector: - Nette\ComponentModel\Component: - lookup: 'Nette\ComponentModel\IComponent' - lookupPath: '?string' - monitor: 'void' - unmonitor: 'void' - attached: 'void' - detached: 'void' - getName: '?string' - - Nette\ComponentModel\IComponent: - getName: '?string' - getParent: '?Nette\ComponentModel\IContainer' - - Nette\ComponentModel\Container: - removeComponent: 'void' - getComponent: '?Nette\ComponentModel\IComponent' - createComponent: '?Nette\ComponentModel\IComponent' - getComponents: 'Iterator' - validateChildComponent: 'void' - _isCloning: '?Nette\ComponentModel\IComponent' - - Nette\ComponentModel\IContainer: - removeComponent: 'void' - getComponent: '?Nette\ComponentModel\IContainer' - getComponents: 'Iterator' diff --git a/config/set/nette/nette-30/nette-security-param-types.yaml b/config/set/nette/nette-30/nette-param-types.yaml similarity index 62% rename from config/set/nette/nette-30/nette-security-param-types.yaml rename to config/set/nette/nette-30/nette-param-types.yaml index 4e5c845c0b78..78fbffaf6359 100644 --- a/config/set/nette/nette-30/nette-security-param-types.yaml +++ b/config/set/nette/nette-30/nette-param-types.yaml @@ -1,6 +1,38 @@ services: - # scalar param types https://github.com/nette/security/commit/84024f612fb3f55f5d6e3e3e28eef1ad0388fa56 Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector: + # scalar type hints, see https://github.com/nette/component-model/commit/f69df2ca224cad7b07f1c8835679393263ea6771 + Nette\ComponentModel\Component: + lookup: + 0: '?string' + 1: 'bool' + lookupPath: + 0: 'string' + 1: 'bool' + monitor: + 0: 'string' + unmonitor: + 0: 'string' + attached: + 0: 'Nette\ComponentModel\IComponent' + detached: + 0: 'Nette\ComponentModel\IComponent' + + Nette\ComponentModel\Container: + getComponent: + 1: 'bool' + createComponent: + 0: 'string' + + Nette\ComponentModel\IComponent: + setParent: + 0: '?Nette\ComponentModel\IContainer' + 1: 'string' + + Nette\ComponentModel\IContainer: + getComponents: + 0: 'bool' + + # scalar param types https://github.com/nette/security/commit/84024f612fb3f55f5d6e3e3e28eef1ad0388fa56 Nette\Bridges\SecurityDI\SecurityExtension: __construct: 0: bool @@ -70,3 +102,4 @@ services: 0: 'string' getAuthorizator: 0: 'bool' + 1: 'string' diff --git a/config/set/nette/nette-30/nette-application-return-types.yaml b/config/set/nette/nette-30/nette-return-types.yaml similarity index 78% rename from config/set/nette/nette-30/nette-application-return-types.yaml rename to config/set/nette/nette-30/nette-return-types.yaml index e1136b1ac0cf..8e0ffcedf301 100644 --- a/config/set/nette/nette-30/nette-application-return-types.yaml +++ b/config/set/nette/nette-30/nette-return-types.yaml @@ -1,6 +1,64 @@ services: - # scalar type hints, see https://github.com/nette/application/commit/b71d69c507f90b48fbc1e40447d451b4b5c6f063 + # scalar type hints, see https://github.com/nette/security/commit/84024f612fb3f55f5d6e3e3e28eef1ad0388fa56 Rector\Rector\ClassMethod\AddReturnTypeDeclarationRector: + Nette\Security\IAuthenticator: + authenticate: 'Nette\Security\IIdentity' + + Nette\Security\IAuthorizator: + isAllowed: 'bool' + + Nette\Security\Identity: + getData: 'array' + + Nette\Security\IIdentity: + getRoles: 'array' + + Nette\Security\User: + getStorage: 'Nette\Security\IUserStorage' + login: 'void' + logout: 'void' + isLoggedIn: 'bool' + getIdentity: '?Nette\Security\IIdentity' + getAuthenticator: '?Nette\Security\IAuthenticator' + getAuthorizator: '?Nette\Security\IAuthorizator' + getLogoutReason: '?int' + getRoles: 'array' + isInRole: 'bool' + isAllowed: 'bool' + + Nette\Security\IUserStorage: + isAuthenticated: 'bool' + getIdentity: '?Nette\Security\IIdentity' + getLogoutReason: '?int' + + # scalar type hints, see https://github.com/nette/component-model/commit/f69df2ca224cad7b07f1c8835679393263ea6771 + Nette\ComponentModel\Component: + lookup: 'Nette\ComponentModel\IComponent' + lookupPath: '?string' + monitor: 'void' + unmonitor: 'void' + attached: 'void' + detached: 'void' + getName: '?string' + + Nette\ComponentModel\IComponent: + getName: '?string' + getParent: '?Nette\ComponentModel\IContainer' + + Nette\ComponentModel\Container: + removeComponent: 'void' + getComponent: '?Nette\ComponentModel\IComponent' + createComponent: '?Nette\ComponentModel\IComponent' + getComponents: 'Iterator' + validateChildComponent: 'void' + _isCloning: '?Nette\ComponentModel\IComponent' + + Nette\ComponentModel\IContainer: + removeComponent: 'void' + getComponent: '?Nette\ComponentModel\IContainer' + getComponents: 'Iterator' + + # scalar type hints, see https://github.com/nette/application/commit/b71d69c507f90b48fbc1e40447d451b4b5c6f063 Nette\Application\Application: run: 'void' createInitialRequest: 'Nette\Application\Request' diff --git a/config/set/nette/nette-30/nette-security-return-types.yaml b/config/set/nette/nette-30/nette-security-return-types.yaml deleted file mode 100644 index b7bf72a40ea1..000000000000 --- a/config/set/nette/nette-30/nette-security-return-types.yaml +++ /dev/null @@ -1,33 +0,0 @@ -services: - # scalar type hints, see https://github.com/nette/security/commit/84024f612fb3f55f5d6e3e3e28eef1ad0388fa56 - Rector\Rector\ClassMethod\AddReturnTypeDeclarationRector: - Nette\Security\IAuthenticator: - authenticate: 'Nette\Security\IIdentity' - - Nette\Security\IAuthorizator: - isAllowed: 'bool' - - Nette\Security\Identity: - getData: 'array' - - Nette\Security\IIdentity: - getRoles: 'array' - - Nette\Security\User: - getStorage: 'Nette\Security\IUserStorage' - login: 'void' - logout: 'void' - isLoggedIn: 'bool' - getIdentity: '?Nette\Security\IIdentity' - getAuthenticator: '?Nette\Security\IAuthenticator' - getAuthorizator: '?Nette\Security\IAuthorizator' - getLogoutReason: '?int' - getRoles: 'array' - isInRole: 'bool' - isAllowed: 'bool' - - Nette\Security\IUserStorage: - isAuthenticated: 'bool' - getIdentity: '?Nette\Security\IIdentity' - getLogoutReason: '?int' -