Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
language: php

matrix:
fast_finish: true
include:
- php: '7.1'
env: STATIC_ANALYSIS=true RUN_RECTOR=true
Expand Down
3 changes: 1 addition & 2 deletions packages/Php/src/Rector/Name/ReservedObjectRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace Rector\Php\Tests\Rector\Name\ReservedObjectRector\Fixture;

function myFunction(): object
{
return new \stdClass;
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,24 @@ final class ReservedObjectRectorTest extends AbstractRectorTestCase
{
public function test(): void
{
$this->doTestFiles([__DIR__ . '/Fixture/ReservedObject.php']);
$this->doTestFiles([
__DIR__ . '/Fixture/ReservedObject.php',
__DIR__ . '/Fixture/skip_type_declaration_object.php',
]);
}

/**
* @return mixed[]
*/
protected function getRectorsWithConfiguration(): array
{
return [ReservedObjectRector::class => [
'$reservedKeywordsToReplacements' => [
'ReservedObject' => 'SmartObject',
return [
ReservedObjectRector::class => [
'$reservedKeywordsToReplacements' => [
'ReservedObject' => 'SmartObject',
'Object' => 'AnotherSmartObject',
],
],
]];
];
}
}