Completed
Push — master ( 52755b...6c4366 )
by smiley
02:13
created
vendor/phpunit/phpunit/src/Framework/Constraint/IsWritable.php 1 patch
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -16,44 +16,44 @@
 block discarded – undo
16 16
  */
17 17
 class IsWritable 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_writable($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_writable($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
-            '"%s" is writable',
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
+			'"%s" is writable',
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 'is writable';
58
-    }
50
+	/**
51
+	 * Returns a string representation of the constraint.
52
+	 *
53
+	 * @return string
54
+	 */
55
+	public function toString()
56
+	{
57
+		return 'is writable';
58
+	}
59 59
 }
Please login to merge, or discard this patch.
vendor/phpunit/phpunit/src/Framework/Constraint/ClassHasAttribute.php 1 patch
Indentation   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -19,65 +19,65 @@
 block discarded – undo
19 19
  */
20 20
 class ClassHasAttribute extends Constraint
21 21
 {
22
-    /**
23
-     * @var string
24
-     */
25
-    protected $attributeName;
22
+	/**
23
+	 * @var string
24
+	 */
25
+	protected $attributeName;
26 26
 
27
-    /**
28
-     * @param string $attributeName
29
-     */
30
-    public function __construct($attributeName)
31
-    {
32
-        parent::__construct();
33
-        $this->attributeName = $attributeName;
34
-    }
27
+	/**
28
+	 * @param string $attributeName
29
+	 */
30
+	public function __construct($attributeName)
31
+	{
32
+		parent::__construct();
33
+		$this->attributeName = $attributeName;
34
+	}
35 35
 
36
-    /**
37
-     * Evaluates the constraint for parameter $other. Returns true if the
38
-     * constraint is met, false otherwise.
39
-     *
40
-     * @param mixed $other Value or object to evaluate.
41
-     *
42
-     * @return bool
43
-     */
44
-    protected function matches($other)
45
-    {
46
-        $class = new ReflectionClass($other);
36
+	/**
37
+	 * Evaluates the constraint for parameter $other. Returns true if the
38
+	 * constraint is met, false otherwise.
39
+	 *
40
+	 * @param mixed $other Value or object to evaluate.
41
+	 *
42
+	 * @return bool
43
+	 */
44
+	protected function matches($other)
45
+	{
46
+		$class = new ReflectionClass($other);
47 47
 
48
-        return $class->hasProperty($this->attributeName);
49
-    }
48
+		return $class->hasProperty($this->attributeName);
49
+	}
50 50
 
51
-    /**
52
-     * Returns a string representation of the constraint.
53
-     *
54
-     * @return string
55
-     */
56
-    public function toString()
57
-    {
58
-        return \sprintf(
59
-            'has attribute "%s"',
60
-            $this->attributeName
61
-        );
62
-    }
51
+	/**
52
+	 * Returns a string representation of the constraint.
53
+	 *
54
+	 * @return string
55
+	 */
56
+	public function toString()
57
+	{
58
+		return \sprintf(
59
+			'has attribute "%s"',
60
+			$this->attributeName
61
+		);
62
+	}
63 63
 
64
-    /**
65
-     * Returns the description of the failure
66
-     *
67
-     * The beginning of failure messages is "Failed asserting that" in most
68
-     * cases. This method should return the second part of that sentence.
69
-     *
70
-     * @param mixed $other Evaluated value or object.
71
-     *
72
-     * @return string
73
-     */
74
-    protected function failureDescription($other)
75
-    {
76
-        return \sprintf(
77
-            '%sclass "%s" %s',
78
-            \is_object($other) ? 'object of ' : '',
79
-            \is_object($other) ? \get_class($other) : $other,
80
-            $this->toString()
81
-        );
82
-    }
64
+	/**
65
+	 * Returns the description of the failure
66
+	 *
67
+	 * The beginning of failure messages is "Failed asserting that" in most
68
+	 * cases. This method should return the second part of that sentence.
69
+	 *
70
+	 * @param mixed $other Evaluated value or object.
71
+	 *
72
+	 * @return string
73
+	 */
74
+	protected function failureDescription($other)
75
+	{
76
+		return \sprintf(
77
+			'%sclass "%s" %s',
78
+			\is_object($other) ? 'object of ' : '',
79
+			\is_object($other) ? \get_class($other) : $other,
80
+			$this->toString()
81
+		);
82
+	}
83 83
 }
