Skip to content

Remove assertions that operate on class/object properties #4601

@sebastianbergmann

Description

@sebastianbergmann

Object-Oriented Programming (OOP) is a programming paradigm based on the concept of "objects", which can contain data and code: data in the form of fields (often known as attributes or properties), and code, in the form of procedures (often known as methods).

Wikipedia

PHPUnit currently refers to "fields" (see above) as "attributes". This is (or will become) confusing considering the introduction of attributes in PHP 8 and their support in PHPUnit.

PHPUnit will be changed to use the term "property" instead of "attribute" where "field" is meant.

The following methods of PHPUnit\Framework\Assert will be removed in PHPUnit 10:

  • assertClassHasAttribute()
  • assertClassNotHasAttribute()
  • assertClassHasStaticAttribute()
  • assertClassNotHasStaticAttribute()
  • assertObjectHasAttribute()
  • assertObjectNotHasAttribute()
  • classHasAttribute()
  • classHasStaticAttribute()
  • objectHasAttribute()

The following classes will be removed in PHPUnit 10:

  • PHPUnit\Framework\Constraint\ClassHasAttribute
  • PHPUnit\Framework\Constraint\ClassHasStaticAttribute
  • PHPUnit\Framework\Constraint\ObjectHasAttribute

At this time, no replacements are planned as these assertions are not wildly used (to the best of my knowledge) and, if at all, should only be used in edge case situations that I consider outside the scope of PHPUnit's standard distribution.

Metadata

Metadata

Labels

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions