-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PHPUnit 10] Skip with Magic __get() on AssertIssetToAssertObjectHasP…
…ropertyRector (#403) * [PHPUnit 10] Skip with Magic __get() on AssertIssetToAssertObjectHasPropertyRector * fixture * Fix
- Loading branch information
1 parent
f9a8848
commit 38bdce4
Showing
3 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
...MethodCall/AssertIssetToAssertObjectHasPropertyRector/Fixture/skip_with_magic_get.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
namespace Rector\PHPUnit\Tests\PHPUnit100\Rector\MethodCall\AssertIssetToAssertObjectHasPropertyRector\Fixture; | ||
|
||
use ArrayAccess; | ||
use PHPUnit\Framework\TestCase; | ||
use Rector\PHPUnit\Tests\PHPUnit100\Rector\MethodCall\AssertIssetToAssertObjectHasPropertyRector\Source\WithMagicGet; | ||
|
||
final class SkipWithMagicGet extends TestCase | ||
{ | ||
public function test() | ||
{ | ||
$object = new WithMagicGet(); | ||
$this->assertTrue(isset($object->one)); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
...t100/Rector/MethodCall/AssertIssetToAssertObjectHasPropertyRector/Source/WithMagicGet.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
namespace Rector\PHPUnit\Tests\PHPUnit100\Rector\MethodCall\AssertIssetToAssertObjectHasPropertyRector\Source; | ||
|
||
use ArrayAccess; | ||
|
||
class WithMagicGet implements ArrayAccess { | ||
public $container = [ | ||
"one" => 1, | ||
"two" => 2, | ||
"three" => 3, | ||
]; | ||
|
||
public function offsetSet($offset, $value): void { | ||
if (is_null($offset)) { | ||
$this->container[] = $value; | ||
} else { | ||
$this->container[$offset] = $value; | ||
} | ||
} | ||
|
||
public function offsetExists($offset): bool { | ||
return isset($this->container[$offset]); | ||
} | ||
|
||
public function offsetUnset($offset): void { | ||
unset($this->container[$offset]); | ||
} | ||
|
||
public function offsetGet($offset): mixed { | ||
return isset($this->container[$offset]) ? $this->container[$offset] : null; | ||
} | ||
|
||
public function __get(string $name): mixed | ||
{ | ||
return $this->offsetGet($name); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters