From c470d6b5f027277134d0a0e0bcc3db876b12c6a4 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Sun, 19 May 2019 10:34:24 +0200 Subject: [PATCH 1/2] fix ReservedObjectRector for lowercased object --- .../Php/src/Rector/Name/ReservedObjectRector.php | 3 +-- .../Fixture/skip_type_declaration_object.php | 8 ++++++++ .../ReservedObjectRectorTest.php | 16 +++++++++++----- 3 files changed, 20 insertions(+), 7 deletions(-) create mode 100644 packages/Php/tests/Rector/Name/ReservedObjectRector/Fixture/skip_type_declaration_object.php diff --git a/packages/Php/src/Rector/Name/ReservedObjectRector.php b/packages/Php/src/Rector/Name/ReservedObjectRector.php index 633188ca5a5b..ddeeb0ec86ab 100644 --- a/packages/Php/src/Rector/Name/ReservedObjectRector.php +++ b/packages/Php/src/Rector/Name/ReservedObjectRector.php @@ -13,7 +13,6 @@ /** * @see https://wiki.php.net/rfc/object-typehint - * * @see https://github.com/cebe/yii2/commit/9548a212ecf6e50fcdb0e5ba6daad88019cfc544 */ final class ReservedObjectRector extends AbstractRector @@ -76,7 +75,7 @@ public function refactor(Node $node): ?Node private function processIdentifier(Identifier $identifier): Identifier { foreach ($this->reservedKeywordsToReplacements as $reservedKeyword => $replacement) { - if ($this->isNameInsensitive($identifier, $reservedKeyword)) { + if ($this->isName($identifier, $reservedKeyword)) { $identifier->name = $replacement; } } diff --git a/packages/Php/tests/Rector/Name/ReservedObjectRector/Fixture/skip_type_declaration_object.php b/packages/Php/tests/Rector/Name/ReservedObjectRector/Fixture/skip_type_declaration_object.php new file mode 100644 index 000000000000..8b1322eee4d9 --- /dev/null +++ b/packages/Php/tests/Rector/Name/ReservedObjectRector/Fixture/skip_type_declaration_object.php @@ -0,0 +1,8 @@ +doTestFiles([__DIR__ . '/Fixture/ReservedObject.php']); + $this->doTestFiles([ + __DIR__ . '/Fixture/ReservedObject.php', + __DIR__ . '/Fixture/skip_type_declaration_object.php', + ]); } /** @@ -17,10 +20,13 @@ public function test(): void */ protected function getRectorsWithConfiguration(): array { - return [ReservedObjectRector::class => [ - '$reservedKeywordsToReplacements' => [ - 'ReservedObject' => 'SmartObject', + return [ + ReservedObjectRector::class => [ + '$reservedKeywordsToReplacements' => [ + 'ReservedObject' => 'SmartObject', + 'Object' => 'AnotherSmartObject', + ], ], - ]]; + ]; } } From 26ce8e4c77000bf652ff12a60498e15e1d99346e Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Sun, 19 May 2019 10:44:14 +0200 Subject: [PATCH 2/2] travis: add fast_finish [skip ci] --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 48340340a624..8413abe7d2ff 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,7 @@ language: php matrix: + fast_finish: true include: - php: '7.1' env: STATIC_ANALYSIS=true RUN_RECTOR=true