Please login to merge, or discard this patch.
vendor/phpunit/phpunit/src/Framework/Constraint/ExceptionMessage.php 1 patch
Indentation   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -11,73 +11,73 @@
 block discarded – undo
11 11
 
12 12
 class ExceptionMessage extends Constraint
13 13
 {
14
-    /**
15
-     * @var int
16
-     */
17
-    protected $expectedMessage;
14
+	/**
15
+	 * @var int
16
+	 */
17
+	protected $expectedMessage;
18 18
 
19
-    /**
20
-     * @param string $expected
21
-     */
22
-    public function __construct($expected)
23
-    {
24
-        parent::__construct();
19
+	/**
20
+	 * @param string $expected
21
+	 */
22
+	public function __construct($expected)
23
+	{
24
+		parent::__construct();
25 25
 
26
-        $this->expectedMessage = $expected;
27
-    }
26
+		$this->expectedMessage = $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
-        if ($this->expectedMessage === '') {
40
-            return $other->getMessage() === '';
41
-        }
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
+		if ($this->expectedMessage === '') {
40
+			return $other->getMessage() === '';
41
+		}
42 42
 
43
-        return \strpos($other->getMessage(), $this->expectedMessage) !== false;
44
-    }
43
+		return \strpos($other->getMessage(), $this->expectedMessage) !== false;
44
+	}
45 45
 
46
-    /**
47
-     * Returns the description of the failure
48
-     *
49
-     * The beginning of failure messages is "Failed asserting that" in most
50
-     * cases. This method should return the second part of that sentence.
51
-     *
52
-     * @param mixed $other Evaluated value or object.
53
-     *
54
-     * @return string
55
-     */
56
-    protected function failureDescription($other)
57
-    {
58
-        if ($this->expectedMessage === '') {
59
-            return \sprintf(
60
-                "exception message is empty but is '%s'",
61
-                $other->getMessage()
62
-            );
63
-        }
46
+	/**
47
+	 * Returns the description of the failure
48
+	 *
49
+	 * The beginning of failure messages is "Failed asserting that" in most
50
+	 * cases. This method should return the second part of that sentence.
51
+	 *
52
+	 * @param mixed $other Evaluated value or object.
53
+	 *
54
+	 * @return string
55
+	 */
56
+	protected function failureDescription($other)
57
+	{
58
+		if ($this->expectedMessage === '') {
59
+			return \sprintf(
60
+				"exception message is empty but is '%s'",
61
+				$other->getMessage()
62
+			);
63
+		}
64 64
 
65
-        return \sprintf(
66
-            "exception message '%s' contains '%s'",
67
-            $other->getMessage(),
68
-            $this->expectedMessage
69
-        );
70
-    }
65
+		return \sprintf(
66
+			"exception message '%s' contains '%s'",
67
+			$other->getMessage(),
68
+			$this->expectedMessage
69
+		);
70
+	}
71 71
 
72
-    /**
73
-     * @return string
74
-     */
75
-    public function toString()
76
-    {
77
-        if ($this->expectedMessage === '') {
78
-            return 'exception message is empty';
79
-        }
72
+	/**
73
+	 * @return string
74
+	 */
75
+	public function toString()
76
+	{
77
+		if ($this->expectedMessage === '') {
78
+			return 'exception message is empty';
79
+		}
80 80
 
81
-        return 'exception message contains ';
82
-    }
81
+		return 'exception message contains ';
82
+	}
83 83
 }
Please login to merge, or discard this patch.
vendor/phpunit/phpunit/src/Framework/Constraint/Count.php 1 patch
Indentation   +115 added lines, -115 removed lines patch added patch discarded remove patch
@@ -17,119 +17,119 @@
 block discarded – undo
17 17
 
18 18
 class Count extends Constraint
