Skip to content

Conversation

@samsonasik
Copy link
Member

This rule is apply invalid transformation, since isset() is verify if property has null value as well, see https://3v4l.org/KBkr3

so the transformation is invalid.

For transform to assertObjectHasProperty, there is already configured config for that, see

// https://github.com/sebastianbergmann/phpunit/issues/5220
new MethodCallRename('PHPUnit\Framework\Assert', 'assertObjectHasAttribute', 'assertObjectHasProperty'),
new MethodCallRename('PHPUnit\Framework\Assert', 'assertObjectNotHasAttribute', 'assertObjectNotHasProperty'),

which transformable from AssertPropertyExistsRector rule for that, see

final class AssertPropertyExistsRector extends AbstractRector

final class MyTest2 extends \PHPUnit\Framework\TestCase
{
public function test()
{
$response = new \Namespaced\Response();
$this->assertFalse(property_exists($response, 'property'));
}
}
?>
-----
<?php
namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\AssertPropertyExistsRector\Fixture;
final class MyTest2 extends \PHPUnit\Framework\TestCase
{
public function test()
{
$response = new \Namespaced\Response();
$this->assertObjectNotHasAttribute('property', $response);
}
}

so combine them will apply the syntax transformation.

@samsonasik
Copy link
Member Author

@TomasVotruba Ready to merge 👍

@TomasVotruba
Copy link
Member

Makes sense, thank you ☺️

@TomasVotruba TomasVotruba merged commit 1e74358 into main Nov 10, 2024
@TomasVotruba TomasVotruba deleted the remove-assert-isset branch November 10, 2024 07:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants