\PHPUnit_Framework_Constraint_IsType

Constraint that asserts that the value it is evaluated for is of a specified type.

The expected value is passed in the constructor.

Synopsis

class PHPUnit_Framework_Constraint_IsType extends PHPUnit_Framework_Constraint {
  • // constants
  • const TYPE_ARRAY = 'array';
  • const TYPE_BOOL = 'bool';
  • const TYPE_FLOAT = 'float';
  • const TYPE_INT = 'int';
  • const TYPE_NULL = 'null';
  • const TYPE_NUMERIC = 'numeric';
  • const TYPE_OBJECT = 'object';
  • const TYPE_RESOURCE = 'resource';
  • const TYPE_STRING = 'string';
  • const TYPE_SCALAR = 'scalar';
  • const TYPE_CALLABLE = 'callable';
  • // members
  • protected array $types;
  • protected string $type;
  • // Inherited members from PHPUnit_Framework_Constraint
  • protected $exporter;
}

Hierarchy

Violations

PHPMessDetector

Line Rule Message
128 - 177 CyclomaticComplexity The method matches() has a Cyclomatic Complexity of 14. The configured cyclomatic complexity threshold is 10.

Checkstyle

Line Column Severity Message
131 13 error CASE statements must not be defined using curly braces
136 13 error CASE statements must not be defined using curly braces
140 13 error CASE statements must not be defined using curly braces
144 13 error CASE statements must not be defined using curly braces
149 13 error CASE statements must not be defined using curly braces
153 13 error CASE statements must not be defined using curly braces
157 13 error CASE statements must not be defined using curly braces
161 13 error CASE statements must not be defined using curly braces
165 13 error CASE statements must not be defined using curly braces
169 13 error CASE statements must not be defined using curly braces
173 13 error CASE statements must not be defined using curly braces

Constants

Name Value
TYPE_ARRAY 'array'
TYPE_BOOL 'bool'
TYPE_FLOAT 'float'
TYPE_INT 'int'
TYPE_NULL 'null'
TYPE_NUMERIC 'numeric'
TYPE_OBJECT 'object'
TYPE_RESOURCE 'resource'
TYPE_STRING 'string'
TYPE_SCALAR 'scalar'
TYPE_CALLABLE 'callable'

Members

protected

  • $exporter
  • $type — string
  • $types — array

Methods

protected

  • matches() — Evaluates the constraint for parameter $other. Returns true if the constraint is met, false otherwise.

public

Inherited from PHPUnit_Framework_Constraint

protected

  • additionalFailureDescription() — Return additional failure description where needed
  • fail() — Throws an exception for the given compared value and test description
  • failureDescription() — Returns the description of the failure
  • matches() — Evaluates the constraint for parameter $other. Returns true if the constraint is met, false otherwise.

public

  • count() — Counts the number of constraint elements.
  • evaluate() — Evaluates the constraint for parameter $other

History