19 19
 {
20
-    /**
21
-     * @var int
22
-     */
23
-    protected $expectedCount = 0;
24
-
25
-    /**
26
-     * @param int $expected
27
-     */
28
-    public function __construct($expected)
29
-    {
30
-        parent::__construct();
31
-        $this->expectedCount = $expected;
32
-    }
33
-
34
-    /**
35
-     * Evaluates the constraint for parameter $other. Returns true if the
36
-     * constraint is met, false otherwise.
37
-     *
38
-     * @param mixed $other
39
-     *
40
-     * @return bool
41
-     */
42
-    protected function matches($other)
43
-    {
44
-        return $this->expectedCount === $this->getCountOf($other);
45
-    }
46
-
47
-    /**
48
-     * @param \Countable|\Traversable|array $other
49
-     *
50
-     * @return int|null
51
-     */
52
-    protected function getCountOf($other)
53
-    {
54
-        if ($other instanceof Countable || \is_array($other)) {
55
-            return \count($other);
56
-        }
57
-
58
-        if ($other instanceof Traversable) {
59
-            while ($other instanceof IteratorAggregate) {
60
-                $other = $other->getIterator();
61
-            }
62
-
63
-            $iterator = $other;
64
-
65
-            if ($iterator instanceof Generator) {
66
-                return $this->getCountOfGenerator($iterator);
67
-            }
68
-
69
-            if (!$iterator instanceof Iterator) {
70
-                return \iterator_count($iterator);
71
-            }
72
-
73
-            $key   = $iterator->key();
74
-            $count = \iterator_count($iterator);
75
-
76
-            // Manually rewind $iterator to previous key, since iterator_count
77
-            // moves pointer.
78
-            if ($key !== null) {
79
-                $iterator->rewind();
80
-                while ($iterator->valid() && $key !== $iterator->key()) {
81
-                    $iterator->next();
82
-                }
83
-            }
84
-
85
-            return $count;
86
-        }
87
-    }
88
-
89
-    /**
90
-     * Returns the total number of iterations from a generator.
91
-     * This will fully exhaust the generator.
92
-     *
93
-     * @param Generator $generator
94
-     *
95
-     * @return int
96
-     */
97
-    protected function getCountOfGenerator(Generator $generator)
98
-    {
99
-        for ($count = 0; $generator->valid(); $generator->next()) {
100
-            ++$count;
101
-        }
102
-
103
-        return $count;
104
-    }
105
-
106
-    /**
107
-     * Returns the description of the failure.
108
-     *
109
-     * The beginning of failure messages is "Failed asserting that" in most
110
-     * cases. This method should return the second part of that sentence.
111
-     *
112
-     * @param mixed $other Evaluated value or object.
113
-     *
114
-     * @return string
115
-     */
116
-    protected function failureDescription($other)
117
-    {
118
-        return \sprintf(
119
-            'actual size %d matches expected size %d',
120
-            $this->getCountOf($other),
121
-            $this->expectedCount
122
-        );
123
-    }
124
-
125
-    /**
126
-     * @return string
127
-     */
128
-    public function toString()
129
-    {
130
-        return \sprintf(
131
-            'count matches %d',
132
-            $this->expectedCount
133
-        );
134
-    }
20
+	/**
21
+	 * @var int
22
+	 */
23
+	protected $expectedCount = 0;
24
+
25
+	/**
26
+	 * @param int $expected
27
+	 */
28
+	public function __construct($expected)
29
+	{
30
+		parent::__construct();
31
+		$this->expectedCount = $expected;
32
+	}
33
+
34
+	/**
35
+	 * Evaluates the constraint for parameter $other. Returns true if the
36
+	 * constraint is met, false otherwise.
37
+	 *
38
+	 * @param mixed $other
39
+	 *
40
+	 * @return bool
41
+	 */
42
+	protected function matches($other)
43
+	{
44
+		return $this->expectedCount === $this->getCountOf($other);
45
+	}
46
+
47
+	/**
48
+	 * @param \Countable|\Traversable|array $other
49
+	 *
50
+	 * @return int|null
51
+	 */
52
+	protected function getCountOf($other)
53
+	{
54
+		if ($other instanceof Countable || \is_array($other)) {
55
+			return \count($other);
56
+		}
57
+
58
+		if ($other instanceof Traversable) {
59
+			while ($other instanceof IteratorAggregate) {
60
+				$other = $other->getIterator();
61
+			}
62
+
63
+			$iterator = $other;
64
+
65
+			if ($iterator instanceof Generator) {
66
+				return $this->getCountOfGenerator($iterator);
67
+			}
68
+
69
+			if (!$iterator instanceof Iterator) {
70
+				return \iterator_count($iterator);
71
+			}
72
+
73
+			$key   = $iterator->key();
74
+			$count = \iterator_count($iterator);
75
+
76
+			// Manually rewind $iterator to previous key, since iterator_count
77
+			// moves pointer.
78
+			if ($key !== null) {
79
+				$iterator->rewind();
80
+				while ($iterator->valid() && $key !== $iterator->key()) {
81
+					$iterator->next();
82
+				}
83
+			}
84
+
85
+			return $count;
86
+		}
87
+	}
88
+
89
+	/**
90
+	 * Returns the total number of iterations from a generator.
91
+	 * This will fully exhaust the generator.
92
+	 *
93
+	 * @param Generator $generator
94
+	 *
95
+	 * @return int
96
+	 */
97
+	protected function getCountOfGenerator(Generator $generator)
98
+	{
99
+		for ($count = 0; $generator->valid(); $generator->next()) {
100
+			++$count;
101
+		}
102
+
103
+		return $count;
104
+	}
105
+
106
+	/**
107
+	 * Returns the description of the failure.
108
+	 *
109
+	 * The beginning of failure messages is "Failed asserting that" in most
110
+	 * cases. This method should return the second part of that sentence.
111
+	 *
112
+	 * @param mixed $other Evaluated value or object.
113
+	 *
114
+	 * @return string
115
+	 */
116
+	protected function failureDescription($other)
117
+	{
118
+		return \sprintf(
119
+			'actual size %d matches expected size %d',
120
+			$this->getCountOf($other),
121
+			$this->expectedCount
122
+		);
123
+	}
124
+
125
+	/**
126
+	 * @return string
127
+	 */
128
+	public function toString()
129
+	{
130
+		return \sprintf(
131
+			'count matches %d',
132
+			$this->expectedCount
133
+		);
134
+	}
135 135
 }
