Skip to content

Commit

Permalink
Closes #4601
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Feb 9, 2021
1 parent 6d51b93 commit d44da6e
Show file tree
Hide file tree
Showing 8 changed files with 138 additions and 305 deletions.
38 changes: 38 additions & 0 deletions .psalm/baseline.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="4.x-dev@">
<file src="src/Framework/Assert.php">
<DeprecatedClass occurrences="12">
<code>ClassHasAttribute</code>
<code>ClassHasStaticAttribute</code>
<code>ObjectHasAttribute</code>
<code>new ClassHasAttribute($attributeName)</code>
<code>new ClassHasAttribute($attributeName)</code>
<code>new ClassHasAttribute($attributeName)</code>
<code>new ClassHasStaticAttribute($attributeName)</code>
<code>new ClassHasStaticAttribute($attributeName)</code>
<code>new ClassHasStaticAttribute($attributeName)</code>
<code>new ObjectHasAttribute($attributeName)</code>
<code>new ObjectHasAttribute($attributeName)</code>
<code>new ObjectHasAttribute($attributeName)</code>
</DeprecatedClass>
<DocblockTypeContradiction occurrences="16">
<code>!$actual instanceof Countable &amp;&amp; !is_iterable($actual)</code>
<code>!$actual instanceof Countable &amp;&amp; !is_iterable($actual)</code>
Expand Down Expand Up @@ -144,6 +158,22 @@
</PossiblyInvalidArgument>
</file>
<file src="src/Framework/Assert/Functions.php">
<DeprecatedClass occurrences="3">
<code>ClassHasAttribute</code>
<code>ClassHasStaticAttribute</code>
<code>ObjectHasAttribute</code>
</DeprecatedClass>
<DeprecatedMethod occurrences="9">
<code>Assert::assertClassHasAttribute(...func_get_args())</code>
<code>Assert::assertClassHasStaticAttribute(...func_get_args())</code>
<code>Assert::assertClassNotHasAttribute(...func_get_args())</code>
<code>Assert::assertClassNotHasStaticAttribute(...func_get_args())</code>
<code>Assert::assertObjectHasAttribute(...func_get_args())</code>
<code>Assert::assertObjectNotHasAttribute(...func_get_args())</code>
<code>Assert::classHasAttribute(...func_get_args())</code>
<code>Assert::classHasStaticAttribute(...func_get_args())</code>
<code>Assert::objectHasAttribute(...func_get_args())</code>
</DeprecatedMethod>
<MissingParamType occurrences="85">
<code>$actual</code>
<code>$actual</code>
Expand Down Expand Up @@ -330,8 +360,16 @@
<MissingThrowsDocblock occurrences="1"/>
</file>
<file src="src/Framework/Constraint/Object/ClassHasStaticAttribute.php">
<DeprecatedClass occurrences="1">
<code>ClassHasAttribute</code>
</DeprecatedClass>
<MissingThrowsDocblock occurrences="1"/>
</file>
<file src="src/Framework/Constraint/Object/ObjectHasAttribute.php">
<DeprecatedClass occurrences="1">
<code>ClassHasAttribute</code>
</DeprecatedClass>
</file>
<file src="src/Framework/Constraint/Operator/BinaryOperator.php">
<UnsafeInstantiation occurrences="1">
<code>new static</code>
Expand Down
1 change: 1 addition & 0 deletions ChangeLog-10.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ All notable changes of the PHPUnit 10.0 release series are documented in this fi
* [#4564](https://github.com/sebastianbergmann/phpunit/issues/4564): Deprecate `withConsecutive()`
* [#4567](https://github.com/sebastianbergmann/phpunit/issues/4567): Deprecate support for generators in `assertCount()` and `Count` constraint
* [#4595](https://github.com/sebastianbergmann/phpunit/issues/4595): Deprecate Test Hooks
* [#4601](https://github.com/sebastianbergmann/phpunit/issues/4601): Deprecate assertions that operate on class/object properties
* Removed the `PHPUnit\Runner\TestSuiteLoader` interface
* Removed the `<listeners>` XML configuration element and its children
* Removed the `groups` attribute on the `test` element in the TestDox XML report
Expand Down
63 changes: 63 additions & 0 deletions src/Framework/Assert.php
Original file line number Diff line number Diff line change
Expand Up @@ -1029,6 +1029,10 @@ public static function assertNan($actual, string $message = ''): void
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
* @throws Exception
* @throws ExpectationFailedException
*
* @codeCoverageIgnore
*
* @deprecated https://github.com/sebastianbergmann/phpunit/issues/4601
*/
public static function assertClassHasAttribute(string $attributeName, string $className, string $message = ''): void
{
Expand All @@ -1040,6 +1044,10 @@ public static function assertClassHasAttribute(string $attributeName, string $cl
throw InvalidArgumentException::create(2, 'class name');
}

(new WarningUtil)->createForTestCaseObjectOnCallStack(
'assertClassHasAttribute() is deprecated and will be removed in PHPUnit 11.'
);

static::assertThat($className, new ClassHasAttribute($attributeName), $message);
}

Expand All @@ -1049,6 +1057,10 @@ public static function assertClassHasAttribute(string $attributeName, string $cl
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
* @throws Exception
* @throws ExpectationFailedException
*
* @codeCoverageIgnore
*
* @deprecated https://github.com/sebastianbergmann/phpunit/issues/4601
*/
public static function assertClassNotHasAttribute(string $attributeName, string $className, string $message = ''): void
{
Expand All @@ -1060,6 +1072,10 @@ public static function assertClassNotHasAttribute(string $attributeName, string
throw InvalidArgumentException::create(2, 'class name');
}

(new WarningUtil)->createForTestCaseObjectOnCallStack(
'assertClassHasAttribute() is deprecated and will be removed in PHPUnit 11.'
);

static::assertThat(
$className,
new LogicalNot(
Expand All @@ -1075,6 +1091,10 @@ public static function assertClassNotHasAttribute(string $attributeName, string
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
* @throws Exception
* @throws ExpectationFailedException
*
* @codeCoverageIgnore
*
* @deprecated https://github.com/sebastianbergmann/phpunit/issues/4601
*/
public static function assertClassHasStaticAttribute(string $attributeName, string $className, string $message = ''): void
{
Expand All @@ -1086,6 +1106,10 @@ public static function assertClassHasStaticAttribute(string $attributeName, stri
throw InvalidArgumentException::create(2, 'class name');
}

(new WarningUtil)->createForTestCaseObjectOnCallStack(
'assertClassHasAttribute() is deprecated and will be removed in PHPUnit 11.'
);

static::assertThat(
$className,
new ClassHasStaticAttribute($attributeName),
Expand All @@ -1099,6 +1123,10 @@ public static function assertClassHasStaticAttribute(string $attributeName, stri
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
* @throws Exception
* @throws ExpectationFailedException
*
* @codeCoverageIgnore
*
* @deprecated https://github.com/sebastianbergmann/phpunit/issues/4601
*/
public static function assertClassNotHasStaticAttribute(string $attributeName, string $className, string $message = ''): void
{
Expand All @@ -1110,6 +1138,10 @@ public static function assertClassNotHasStaticAttribute(string $attributeName, s
throw InvalidArgumentException::create(2, 'class name');
}

(new WarningUtil)->createForTestCaseObjectOnCallStack(
'assertClassHasAttribute() is deprecated and will be removed in PHPUnit 11.'
);

static::assertThat(
$className,
new LogicalNot(
Expand All @@ -1127,6 +1159,10 @@ public static function assertClassNotHasStaticAttribute(string $attributeName, s
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
* @throws Exception
* @throws ExpectationFailedException
*
* @codeCoverageIgnore
*
* @deprecated https://github.com/sebastianbergmann/phpunit/issues/4601
*/
public static function assertObjectHasAttribute(string $attributeName, $object, string $message = ''): void
{
Expand All @@ -1138,6 +1174,10 @@ public static function assertObjectHasAttribute(string $attributeName, $object,
throw InvalidArgumentException::create(2, 'object');
}

(new WarningUtil)->createForTestCaseObjectOnCallStack(
'assertClassHasAttribute() is deprecated and will be removed in PHPUnit 11.'
);

static::assertThat(
$object,
new ObjectHasAttribute($attributeName),
Expand All @@ -1153,6 +1193,10 @@ public static function assertObjectHasAttribute(string $attributeName, $object,
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
* @throws Exception
* @throws ExpectationFailedException
*
* @codeCoverageIgnore
*
* @deprecated https://github.com/sebastianbergmann/phpunit/issues/4601
*/
public static function assertObjectNotHasAttribute(string $attributeName, $object, string $message = ''): void
{
Expand All @@ -1164,6 +1208,10 @@ public static function assertObjectNotHasAttribute(string $attributeName, $objec
throw InvalidArgumentException::create(2, 'object');
}

(new WarningUtil)->createForTestCaseObjectOnCallStack(
'assertClassHasAttribute() is deprecated and will be removed in PHPUnit 11.'
);

static::assertThat(
$object,
new LogicalNot(
Expand Down Expand Up @@ -2353,16 +2401,31 @@ public static function greaterThanOrEqual($value): LogicalOr
);
}

/**
* @codeCoverageIgnore
*
* @deprecated https://github.com/sebastianbergmann/phpunit/issues/4601
*/
public static function classHasAttribute(string $attributeName): ClassHasAttribute
{
return new ClassHasAttribute($attributeName);
}

/**
* @codeCoverageIgnore
*
* @deprecated https://github.com/sebastianbergmann/phpunit/issues/4601
*/
public static function classHasStaticAttribute(string $attributeName): ClassHasStaticAttribute
{
return new ClassHasStaticAttribute($attributeName);
}

/**
* @codeCoverageIgnore
*
* @deprecated https://github.com/sebastianbergmann/phpunit/issues/4601
*/
public static function objectHasAttribute($attributeName): ObjectHasAttribute
{
return new ObjectHasAttribute($attributeName);
Expand Down
24 changes: 24 additions & 0 deletions src/Framework/Assert/Functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1168,6 +1168,10 @@ function assertNan($actual, string $message = ''): void
* @throws Exception
* @throws ExpectationFailedException
*
* @codeCoverageIgnore
*
* @deprecated https://github.com/sebastianbergmann/phpunit/issues/4601
*
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
*
* @see Assert::assertClassHasAttribute
Expand All @@ -1186,6 +1190,10 @@ function assertClassHasAttribute(string $attributeName, string $className, strin
* @throws Exception
* @throws ExpectationFailedException
*
* @codeCoverageIgnore
*
* @deprecated https://github.com/sebastianbergmann/phpunit/issues/4601
*
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
*
* @see Assert::assertClassNotHasAttribute
Expand All @@ -1204,6 +1212,10 @@ function assertClassNotHasAttribute(string $attributeName, string $className, st
* @throws Exception
* @throws ExpectationFailedException
*
* @codeCoverageIgnore
*
* @deprecated https://github.com/sebastianbergmann/phpunit/issues/4601
*
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
*
* @see Assert::assertClassHasStaticAttribute
Expand All @@ -1222,6 +1234,10 @@ function assertClassHasStaticAttribute(string $attributeName, string $className,
* @throws Exception
* @throws ExpectationFailedException
*
* @codeCoverageIgnore
*
* @deprecated https://github.com/sebastianbergmann/phpunit/issues/4601
*
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
*
* @see Assert::assertClassNotHasStaticAttribute
Expand All @@ -1242,6 +1258,10 @@ function assertClassNotHasStaticAttribute(string $attributeName, string $classNa
* @throws Exception
* @throws ExpectationFailedException
*
* @codeCoverageIgnore
*
* @deprecated https://github.com/sebastianbergmann/phpunit/issues/4601
*
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
*
* @see Assert::assertObjectHasAttribute
Expand All @@ -1262,6 +1282,10 @@ function assertObjectHasAttribute(string $attributeName, $object, string $messag
* @throws Exception
* @throws ExpectationFailedException
*
* @codeCoverageIgnore
*
* @deprecated https://github.com/sebastianbergmann/phpunit/issues/4601
*
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
*
* @see Assert::assertObjectNotHasAttribute
Expand Down
4 changes: 4 additions & 0 deletions src/Framework/Constraint/Object/ClassHasAttribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@

/**
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
*
* @codeCoverageIgnore
*
* @deprecated https://github.com/sebastianbergmann/phpunit/issues/4601
*/
class ClassHasAttribute extends Constraint
{
Expand Down
4 changes: 4 additions & 0 deletions src/Framework/Constraint/Object/ClassHasStaticAttribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@

/**
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
*
* @codeCoverageIgnore
*
* @deprecated https://github.com/sebastianbergmann/phpunit/issues/4601
*/
final class ClassHasStaticAttribute extends ClassHasAttribute
{
Expand Down
4 changes: 4 additions & 0 deletions src/Framework/Constraint/Object/ObjectHasAttribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@

/**
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
*
* @codeCoverageIgnore
*
* @deprecated https://github.com/sebastianbergmann/phpunit/issues/4601
*/
final class ObjectHasAttribute extends ClassHasAttribute
{
Expand Down
Loading

0 comments on commit d44da6e

Please sign in to comment.