@@ -11,5 +11,5 @@ |
||
11 | 11 | |
12 | 12 | class Notice extends Error |
13 | 13 | { |
14 | - public static $enabled = true; |
|
14 | + public static $enabled = true; |
|
15 | 15 | } |
@@ -11,5 +11,5 @@ |
||
11 | 11 | |
12 | 12 | class Deprecated extends Error |
13 | 13 | { |
14 | - public static $enabled = true; |
|
14 | + public static $enabled = true; |
|
15 | 15 | } |
@@ -11,5 +11,5 @@ |
||
11 | 11 | |
12 | 12 | class Warning extends Error |
13 | 13 | { |
14 | - public static $enabled = true; |
|
14 | + public static $enabled = true; |
|
15 | 15 | } |
@@ -17,20 +17,20 @@ |
||
17 | 17 | */ |
18 | 18 | class Error extends Exception |
19 | 19 | { |
20 | - /** |
|
21 | - * Constructor. |
|
22 | - * |
|
23 | - * @param string $message |
|
24 | - * @param int $code |
|
25 | - * @param string $file |
|
26 | - * @param int $line |
|
27 | - * @param \Exception $previous |
|
28 | - */ |
|
29 | - public function __construct($message, $code, $file, $line, \Exception $previous = null) |
|
30 | - { |
|
31 | - parent::__construct($message, $code, $previous); |
|
20 | + /** |
|
21 | + * Constructor. |
|
22 | + * |
|
23 | + * @param string $message |
|
24 | + * @param int $code |
|
25 | + * @param string $file |
|
26 | + * @param int $line |
|
27 | + * @param \Exception $previous |
|
28 | + */ |
|
29 | + public function __construct($message, $code, $file, $line, \Exception $previous = null) |
|
30 | + { |
|
31 | + parent::__construct($message, $code, $previous); |
|
32 | 32 | |
33 | - $this->file = $file; |
|
34 | - $this->line = $line; |
|
35 | - } |
|
33 | + $this->file = $file; |
|
34 | + $this->line = $line; |
|
35 | + } |
|
36 | 36 | } |
@@ -13,58 +13,58 @@ |
||
13 | 13 | |
14 | 14 | abstract class Composite extends Constraint |
15 | 15 | { |
16 | - /** |
|
17 | - * @var Constraint |
|
18 | - */ |
|
19 | - protected $innerConstraint; |
|
16 | + /** |
|
17 | + * @var Constraint |
|
18 | + */ |
|
19 | + protected $innerConstraint; |
|
20 | 20 | |
21 | - /** |
|
22 | - * @param Constraint $innerConstraint |
|
23 | - */ |
|
24 | - public function __construct(Constraint $innerConstraint) |
|
25 | - { |
|
26 | - parent::__construct(); |
|
27 | - $this->innerConstraint = $innerConstraint; |
|
28 | - } |
|
21 | + /** |
|
22 | + * @param Constraint $innerConstraint |
|
23 | + */ |
|
24 | + public function __construct(Constraint $innerConstraint) |
|
25 | + { |
|
26 | + parent::__construct(); |
|
27 | + $this->innerConstraint = $innerConstraint; |
|
28 | + } |
|
29 | 29 | |
30 | - /** |
|
31 | - * Evaluates the constraint for parameter $other |
|
32 | - * |
|
33 | - * If $returnResult is set to false (the default), an exception is thrown |
|
34 | - * in case of a failure. null is returned otherwise. |
|
35 | - * |
|
36 | - * If $returnResult is true, the result of the evaluation is returned as |
|
37 | - * a boolean value instead: true in case of success, false in case of a |
|
38 | - * failure. |
|
39 | - * |
|
40 | - * @param mixed $other Value or object to evaluate. |
|
41 | - * @param string $description Additional information about the test |
|
42 | - * @param bool $returnResult Whether to return a result or throw an exception |
|
43 | - * |
|
44 | - * @return mixed |
|
45 | - * |
|
46 | - * @throws ExpectationFailedException |
|
47 | - */ |
|
48 | - public function evaluate($other, $description = '', $returnResult = false) |
|
49 | - { |
|
50 | - try { |
|
51 | - return $this->innerConstraint->evaluate( |
|
52 | - $other, |
|
53 | - $description, |
|
54 | - $returnResult |
|
55 | - ); |
|
56 | - } catch (ExpectationFailedException $e) { |
|
57 | - $this->fail($other, $description, $e->getComparisonFailure()); |
|
58 | - } |
|
59 | - } |
|
30 | + /** |
|
31 | + * Evaluates the constraint for parameter $other |
|
32 | + * |
|
33 | + * If $returnResult is set to false (the default), an exception is thrown |
|
34 | + * in case of a failure. null is returned otherwise. |
|
35 | + * |
|
36 | + * If $returnResult is true, the result of the evaluation is returned as |
|
37 | + * a boolean value instead: true in case of success, false in case of a |
|
38 | + * failure. |
|
39 | + * |
|
40 | + * @param mixed $other Value or object to evaluate. |
|
41 | + * @param string $description Additional information about the test |
|
42 | + * @param bool $returnResult Whether to return a result or throw an exception |
|
43 | + * |
|
44 | + * @return mixed |
|
45 | + * |
|
46 | + * @throws ExpectationFailedException |
|
47 | + */ |
|
48 | + public function evaluate($other, $description = '', $returnResult = false) |
|
49 | + { |
|
50 | + try { |
|
51 | + return $this->innerConstraint->evaluate( |
|
52 | + $other, |
|
53 | + $description, |
|
54 | + $returnResult |
|
55 | + ); |
|
56 | + } catch (ExpectationFailedException $e) { |
|
57 | + $this->fail($other, $description, $e->getComparisonFailure()); |
|
58 | + } |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * Counts the number of constraint elements. |
|
63 | - * |
|
64 | - * @return int |
|
65 | - */ |
|
66 | - public function count() |
|
67 | - { |
|
68 | - return \count($this->innerConstraint); |
|
69 | - } |
|
61 | + /** |
|
62 | + * Counts the number of constraint elements. |
|
63 | + * |
|
64 | + * @return int |
|
65 | + */ |
|
66 | + public function count() |
|
67 | + { |
|
68 | + return \count($this->innerConstraint); |
|
69 | + } |
|
70 | 70 | } |
@@ -11,58 +11,58 @@ |
||
11 | 11 | |
12 | 12 | class ExceptionCode extends Constraint |
13 | 13 | { |
14 | - /** |
|
15 | - * @var int |
|
16 | - */ |
|
17 | - protected $expectedCode; |
|
14 | + /** |
|
15 | + * @var int |
|
16 | + */ |
|
17 | + protected $expectedCode; |
|
18 | 18 | |
19 | - /** |
|
20 | - * @param int $expected |
|
21 | - */ |
|
22 | - public function __construct($expected) |
|
23 | - { |
|
24 | - parent::__construct(); |
|
19 | + /** |
|
20 | + * @param int $expected |
|
21 | + */ |
|
22 | + public function __construct($expected) |
|
23 | + { |
|
24 | + parent::__construct(); |
|
25 | 25 | |
26 | - $this->expectedCode = $expected; |
|
27 | - } |
|
26 | + $this->expectedCode = $expected; |
|
27 | + } |
|
28 | 28 | |
29 | - /** |
|
30 | - * Evaluates the constraint for parameter $other. Returns true if the |
|
31 | - * constraint is met, false otherwise. |
|
32 | - * |
|
33 | - * @param \Throwable $other |
|
34 | - * |
|
35 | - * @return bool |
|
36 | - */ |
|
37 | - protected function matches($other) |
|
38 | - { |
|
39 | - return (string) $other->getCode() == (string) $this->expectedCode; |
|
40 | - } |
|
29 | + /** |
|
30 | + * Evaluates the constraint for parameter $other. Returns true if the |
|
31 | + * constraint is met, false otherwise. |
|
32 | + * |
|
33 | + * @param \Throwable $other |
|
34 | + * |
|
35 | + * @return bool |
|
36 | + */ |
|
37 | + protected function matches($other) |
|
38 | + { |
|
39 | + return (string) $other->getCode() == (string) $this->expectedCode; |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * Returns the description of the failure |
|
44 | - * |
|
45 | - * The beginning of failure messages is "Failed asserting that" in most |
|
46 | - * cases. This method should return the second part of that sentence. |
|
47 | - * |
|
48 | - * @param mixed $other Evaluated value or object. |
|
49 | - * |
|
50 | - * @return string |
|
51 | - */ |
|
52 | - protected function failureDescription($other) |
|
53 | - { |
|
54 | - return \sprintf( |
|
55 | - '%s is equal to expected exception code %s', |
|
56 | - $this->exporter->export($other->getCode()), |
|
57 | - $this->exporter->export($this->expectedCode) |
|
58 | - ); |
|
59 | - } |
|
42 | + /** |
|
43 | + * Returns the description of the failure |
|
44 | + * |
|
45 | + * The beginning of failure messages is "Failed asserting that" in most |
|
46 | + * cases. This method should return the second part of that sentence. |
|
47 | + * |
|
48 | + * @param mixed $other Evaluated value or object. |
|
49 | + * |
|
50 | + * @return string |
|
51 | + */ |
|
52 | + protected function failureDescription($other) |
|
53 | + { |
|
54 | + return \sprintf( |
|
55 | + '%s is equal to expected exception code %s', |
|
56 | + $this->exporter->export($other->getCode()), |
|
57 | + $this->exporter->export($this->expectedCode) |
|
58 | + ); |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * @return string |
|
63 | - */ |
|
64 | - public function toString() |
|
65 | - { |
|
66 | - return 'exception code is '; |
|
67 | - } |
|
61 | + /** |
|
62 | + * @return string |
|
63 | + */ |
|
64 | + public function toString() |
|
65 | + { |
|
66 | + return 'exception code is '; |
|
67 | + } |
|
68 | 68 | } |
@@ -16,44 +16,44 @@ |
||
16 | 16 | */ |
17 | 17 | class DirectoryExists extends Constraint |
18 | 18 | { |
19 | - /** |
|
20 | - * Evaluates the constraint for parameter $other. Returns true if the |
|
21 | - * constraint is met, false otherwise. |
|
22 | - * |
|
23 | - * @param mixed $other Value or object to evaluate. |
|
24 | - * |
|
25 | - * @return bool |
|
26 | - */ |
|
27 | - protected function matches($other) |
|
28 | - { |
|
29 | - return \is_dir($other); |
|
30 | - } |
|
19 | + /** |
|
20 | + * Evaluates the constraint for parameter $other. Returns true if the |
|
21 | + * constraint is met, false otherwise. |
|
22 | + * |
|
23 | + * @param mixed $other Value or object to evaluate. |
|
24 | + * |
|
25 | + * @return bool |
|
26 | + */ |
|
27 | + protected function matches($other) |
|
28 | + { |
|
29 | + return \is_dir($other); |
|
30 | + } |
|
31 | 31 | |
32 | - /** |
|
33 | - * Returns the description of the failure |
|
34 | - * |
|
35 | - * The beginning of failure messages is "Failed asserting that" in most |
|
36 | - * cases. This method should return the second part of that sentence. |
|
37 | - * |
|
38 | - * @param mixed $other Evaluated value or object. |
|
39 | - * |
|
40 | - * @return string |
|
41 | - */ |
|
42 | - protected function failureDescription($other) |
|
43 | - { |
|
44 | - return \sprintf( |
|
45 | - 'directory "%s" exists', |
|
46 | - $other |
|
47 | - ); |
|
48 | - } |
|
32 | + /** |
|
33 | + * Returns the description of the failure |
|
34 | + * |
|
35 | + * The beginning of failure messages is "Failed asserting that" in most |
|
36 | + * cases. This method should return the second part of that sentence. |
|
37 | + * |
|
38 | + * @param mixed $other Evaluated value or object. |
|
39 | + * |
|
40 | + * @return string |
|
41 | + */ |
|
42 | + protected function failureDescription($other) |
|
43 | + { |
|
44 | + return \sprintf( |
|
45 | + 'directory "%s" exists', |
|
46 | + $other |
|
47 | + ); |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * Returns a string representation of the constraint. |
|
52 | - * |
|
53 | - * @return string |
|
54 | - */ |
|
55 | - public function toString() |
|
56 | - { |
|
57 | - return 'directory exists'; |
|
58 | - } |
|
50 | + /** |
|
51 | + * Returns a string representation of the constraint. |
|
52 | + * |
|
53 | + * @return string |
|
54 | + */ |
|
55 | + public function toString() |
|
56 | + { |
|
57 | + return 'directory exists'; |
|
58 | + } |
|
59 | 59 | } |
@@ -14,26 +14,26 @@ |
||
14 | 14 | */ |
15 | 15 | class IsNan extends Constraint |
16 | 16 | { |
17 | - /** |
|
18 | - * Evaluates the constraint for parameter $other. Returns true if the |
|
19 | - * constraint is met, false otherwise. |
|
20 | - * |
|
21 | - * @param mixed $other Value or object to evaluate. |
|
22 | - * |
|
23 | - * @return bool |
|
24 | - */ |
|
25 | - protected function matches($other) |
|
26 | - { |
|
27 | - return \is_nan($other); |
|
28 | - } |
|
17 | + /** |
|
18 | + * Evaluates the constraint for parameter $other. Returns true if the |
|
19 | + * constraint is met, false otherwise. |
|
20 | + * |
|
21 | + * @param mixed $other Value or object to evaluate. |
|
22 | + * |
|
23 | + * @return bool |
|
24 | + */ |
|
25 | + protected function matches($other) |
|
26 | + { |
|
27 | + return \is_nan($other); |
|
28 | + } |
|
29 | 29 | |
30 | - /** |
|
31 | - * Returns a string representation of the constraint. |
|
32 | - * |
|
33 | - * @return string |
|
34 | - */ |
|
35 | - public function toString() |
|
36 | - { |
|
37 | - return 'is nan'; |
|
38 | - } |
|
30 | + /** |
|
31 | + * Returns a string representation of the constraint. |
|
32 | + * |
|
33 | + * @return string |
|
34 | + */ |
|
35 | + public function toString() |
|
36 | + { |
|
37 | + return 'is nan'; |
|
38 | + } |
|
39 | 39 | } |
@@ -19,18 +19,18 @@ |
||
19 | 19 | */ |
20 | 20 | class ObjectHasAttribute extends ClassHasAttribute |
21 | 21 | { |
22 | - /** |
|
23 | - * Evaluates the constraint for parameter $other. Returns true if the |
|
24 | - * constraint is met, false otherwise. |
|
25 | - * |
|
26 | - * @param mixed $other Value or object to evaluate. |
|
27 | - * |
|
28 | - * @return bool |
|
29 | - */ |
|
30 | - protected function matches($other) |
|
31 | - { |
|
32 | - $object = new ReflectionObject($other); |
|
22 | + /** |
|
23 | + * Evaluates the constraint for parameter $other. Returns true if the |
|
24 | + * constraint is met, false otherwise. |
|
25 | + * |
|
26 | + * @param mixed $other Value or object to evaluate. |
|
27 | + * |
|
28 | + * @return bool |
|
29 | + */ |
|
30 | + protected function matches($other) |
|
31 | + { |
|
32 | + $object = new ReflectionObject($other); |
|
33 | 33 | |
34 | - return $object->hasProperty($this->attributeName); |
|
35 | - } |
|
34 | + return $object->hasProperty($this->attributeName); |
|
35 | + } |
|
36 | 36 | } |