Please login to merge, or discard this patch.
vendor/phpunit/phpunit/src/Framework/Constraint/IsEmpty.php 1 patch
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -16,52 +16,52 @@
 block discarded – undo
16 16
  */
17 17
 class IsEmpty 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
-        if ($other instanceof Countable) {
30
-            return \count($other) === 0;
31
-        }
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
+		if ($other instanceof Countable) {
30
+			return \count($other) === 0;
31
+		}
32 32
 
33
-        return empty($other);
34
-    }
33
+		return empty($other);
34
+	}
35 35
 
36
-    /**
37
-     * Returns a string representation of the constraint.
38
-     *
39
-     * @return string
40
-     */
41
-    public function toString()
42
-    {
43
-        return 'is empty';
44
-    }
36
+	/**
37
+	 * Returns a string representation of the constraint.
38
+	 *
39
+	 * @return string
40
+	 */
41
+	public function toString()
42
+	{
43
+		return 'is empty';
44
+	}
45 45
 
46
-    /**
47
-     * Returns the description of the failure
48
-     *
49
-     * The beginning of failure messages is "Failed asserting that" in most
50
-     * cases. This method should return the second part of that sentence.
51
-     *
52
-     * @param mixed $other Evaluated value or object.
53
-     *
54
-     * @return string
55
-     */
56
-    protected function failureDescription($other)
57
-    {
58
-        $type = \gettype($other);
46
+	/**
47
+	 * Returns the description of the failure
48
+	 *
49
+	 * The beginning of failure messages is "Failed asserting that" in most
50
+	 * cases. This method should return the second part of that sentence.
51
+	 *
52
+	 * @param mixed $other Evaluated value or object.
53
+	 *
54
+	 * @return string
55
+	 */
56
+	protected function failureDescription($other)
57
+	{
58
+		$type = \gettype($other);
59 59
 
60
-        return \sprintf(
61
-            '%s %s %s',
62
-            $type[0] == 'a' || $type[0] == 'o' ? 'an' : 'a',
63
-            $type,
64
-            $this->toString()
65
-        );
66
-    }
60
+		return \sprintf(
61
+			'%s %s %s',
62
+			$type[0] == 'a' || $type[0] == 'o' ? 'an' : 'a',
63
+			$type,
64
+			$this->toString()
65
+		);
66
+	}
67 67
 }
Please login to merge, or discard this patch.
vendor/phpunit/phpunit/src/Framework/Constraint/FileExists.php 1 patch
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -16,44 +16,44 @@
 block discarded – undo
16 16
  */
17 17
 class FileExists 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 \file_exists($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 \file_exists($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
-            'file "%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
+			'file "%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 'file exists';
58
-    }
50
+	/**
51
+	 * Returns a string representation of the constraint.
52
+	 *
53
+	 * @return string
54
+	 */
55
+	public function toString()
56
+	{
57
+		return 'file exists';
58
+	}
59 59
 }
Please login to merge, or discard this patch.
vendor/phpunit/phpunit/src/Framework/Constraint/ArraySubset.php 1 patch
Indentation   +118 added lines, -118 removed lines patch added patch discarded remove patch
@@ -20,122 +20,122 @@
 block discarded – undo
20 20
  */
21 21
 class ArraySubset extends Constraint
