AbstractInheritanceConstraint
abstract class AbstractInheritanceConstraint extends Constraint
| internal | This class is not covered by the backward compatibility promise |
Abstract base class for inheritance constraints (ExtendsClass, ImplementsInterface, UsesTrait, etc.).
Methods
Initializes the constraint.
Returns a string representation of the constraint.
Evaluates the constraint for parameter $other. Returns true if the constraint is met, false otherwise.
Returns the description of the failure.
Returns short description of what we examine, e.g. 'implements interface'.
Returns short negated description of what we examine, e.g. 'does not implement interface'.
Returns an array of "inherited classes" -- eiher interfaces $class implements, parent classes it extends or traits it uses, depending on the actual implementation of this constraint.
Checks if $subject may be used as an argument to inheritance().
Returns a custom string representation of the constraint object when it appears in context of an $operator expression.
Returns the description of the failure when this constraint appears in context of an $operator expression.
Details
at line 39
protected
__construct(string $expected)
Initializes the constraint.
at line 47
final string
toString()
Returns a string representation of the constraint.
at line 58
final bool
matches(mixed $other)
Evaluates the constraint for parameter $other. Returns true if the constraint is met, false otherwise.
at line 79
final string
failureDescription(mixed $other)
Returns the description of the failure.
The beginning of failure messages is "Failed asserting that" in most cases. This method should return the second part of that sentence.
at line 87
abstract protected string
verb()
Returns short description of what we examine, e.g. 'implements interface'.
at line 92
abstract protected string
negatedVerb()
Returns short negated description of what we examine, e.g. 'does not implement interface'.
at line 101
abstract protected array
inheritance(string $class)
Returns an array of "inherited classes" -- eiher interfaces $class implements, parent classes it extends or traits it uses, depending on the actual implementation of this constraint.
at line 106
abstract protected bool
supports(string $subject)
Checks if $subject may be used as an argument to inheritance().
at line 123
final protected string
toStringInContext(Operator $operator, mixed $role)
Returns a custom string representation of the constraint object when it appears in context of an $operator expression.
The purpose of this method is to provide meaningful descriptive string in context of operators such as LogicalNot. Native PHPUnit constraints are supported out of the box by LogicalNot, but externally developed ones had no way to provide correct strings in this context.
The method shall return empty string, when it does not handle customization by itself.
at line 150
final protected string
failureDescriptionInContext(Operator $operator, mixed $role, mixed $other)
Returns the description of the failure when this constraint appears in context of an $operator expression.
The purpose of this method is to provide meaningful failure description in context of operators such as LogicalNot. Native PHPUnit constraints are supported out of the box by LogicalNot, but externally developed ones had no way to provide correct messages in this context.
The method shall return empty string, when it does not handle customization by itself.