22 22
 {
23
-    /**
24
-     * @var array|\Traversable
25
-     */
26
-    protected $subset;
27
-
28
-    /**
29
-     * @var bool
30
-     */
31
-    protected $strict;
32
-
33
-    /**
34
-     * @param array|\Traversable $subset
35
-     * @param bool               $strict Check for object identity
36
-     */
37
-    public function __construct($subset, $strict = false)
38
-    {
39
-        parent::__construct();
40
-
41
-        $this->strict = $strict;
42
-        $this->subset = $subset;
43
-    }
44
-
45
-    /**
46
-     * Evaluates the constraint for parameter $other
47
-     *
48
-     * If $returnResult is set to false (the default), an exception is thrown
49
-     * in case of a failure. null is returned otherwise.
50
-     *
51
-     * If $returnResult is true, the result of the evaluation is returned as
52
-     * a boolean value instead: true in case of success, false in case of a
53
-     * failure.
54
-     *
55
-     * @param mixed  $other        Value or object to evaluate.
56
-     * @param string $description  Additional information about the test
57
-     * @param bool   $returnResult Whether to return a result or throw an exception
58
-     *
59
-     * @return mixed
60
-     *
61
-     * @throws ExpectationFailedException
62
-     */
63
-    public function evaluate($other, $description = '', $returnResult = false)
64
-    {
65
-        //type cast $other & $this->subset as an array to allow
66
-        //support in standard array functions.
67
-        $other        = $this->toArray($other);
68
-        $this->subset = $this->toArray($this->subset);
69
-
70
-        $patched = \array_replace_recursive($other, $this->subset);
71
-
72
-        if ($this->strict) {
73
-            $result = $other === $patched;
74
-        } else {
75
-            $result = $other == $patched;
76
-        }
77
-
78
-        if ($returnResult) {
79
-            return $result;
80
-        }
81
-
82
-        if (!$result) {
83
-            $f = new ComparisonFailure(
84
-                $patched,
85
-                $other,
86
-                \print_r($patched, true),
87
-                \print_r($other, true)
88
-            );
89
-
90
-            $this->fail($other, $description, $f);
91
-        }
92
-    }
93
-
94
-    /**
95
-     * Returns a string representation of the constraint.
96
-     *
97
-     * @return string
98
-     */
99
-    public function toString()
100
-    {
101
-        return 'has the subset ' . $this->exporter->export($this->subset);
102
-    }
103
-
104
-    /**
105
-     * Returns the description of the failure
106
-     *
107
-     * The beginning of failure messages is "Failed asserting that" in most
108
-     * cases. This method should return the second part of that sentence.
109
-     *
110
-     * @param mixed $other Evaluated value or object.
111
-     *
112
-     * @return string
113
-     */
114
-    protected function failureDescription($other)
115
-    {
116
-        return 'an array ' . $this->toString();
117
-    }
118
-
119
-    /**
120
-     * @param array|\Traversable $other
121
-     *
122
-     * @return array
123
-     */
124
-    private function toArray($other)
125
-    {
126
-        if (\is_array($other)) {
127
-            return $other;
128
-        }
129
-
130
-        if ($other instanceof \ArrayObject) {
131
-            return $other->getArrayCopy();
132
-        }
133
-
134
-        if ($other instanceof \Traversable) {
135
-            return \iterator_to_array($other);
136
-        }
137
-
138
-        // Keep BC even if we know that array would not be the expected one
139
-        return (array) $other;
140
-    }
23
+	/**
24
+	 * @var array|\Traversable
25
+	 */
26
+	protected $subset;
27
+
28
+	/**
29
+	 * @var bool
30
+	 */
31
+	protected $strict;
32
+
33
+	/**
34
+	 * @param array|\Traversable $subset
35
+	 * @param bool               $strict Check for object identity
36
+	 */
37
+	public function __construct($subset, $strict = false)
38
+	{
39
+		parent::__construct();
40
+
41
+		$this->strict = $strict;
42
+		$this->subset = $subset;
43
+	}
44
+
45
+	/**
46
+	 * Evaluates the constraint for parameter $other
47
+	 *
48
+	 * If $returnResult is set to false (the default), an exception is thrown
49
+	 * in case of a failure. null is returned otherwise.
50
+	 *
51
+	 * If $returnResult is true, the result of the evaluation is returned as
52
+	 * a boolean value instead: true in case of success, false in case of a
53
+	 * failure.
54
+	 *
55
+	 * @param mixed  $other        Value or object to evaluate.
56
+	 * @param string $description  Additional information about the test
57
+	 * @param bool   $returnResult Whether to return a result or throw an exception
58
+	 *
59
+	 * @return mixed
60
+	 *
61
+	 * @throws ExpectationFailedException
62
+	 */
63
+	public function evaluate($other, $description = '', $returnResult = false)
64
+	{
65
+		//type cast $other & $this->subset as an array to allow
66
+		//support in standard array functions.
67
+		$other        = $this->toArray($other);
68
+		$this->subset = $this->toArray($this->subset);
69
+
70
+		$patched = \array_replace_recursive($other, $this->subset);
71
+
72
+		if ($this->strict) {
73
+			$result = $other === $patched;
74
+		} else {
75
+			$result = $other == $patched;
76
+		}
77
+
78
+		if ($returnResult) {
79
+			return $result;
80
+		}
81
+
82
+		if (!$result) {
83
+			$f = new ComparisonFailure(
84
+				$patched,
85
+				$other,
86
+				\print_r($patched, true),
87
+				\print_r($other, true)
88
+			);
89
+
90
+			$this->fail($other, $description, $f);
91
+		}
92
+	}
93
+
94
+	/**
95
+	 * Returns a string representation of the constraint.
96
+	 *
97
+	 * @return string
98
+	 */
99
+	public function toString()
100
+	{
101
+		return 'has the subset ' . $this->exporter->export($this->subset);
102
+	}
103
+
104
+	/**
105
+	 * Returns the description of the failure
106
+	 *
107
+	 * The beginning of failure messages is "Failed asserting that" in most
108
+	 * cases. This method should return the second part of that sentence.
109
+	 *
110
+	 * @param mixed $other Evaluated value or object.
111
+	 *
112
+	 * @return string
113
+	 */
114
+	protected function failureDescription($other)
115
+	{
116
+		return 'an array ' . $this->toString();
117
+	}
118
+
119
+	/**
120
+	 * @param array|\Traversable $other
121
+	 *
122
+	 * @return array
123
+	 */
124
+	private function toArray($other)
125
+	{
126
+		if (\is_array($other)) {
127
+			return $other;
128
+		}
129
+
130
+		if ($other instanceof \ArrayObject) {
131
+			return $other->getArrayCopy();
132
+		}
133
+
134
+		if ($other instanceof \Traversable) {
135
+			return \iterator_to_array($other);
136
+		}
137
+
138
+		// Keep BC even if we know that array would not be the expected one
139
+		return (array) $other;
140
+	}
141 141
 }
Please login to merge, or discard this patch.
vendor/phpunit/phpunit/src/Framework/Constraint/IsType.php 1 patch
Indentation   +122 added lines, -122 removed lines patch added patch discarded remove patch
@@ -17,126 +17,126 @@
 block discarded – undo
17 17
  */
18 18
 class IsType extends Constraint
19 19
 {
20
-    const TYPE_ARRAY    = 'array';
21
-    const TYPE_BOOL     = 'bool';
22
-    const TYPE_FLOAT    = 'float';
23
-    const TYPE_INT      = 'int';
24
-    const TYPE_NULL     = 'null';
25
-    const TYPE_NUMERIC  = 'numeric';
26
-    const TYPE_OBJECT   = 'object';
27
-    const TYPE_RESOURCE = 'resource';
28
-    const TYPE_STRING   = 'string';
29
-    const TYPE_SCALAR   = 'scalar';
30
-    const TYPE_CALLABLE = 'callable';
31
-
32
-    /**
33
-     * @var array
34
-     */
35
-    protected $types = [
36
-        'array'    => true,
37
-        'boolean'  => true,
38
-        'bool'     => true,
39
-        'double'   => true,
40
-        'float'    => true,
41
-        'integer'  => true,
42
-        'int'      => true,
43
-        'null'     => true,
44
-        'numeric'  => true,
45
-        'object'   => true,
46
-        'real'     => true,
47
-        'resource' => true,
48
-        'string'   => true,
49
-        'scalar'   => true,
50
-        'callable' => true
51
-    ];
52
-
53
-    /**
54
-     * @var string
55
-     */
56
-    protected $type;
57
-
58
-    /**
59
-     * @param string $type
60
-     *
61
-     * @throws \PHPUnit\Framework\Exception
62
-     */
63
-    public function __construct($type)
64
-    {
65
-        parent::__construct();
66
-
67
-        if (!isset($this->types[$type])) {
68
-            throw new \PHPUnit\Framework\Exception(
69
-                \sprintf(
70
-                    'Type specified for PHPUnit\Framework\Constraint\IsType <%s> ' .
71
-                    'is not a valid type.',
72
-                    $type
73
-                )
74
-            );
75
-        }
76
-
77
-        $this->type = $type;
78
-    }
79
-
80
-    /**
81
-     * Evaluates the constraint for parameter $other. Returns true if the
82
-     * constraint is met, false otherwise.
83
-     *
84
-     * @param mixed $other Value or object to evaluate.
85
-     *
86
-     * @return bool
87
-     */
88
-    protected function matches($other)
89
-    {
90
-        switch ($this->type) {
91
-            case 'numeric':
92
-                return \is_numeric($other);
93
-
94
-            case 'integer':
95
-            case 'int':
96
-                return \is_int($other);
97
-
98
-            case 'double':
99
-            case 'float':
100
-            case 'real':
101
-                return \is_float($other);
102
-
103
-            case 'string':
104
-                return \is_string($other);
105
-
106
-            case 'boolean':
107
-            case 'bool':
108
-                return \is_bool($other);
109
-
110
-            case 'null':
111
-                return null === $other;
112
-
113
-            case 'array':
114
-                return \is_array($other);
115
-
116
-            case 'object':
117
-                return \is_object($other);
118
-
119
-            case 'resource':
120
-                return \is_resource($other) || \is_string(@\get_resource_type($other));
121
-
122
-            case 'scalar':
123
-                return \is_scalar($other);
124
-
125
-            case 'callable':
126
-                return \is_callable($other);
127
-        }
128
-    }
129
-
130
-    /**
131
-     * Returns a string representation of the constraint.
132
-     *
133
-     * @return string
134
-     */
135
-    public function toString()
136
-    {
137
-        return \sprintf(
138
-            'is of type "%s"',
139
-            $this->type
140
-        );
141
-    }
20
+	const TYPE_ARRAY    = 'array';
21
+	const TYPE_BOOL     = 'bool';
22
+	const TYPE_FLOAT    = 'float';
23
+	const TYPE_INT      = 'int';
24
+	const TYPE_NULL     = 'null';
25
+	const TYPE_NUMERIC  = 'numeric';
26
+	const TYPE_OBJECT   = 'object';
27
+	const TYPE_RESOURCE = 'resource';
28
+	const TYPE_STRING   = 'string';
29
+	const TYPE_SCALAR   = 'scalar';
30
+	const TYPE_CALLABLE = 'callable';
31
+
32
+	/**
33
+	 * @var array
34
+	 */
35
+	protected $types = [
36
+		'array'    => true,
37
+		'boolean'  => true,
38
+		'bool'     => true,
39
+		'double'   => true,
40
+		'float'    => true,
41
+		'integer'  => true,
42
+		'int'      => true,
43
+		'null'     => true,
44
+		'numeric'  => true,
45
+		'object'   => true,
46
+		'real'     => true,
47
+		'resource' => true,
48
+		'string'   => true,
49
+		'scalar'   => true,
50
+		'callable' => true
51
+	];
52
+
53
+	/**
54
+	 * @var string
55
+	 */
56
+	protected $type;
57
+
58
+	/**
59
+	 * @param string $type
60
+	 *
61
+	 * @throws \PHPUnit\Framework\Exception
62
+	 */
63
+	public function __construct($type)
64
+	{
65
+		parent::__construct();
66
+
67
+		if (!isset($this->types[$type])) {
68
+			throw new \PHPUnit\Framework\Exception(
69
+				\sprintf(
70
+					'Type specified for PHPUnit\Framework\Constraint\IsType <%s> ' .
71
+					'is not a valid type.',
72
+					$type
73
+				)
74
+			);
75
+		}
76
+
77
+		$this->type = $type;
78
+	}
79
+
80
+	/**
81
+	 * Evaluates the constraint for parameter $other. Returns true if the
82
+	 * constraint is met, false otherwise.
83
+	 *
84
+	 * @param mixed $other Value or object to evaluate.
85
+	 *
86
+	 * @return bool
87
+	 */
88
+	protected function matches($other)
89
+	{
90
+		switch ($this->type) {
91
+			case 'numeric':
92
+				return \is_numeric($other);
93
+
94
+			case 'integer':
95
+			case 'int':
96
+				return \is_int($other);
97
+
98
+			case 'double':
99
+			case 'float':
100
+			case 'real':
101
+				return \is_float($other);
102
+
103
+			case 'string':
104
+				return \is_string($other);
105
+
106
+			case 'boolean':
107
+			case 'bool':
108
+				return \is_bool($other);
109
+
110
+			case 'null':
111
+				return null === $other;
112
+
113
+			case 'array':
114
+				return \is_array($other);
115
+
116
+			case 'object':
117
+				return \is_object($other);
118
+
119
+			case 'resource':
120
+				return \is_resource($other) || \is_string(@\get_resource_type($other));
121
+
122
+			case 'scalar':
123
+				return \is_scalar($other);
124
+
125
+			case 'callable':
126
+				return \is_callable($other);
127
+		}
128
+	}
129
+
130
+	/**
131
+	 * Returns a string representation of the constraint.
132
+	 *
133
+	 * @return string
134
+	 */
135
+	public function toString()
136
+	{
137
+		return \sprintf(
138
+			'is of type "%s"',
139
+			$this->type
140
+		);
141
+	}
142 142
 }
Please login to merge, or discard this patch.
vendor/phpunit/phpunit/src/Framework/Constraint/ArrayHasKey.php 1 patch
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -21,63 +21,63 @@
 block discarded – undo
21 21
  */
22 22
 class ArrayHasKey extends Constraint
23 23
 {
24
-    /**
25
-     * @var int|string
26
-     */
27
-    protected $key;
24
+	/**
25
+	 * @var int|string
26
+	 */
27
+	protected $key;
28 28
 
29
-    /**
30
-     * @param int|string $key
31
-     */
32
-    public function __construct($key)
33
-    {
34
-        parent::__construct();
35
-        $this->key = $key;
36
-    }
29
+	/**
30
+	 * @param int|string $key
31
+	 */
32
+	public function __construct($key)
33
+	{
34
+		parent::__construct();
35
+		$this->key = $key;
36
+	}
37 37
 
38
-    /**
39
-     * Evaluates the constraint for parameter $other. Returns true if the
40
-     * constraint is met, false otherwise.
41
-     *
42
-     * @param mixed $other Value or object to evaluate.
43
-     *
44
-     * @return bool
45
-     */
46
-    protected function matches($other)
47
-    {
48
-        if (\is_array($other)) {
49
-            return \array_key_exists($this->key, $other);
50
-        }
38
+	/**
39
+	 * Evaluates the constraint for parameter $other. Returns true if the
40
+	 * constraint is met, false otherwise.
41
+	 *
42
+	 * @param mixed $other Value or object to evaluate.
43
+	 *
44
+	 * @return bool
45
+	 */
46
+	protected function matches($other)
47
+	{
48
+		if (\is_array($other)) {
49
+			return \array_key_exists($this->key, $other);
50
+		}
51 51
 
52
-        if ($other instanceof ArrayAccess) {
53
-            return $other->offsetExists($this->key);
54
-        }
52
+		if ($other instanceof ArrayAccess) {
53
+			return $other->offsetExists($this->key);
54
+		}
55 55
 
56
-        return false;
57
-    }
56
+		return false;
57
+	}
58 58
 
59
-    /**
60
-     * Returns a string representation of the constraint.
61
-     *
62
-     * @return string
63
-     */
64
-    public function toString()
65
-    {
66
-        return 'has the key ' . $this->exporter->export($this->key);
67
-    }
59
+	/**
60
+	 * Returns a string representation of the constraint.
61
+	 *
62
+	 * @return string
63
+	 */
64
+	public function toString()
65
+	{
66
+		return 'has the key ' . $this->exporter->export($this->key);
67
+	}
68 68
 
69
-    /**
70
-     * Returns the description of the failure
71
-     *
72
-     * The beginning of failure messages is "Failed asserting that" in most
73
-     * cases. This method should return the second part of that sentence.
74
-     *
75
-     * @param mixed $other Evaluated value or object.
76
-     *
77
-     * @return string
78
-     */
79
-    protected function failureDescription($other)
80
-    {
81
-        return 'an array ' . $this->toString();
82
-    }
69
+	/**
70
+	 * Returns the description of the failure
71
+	 *
72
+	 * The beginning of failure messages is "Failed asserting that" in most
73
+	 * cases. This method should return the second part of that sentence.
74
+	 *
75
+	 * @param mixed $other Evaluated value or object.
76
+	 *
77
+	 * @return string
78
+	 */
79
+	protected function failureDescription($other)
80
+	{
81
+		return 'an array ' . $this->toString();
82
+	}
83 83
 }
Please login to merge, or discard this patch.