Completed
Push — master ( 52755b...6c4366 )
by smiley
02:13
created
vendor/phpunit/phpunit/src/Framework/BaseTestListener.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -16,5 +16,5 @@
 block discarded – undo
16 16
  */
17 17
 abstract class BaseTestListener implements TestListener
18 18
 {
19
-    use TestListenerDefaultImplementation;
19
+	use TestListenerDefaultImplementation;
20 20
 }
Please login to merge, or discard this patch.
vendor/phpunit/phpunit/src/Framework/Assert.php 1 patch
Indentation   +2848 added lines, -2848 removed lines patch added patch discarded remove patch
@@ -69,2852 +69,2852 @@
 block discarded – undo
69 69
  */
70 70
 abstract class Assert
71 71
 {
72
-    /**
73
-     * @var int
74
-     */
75
-    private static $count = 0;
76
-
77
-    /**
78
-     * Asserts that an array has a specified key.
79
-     *
80
-     * @param mixed             $key
81
-     * @param array|ArrayAccess $array
82
-     * @param string            $message
83
-     */
84
-    public static function assertArrayHasKey($key, $array, $message = '')
85
-    {
86
-        if (!(\is_int($key) || \is_string($key))) {
87
-            throw InvalidArgumentHelper::factory(
88
-                1,
89
-                'integer or string'
90
-            );
91
-        }
92
-
93
-        if (!(\is_array($array) || $array instanceof ArrayAccess)) {
94
-            throw InvalidArgumentHelper::factory(
95
-                2,
96
-                'array or ArrayAccess'
97
-            );
98
-        }
99
-
100
-        $constraint = new ArrayHasKey($key);
101
-
102
-        static::assertThat($array, $constraint, $message);
103
-    }
104
-
105
-    /**
106
-     * Asserts that an array has a specified subset.
107
-     *
108
-     * @param array|ArrayAccess $subset
109
-     * @param array|ArrayAccess $array
110
-     * @param bool              $strict  Check for object identity
111
-     * @param string            $message
112
-     */
113
-    public static function assertArraySubset($subset, $array, $strict = false, $message = '')
114
-    {
115
-        if (!(\is_array($subset) || $subset instanceof ArrayAccess)) {
116
-            throw InvalidArgumentHelper::factory(
117
-                1,
118
-                'array or ArrayAccess'
119
-            );
120
-        }
121
-
122
-        if (!(\is_array($array) || $array instanceof ArrayAccess)) {
123
-            throw InvalidArgumentHelper::factory(
124
-                2,
125
-                'array or ArrayAccess'
126
-            );
127
-        }
128
-
129
-        $constraint = new ArraySubset($subset, $strict);
130
-
131
-        static::assertThat($array, $constraint, $message);
132
-    }
133
-
134
-    /**
135
-     * Asserts that an array does not have a specified key.
136
-     *
137
-     * @param mixed             $key
138
-     * @param array|ArrayAccess $array
139
-     * @param string            $message
140
-     */
141
-    public static function assertArrayNotHasKey($key, $array, $message = '')
142
-    {
143
-        if (!(\is_int($key) || \is_string($key))) {
144
-            throw InvalidArgumentHelper::factory(
145
-                1,
146
-                'integer or string'
147
-            );
148
-        }
149
-
150
-        if (!(\is_array($array) || $array instanceof ArrayAccess)) {
151
-            throw InvalidArgumentHelper::factory(
152
-                2,
153
-                'array or ArrayAccess'
154
-            );
155
-        }
156
-
157
-        $constraint = new LogicalNot(
158
-            new ArrayHasKey($key)
159
-        );
160
-
161
-        static::assertThat($array, $constraint, $message);
162
-    }
163
-
164
-    /**
165
-     * Asserts that a haystack contains a needle.
166
-     *
167
-     * @param mixed  $needle
168
-     * @param mixed  $haystack
169
-     * @param string $message
170
-     * @param bool   $ignoreCase
171
-     * @param bool   $checkForObjectIdentity
172
-     * @param bool   $checkForNonObjectIdentity
173
-     */
174
-    public static function assertContains($needle, $haystack, $message = '', $ignoreCase = false, $checkForObjectIdentity = true, $checkForNonObjectIdentity = false)
175
-    {
176
-        if (\is_array($haystack) ||
177
-            (\is_object($haystack) && $haystack instanceof Traversable)) {
178
-            $constraint = new TraversableContains(
179
-                $needle,
180
-                $checkForObjectIdentity,
181
-                $checkForNonObjectIdentity
182
-            );
183
-        } elseif (\is_string($haystack)) {
184
-            if (!\is_string($needle)) {
185
-                throw InvalidArgumentHelper::factory(
186
-                    1,
187
-                    'string'
188
-                );
189
-            }
190
-
191
-            $constraint = new StringContains(
192
-                $needle,
193
-                $ignoreCase
194
-            );
195
-        } else {
196
-            throw InvalidArgumentHelper::factory(
197
-                2,
198
-                'array, traversable or string'
199
-            );
200
-        }
201
-
202
-        static::assertThat($haystack, $constraint, $message);
203
-    }
204
-
205
-    /**
206
-     * Asserts that a haystack that is stored in a static attribute of a class
207
-     * or an attribute of an object contains a needle.
208
-     *
209
-     * @param mixed         $needle
210
-     * @param string        $haystackAttributeName
211
-     * @param string|object $haystackClassOrObject
212
-     * @param string        $message
213
-     * @param bool          $ignoreCase
214
-     * @param bool          $checkForObjectIdentity
215
-     * @param bool          $checkForNonObjectIdentity
216
-     */
217
-    public static function assertAttributeContains($needle, $haystackAttributeName, $haystackClassOrObject, $message = '', $ignoreCase = false, $checkForObjectIdentity = true, $checkForNonObjectIdentity = false)
218
-    {
219
-        static::assertContains(
220
-            $needle,
221
-            static::readAttribute($haystackClassOrObject, $haystackAttributeName),
222
-            $message,
223
-            $ignoreCase,
224
-            $checkForObjectIdentity,
225
-            $checkForNonObjectIdentity
226
-        );
227
-    }
228
-
229
-    /**
230
-     * Asserts that a haystack does not contain a needle.
231
-     *
232
-     * @param mixed  $needle
233
-     * @param mixed  $haystack
234
-     * @param string $message
235
-     * @param bool   $ignoreCase
236
-     * @param bool   $checkForObjectIdentity
237
-     * @param bool   $checkForNonObjectIdentity
238
-     */
239
-    public static function assertNotContains($needle, $haystack, $message = '', $ignoreCase = false, $checkForObjectIdentity = true, $checkForNonObjectIdentity = false)
240
-    {
241
-        if (\is_array($haystack) ||
242
-            (\is_object($haystack) && $haystack instanceof Traversable)) {
243
-            $constraint = new LogicalNot(
244
-                new TraversableContains(
245
-                    $needle,
246
-                    $checkForObjectIdentity,
247
-                    $checkForNonObjectIdentity
248
-                )
249
-            );
250
-        } elseif (\is_string($haystack)) {
251
-            if (!\is_string($needle)) {
252
-                throw InvalidArgumentHelper::factory(
253
-                    1,
254
-                    'string'
255
-                );
256
-            }
257
-
258
-            $constraint = new LogicalNot(
259
-                new StringContains(
260
-                    $needle,
261
-                    $ignoreCase
262
-                )
263
-            );
264
-        } else {
265
-            throw InvalidArgumentHelper::factory(
266
-                2,
267
-                'array, traversable or string'
268
-            );
269
-        }
270
-
271
-        static::assertThat($haystack, $constraint, $message);
272
-    }
273
-
274
-    /**
275
-     * Asserts that a haystack that is stored in a static attribute of a class
276
-     * or an attribute of an object does not contain a needle.
277
-     *
278
-     * @param mixed         $needle
279
-     * @param string        $haystackAttributeName
280
-     * @param string|object $haystackClassOrObject
281
-     * @param string        $message
282
-     * @param bool          $ignoreCase
283
-     * @param bool          $checkForObjectIdentity
284
-     * @param bool          $checkForNonObjectIdentity
285
-     */
286
-    public static function assertAttributeNotContains($needle, $haystackAttributeName, $haystackClassOrObject, $message = '', $ignoreCase = false, $checkForObjectIdentity = true, $checkForNonObjectIdentity = false)
287
-    {
288
-        static::assertNotContains(
289
-            $needle,
290
-            static::readAttribute($haystackClassOrObject, $haystackAttributeName),
291
-            $message,
292
-            $ignoreCase,
293
-            $checkForObjectIdentity,
294
-            $checkForNonObjectIdentity
295
-        );
296
-    }
297
-
298
-    /**
299
-     * Asserts that a haystack contains only values of a given type.
300
-     *
301
-     * @param string $type
302
-     * @param mixed  $haystack
303
-     * @param bool   $isNativeType
304
-     * @param string $message
305
-     */
306
-    public static function assertContainsOnly($type, $haystack, $isNativeType = null, $message = '')
307
-    {
308
-        if (!\is_array($haystack) &&
309
-            !(\is_object($haystack) && $haystack instanceof Traversable)) {
310
-            throw InvalidArgumentHelper::factory(
311
-                2,
312
-                'array or traversable'
313
-            );
314
-        }
315
-
316
-        if ($isNativeType == null) {
317
-            $isNativeType = Type::isType($type);
318
-        }
319
-
320
-        static::assertThat(
321
-            $haystack,
322
-            new TraversableContainsOnly(
323
-                $type,
324
-                $isNativeType
325
-            ),
326
-            $message
327
-        );
328
-    }
329
-
330
-    /**
331
-     * Asserts that a haystack contains only instances of a given classname
332
-     *
333
-     * @param string             $classname
334
-     * @param array|\Traversable $haystack
335
-     * @param string             $message
336
-     */
337
-    public static function assertContainsOnlyInstancesOf($classname, $haystack, $message = '')
338
-    {
339
-        if (!\is_array($haystack) &&
340
-            !(\is_object($haystack) && $haystack instanceof Traversable)) {
341
-            throw InvalidArgumentHelper::factory(
342
-                2,
343
-                'array or traversable'
344
-            );
345
-        }
346
-
347
-        static::assertThat(
348
-            $haystack,
349
-            new TraversableContainsOnly(
350
-                $classname,
351
-                false
352
-            ),
353
-            $message
354
-        );
355
-    }
356
-
357
-    /**
358
-     * Asserts that a haystack that is stored in a static attribute of a class
359
-     * or an attribute of an object contains only values of a given type.
360
-     *
361
-     * @param string        $type
362
-     * @param string        $haystackAttributeName
363
-     * @param string|object $haystackClassOrObject
364
-     * @param bool          $isNativeType
365
-     * @param string        $message
366
-     */
367
-    public static function assertAttributeContainsOnly($type, $haystackAttributeName, $haystackClassOrObject, $isNativeType = null, $message = '')
368
-    {
369
-        static::assertContainsOnly(
370
-            $type,
371
-            static::readAttribute($haystackClassOrObject, $haystackAttributeName),
372
-            $isNativeType,
373
-            $message
374
-        );
375
-    }
376
-
377
-    /**
378
-     * Asserts that a haystack does not contain only values of a given type.
379
-     *
380
-     * @param string $type
381
-     * @param mixed  $haystack
382
-     * @param bool   $isNativeType
383
-     * @param string $message
384
-     */
385
-    public static function assertNotContainsOnly($type, $haystack, $isNativeType = null, $message = '')
386
-    {
387
-        if (!\is_array($haystack) &&
388
-            !(\is_object($haystack) && $haystack instanceof Traversable)) {
389
-            throw InvalidArgumentHelper::factory(
390
-                2,
391
-                'array or traversable'
392
-            );
393
-        }
394
-
395
-        if ($isNativeType == null) {
396
-            $isNativeType = Type::isType($type);
397
-        }
398
-
399
-        static::assertThat(
400
-            $haystack,
401
-            new LogicalNot(
402
-                new TraversableContainsOnly(
403
-                    $type,
404
-                    $isNativeType
405
-                )
406
-            ),
407
-            $message
408
-        );
409
-    }
410
-
411
-    /**
412
-     * Asserts that a haystack that is stored in a static attribute of a class
413
-     * or an attribute of an object does not contain only values of a given
414
-     * type.
415
-     *
416
-     * @param string        $type
417
-     * @param string        $haystackAttributeName
418
-     * @param string|object $haystackClassOrObject
419
-     * @param bool          $isNativeType
420
-     * @param string        $message
421
-     */
422
-    public static function assertAttributeNotContainsOnly($type, $haystackAttributeName, $haystackClassOrObject, $isNativeType = null, $message = '')
423
-    {
424
-        static::assertNotContainsOnly(
425
-            $type,
426
-            static::readAttribute($haystackClassOrObject, $haystackAttributeName),
427
-            $isNativeType,
428
-            $message
429
-        );
430
-    }
431
-
432
-    /**
433
-     * Asserts the number of elements of an array, Countable or Traversable.
434
-     *
435
-     * @param int    $expectedCount
436
-     * @param mixed  $haystack
437
-     * @param string $message
438
-     */
439
-    public static function assertCount($expectedCount, $haystack, $message = '')
440
-    {
441
-        if (!\is_int($expectedCount)) {
442
-            throw InvalidArgumentHelper::factory(1, 'integer');
443
-        }
444
-
445
-        if (!$haystack instanceof Countable &&
446
-            !$haystack instanceof Traversable &&
447
-            !\is_array($haystack)) {
448
-            throw InvalidArgumentHelper::factory(2, 'countable or traversable');
449
-        }
450
-
451
-        static::assertThat(
452
-            $haystack,
453
-            new Count($expectedCount),
454
-            $message
455
-        );
456
-    }
457
-
458
-    /**
459
-     * Asserts the number of elements of an array, Countable or Traversable
460
-     * that is stored in an attribute.
461
-     *
462
-     * @param int           $expectedCount
463
-     * @param string        $haystackAttributeName
464
-     * @param string|object $haystackClassOrObject
465
-     * @param string        $message
466
-     */
467
-    public static function assertAttributeCount($expectedCount, $haystackAttributeName, $haystackClassOrObject, $message = '')
468
-    {
469
-        static::assertCount(
470
-            $expectedCount,
471
-            static::readAttribute($haystackClassOrObject, $haystackAttributeName),
472
-            $message
473
-        );
474
-    }
475
-
476
-    /**
477
-     * Asserts the number of elements of an array, Countable or Traversable.
478
-     *
479
-     * @param int    $expectedCount
480
-     * @param mixed  $haystack
481
-     * @param string $message
482
-     */
483
-    public static function assertNotCount($expectedCount, $haystack, $message = '')
484
-    {
485
-        if (!\is_int($expectedCount)) {
486
-            throw InvalidArgumentHelper::factory(1, 'integer');
487
-        }
488
-
489
-        if (!$haystack instanceof Countable &&
490
-            !$haystack instanceof Traversable &&
491
-            !\is_array($haystack)) {
492
-            throw InvalidArgumentHelper::factory(2, 'countable or traversable');
493
-        }
494
-
495
-        $constraint = new LogicalNot(
496
-            new Count($expectedCount)
497
-        );
498
-
499
-        static::assertThat($haystack, $constraint, $message);
500
-    }
501
-
502
-    /**
503
-     * Asserts the number of elements of an array, Countable or Traversable
504
-     * that is stored in an attribute.
505
-     *
506
-     * @param int           $expectedCount
507
-     * @param string        $haystackAttributeName
508
-     * @param string|object $haystackClassOrObject
509
-     * @param string        $message
510
-     */
511
-    public static function assertAttributeNotCount($expectedCount, $haystackAttributeName, $haystackClassOrObject, $message = '')
512
-    {
513
-        static::assertNotCount(
514
-            $expectedCount,
515
-            static::readAttribute($haystackClassOrObject, $haystackAttributeName),
516
-            $message
517
-        );
518
-    }
519
-
520
-    /**
521
-     * Asserts that two variables are equal.
522
-     *
523
-     * @param mixed  $expected
524
-     * @param mixed  $actual
525
-     * @param string $message
526
-     * @param float  $delta
527
-     * @param int    $maxDepth
528
-     * @param bool   $canonicalize
529
-     * @param bool   $ignoreCase
530
-     */
531
-    public static function assertEquals($expected, $actual, $message = '', $delta = 0.0, $maxDepth = 10, $canonicalize = false, $ignoreCase = false)
532
-    {
533
-        $constraint = new IsEqual(
534
-            $expected,
535
-            $delta,
536
-            $maxDepth,
537
-            $canonicalize,
538
-            $ignoreCase
539
-        );
540
-
541
-        static::assertThat($actual, $constraint, $message);
542
-    }
543
-
544
-    /**
545
-     * Asserts that a variable is equal to an attribute of an object.
546
-     *
547
-     * @param mixed         $expected
548
-     * @param string        $actualAttributeName
549
-     * @param string|object $actualClassOrObject
550
-     * @param string        $message
551
-     * @param float         $delta
552
-     * @param int           $maxDepth
553
-     * @param bool          $canonicalize
554
-     * @param bool          $ignoreCase
555
-     */
556
-    public static function assertAttributeEquals($expected, $actualAttributeName, $actualClassOrObject, $message = '', $delta = 0.0, $maxDepth = 10, $canonicalize = false, $ignoreCase = false)
557
-    {
558
-        static::assertEquals(
559
-            $expected,
560
-            static::readAttribute($actualClassOrObject, $actualAttributeName),
561
-            $message,
562
-            $delta,
563
-            $maxDepth,
564
-            $canonicalize,
565
-            $ignoreCase
566
-        );
567
-    }
568
-
569
-    /**
570
-     * Asserts that two variables are not equal.
571
-     *
572
-     * @param mixed  $expected
573
-     * @param mixed  $actual
574
-     * @param string $message
575
-     * @param float  $delta
576
-     * @param int    $maxDepth
577
-     * @param bool   $canonicalize
578
-     * @param bool   $ignoreCase
579
-     */
580
-    public static function assertNotEquals($expected, $actual, $message = '', $delta = 0.0, $maxDepth = 10, $canonicalize = false, $ignoreCase = false)
581
-    {
582
-        $constraint = new LogicalNot(
583
-            new IsEqual(
584
-                $expected,
585
-                $delta,
586
-                $maxDepth,
587
-                $canonicalize,
588
-                $ignoreCase
589
-            )
590
-        );
591
-
592
-        static::assertThat($actual, $constraint, $message);
593
-    }
594
-
595
-    /**
596
-     * Asserts that a variable is not equal to an attribute of an object.
597
-     *
598
-     * @param mixed         $expected
599
-     * @param string        $actualAttributeName
600
-     * @param string|object $actualClassOrObject
601
-     * @param string        $message
602
-     * @param float         $delta
603
-     * @param int           $maxDepth
604
-     * @param bool          $canonicalize
605
-     * @param bool          $ignoreCase
606
-     */
607
-    public static function assertAttributeNotEquals($expected, $actualAttributeName, $actualClassOrObject, $message = '', $delta = 0.0, $maxDepth = 10, $canonicalize = false, $ignoreCase = false)
608
-    {
609
-        static::assertNotEquals(
610
-            $expected,
611
-            static::readAttribute($actualClassOrObject, $actualAttributeName),
612
-            $message,
613
-            $delta,
614
-            $maxDepth,
615
-            $canonicalize,
616
-            $ignoreCase
617
-        );
618
-    }
619
-
620
-    /**
621
-     * Asserts that a variable is empty.
622
-     *
623
-     * @param mixed  $actual
624
-     * @param string $message
625
-     *
626
-     * @throws AssertionFailedError
627
-     */
628
-    public static function assertEmpty($actual, $message = '')
629
-    {
630
-        static::assertThat($actual, static::isEmpty(), $message);
631
-    }
632
-
633
-    /**
634
-     * Asserts that a static attribute of a class or an attribute of an object
635
-     * is empty.
636
-     *
637
-     * @param string        $haystackAttributeName
638
-     * @param string|object $haystackClassOrObject
639
-     * @param string        $message
640
-     */
641
-    public static function assertAttributeEmpty($haystackAttributeName, $haystackClassOrObject, $message = '')
642
-    {
643
-        static::assertEmpty(
644
-            static::readAttribute($haystackClassOrObject, $haystackAttributeName),
645
-            $message
646
-        );
647
-    }
648
-
649
-    /**
650
-     * Asserts that a variable is not empty.
651
-     *
652
-     * @param mixed  $actual
653
-     * @param string $message
654
-     *
655
-     * @throws AssertionFailedError
656
-     */
657
-    public static function assertNotEmpty($actual, $message = '')
658
-    {
659
-        static::assertThat($actual, static::logicalNot(static::isEmpty()), $message);
660
-    }
661
-
662
-    /**
663
-     * Asserts that a static attribute of a class or an attribute of an object
664
-     * is not empty.
665
-     *
666
-     * @param string        $haystackAttributeName
667
-     * @param string|object $haystackClassOrObject
668
-     * @param string        $message
669
-     */
670
-    public static function assertAttributeNotEmpty($haystackAttributeName, $haystackClassOrObject, $message = '')
671
-    {
672
-        static::assertNotEmpty(
673
-            static::readAttribute($haystackClassOrObject, $haystackAttributeName),
674
-            $message
675
-        );
676
-    }
677
-
678
-    /**
679
-     * Asserts that a value is greater than another value.
680
-     *
681
-     * @param mixed  $expected
682
-     * @param mixed  $actual
683
-     * @param string $message
684
-     */
685
-    public static function assertGreaterThan($expected, $actual, $message = '')
686
-    {
687
-        static::assertThat($actual, static::greaterThan($expected), $message);
688
-    }
689
-
690
-    /**
691
-     * Asserts that an attribute is greater than another value.
692
-     *
693
-     * @param mixed         $expected
694
-     * @param string        $actualAttributeName
695
-     * @param string|object $actualClassOrObject
696
-     * @param string        $message
697
-     */
698
-    public static function assertAttributeGreaterThan($expected, $actualAttributeName, $actualClassOrObject, $message = '')
699
-    {
700
-        static::assertGreaterThan(
701
-            $expected,
702
-            static::readAttribute($actualClassOrObject, $actualAttributeName),
703
-            $message
704
-        );
705
-    }
706
-
707
-    /**
708
-     * Asserts that a value is greater than or equal to another value.
709
-     *
710
-     * @param mixed  $expected
711
-     * @param mixed  $actual
712
-     * @param string $message
713
-     */
714
-    public static function assertGreaterThanOrEqual($expected, $actual, $message = '')
715
-    {
716
-        static::assertThat(
717
-            $actual,
718
-            static::greaterThanOrEqual($expected),
719
-            $message
720
-        );
721
-    }
722
-
723
-    /**
724
-     * Asserts that an attribute is greater than or equal to another value.
725
-     *
726
-     * @param mixed         $expected
727
-     * @param string        $actualAttributeName
728
-     * @param string|object $actualClassOrObject
729
-     * @param string        $message
730
-     */
731
-    public static function assertAttributeGreaterThanOrEqual($expected, $actualAttributeName, $actualClassOrObject, $message = '')
732
-    {
733
-        static::assertGreaterThanOrEqual(
734
-            $expected,
735
-            static::readAttribute($actualClassOrObject, $actualAttributeName),
736
-            $message
737
-        );
738
-    }
739
-
740
-    /**
741
-     * Asserts that a value is smaller than another value.
742
-     *
743
-     * @param mixed  $expected
744
-     * @param mixed  $actual
745
-     * @param string $message
746
-     */
747
-    public static function assertLessThan($expected, $actual, $message = '')
748
-    {
749
-        static::assertThat($actual, static::lessThan($expected), $message);
750
-    }
751
-
752
-    /**
753
-     * Asserts that an attribute is smaller than another value.
754
-     *
755
-     * @param mixed         $expected
756
-     * @param string        $actualAttributeName
757
-     * @param string|object $actualClassOrObject
758
-     * @param string        $message
759
-     */
760
-    public static function assertAttributeLessThan($expected, $actualAttributeName, $actualClassOrObject, $message = '')
761
-    {
762
-        static::assertLessThan(
763
-            $expected,
764
-            static::readAttribute($actualClassOrObject, $actualAttributeName),
765
-            $message
766
-        );
767
-    }
768
-
769
-    /**
770
-     * Asserts that a value is smaller than or equal to another value.
771
-     *
772
-     * @param mixed  $expected
773
-     * @param mixed  $actual
774
-     * @param string $message
775
-     */
776
-    public static function assertLessThanOrEqual($expected, $actual, $message = '')
777
-    {
778
-        static::assertThat($actual, static::lessThanOrEqual($expected), $message);
779
-    }
780
-
781
-    /**
782
-     * Asserts that an attribute is smaller than or equal to another value.
783
-     *
784
-     * @param mixed         $expected
785
-     * @param string        $actualAttributeName
786
-     * @param string|object $actualClassOrObject
787
-     * @param string        $message
788
-     */
789
-    public static function assertAttributeLessThanOrEqual($expected, $actualAttributeName, $actualClassOrObject, $message = '')
790
-    {
791
-        static::assertLessThanOrEqual(
792
-            $expected,
793
-            static::readAttribute($actualClassOrObject, $actualAttributeName),
794
-            $message
795
-        );
796
-    }
797
-
798
-    /**
799
-     * Asserts that the contents of one file is equal to the contents of another
800
-     * file.
801
-     *
802
-     * @param string $expected
803
-     * @param string $actual
804
-     * @param string $message
805
-     * @param bool   $canonicalize
806
-     * @param bool   $ignoreCase
807
-     */
808
-    public static function assertFileEquals($expected, $actual, $message = '', $canonicalize = false, $ignoreCase = false)
809
-    {
810
-        static::assertFileExists($expected, $message);
811
-        static::assertFileExists($actual, $message);
812
-
813
-        static::assertEquals(
814
-            \file_get_contents($expected),
815
-            \file_get_contents($actual),
816
-            $message,
817
-            0,
818
-            10,
819
-            $canonicalize,
820
-            $ignoreCase
821
-        );
822
-    }
823
-
824
-    /**
825
-     * Asserts that the contents of one file is not equal to the contents of
826
-     * another file.
827
-     *
828
-     * @param string $expected
829
-     * @param string $actual
830
-     * @param string $message
831
-     * @param bool   $canonicalize
832
-     * @param bool   $ignoreCase
833
-     */
834
-    public static function assertFileNotEquals($expected, $actual, $message = '', $canonicalize = false, $ignoreCase = false)
835
-    {
836
-        static::assertFileExists($expected, $message);
837
-        static::assertFileExists($actual, $message);
838
-
839
-        static::assertNotEquals(
840
-            \file_get_contents($expected),
841
-            \file_get_contents($actual),
842
-            $message,
843
-            0,
844
-            10,
845
-            $canonicalize,
846
-            $ignoreCase
847
-        );
848
-    }
849
-
850
-    /**
851
-     * Asserts that the contents of a string is equal
852
-     * to the contents of a file.
853
-     *
854
-     * @param string $expectedFile
855
-     * @param string $actualString
856
-     * @param string $message
857
-     * @param bool   $canonicalize
858
-     * @param bool   $ignoreCase
859
-     */
860
-    public static function assertStringEqualsFile($expectedFile, $actualString, $message = '', $canonicalize = false, $ignoreCase = false)
861
-    {
862
-        static::assertFileExists($expectedFile, $message);
863
-
864
-        static::assertEquals(
865
-            \file_get_contents($expectedFile),
866
-            $actualString,
867
-            $message,
868
-            0,
869
-            10,
870
-            $canonicalize,
871
-            $ignoreCase
872
-        );
873
-    }
874
-
875
-    /**
876
-     * Asserts that the contents of a string is not equal
877
-     * to the contents of a file.
878
-     *
879
-     * @param string $expectedFile
880
-     * @param string $actualString
881
-     * @param string $message
882
-     * @param bool   $canonicalize
883
-     * @param bool   $ignoreCase
884
-     */
885
-    public static function assertStringNotEqualsFile($expectedFile, $actualString, $message = '', $canonicalize = false, $ignoreCase = false)
886
-    {
887
-        static::assertFileExists($expectedFile, $message);
888
-
889
-        static::assertNotEquals(
890
-            \file_get_contents($expectedFile),
891
-            $actualString,
892
-            $message,
893
-            0,
894
-            10,
895
-            $canonicalize,
896
-            $ignoreCase
897
-        );
898
-    }
899
-
900
-    /**
901
-     * Asserts that a file/dir is readable.
902
-     *
903
-     * @param string $filename
904
-     * @param string $message
905
-     */
906
-    public static function assertIsReadable($filename, $message = '')
907
-    {
908
-        if (!\is_string($filename)) {
909
-            throw InvalidArgumentHelper::factory(1, 'string');
910
-        }
911
-
912
-        $constraint = new IsReadable;
913
-
914
-        static::assertThat($filename, $constraint, $message);
915
-    }
916
-
917
-    /**
918
-     * Asserts that a file/dir exists and is not readable.
919
-     *
920
-     * @param string $filename
921
-     * @param string $message
922
-     */
923
-    public static function assertNotIsReadable($filename, $message = '')
924
-    {
925
-        if (!\is_string($filename)) {
926
-            throw InvalidArgumentHelper::factory(1, 'string');
927
-        }
928
-
929
-        $constraint = new LogicalNot(
930
-            new IsReadable
931
-        );
932
-
933
-        static::assertThat($filename, $constraint, $message);
934
-    }
935
-
936
-    /**
937
-     * Asserts that a file/dir exists and is writable.
938
-     *
939
-     * @param string $filename
940
-     * @param string $message
941
-     */
942
-    public static function assertIsWritable($filename, $message = '')
943
-    {
944
-        if (!\is_string($filename)) {
945
-            throw InvalidArgumentHelper::factory(1, 'string');
946
-        }
947
-
948
-        $constraint = new IsWritable;
949
-
950
-        static::assertThat($filename, $constraint, $message);
951
-    }
952
-
953
-    /**
954
-     * Asserts that a file/dir exists and is not writable.
955
-     *
956
-     * @param string $filename
957
-     * @param string $message
958
-     */
959
-    public static function assertNotIsWritable($filename, $message = '')
960
-    {
961
-        if (!\is_string($filename)) {
962
-            throw InvalidArgumentHelper::factory(1, 'string');
963
-        }
964
-
965
-        $constraint = new LogicalNot(
966
-            new IsWritable
967
-        );
968
-
969
-        static::assertThat($filename, $constraint, $message);
970
-    }
971
-
972
-    /**
973
-     * Asserts that a directory exists.
974
-     *
975
-     * @param string $directory
976
-     * @param string $message
977
-     */
978
-    public static function assertDirectoryExists($directory, $message = '')
979
-    {
980
-        if (!\is_string($directory)) {
981
-            throw InvalidArgumentHelper::factory(1, 'string');
982
-        }
983
-
984
-        $constraint = new DirectoryExists;
985
-
986
-        static::assertThat($directory, $constraint, $message);
987
-    }
988
-
989
-    /**
990
-     * Asserts that a directory does not exist.
991
-     *
992
-     * @param string $directory
993
-     * @param string $message
994
-     */
995
-    public static function assertDirectoryNotExists($directory, $message = '')
996
-    {
997
-        if (!\is_string($directory)) {
998
-            throw InvalidArgumentHelper::factory(1, 'string');
999
-        }
1000
-
1001
-        $constraint = new LogicalNot(
1002
-            new DirectoryExists
1003
-        );
1004
-
1005
-        static::assertThat($directory, $constraint, $message);
1006
-    }
1007
-
1008
-    /**
1009
-     * Asserts that a directory exists and is readable.
1010
-     *
1011
-     * @param string $directory
1012
-     * @param string $message
1013
-     */
1014
-    public static function assertDirectoryIsReadable($directory, $message = '')
1015
-    {
1016
-        self::assertDirectoryExists($directory, $message);
1017
-        self::assertIsReadable($directory, $message);
1018
-    }
1019
-
1020
-    /**
1021
-     * Asserts that a directory exists and is not readable.
1022
-     *
1023
-     * @param string $directory
1024
-     * @param string $message
1025
-     */
1026
-    public static function assertDirectoryNotIsReadable($directory, $message = '')
1027
-    {
1028
-        self::assertDirectoryExists($directory, $message);
1029
-        self::assertNotIsReadable($directory, $message);
1030
-    }
1031
-
1032
-    /**
1033
-     * Asserts that a directory exists and is writable.
1034
-     *
1035
-     * @param string $directory
1036
-     * @param string $message
1037
-     */
1038
-    public static function assertDirectoryIsWritable($directory, $message = '')
1039
-    {
1040
-        self::assertDirectoryExists($directory, $message);
1041
-        self::assertIsWritable($directory, $message);
1042
-    }
1043
-
1044
-    /**
1045
-     * Asserts that a directory exists and is not writable.
1046
-     *
1047
-     * @param string $directory
1048
-     * @param string $message
1049
-     */
1050
-    public static function assertDirectoryNotIsWritable($directory, $message = '')
1051
-    {
1052
-        self::assertDirectoryExists($directory, $message);
1053
-        self::assertNotIsWritable($directory, $message);
1054
-    }
1055
-
1056
-    /**
1057
-     * Asserts that a file exists.
1058
-     *
1059
-     * @param string $filename
1060
-     * @param string $message
1061
-     */
1062
-    public static function assertFileExists($filename, $message = '')
1063
-    {
1064
-        if (!\is_string($filename)) {
1065
-            throw InvalidArgumentHelper::factory(1, 'string');
1066
-        }
1067
-
1068
-        $constraint = new FileExists;
1069
-
1070
-        static::assertThat($filename, $constraint, $message);
1071
-    }
1072
-
1073
-    /**
1074
-     * Asserts that a file does not exist.
1075
-     *
1076
-     * @param string $filename
1077
-     * @param string $message
1078
-     */
1079
-    public static function assertFileNotExists($filename, $message = '')
1080
-    {
1081
-        if (!\is_string($filename)) {
1082
-            throw InvalidArgumentHelper::factory(1, 'string');
1083
-        }
1084
-
1085
-        $constraint = new LogicalNot(
1086
-            new FileExists
1087
-        );
1088
-
1089
-        static::assertThat($filename, $constraint, $message);
1090
-    }
1091
-
1092
-    /**
1093
-     * Asserts that a file exists and is readable.
1094
-     *
1095
-     * @param string $file
1096
-     * @param string $message
1097
-     */
1098
-    public static function assertFileIsReadable($file, $message = '')
1099
-    {
1100
-        self::assertFileExists($file, $message);
1101
-        self::assertIsReadable($file, $message);
1102
-    }
1103
-
1104
-    /**
1105
-     * Asserts that a file exists and is not readable.
1106
-     *
1107
-     * @param string $file
1108
-     * @param string $message
1109
-     */
1110
-    public static function assertFileNotIsReadable($file, $message = '')
1111
-    {
1112
-        self::assertFileExists($file, $message);
1113
-        self::assertNotIsReadable($file, $message);
1114
-    }
1115
-
1116
-    /**
1117
-     * Asserts that a file exists and is writable.
1118
-     *
1119
-     * @param string $file
1120
-     * @param string $message
1121
-     */
1122
-    public static function assertFileIsWritable($file, $message = '')
1123
-    {
1124
-        self::assertFileExists($file, $message);
1125
-        self::assertIsWritable($file, $message);
1126
-    }
1127
-
1128
-    /**
1129
-     * Asserts that a file exists and is not writable.
1130
-     *
1131
-     * @param string $file
1132
-     * @param string $message
1133
-     */
1134
-    public static function assertFileNotIsWritable($file, $message = '')
1135
-    {
1136
-        self::assertFileExists($file, $message);
1137
-        self::assertNotIsWritable($file, $message);
1138
-    }
1139
-
1140
-    /**
1141
-     * Asserts that a condition is true.
1142
-     *
1143
-     * @param bool   $condition
1144
-     * @param string $message
1145
-     *
1146
-     * @throws AssertionFailedError
1147
-     */
1148
-    public static function assertTrue($condition, $message = '')
1149
-    {
1150
-        static::assertThat($condition, static::isTrue(), $message);
1151
-    }
1152
-
1153
-    /**
1154
-     * Asserts that a condition is not true.
1155
-     *
1156
-     * @param bool   $condition
1157
-     * @param string $message
1158
-     *
1159
-     * @throws AssertionFailedError
1160
-     */
1161
-    public static function assertNotTrue($condition, $message = '')
1162
-    {
1163
-        static::assertThat($condition, static::logicalNot(static::isTrue()), $message);
1164
-    }
1165
-
1166
-    /**
1167
-     * Asserts that a condition is false.
1168
-     *
1169
-     * @param bool   $condition
1170
-     * @param string $message
1171
-     *
1172
-     * @throws AssertionFailedError
1173
-     */
1174
-    public static function assertFalse($condition, $message = '')
1175
-    {
1176
-        static::assertThat($condition, static::isFalse(), $message);
1177
-    }
1178
-
1179
-    /**
1180
-     * Asserts that a condition is not false.
1181
-     *
1182
-     * @param bool   $condition
1183
-     * @param string $message
1184
-     *
1185
-     * @throws AssertionFailedError
1186
-     */
1187
-    public static function assertNotFalse($condition, $message = '')
1188
-    {
1189
-        static::assertThat($condition, static::logicalNot(static::isFalse()), $message);
1190
-    }
1191
-
1192
-    /**
1193
-     * Asserts that a variable is null.
1194
-     *
1195
-     * @param mixed  $actual
1196
-     * @param string $message
1197
-     */
1198
-    public static function assertNull($actual, $message = '')
1199
-    {
1200
-        static::assertThat($actual, static::isNull(), $message);
1201
-    }
1202
-
1203
-    /**
1204
-     * Asserts that a variable is not null.
1205
-     *
1206
-     * @param mixed  $actual
1207
-     * @param string $message
1208
-     */
1209
-    public static function assertNotNull($actual, $message = '')
1210
-    {
1211
-        static::assertThat($actual, static::logicalNot(static::isNull()), $message);
1212
-    }
1213
-
1214
-    /**
1215
-     * Asserts that a variable is finite.
1216
-     *
1217
-     * @param mixed  $actual
1218
-     * @param string $message
1219
-     */
1220
-    public static function assertFinite($actual, $message = '')
1221
-    {
1222
-        static::assertThat($actual, static::isFinite(), $message);
1223
-    }
1224
-
1225
-    /**
1226
-     * Asserts that a variable is infinite.
1227
-     *
1228
-     * @param mixed  $actual
1229
-     * @param string $message
1230
-     */
1231
-    public static function assertInfinite($actual, $message = '')
1232
-    {
1233
-        static::assertThat($actual, static::isInfinite(), $message);
1234
-    }
1235
-
1236
-    /**
1237
-     * Asserts that a variable is nan.
1238
-     *
1239
-     * @param mixed  $actual
1240
-     * @param string $message
1241
-     */
1242
-    public static function assertNan($actual, $message = '')
1243
-    {
1244
-        static::assertThat($actual, static::isNan(), $message);
1245
-    }
1246
-
1247
-    /**
1248
-     * Asserts that a class has a specified attribute.
1249
-     *
1250
-     * @param string $attributeName
1251
-     * @param string $className
1252
-     * @param string $message
1253
-     */
1254
-    public static function assertClassHasAttribute($attributeName, $className, $message = '')
1255
-    {
1256
-        if (!\is_string($attributeName)) {
1257
-            throw InvalidArgumentHelper::factory(1, 'string');
1258
-        }
1259
-
1260
-        if (!\preg_match('/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/', $attributeName)) {
1261
-            throw InvalidArgumentHelper::factory(1, 'valid attribute name');
1262
-        }
1263
-
1264
-        if (!\is_string($className) || !\class_exists($className)) {
1265
-            throw InvalidArgumentHelper::factory(2, 'class name', $className);
1266
-        }
1267
-
1268
-        $constraint = new ClassHasAttribute(
1269
-            $attributeName
1270
-        );
1271
-
1272
-        static::assertThat($className, $constraint, $message);
1273
-    }
1274
-
1275
-    /**
1276
-     * Asserts that a class does not have a specified attribute.
1277
-     *
1278
-     * @param string $attributeName
1279
-     * @param string $className
1280
-     * @param string $message
1281
-     */
1282
-    public static function assertClassNotHasAttribute($attributeName, $className, $message = '')
1283
-    {
1284
-        if (!\is_string($attributeName)) {
1285
-            throw InvalidArgumentHelper::factory(1, 'string');
1286
-        }
1287
-
1288
-        if (!\preg_match('/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/', $attributeName)) {
1289
-            throw InvalidArgumentHelper::factory(1, 'valid attribute name');
1290
-        }
1291
-
1292
-        if (!\is_string($className) || !\class_exists($className)) {
1293
-            throw InvalidArgumentHelper::factory(2, 'class name', $className);
1294
-        }
1295
-
1296
-        $constraint = new LogicalNot(
1297
-            new ClassHasAttribute($attributeName)
1298
-        );
1299
-
1300
-        static::assertThat($className, $constraint, $message);
1301
-    }
1302
-
1303
-    /**
1304
-     * Asserts that a class has a specified static attribute.
1305
-     *
1306
-     * @param string $attributeName
1307
-     * @param string $className
1308
-     * @param string $message
1309
-     */
1310
-    public static function assertClassHasStaticAttribute($attributeName, $className, $message = '')
1311
-    {
1312
-        if (!\is_string($attributeName)) {
1313
-            throw InvalidArgumentHelper::factory(1, 'string');
1314
-        }
1315
-
1316
-        if (!\preg_match('/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/', $attributeName)) {
1317
-            throw InvalidArgumentHelper::factory(1, 'valid attribute name');
1318
-        }
1319
-
1320
-        if (!\is_string($className) || !\class_exists($className)) {
1321
-            throw InvalidArgumentHelper::factory(2, 'class name', $className);
1322
-        }
1323
-
1324
-        $constraint = new ClassHasStaticAttribute(
1325
-            $attributeName
1326
-        );
1327
-
1328
-        static::assertThat($className, $constraint, $message);
1329
-    }
1330
-
1331
-    /**
1332
-     * Asserts that a class does not have a specified static attribute.
1333
-     *
1334
-     * @param string $attributeName
1335
-     * @param string $className
1336
-     * @param string $message
1337
-     */
1338
-    public static function assertClassNotHasStaticAttribute($attributeName, $className, $message = '')
1339
-    {
1340
-        if (!\is_string($attributeName)) {
1341
-            throw InvalidArgumentHelper::factory(1, 'string');
1342
-        }
1343
-
1344
-        if (!\preg_match('/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/', $attributeName)) {
1345
-            throw InvalidArgumentHelper::factory(1, 'valid attribute name');
1346
-        }
1347
-
1348
-        if (!\is_string($className) || !\class_exists($className)) {
1349
-            throw InvalidArgumentHelper::factory(2, 'class name', $className);
1350
-        }
1351
-
1352
-        $constraint = new LogicalNot(
1353
-            new ClassHasStaticAttribute(
1354
-                $attributeName
1355
-            )
1356
-        );
1357
-
1358
-        static::assertThat($className, $constraint, $message);
1359
-    }
1360
-
1361
-    /**
1362
-     * Asserts that an object has a specified attribute.
1363
-     *
1364
-     * @param string $attributeName
1365
-     * @param object $object
1366
-     * @param string $message
1367
-     */
1368
-    public static function assertObjectHasAttribute($attributeName, $object, $message = '')
1369
-    {
1370
-        if (!\is_string($attributeName)) {
1371
-            throw InvalidArgumentHelper::factory(1, 'string');
1372
-        }
1373
-
1374
-        if (!\preg_match('/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/', $attributeName)) {
1375
-            throw InvalidArgumentHelper::factory(1, 'valid attribute name');
1376
-        }
1377
-
1378
-        if (!\is_object($object)) {
1379
-            throw InvalidArgumentHelper::factory(2, 'object');
1380
-        }
1381
-
1382
-        $constraint = new ObjectHasAttribute(
1383
-            $attributeName
1384
-        );
1385
-
1386
-        static::assertThat($object, $constraint, $message);
1387
-    }
1388
-
1389
-    /**
1390
-     * Asserts that an object does not have a specified attribute.
1391
-     *
1392
-     * @param string $attributeName
1393
-     * @param object $object
1394
-     * @param string $message
1395
-     */
1396
-    public static function assertObjectNotHasAttribute($attributeName, $object, $message = '')
1397
-    {
1398
-        if (!\is_string($attributeName)) {
1399
-            throw InvalidArgumentHelper::factory(1, 'string');
1400
-        }
1401
-
1402
-        if (!\preg_match('/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/', $attributeName)) {
1403
-            throw InvalidArgumentHelper::factory(1, 'valid attribute name');
1404
-        }
1405
-
1406
-        if (!\is_object($object)) {
1407
-            throw InvalidArgumentHelper::factory(2, 'object');
1408
-        }
1409
-
1410
-        $constraint = new LogicalNot(
1411
-            new ObjectHasAttribute($attributeName)
1412
-        );
1413
-
1414
-        static::assertThat($object, $constraint, $message);
1415
-    }
1416
-
1417
-    /**
1418
-     * Asserts that two variables have the same type and value.
1419
-     * Used on objects, it asserts that two variables reference
1420
-     * the same object.
1421
-     *
1422
-     * @param mixed  $expected
1423
-     * @param mixed  $actual
1424
-     * @param string $message
1425
-     */
1426
-    public static function assertSame($expected, $actual, $message = '')
1427
-    {
1428
-        if (\is_bool($expected) && \is_bool($actual)) {
1429
-            static::assertEquals($expected, $actual, $message);
1430
-        } else {
1431
-            $constraint = new IsIdentical(
1432
-                $expected
1433
-            );
1434
-
1435
-            static::assertThat($actual, $constraint, $message);
1436
-        }
1437
-    }
1438
-
1439
-    /**
1440
-     * Asserts that a variable and an attribute of an object have the same type
1441
-     * and value.
1442
-     *
1443
-     * @param mixed         $expected
1444
-     * @param string        $actualAttributeName
1445
-     * @param string|object $actualClassOrObject
1446
-     * @param string        $message
1447
-     */
1448
-    public static function assertAttributeSame($expected, $actualAttributeName, $actualClassOrObject, $message = '')
1449
-    {
1450
-        static::assertSame(
1451
-            $expected,
1452
-            static::readAttribute($actualClassOrObject, $actualAttributeName),
1453
-            $message
1454
-        );
1455
-    }
1456
-
1457
-    /**
1458
-     * Asserts that two variables do not have the same type and value.
1459
-     * Used on objects, it asserts that two variables do not reference
1460
-     * the same object.
1461
-     *
1462
-     * @param mixed  $expected
1463
-     * @param mixed  $actual
1464
-     * @param string $message
1465
-     */
1466
-    public static function assertNotSame($expected, $actual, $message = '')
1467
-    {
1468
-        if (\is_bool($expected) && \is_bool($actual)) {
1469
-            static::assertNotEquals($expected, $actual, $message);
1470
-        } else {
1471
-            $constraint = new LogicalNot(
1472
-                new IsIdentical($expected)
1473
-            );
1474
-
1475
-            static::assertThat($actual, $constraint, $message);
1476
-        }
1477
-    }
1478
-
1479
-    /**
1480
-     * Asserts that a variable and an attribute of an object do not have the
1481
-     * same type and value.
1482
-     *
1483
-     * @param mixed         $expected
1484
-     * @param string        $actualAttributeName
1485
-     * @param string|object $actualClassOrObject
1486
-     * @param string        $message
1487
-     */
1488
-    public static function assertAttributeNotSame($expected, $actualAttributeName, $actualClassOrObject, $message = '')
1489
-    {
1490
-        static::assertNotSame(
1491
-            $expected,
1492
-            static::readAttribute($actualClassOrObject, $actualAttributeName),
1493
-            $message
1494
-        );
1495
-    }
1496
-
1497
-    /**
1498
-     * Asserts that a variable is of a given type.
1499
-     *
1500
-     * @param string $expected
1501
-     * @param mixed  $actual
1502
-     * @param string $message
1503
-     */
1504
-    public static function assertInstanceOf($expected, $actual, $message = '')
1505
-    {
1506
-        if (!(\is_string($expected) && (\class_exists($expected) || \interface_exists($expected)))) {
1507
-            throw InvalidArgumentHelper::factory(1, 'class or interface name');
1508
-        }
1509
-
1510
-        $constraint = new IsInstanceOf(
1511
-            $expected
1512
-        );
1513
-
1514
-        static::assertThat($actual, $constraint, $message);
1515
-    }
1516
-
1517
-    /**
1518
-     * Asserts that an attribute is of a given type.
1519
-     *
1520
-     * @param string        $expected
1521
-     * @param string        $attributeName
1522
-     * @param string|object $classOrObject
1523
-     * @param string        $message
1524
-     */
1525
-    public static function assertAttributeInstanceOf($expected, $attributeName, $classOrObject, $message = '')
1526
-    {
1527
-        static::assertInstanceOf(
1528
-            $expected,
1529
-            static::readAttribute($classOrObject, $attributeName),
1530
-            $message
1531
-        );
1532
-    }
1533
-
1534
-    /**
1535
-     * Asserts that a variable is not of a given type.
1536
-     *
1537
-     * @param string $expected
1538
-     * @param mixed  $actual
1539
-     * @param string $message
1540
-     */
1541
-    public static function assertNotInstanceOf($expected, $actual, $message = '')
1542
-    {
1543
-        if (!(\is_string($expected) && (\class_exists($expected) || \interface_exists($expected)))) {
1544
-            throw InvalidArgumentHelper::factory(1, 'class or interface name');
1545
-        }
1546
-
1547
-        $constraint = new LogicalNot(
1548
-            new IsInstanceOf($expected)
1549
-        );
1550
-
1551
-        static::assertThat($actual, $constraint, $message);
1552
-    }
1553
-
1554
-    /**
1555
-     * Asserts that an attribute is of a given type.
1556
-     *
1557
-     * @param string        $expected
1558
-     * @param string        $attributeName
1559
-     * @param string|object $classOrObject
1560
-     * @param string        $message
1561
-     */
1562
-    public static function assertAttributeNotInstanceOf($expected, $attributeName, $classOrObject, $message = '')
1563
-    {
1564
-        static::assertNotInstanceOf(
1565
-            $expected,
1566
-            static::readAttribute($classOrObject, $attributeName),
1567
-            $message
1568
-        );
1569
-    }
1570
-
1571
-    /**
1572
-     * Asserts that a variable is of a given type.
1573
-     *
1574
-     * @param string $expected
1575
-     * @param mixed  $actual
1576
-     * @param string $message
1577
-     */
1578
-    public static function assertInternalType($expected, $actual, $message = '')
1579
-    {
1580
-        if (!\is_string($expected)) {
1581
-            throw InvalidArgumentHelper::factory(1, 'string');
1582
-        }
1583
-
1584
-        $constraint = new IsType(
1585
-            $expected
1586
-        );
1587
-
1588
-        static::assertThat($actual, $constraint, $message);
1589
-    }
1590
-
1591
-    /**
1592
-     * Asserts that an attribute is of a given type.
1593
-     *
1594
-     * @param string        $expected
1595
-     * @param string        $attributeName
1596
-     * @param string|object $classOrObject
1597
-     * @param string        $message
1598
-     */
1599
-    public static function assertAttributeInternalType($expected, $attributeName, $classOrObject, $message = '')
1600
-    {
1601
-        static::assertInternalType(
1602
-            $expected,
1603
-            static::readAttribute($classOrObject, $attributeName),
1604
-            $message
1605
-        );
1606
-    }
1607
-
1608
-    /**
1609
-     * Asserts that a variable is not of a given type.
1610
-     *
1611
-     * @param string $expected
1612
-     * @param mixed  $actual
1613
-     * @param string $message
1614
-     */
1615
-    public static function assertNotInternalType($expected, $actual, $message = '')
1616
-    {
1617
-        if (!\is_string($expected)) {
1618
-            throw InvalidArgumentHelper::factory(1, 'string');
1619
-        }
1620
-
1621
-        $constraint = new LogicalNot(
1622
-            new IsType($expected)
1623
-        );
1624
-
1625
-        static::assertThat($actual, $constraint, $message);
1626
-    }
1627
-
1628
-    /**
1629
-     * Asserts that an attribute is of a given type.
1630
-     *
1631
-     * @param string        $expected
1632
-     * @param string        $attributeName
1633
-     * @param string|object $classOrObject
1634
-     * @param string        $message
1635
-     */
1636
-    public static function assertAttributeNotInternalType($expected, $attributeName, $classOrObject, $message = '')
1637
-    {
1638
-        static::assertNotInternalType(
1639
-            $expected,
1640
-            static::readAttribute($classOrObject, $attributeName),
1641
-            $message
1642
-        );
1643
-    }
1644
-
1645
-    /**
1646
-     * Asserts that a string matches a given regular expression.
1647
-     *
1648
-     * @param string $pattern
1649
-     * @param string $string
1650
-     * @param string $message
1651
-     */
1652
-    public static function assertRegExp($pattern, $string, $message = '')
1653
-    {
1654
-        if (!\is_string($pattern)) {
1655
-            throw InvalidArgumentHelper::factory(1, 'string');
1656
-        }
1657
-
1658
-        if (!\is_string($string)) {
1659
-            throw InvalidArgumentHelper::factory(2, 'string');
1660
-        }
1661
-
1662
-        $constraint = new RegularExpression($pattern);
1663
-
1664
-        static::assertThat($string, $constraint, $message);
1665
-    }
1666
-
1667
-    /**
1668
-     * Asserts that a string does not match a given regular expression.
1669
-     *
1670
-     * @param string $pattern
1671
-     * @param string $string
1672
-     * @param string $message
1673
-     */
1674
-    public static function assertNotRegExp($pattern, $string, $message = '')
1675
-    {
1676
-        if (!\is_string($pattern)) {
1677
-            throw InvalidArgumentHelper::factory(1, 'string');
1678
-        }
1679
-
1680
-        if (!\is_string($string)) {
1681
-            throw InvalidArgumentHelper::factory(2, 'string');
1682
-        }
1683
-
1684
-        $constraint = new LogicalNot(
1685
-            new RegularExpression($pattern)
1686
-        );
1687
-
1688
-        static::assertThat($string, $constraint, $message);
1689
-    }
1690
-
1691
-    /**
1692
-     * Assert that the size of two arrays (or `Countable` or `Traversable` objects)
1693
-     * is the same.
1694
-     *
1695
-     * @param array|\Countable|\Traversable $expected
1696
-     * @param array|\Countable|\Traversable $actual
1697
-     * @param string                        $message
1698
-     */
1699
-    public static function assertSameSize($expected, $actual, $message = '')
1700
-    {
1701
-        if (!$expected instanceof Countable &&
1702
-            !$expected instanceof Traversable &&
1703
-            !\is_array($expected)) {
1704
-            throw InvalidArgumentHelper::factory(1, 'countable or traversable');
1705
-        }
1706
-
1707
-        if (!$actual instanceof Countable &&
1708
-            !$actual instanceof Traversable &&
1709
-            !\is_array($actual)) {
1710
-            throw InvalidArgumentHelper::factory(2, 'countable or traversable');
1711
-        }
1712
-
1713
-        static::assertThat(
1714
-            $actual,
1715
-            new SameSize($expected),
1716
-            $message
1717
-        );
1718
-    }
1719
-
1720
-    /**
1721
-     * Assert that the size of two arrays (or `Countable` or `Traversable` objects)
1722
-     * is not the same.
1723
-     *
1724
-     * @param array|\Countable|\Traversable $expected
1725
-     * @param array|\Countable|\Traversable $actual
1726
-     * @param string                        $message
1727
-     */
1728
-    public static function assertNotSameSize($expected, $actual, $message = '')
1729
-    {
1730
-        if (!$expected instanceof Countable &&
1731
-            !$expected instanceof Traversable &&
1732
-            !\is_array($expected)) {
1733
-            throw InvalidArgumentHelper::factory(1, 'countable or traversable');
1734
-        }
1735
-
1736
-        if (!$actual instanceof Countable &&
1737
-            !$actual instanceof Traversable &&
1738
-            !\is_array($actual)) {
1739
-            throw InvalidArgumentHelper::factory(2, 'countable or traversable');
1740
-        }
1741
-
1742
-        $constraint = new LogicalNot(
1743
-            new SameSize($expected)
1744
-        );
1745
-
1746
-        static::assertThat($actual, $constraint, $message);
1747
-    }
1748
-
1749
-    /**
1750
-     * Asserts that a string matches a given format string.
1751
-     *
1752
-     * @param string $format
1753
-     * @param string $string
1754
-     * @param string $message
1755
-     */
1756
-    public static function assertStringMatchesFormat($format, $string, $message = '')
1757
-    {
1758
-        if (!\is_string($format)) {
1759
-            throw InvalidArgumentHelper::factory(1, 'string');
1760
-        }
1761
-
1762
-        if (!\is_string($string)) {
1763
-            throw InvalidArgumentHelper::factory(2, 'string');
1764
-        }
1765
-
1766
-        $constraint = new StringMatchesFormatDescription($format);
1767
-
1768
-        static::assertThat($string, $constraint, $message);
1769
-    }
1770
-
1771
-    /**
1772
-     * Asserts that a string does not match a given format string.
1773
-     *
1774
-     * @param string $format
1775
-     * @param string $string
1776
-     * @param string $message
1777
-     */
1778
-    public static function assertStringNotMatchesFormat($format, $string, $message = '')
1779
-    {
1780
-        if (!\is_string($format)) {
1781
-            throw InvalidArgumentHelper::factory(1, 'string');
1782
-        }
1783
-
1784
-        if (!\is_string($string)) {
1785
-            throw InvalidArgumentHelper::factory(2, 'string');
1786
-        }
1787
-
1788
-        $constraint = new LogicalNot(
1789
-            new StringMatchesFormatDescription($format)
1790
-        );
1791
-
1792
-        static::assertThat($string, $constraint, $message);
1793
-    }
1794
-
1795
-    /**
1796
-     * Asserts that a string matches a given format file.
1797
-     *
1798
-     * @param string $formatFile
1799
-     * @param string $string
1800
-     * @param string $message
1801
-     */
1802
-    public static function assertStringMatchesFormatFile($formatFile, $string, $message = '')
1803
-    {
1804
-        static::assertFileExists($formatFile, $message);
1805
-
1806
-        if (!\is_string($string)) {
1807
-            throw InvalidArgumentHelper::factory(2, 'string');
1808
-        }
1809
-
1810
-        $constraint = new StringMatchesFormatDescription(
1811
-            \file_get_contents($formatFile)
1812
-        );
1813
-
1814
-        static::assertThat($string, $constraint, $message);
1815
-    }
1816
-
1817
-    /**
1818
-     * Asserts that a string does not match a given format string.
1819
-     *
1820
-     * @param string $formatFile
1821
-     * @param string $string
1822
-     * @param string $message
1823
-     */
1824
-    public static function assertStringNotMatchesFormatFile($formatFile, $string, $message = '')
1825
-    {
1826
-        static::assertFileExists($formatFile, $message);
1827
-
1828
-        if (!\is_string($string)) {
1829
-            throw InvalidArgumentHelper::factory(2, 'string');
1830
-        }
1831
-
1832
-        $constraint = new LogicalNot(
1833
-            new StringMatchesFormatDescription(
1834
-                \file_get_contents($formatFile)
1835
-            )
1836
-        );
1837
-
1838
-        static::assertThat($string, $constraint, $message);
1839
-    }
1840
-
1841
-    /**
1842
-     * Asserts that a string starts with a given prefix.
1843
-     *
1844
-     * @param string $prefix
1845
-     * @param string $string
1846
-     * @param string $message
1847
-     */
1848
-    public static function assertStringStartsWith($prefix, $string, $message = '')
1849
-    {
1850
-        if (!\is_string($prefix)) {
1851
-            throw InvalidArgumentHelper::factory(1, 'string');
1852
-        }
1853
-
1854
-        if (!\is_string($string)) {
1855
-            throw InvalidArgumentHelper::factory(2, 'string');
1856
-        }
1857
-
1858
-        $constraint = new StringStartsWith(
1859
-            $prefix
1860
-        );
1861
-
1862
-        static::assertThat($string, $constraint, $message);
1863
-    }
1864
-
1865
-    /**
1866
-     * Asserts that a string starts not with a given prefix.
1867
-     *
1868
-     * @param string $prefix
1869
-     * @param string $string
1870
-     * @param string $message
1871
-     */
1872
-    public static function assertStringStartsNotWith($prefix, $string, $message = '')
1873
-    {
1874
-        if (!\is_string($prefix)) {
1875
-            throw InvalidArgumentHelper::factory(1, 'string');
1876
-        }
1877
-
1878
-        if (!\is_string($string)) {
1879
-            throw InvalidArgumentHelper::factory(2, 'string');
1880
-        }
1881
-
1882
-        $constraint = new LogicalNot(
1883
-            new StringStartsWith($prefix)
1884
-        );
1885
-
1886
-        static::assertThat($string, $constraint, $message);
1887
-    }
1888
-
1889
-    /**
1890
-     * Asserts that a string ends with a given suffix.
1891
-     *
1892
-     * @param string $suffix
1893
-     * @param string $string
1894
-     * @param string $message
1895
-     */
1896
-    public static function assertStringEndsWith($suffix, $string, $message = '')
1897
-    {
1898
-        if (!\is_string($suffix)) {
1899
-            throw InvalidArgumentHelper::factory(1, 'string');
1900
-        }
1901
-
1902
-        if (!\is_string($string)) {
1903
-            throw InvalidArgumentHelper::factory(2, 'string');
1904
-        }
1905
-
1906
-        $constraint = new StringEndsWith($suffix);
1907
-
1908
-        static::assertThat($string, $constraint, $message);
1909
-    }
1910
-
1911
-    /**
1912
-     * Asserts that a string ends not with a given suffix.
1913
-     *
1914
-     * @param string $suffix
1915
-     * @param string $string
1916
-     * @param string $message
1917
-     */
1918
-    public static function assertStringEndsNotWith($suffix, $string, $message = '')
1919
-    {
1920
-        if (!\is_string($suffix)) {
1921
-            throw InvalidArgumentHelper::factory(1, 'string');
1922
-        }
1923
-
1924
-        if (!\is_string($string)) {
1925
-            throw InvalidArgumentHelper::factory(2, 'string');
1926
-        }
1927
-
1928
-        $constraint = new LogicalNot(
1929
-            new StringEndsWith($suffix)
1930
-        );
1931
-
1932
-        static::assertThat($string, $constraint, $message);
1933
-    }
1934
-
1935
-    /**
1936
-     * Asserts that two XML files are equal.
1937
-     *
1938
-     * @param string $expectedFile
1939
-     * @param string $actualFile
1940
-     * @param string $message
1941
-     */
1942
-    public static function assertXmlFileEqualsXmlFile($expectedFile, $actualFile, $message = '')
1943
-    {
1944
-        $expected = Xml::loadFile($expectedFile);
1945
-        $actual   = Xml::loadFile($actualFile);
1946
-
1947
-        static::assertEquals($expected, $actual, $message);
1948
-    }
1949
-
1950
-    /**
1951
-     * Asserts that two XML files are not equal.
1952
-     *
1953
-     * @param string $expectedFile
1954
-     * @param string $actualFile
1955
-     * @param string $message
1956
-     */
1957
-    public static function assertXmlFileNotEqualsXmlFile($expectedFile, $actualFile, $message = '')
1958
-    {
1959
-        $expected = Xml::loadFile($expectedFile);
1960
-        $actual   = Xml::loadFile($actualFile);
1961
-
1962
-        static::assertNotEquals($expected, $actual, $message);
1963
-    }
1964
-
1965
-    /**
1966
-     * Asserts that two XML documents are equal.
1967
-     *
1968
-     * @param string             $expectedFile
1969
-     * @param string|DOMDocument $actualXml
1970
-     * @param string             $message
1971
-     */
1972
-    public static function assertXmlStringEqualsXmlFile($expectedFile, $actualXml, $message = '')
1973
-    {
1974
-        $expected = Xml::loadFile($expectedFile);
1975
-        $actual   = Xml::load($actualXml);
1976
-
1977
-        static::assertEquals($expected, $actual, $message);
1978
-    }
1979
-
1980
-    /**
1981
-     * Asserts that two XML documents are not equal.
1982
-     *
1983
-     * @param string             $expectedFile
1984
-     * @param string|DOMDocument $actualXml
1985
-     * @param string             $message
1986
-     */
1987
-    public static function assertXmlStringNotEqualsXmlFile($expectedFile, $actualXml, $message = '')
1988
-    {
1989
-        $expected = Xml::loadFile($expectedFile);
1990
-        $actual   = Xml::load($actualXml);
1991
-
1992
-        static::assertNotEquals($expected, $actual, $message);
1993
-    }
1994
-
1995
-    /**
1996
-     * Asserts that two XML documents are equal.
1997
-     *
1998
-     * @param string|DOMDocument $expectedXml
1999
-     * @param string|DOMDocument $actualXml
2000
-     * @param string             $message
2001
-     */
2002
-    public static function assertXmlStringEqualsXmlString($expectedXml, $actualXml, $message = '')
2003
-    {
2004
-        $expected = Xml::load($expectedXml);
2005
-        $actual   = Xml::load($actualXml);
2006
-
2007
-        static::assertEquals($expected, $actual, $message);
2008
-    }
2009
-
2010
-    /**
2011
-     * Asserts that two XML documents are not equal.
2012
-     *
2013
-     * @param string|DOMDocument $expectedXml
2014
-     * @param string|DOMDocument $actualXml
2015
-     * @param string             $message
2016
-     */
2017
-    public static function assertXmlStringNotEqualsXmlString($expectedXml, $actualXml, $message = '')
2018
-    {
2019
-        $expected = Xml::load($expectedXml);
2020
-        $actual   = Xml::load($actualXml);
2021
-
2022
-        static::assertNotEquals($expected, $actual, $message);
2023
-    }
2024
-
2025
-    /**
2026
-     * Asserts that a hierarchy of DOMElements matches.
2027
-     *
2028
-     * @param DOMElement $expectedElement
2029
-     * @param DOMElement $actualElement
2030
-     * @param bool       $checkAttributes
2031
-     * @param string     $message
2032
-     */
2033
-    public static function assertEqualXMLStructure(DOMElement $expectedElement, DOMElement $actualElement, $checkAttributes = false, $message = '')
2034
-    {
2035
-        $tmp             = new DOMDocument;
2036
-        $expectedElement = $tmp->importNode($expectedElement, true);
2037
-
2038
-        $tmp           = new DOMDocument;
2039
-        $actualElement = $tmp->importNode($actualElement, true);
2040
-
2041
-        unset($tmp);
2042
-
2043
-        static::assertEquals(
2044
-            $expectedElement->tagName,
2045
-            $actualElement->tagName,
2046
-            $message
2047
-        );
2048
-
2049
-        if ($checkAttributes) {
2050
-            static::assertEquals(
2051
-                $expectedElement->attributes->length,
2052
-                $actualElement->attributes->length,
2053
-                \sprintf(
2054
-                    '%s%sNumber of attributes on node "%s" does not match',
2055
-                    $message,
2056
-                    !empty($message) ? "\n" : '',
2057
-                    $expectedElement->tagName
2058
-                )
2059
-            );
2060
-
2061
-            for ($i = 0; $i < $expectedElement->attributes->length; $i++) {
2062
-                $expectedAttribute = $expectedElement->attributes->item($i);
2063
-                $actualAttribute   = $actualElement->attributes->getNamedItem(
2064
-                    $expectedAttribute->name
2065
-                );
2066
-
2067
-                if (!$actualAttribute) {
2068
-                    static::fail(
2069
-                        \sprintf(
2070
-                            '%s%sCould not find attribute "%s" on node "%s"',
2071
-                            $message,
2072
-                            !empty($message) ? "\n" : '',
2073
-                            $expectedAttribute->name,
2074
-                            $expectedElement->tagName
2075
-                        )
2076
-                    );
2077
-                }
2078
-            }
2079
-        }
2080
-
2081
-        Xml::removeCharacterDataNodes($expectedElement);
2082
-        Xml::removeCharacterDataNodes($actualElement);
2083
-
2084
-        static::assertEquals(
2085
-            $expectedElement->childNodes->length,
2086
-            $actualElement->childNodes->length,
2087
-            \sprintf(
2088
-                '%s%sNumber of child nodes of "%s" differs',
2089
-                $message,
2090
-                !empty($message) ? "\n" : '',
2091
-                $expectedElement->tagName
2092
-            )
2093
-        );
2094
-
2095
-        for ($i = 0; $i < $expectedElement->childNodes->length; $i++) {
2096
-            static::assertEqualXMLStructure(
2097
-                $expectedElement->childNodes->item($i),
2098
-                $actualElement->childNodes->item($i),
2099
-                $checkAttributes,
2100
-                $message
2101
-            );
2102
-        }
2103
-    }
2104
-
2105
-    /**
2106
-     * Evaluates a PHPUnit\Framework\Constraint matcher object.
2107
-     *
2108
-     * @param mixed      $value
2109
-     * @param Constraint $constraint
2110
-     * @param string     $message
2111
-     */
2112
-    public static function assertThat($value, Constraint $constraint, $message = '')
2113
-    {
2114
-        self::$count += \count($constraint);
2115
-
2116
-        $constraint->evaluate($value, $message);
2117
-    }
2118
-
2119
-    /**
2120
-     * Asserts that a string is a valid JSON string.
2121
-     *
2122
-     * @param string $actualJson
2123
-     * @param string $message
2124
-     */
2125
-    public static function assertJson($actualJson, $message = '')
2126
-    {
2127
-        if (!\is_string($actualJson)) {
2128
-            throw InvalidArgumentHelper::factory(1, 'string');
2129
-        }
2130
-
2131
-        static::assertThat($actualJson, static::isJson(), $message);
2132
-    }
2133
-
2134
-    /**
2135
-     * Asserts that two given JSON encoded objects or arrays are equal.
2136
-     *
2137
-     * @param string $expectedJson
2138
-     * @param string $actualJson
2139
-     * @param string $message
2140
-     */
2141
-    public static function assertJsonStringEqualsJsonString($expectedJson, $actualJson, $message = '')
2142
-    {
2143
-        static::assertJson($expectedJson, $message);
2144
-        static::assertJson($actualJson, $message);
2145
-
2146
-        $constraint = new JsonMatches(
2147
-            $expectedJson
2148
-        );
2149
-
2150
-        static::assertThat($actualJson, $constraint, $message);
2151
-    }
2152
-
2153
-    /**
2154
-     * Asserts that two given JSON encoded objects or arrays are not equal.
2155
-     *
2156
-     * @param string $expectedJson
2157
-     * @param string $actualJson
2158
-     * @param string $message
2159
-     */
2160
-    public static function assertJsonStringNotEqualsJsonString($expectedJson, $actualJson, $message = '')
2161
-    {
2162
-        static::assertJson($expectedJson, $message);
2163
-        static::assertJson($actualJson, $message);
2164
-
2165
-        $constraint = new JsonMatches(
2166
-            $expectedJson
2167
-        );
2168
-
2169
-        static::assertThat($actualJson, new LogicalNot($constraint), $message);
2170
-    }
2171
-
2172
-    /**
2173
-     * Asserts that the generated JSON encoded object and the content of the given file are equal.
2174
-     *
2175
-     * @param string $expectedFile
2176
-     * @param string $actualJson
2177
-     * @param string $message
2178
-     */
2179
-    public static function assertJsonStringEqualsJsonFile($expectedFile, $actualJson, $message = '')
2180
-    {
2181
-        static::assertFileExists($expectedFile, $message);
2182
-        $expectedJson = \file_get_contents($expectedFile);
2183
-
2184
-        static::assertJson($expectedJson, $message);
2185
-        static::assertJson($actualJson, $message);
2186
-
2187
-        $constraint = new JsonMatches(
2188
-            $expectedJson
2189
-        );
2190
-
2191
-        static::assertThat($actualJson, $constraint, $message);
2192
-    }
2193
-
2194
-    /**
2195
-     * Asserts that the generated JSON encoded object and the content of the given file are not equal.
2196
-     *
2197
-     * @param string $expectedFile
2198
-     * @param string $actualJson
2199
-     * @param string $message
2200
-     */
2201
-    public static function assertJsonStringNotEqualsJsonFile($expectedFile, $actualJson, $message = '')
2202
-    {
2203
-        static::assertFileExists($expectedFile, $message);
2204
-        $expectedJson = \file_get_contents($expectedFile);
2205
-
2206
-        static::assertJson($expectedJson, $message);
2207
-        static::assertJson($actualJson, $message);
2208
-
2209
-        $constraint = new JsonMatches(
2210
-            $expectedJson
2211
-        );
2212
-
2213
-        static::assertThat($actualJson, new LogicalNot($constraint), $message);
2214
-    }
2215
-
2216
-    /**
2217
-     * Asserts that two JSON files are equal.
2218
-     *
2219
-     * @param string $expectedFile
2220
-     * @param string $actualFile
2221
-     * @param string $message
2222
-     */
2223
-    public static function assertJsonFileEqualsJsonFile($expectedFile, $actualFile, $message = '')
2224
-    {
2225
-        static::assertFileExists($expectedFile, $message);
2226
-        static::assertFileExists($actualFile, $message);
2227
-
2228
-        $actualJson   = \file_get_contents($actualFile);
2229
-        $expectedJson = \file_get_contents($expectedFile);
2230
-
2231
-        static::assertJson($expectedJson, $message);
2232
-        static::assertJson($actualJson, $message);
2233
-
2234
-        $constraintExpected = new JsonMatches(
2235
-            $expectedJson
2236
-        );
2237
-
2238
-        $constraintActual = new JsonMatches($actualJson);
2239
-
2240
-        static::assertThat($expectedJson, $constraintActual, $message);
2241
-        static::assertThat($actualJson, $constraintExpected, $message);
2242
-    }
2243
-
2244
-    /**
2245
-     * Asserts that two JSON files are not equal.
2246
-     *
2247
-     * @param string $expectedFile
2248
-     * @param string $actualFile
2249
-     * @param string $message
2250
-     */
2251
-    public static function assertJsonFileNotEqualsJsonFile($expectedFile, $actualFile, $message = '')
2252
-    {
2253
-        static::assertFileExists($expectedFile, $message);
2254
-        static::assertFileExists($actualFile, $message);
2255
-
2256
-        $actualJson   = \file_get_contents($actualFile);
2257
-        $expectedJson = \file_get_contents($expectedFile);
2258
-
2259
-        static::assertJson($expectedJson, $message);
2260
-        static::assertJson($actualJson, $message);
2261
-
2262
-        $constraintExpected = new JsonMatches(
2263
-            $expectedJson
2264
-        );
2265
-
2266
-        $constraintActual = new JsonMatches($actualJson);
2267
-
2268
-        static::assertThat($expectedJson, new LogicalNot($constraintActual), $message);
2269
-        static::assertThat($actualJson, new LogicalNot($constraintExpected), $message);
2270
-    }
2271
-
2272
-    /**
2273
-     * @return LogicalAnd
2274
-     */
2275
-    public static function logicalAnd()
2276
-    {
2277
-        $constraints = \func_get_args();
2278
-
2279
-        $constraint = new LogicalAnd;
2280
-        $constraint->setConstraints($constraints);
2281
-
2282
-        return $constraint;
2283
-    }
2284
-
2285
-    /**
2286
-     * @return LogicalOr
2287
-     */
2288
-    public static function logicalOr()
2289
-    {
2290
-        $constraints = \func_get_args();
2291
-
2292
-        $constraint = new LogicalOr;
2293
-        $constraint->setConstraints($constraints);
2294
-
2295
-        return $constraint;
2296
-    }
2297
-
2298
-    /**
2299
-     * @param Constraint $constraint
2300
-     *
2301
-     * @return LogicalNot
2302
-     */
2303
-    public static function logicalNot(Constraint $constraint)
2304
-    {
2305
-        return new LogicalNot($constraint);
2306
-    }
2307
-
2308
-    /**
2309
-     * @return LogicalXor
2310
-     */
2311
-    public static function logicalXor()
2312
-    {
2313
-        $constraints = \func_get_args();
2314
-
2315
-        $constraint = new LogicalXor;
2316
-        $constraint->setConstraints($constraints);
2317
-
2318
-        return $constraint;
2319
-    }
2320
-
2321
-    /**
2322
-     * @return IsAnything
2323
-     */
2324
-    public static function anything()
2325
-    {
2326
-        return new IsAnything;
2327
-    }
2328
-
2329
-    /**
2330
-     * @return IsTrue
2331
-     */
2332
-    public static function isTrue()
2333
-    {
2334
-        return new IsTrue;
2335
-    }
2336
-
2337
-    /**
2338
-     * @param callable $callback
2339
-     *
2340
-     * @return Callback
2341
-     */
2342
-    public static function callback($callback)
2343
-    {
2344
-        return new Callback($callback);
2345
-    }
2346
-
2347
-    /**
2348
-     * @return IsFalse
2349
-     */
2350
-    public static function isFalse()
2351
-    {
2352
-        return new IsFalse;
2353
-    }
2354
-
2355
-    /**
2356
-     * @return IsJson
2357
-     */
2358
-    public static function isJson()
2359
-    {
2360
-        return new IsJson;
2361
-    }
2362
-
2363
-    /**
2364
-     * @return IsNull
2365
-     */
2366
-    public static function isNull()
2367
-    {
2368
-        return new IsNull;
2369
-    }
2370
-
2371
-    /**
2372
-     * @return IsFinite
2373
-     */
2374
-    public static function isFinite()
2375
-    {
2376
-        return new IsFinite;
2377
-    }
2378
-
2379
-    /**
2380
-     * @return IsInfinite
2381
-     */
2382
-    public static function isInfinite()
2383
-    {
2384
-        return new IsInfinite;
2385
-    }
2386
-
2387
-    /**
2388
-     * @return IsNan
2389
-     */
2390
-    public static function isNan()
2391
-    {
2392
-        return new IsNan;
2393
-    }
2394
-
2395
-    /**
2396
-     * @param Constraint $constraint
2397
-     * @param string     $attributeName
2398
-     *
2399
-     * @return Attribute
2400
-     */
2401
-    public static function attribute(Constraint $constraint, $attributeName)
2402
-    {
2403
-        return new Attribute(
2404
-            $constraint,
2405
-            $attributeName
2406
-        );
2407
-    }
2408
-
2409
-    /**
2410
-     * @param mixed $value
2411
-     * @param bool  $checkForObjectIdentity
2412
-     * @param bool  $checkForNonObjectIdentity
2413
-     *
2414
-     * @return TraversableContains
2415
-     */
2416
-    public static function contains($value, $checkForObjectIdentity = true, $checkForNonObjectIdentity = false)
2417
-    {
2418
-        return new TraversableContains($value, $checkForObjectIdentity, $checkForNonObjectIdentity);
2419
-    }
2420
-
2421
-    /**
2422
-     * @param string $type
2423
-     *
2424
-     * @return TraversableContainsOnly
2425
-     */
2426
-    public static function containsOnly($type)
2427
-    {
2428
-        return new TraversableContainsOnly($type);
2429
-    }
2430
-
2431
-    /**
2432
-     * @param string $classname
2433
-     *
2434
-     * @return TraversableContainsOnly
2435
-     */
2436
-    public static function containsOnlyInstancesOf($classname)
2437
-    {
2438
-        return new TraversableContainsOnly($classname, false);
2439
-    }
2440
-
2441
-    /**
2442
-     * @param mixed $key
2443
-     *
2444
-     * @return ArrayHasKey
2445
-     */
2446
-    public static function arrayHasKey($key)
2447
-    {
2448
-        return new ArrayHasKey($key);
2449
-    }
2450
-
2451
-    /**
2452
-     * @param mixed $value
2453
-     * @param float $delta
2454
-     * @param int   $maxDepth
2455
-     * @param bool  $canonicalize
2456
-     * @param bool  $ignoreCase
2457
-     *
2458
-     * @return IsEqual
2459
-     */
2460
-    public static function equalTo($value, $delta = 0.0, $maxDepth = 10, $canonicalize = false, $ignoreCase = false)
2461
-    {
2462
-        return new IsEqual(
2463
-            $value,
2464
-            $delta,
2465
-            $maxDepth,
2466
-            $canonicalize,
2467
-            $ignoreCase
2468
-        );
2469
-    }
2470
-
2471
-    /**
2472
-     * @param string $attributeName
2473
-     * @param mixed  $value
2474
-     * @param float  $delta
2475
-     * @param int    $maxDepth
2476
-     * @param bool   $canonicalize
2477
-     * @param bool   $ignoreCase
2478
-     *
2479
-     * @return Attribute
2480
-     */
2481
-    public static function attributeEqualTo($attributeName, $value, $delta = 0.0, $maxDepth = 10, $canonicalize = false, $ignoreCase = false)
2482
-    {
2483
-        return static::attribute(
2484
-            static::equalTo(
2485
-                $value,
2486
-                $delta,
2487
-                $maxDepth,
2488
-                $canonicalize,
2489
-                $ignoreCase
2490
-            ),
2491
-            $attributeName
2492
-        );
2493
-    }
2494
-
2495
-    /**
2496
-     * @return IsEmpty
2497
-     */
2498
-    public static function isEmpty()
2499
-    {
2500
-        return new IsEmpty;
2501
-    }
2502
-
2503
-    /**
2504
-     * @return IsWritable
2505
-     */
2506
-    public static function isWritable()
2507
-    {
2508
-        return new IsWritable;
2509
-    }
2510
-
2511
-    /**
2512
-     * @return IsReadable
2513
-     */
2514
-    public static function isReadable()
2515
-    {
2516
-        return new IsReadable;
2517
-    }
2518
-
2519
-    /**
2520
-     * @return DirectoryExists
2521
-     */
2522
-    public static function directoryExists()
2523
-    {
2524
-        return new DirectoryExists;
2525
-    }
2526
-
2527
-    /**
2528
-     * @return FileExists
2529
-     */
2530
-    public static function fileExists()
2531
-    {
2532
-        return new FileExists;
2533
-    }
2534
-
2535
-    /**
2536
-     * @param mixed $value
2537
-     *
2538
-     * @return GreaterThan
2539
-     */
2540
-    public static function greaterThan($value)
2541
-    {
2542
-        return new GreaterThan($value);
2543
-    }
2544
-
2545
-    /**
2546
-     * @param mixed $value
2547
-     *
2548
-     * @return LogicalOr
2549
-     */
2550
-    public static function greaterThanOrEqual($value)
2551
-    {
2552
-        return static::logicalOr(
2553
-            new IsEqual($value),
2554
-            new GreaterThan($value)
2555
-        );
2556
-    }
2557
-
2558
-    /**
2559
-     * @param string $attributeName
2560
-     *
2561
-     * @return ClassHasAttribute
2562
-     */
2563
-    public static function classHasAttribute($attributeName)
2564
-    {
2565
-        return new ClassHasAttribute(
2566
-            $attributeName
2567
-        );
2568
-    }
2569
-
2570
-    /**
2571
-     * @param string $attributeName
2572
-     *
2573
-     * @return ClassHasStaticAttribute
2574
-     */
2575
-    public static function classHasStaticAttribute($attributeName)
2576
-    {
2577
-        return new ClassHasStaticAttribute(
2578
-            $attributeName
2579
-        );
2580
-    }
2581
-
2582
-    /**
2583
-     * @param string $attributeName
2584
-     *
2585
-     * @return ObjectHasAttribute
2586
-     */
2587
-    public static function objectHasAttribute($attributeName)
2588
-    {
2589
-        return new ObjectHasAttribute(
2590
-            $attributeName
2591
-        );
2592
-    }
2593
-
2594
-    /**
2595
-     * @param mixed $value
2596
-     *
2597
-     * @return IsIdentical
2598
-     */
2599
-    public static function identicalTo($value)
2600
-    {
2601
-        return new IsIdentical($value);
2602
-    }
2603
-
2604
-    /**
2605
-     * @param string $className
2606
-     *
2607
-     * @return IsInstanceOf
2608
-     */
2609
-    public static function isInstanceOf($className)
2610
-    {
2611
-        return new IsInstanceOf($className);
2612
-    }
2613
-
2614
-    /**
2615
-     * @param string $type
2616
-     *
2617
-     * @return IsType
2618
-     */
2619
-    public static function isType($type)
2620
-    {
2621
-        return new IsType($type);
2622
-    }
2623
-
2624
-    /**
2625
-     * @param mixed $value
2626
-     *
2627
-     * @return LessThan
2628
-     */
2629
-    public static function lessThan($value)
2630
-    {
2631
-        return new LessThan($value);
2632
-    }
2633
-
2634
-    /**
2635
-     * @param mixed $value
2636
-     *
2637
-     * @return LogicalOr
2638
-     */
2639
-    public static function lessThanOrEqual($value)
2640
-    {
2641
-        return static::logicalOr(
2642
-            new IsEqual($value),
2643
-            new LessThan($value)
2644
-        );
2645
-    }
2646
-
2647
-    /**
2648
-     * @param string $pattern
2649
-     *
2650
-     * @return RegularExpression
2651
-     */
2652
-    public static function matchesRegularExpression($pattern)
2653
-    {
2654
-        return new RegularExpression($pattern);
2655
-    }
2656
-
2657
-    /**
2658
-     * @param string $string
2659
-     *
2660
-     * @return StringMatchesFormatDescription
2661
-     */
2662
-    public static function matches($string)
2663
-    {
2664
-        return new StringMatchesFormatDescription($string);
2665
-    }
2666
-
2667
-    /**
2668
-     * @param mixed $prefix
2669
-     *
2670
-     * @return StringStartsWith
2671
-     */
2672
-    public static function stringStartsWith($prefix)
2673
-    {
2674
-        return new StringStartsWith($prefix);
2675
-    }
2676
-
2677
-    /**
2678
-     * @param string $string
2679
-     * @param bool   $case
2680
-     *
2681
-     * @return StringContains
2682
-     */
2683
-    public static function stringContains($string, $case = true)
2684
-    {
2685
-        return new StringContains($string, $case);
2686
-    }
2687
-
2688
-    /**
2689
-     * @param mixed $suffix
2690
-     *
2691
-     * @return StringEndsWith
2692
-     */
2693
-    public static function stringEndsWith($suffix)
2694
-    {
2695
-        return new StringEndsWith($suffix);
2696
-    }
2697
-
2698
-    /**
2699
-     * @param int $count
2700
-     *
2701
-     * @return Count
2702
-     */
2703
-    public static function countOf($count)
2704
-    {
2705
-        return new Count($count);
2706
-    }
2707
-
2708
-    /**
2709
-     * Fails a test with the given message.
2710
-     *
2711
-     * @param string $message
2712
-     *
2713
-     * @throws AssertionFailedError
2714
-     */
2715
-    public static function fail($message = '')
2716
-    {
2717
-        self::$count++;
2718
-
2719
-        throw new AssertionFailedError($message);
2720
-    }
2721
-
2722
-    /**
2723
-     * Returns the value of an attribute of a class or an object.
2724
-     * This also works for attributes that are declared protected or private.
2725
-     *
2726
-     * @param string|object $classOrObject
2727
-     * @param string        $attributeName
2728
-     *
2729
-     * @return mixed
2730
-     *
2731
-     * @throws Exception
2732
-     */
2733
-    public static function readAttribute($classOrObject, $attributeName)
2734
-    {
2735
-        if (!\is_string($attributeName)) {
2736
-            throw InvalidArgumentHelper::factory(2, 'string');
2737
-        }
2738
-
2739
-        if (!\preg_match('/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/', $attributeName)) {
2740
-            throw InvalidArgumentHelper::factory(2, 'valid attribute name');
2741
-        }
2742
-
2743
-        if (\is_string($classOrObject)) {
2744
-            if (!\class_exists($classOrObject)) {
2745
-                throw InvalidArgumentHelper::factory(
2746
-                    1,
2747
-                    'class name'
2748
-                );
2749
-            }
2750
-
2751
-            return static::getStaticAttribute(
2752
-                $classOrObject,
2753
-                $attributeName
2754
-            );
2755
-        }
2756
-
2757
-        if (\is_object($classOrObject)) {
2758
-            return static::getObjectAttribute(
2759
-                $classOrObject,
2760
-                $attributeName
2761
-            );
2762
-        }
2763
-
2764
-        throw InvalidArgumentHelper::factory(
2765
-            1,
2766
-            'class name or object'
2767
-        );
2768
-    }
2769
-
2770
-    /**
2771
-     * Returns the value of a static attribute.
2772
-     * This also works for attributes that are declared protected or private.
2773
-     *
2774
-     * @param string $className
2775
-     * @param string $attributeName
2776
-     *
2777
-     * @return mixed
2778
-     *
2779
-     * @throws Exception
2780
-     */
2781
-    public static function getStaticAttribute($className, $attributeName)
2782
-    {
2783
-        if (!\is_string($className)) {
2784
-            throw InvalidArgumentHelper::factory(1, 'string');
2785
-        }
2786
-
2787
-        if (!\class_exists($className)) {
2788
-            throw InvalidArgumentHelper::factory(1, 'class name');
2789
-        }
2790
-
2791
-        if (!\is_string($attributeName)) {
2792
-            throw InvalidArgumentHelper::factory(2, 'string');
2793
-        }
2794
-
2795
-        if (!\preg_match('/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/', $attributeName)) {
2796
-            throw InvalidArgumentHelper::factory(2, 'valid attribute name');
2797
-        }
2798
-
2799
-        $class = new ReflectionClass($className);
2800
-
2801
-        while ($class) {
2802
-            $attributes = $class->getStaticProperties();
2803
-
2804
-            if (\array_key_exists($attributeName, $attributes)) {
2805
-                return $attributes[$attributeName];
2806
-            }
2807
-
2808
-            $class = $class->getParentClass();
2809
-        }
2810
-
2811
-        throw new Exception(
2812
-            \sprintf(
2813
-                'Attribute "%s" not found in class.',
2814
-                $attributeName
2815
-            )
2816
-        );
2817
-    }
2818
-
2819
-    /**
2820
-     * Returns the value of an object's attribute.
2821
-     * This also works for attributes that are declared protected or private.
2822
-     *
2823
-     * @param object $object
2824
-     * @param string $attributeName
2825
-     *
2826
-     * @return mixed
2827
-     *
2828
-     * @throws Exception
2829
-     */
2830
-    public static function getObjectAttribute($object, $attributeName)
2831
-    {
2832
-        if (!\is_object($object)) {
2833
-            throw InvalidArgumentHelper::factory(1, 'object');
2834
-        }
2835
-
2836
-        if (!\is_string($attributeName)) {
2837
-            throw InvalidArgumentHelper::factory(2, 'string');
2838
-        }
2839
-
2840
-        if (!\preg_match('/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/', $attributeName)) {
2841
-            throw InvalidArgumentHelper::factory(2, 'valid attribute name');
2842
-        }
2843
-
2844
-        try {
2845
-            $attribute = new ReflectionProperty($object, $attributeName);
2846
-        } catch (ReflectionException $e) {
2847
-            $reflector = new ReflectionObject($object);
2848
-
2849
-            while ($reflector = $reflector->getParentClass()) {
2850
-                try {
2851
-                    $attribute = $reflector->getProperty($attributeName);
2852
-
2853
-                    break;
2854
-                } catch (ReflectionException $e) {
2855
-                }
2856
-            }
2857
-        }
2858
-
2859
-        if (isset($attribute)) {
2860
-            if (!$attribute || $attribute->isPublic()) {
2861
-                return $object->$attributeName;
2862
-            }
2863
-
2864
-            $attribute->setAccessible(true);
2865
-            $value = $attribute->getValue($object);
2866
-            $attribute->setAccessible(false);
2867
-
2868
-            return $value;
2869
-        }
2870
-
2871
-        throw new Exception(
2872
-            \sprintf(
2873
-                'Attribute "%s" not found in object.',
2874
-                $attributeName
2875
-            )
2876
-        );
2877
-    }
2878
-
2879
-    /**
2880
-     * Mark the test as incomplete.
2881
-     *
2882
-     * @param string $message
2883
-     *
2884
-     * @throws IncompleteTestError
2885
-     */
2886
-    public static function markTestIncomplete($message = '')
2887
-    {
2888
-        throw new IncompleteTestError($message);
2889
-    }
2890
-
2891
-    /**
2892
-     * Mark the test as skipped.
2893
-     *
2894
-     * @param string $message
2895
-     *
2896
-     * @throws SkippedTestError
2897
-     */
2898
-    public static function markTestSkipped($message = '')
2899
-    {
2900
-        throw new SkippedTestError($message);
2901
-    }
2902
-
2903
-    /**
2904
-     * Return the current assertion count.
2905
-     *
2906
-     * @return int
2907
-     */
2908
-    public static function getCount()
2909
-    {
2910
-        return self::$count;
2911
-    }
2912
-
2913
-    /**
2914
-     * Reset the assertion counter.
2915
-     */
2916
-    public static function resetCount()
2917
-    {
2918
-        self::$count = 0;
2919
-    }
72
+	/**
73
+	 * @var int
74
+	 */
75
+	private static $count = 0;
76
+
77
+	/**
78
+	 * Asserts that an array has a specified key.
79
+	 *
80
+	 * @param mixed             $key
81
+	 * @param array|ArrayAccess $array
82
+	 * @param string            $message
83
+	 */
84
+	public static function assertArrayHasKey($key, $array, $message = '')
85
+	{
86
+		if (!(\is_int($key) || \is_string($key))) {
87
+			throw InvalidArgumentHelper::factory(
88
+				1,
89
+				'integer or string'
90
+			);
91
+		}
92
+
93
+		if (!(\is_array($array) || $array instanceof ArrayAccess)) {
94
+			throw InvalidArgumentHelper::factory(
95
+				2,
96
+				'array or ArrayAccess'
97
+			);
98
+		}
99
+
100
+		$constraint = new ArrayHasKey($key);
101
+
102
+		static::assertThat($array, $constraint, $message);
103
+	}
104
+
105
+	/**
106
+	 * Asserts that an array has a specified subset.
107
+	 *
108
+	 * @param array|ArrayAccess $subset
109
+	 * @param array|ArrayAccess $array
110
+	 * @param bool              $strict  Check for object identity
111
+	 * @param string            $message
112
+	 */
113
+	public static function assertArraySubset($subset, $array, $strict = false, $message = '')
114
+	{
115
+		if (!(\is_array($subset) || $subset instanceof ArrayAccess)) {
116
+			throw InvalidArgumentHelper::factory(
117
+				1,
118
+				'array or ArrayAccess'
119
+			);
120
+		}
121
+
122
+		if (!(\is_array($array) || $array instanceof ArrayAccess)) {
123
+			throw InvalidArgumentHelper::factory(
124
+				2,
125
+				'array or ArrayAccess'
126
+			);
127
+		}
128
+
129
+		$constraint = new ArraySubset($subset, $strict);
130
+
131
+		static::assertThat($array, $constraint, $message);
132
+	}
133
+
134
+	/**
135
+	 * Asserts that an array does not have a specified key.
136
+	 *
137
+	 * @param mixed             $key
138
+	 * @param array|ArrayAccess $array
139
+	 * @param string            $message
140
+	 */
141
+	public static function assertArrayNotHasKey($key, $array, $message = '')
142
+	{
143
+		if (!(\is_int($key) || \is_string($key))) {
144
+			throw InvalidArgumentHelper::factory(
145
+				1,
146
+				'integer or string'
147
+			);
148
+		}
149
+
150
+		if (!(\is_array($array) || $array instanceof ArrayAccess)) {
151
+			throw InvalidArgumentHelper::factory(
152
+				2,
153
+				'array or ArrayAccess'
154
+			);
155
+		}
156
+
157
+		$constraint = new LogicalNot(
158
+			new ArrayHasKey($key)
159
+		);
160
+
161
+		static::assertThat($array, $constraint, $message);
162
+	}
163
+
164
+	/**
165
+	 * Asserts that a haystack contains a needle.
166
+	 *
167
+	 * @param mixed  $needle
168
+	 * @param mixed  $haystack
169
+	 * @param string $message
170
+	 * @param bool   $ignoreCase
171
+	 * @param bool   $checkForObjectIdentity
172
+	 * @param bool   $checkForNonObjectIdentity
173
+	 */
174
+	public static function assertContains($needle, $haystack, $message = '', $ignoreCase = false, $checkForObjectIdentity = true, $checkForNonObjectIdentity = false)
175
+	{
176
+		if (\is_array($haystack) ||
177
+			(\is_object($haystack) && $haystack instanceof Traversable)) {
178
+			$constraint = new TraversableContains(
179
+				$needle,
180
+				$checkForObjectIdentity,
181
+				$checkForNonObjectIdentity
182
+			);
183
+		} elseif (\is_string($haystack)) {
184
+			if (!\is_string($needle)) {
185
+				throw InvalidArgumentHelper::factory(
186
+					1,
187
+					'string'
188
+				);
189
+			}
190
+
191
+			$constraint = new StringContains(
192
+				$needle,
193
+				$ignoreCase
194
+			);
195
+		} else {
196
+			throw InvalidArgumentHelper::factory(
197
+				2,
198
+				'array, traversable or string'
199
+			);
200
+		}
201
+
202
+		static::assertThat($haystack, $constraint, $message);
203
+	}
204
+
205
+	/**
206
+	 * Asserts that a haystack that is stored in a static attribute of a class
207
+	 * or an attribute of an object contains a needle.
208
+	 *
209
+	 * @param mixed         $needle
210
+	 * @param string        $haystackAttributeName
211
+	 * @param string|object $haystackClassOrObject
212
+	 * @param string        $message
213
+	 * @param bool          $ignoreCase
214
+	 * @param bool          $checkForObjectIdentity
215
+	 * @param bool          $checkForNonObjectIdentity
216
+	 */
217
+	public static function assertAttributeContains($needle, $haystackAttributeName, $haystackClassOrObject, $message = '', $ignoreCase = false, $checkForObjectIdentity = true, $checkForNonObjectIdentity = false)
218
+	{
219
+		static::assertContains(
220
+			$needle,
221
+			static::readAttribute($haystackClassOrObject, $haystackAttributeName),
222
+			$message,
223
+			$ignoreCase,
224
+			$checkForObjectIdentity,
225
+			$checkForNonObjectIdentity
226
+		);
227
+	}
228
+
229
+	/**
230
+	 * Asserts that a haystack does not contain a needle.
231
+	 *
232
+	 * @param mixed  $needle
233
+	 * @param mixed  $haystack
234
+	 * @param string $message
235
+	 * @param bool   $ignoreCase
236
+	 * @param bool   $checkForObjectIdentity
237
+	 * @param bool   $checkForNonObjectIdentity
238
+	 */
239
+	public static function assertNotContains($needle, $haystack, $message = '', $ignoreCase = false, $checkForObjectIdentity = true, $checkForNonObjectIdentity = false)
240
+	{
241
+		if (\is_array($haystack) ||
242
+			(\is_object($haystack) && $haystack instanceof Traversable)) {
243
+			$constraint = new LogicalNot(
244
+				new TraversableContains(
245
+					$needle,
246
+					$checkForObjectIdentity,
247
+					$checkForNonObjectIdentity
248
+				)
249
+			);
250
+		} elseif (\is_string($haystack)) {
251
+			if (!\is_string($needle)) {
252
+				throw InvalidArgumentHelper::factory(
253
+					1,
254
+					'string'
255
+				);
256
+			}
257
+
258
+			$constraint = new LogicalNot(
259
+				new StringContains(
260
+					$needle,
261
+					$ignoreCase
262
+				)
263
+			);
264
+		} else {
265
+			throw InvalidArgumentHelper::factory(
266
+				2,
267
+				'array, traversable or string'
268
+			);
269
+		}
270
+
271
+		static::assertThat($haystack, $constraint, $message);
272
+	}
273
+
274
+	/**
275
+	 * Asserts that a haystack that is stored in a static attribute of a class
276
+	 * or an attribute of an object does not contain a needle.
277
+	 *
278
+	 * @param mixed         $needle
279
+	 * @param string        $haystackAttributeName
280
+	 * @param string|object $haystackClassOrObject
281
+	 * @param string        $message
282
+	 * @param bool          $ignoreCase
283
+	 * @param bool          $checkForObjectIdentity
284
+	 * @param bool          $checkForNonObjectIdentity
285
+	 */
286
+	public static function assertAttributeNotContains($needle, $haystackAttributeName, $haystackClassOrObject, $message = '', $ignoreCase = false, $checkForObjectIdentity = true, $checkForNonObjectIdentity = false)
287
+	{
288
+		static::assertNotContains(
289
+			$needle,
290
+			static::readAttribute($haystackClassOrObject, $haystackAttributeName),
291
+			$message,
292
+			$ignoreCase,
293
+			$checkForObjectIdentity,
294
+			$checkForNonObjectIdentity
295
+		);
296
+	}
297
+
298
+	/**
299
+	 * Asserts that a haystack contains only values of a given type.
300
+	 *
301
+	 * @param string $type
302
+	 * @param mixed  $haystack
303
+	 * @param bool   $isNativeType
304
+	 * @param string $message
305
+	 */
306
+	public static function assertContainsOnly($type, $haystack, $isNativeType = null, $message = '')
307
+	{
308
+		if (!\is_array($haystack) &&
309
+			!(\is_object($haystack) && $haystack instanceof Traversable)) {
310
+			throw InvalidArgumentHelper::factory(
311
+				2,
312
+				'array or traversable'
313
+			);
314
+		}
315
+
316
+		if ($isNativeType == null) {
317
+			$isNativeType = Type::isType($type);
318
+		}
319
+
320
+		static::assertThat(
321
+			$haystack,
322
+			new TraversableContainsOnly(
323
+				$type,
324
+				$isNativeType
325
+			),
326
+			$message
327
+		);
328
+	}
329
+
330
+	/**
331
+	 * Asserts that a haystack contains only instances of a given classname
332
+	 *
333
+	 * @param string             $classname
334
+	 * @param array|\Traversable $haystack
335
+	 * @param string             $message
336
+	 */
337
+	public static function assertContainsOnlyInstancesOf($classname, $haystack, $message = '')
338
+	{
339
+		if (!\is_array($haystack) &&
340
+			!(\is_object($haystack) && $haystack instanceof Traversable)) {
341
+			throw InvalidArgumentHelper::factory(
342
+				2,
343
+				'array or traversable'
344
+			);
345
+		}
346
+
347
+		static::assertThat(
348
+			$haystack,
349
+			new TraversableContainsOnly(
350
+				$classname,
351
+				false
352
+			),
353
+			$message
354
+		);
355
+	}
356
+
357
+	/**
358
+	 * Asserts that a haystack that is stored in a static attribute of a class
359
+	 * or an attribute of an object contains only values of a given type.
360
+	 *
361
+	 * @param string        $type
362
+	 * @param string        $haystackAttributeName
363
+	 * @param string|object $haystackClassOrObject
364
+	 * @param bool          $isNativeType
365
+	 * @param string        $message
366
+	 */
367
+	public static function assertAttributeContainsOnly($type, $haystackAttributeName, $haystackClassOrObject, $isNativeType = null, $message = '')
368
+	{
369
+		static::assertContainsOnly(
370
+			$type,
371
+			static::readAttribute($haystackClassOrObject, $haystackAttributeName),
372
+			$isNativeType,
373
+			$message
374
+		);
375
+	}
376
+
377
+	/**
378
+	 * Asserts that a haystack does not contain only values of a given type.
379
+	 *
380
+	 * @param string $type
381
+	 * @param mixed  $haystack
382
+	 * @param bool   $isNativeType
383
+	 * @param string $message
384
+	 */
385
+	public static function assertNotContainsOnly($type, $haystack, $isNativeType = null, $message = '')
386
+	{
387
+		if (!\is_array($haystack) &&
388
+			!(\is_object($haystack) && $haystack instanceof Traversable)) {
389
+			throw InvalidArgumentHelper::factory(
390
+				2,
391
+				'array or traversable'
392
+			);
393
+		}
394
+
395
+		if ($isNativeType == null) {
396
+			$isNativeType = Type::isType($type);
397
+		}
398
+
399
+		static::assertThat(
400
+			$haystack,
401
+			new LogicalNot(
402
+				new TraversableContainsOnly(
403
+					$type,
404
+					$isNativeType
405
+				)
406
+			),
407
+			$message
408
+		);
409
+	}
410
+
411
+	/**
412
+	 * Asserts that a haystack that is stored in a static attribute of a class
413
+	 * or an attribute of an object does not contain only values of a given
414
+	 * type.
415
+	 *
416
+	 * @param string        $type
417
+	 * @param string        $haystackAttributeName
418
+	 * @param string|object $haystackClassOrObject
419
+	 * @param bool          $isNativeType
420
+	 * @param string        $message
421
+	 */
422
+	public static function assertAttributeNotContainsOnly($type, $haystackAttributeName, $haystackClassOrObject, $isNativeType = null, $message = '')
423
+	{
424
+		static::assertNotContainsOnly(
425
+			$type,
426
+			static::readAttribute($haystackClassOrObject, $haystackAttributeName),
427
+			$isNativeType,
428
+			$message
429
+		);
430
+	}
431
+
432
+	/**
433
+	 * Asserts the number of elements of an array, Countable or Traversable.
434
+	 *
435
+	 * @param int    $expectedCount
436
+	 * @param mixed  $haystack
437
+	 * @param string $message
438
+	 */
439
+	public static function assertCount($expectedCount, $haystack, $message = '')
440
+	{
441
+		if (!\is_int($expectedCount)) {
442
+			throw InvalidArgumentHelper::factory(1, 'integer');
443
+		}
444
+
445
+		if (!$haystack instanceof Countable &&
446
+			!$haystack instanceof Traversable &&
447
+			!\is_array($haystack)) {
448
+			throw InvalidArgumentHelper::factory(2, 'countable or traversable');
449
+		}
450
+
451
+		static::assertThat(
452
+			$haystack,
453
+			new Count($expectedCount),
454
+			$message
455
+		);
456
+	}
457
+
458
+	/**
459
+	 * Asserts the number of elements of an array, Countable or Traversable
460
+	 * that is stored in an attribute.
461
+	 *
462
+	 * @param int           $expectedCount
463
+	 * @param string        $haystackAttributeName
464
+	 * @param string|object $haystackClassOrObject
465
+	 * @param string        $message
466
+	 */
467
+	public static function assertAttributeCount($expectedCount, $haystackAttributeName, $haystackClassOrObject, $message = '')
468
+	{
469
+		static::assertCount(
470
+			$expectedCount,
471
+			static::readAttribute($haystackClassOrObject, $haystackAttributeName),
472
+			$message
473
+		);
474
+	}
475
+
476
+	/**
477
+	 * Asserts the number of elements of an array, Countable or Traversable.
478
+	 *
479
+	 * @param int    $expectedCount
480
+	 * @param mixed  $haystack
481
+	 * @param string $message
482
+	 */
483
+	public static function assertNotCount($expectedCount, $haystack, $message = '')
484
+	{
485
+		if (!\is_int($expectedCount)) {
486
+			throw InvalidArgumentHelper::factory(1, 'integer');
487
+		}
488
+
489
+		if (!$haystack instanceof Countable &&
490
+			!$haystack instanceof Traversable &&
491
+			!\is_array($haystack)) {
492
+			throw InvalidArgumentHelper::factory(2, 'countable or traversable');
493
+		}
494
+
495
+		$constraint = new LogicalNot(
496
+			new Count($expectedCount)
497
+		);
498
+
499
+		static::assertThat($haystack, $constraint, $message);
500
+	}
501
+
502
+	/**
503
+	 * Asserts the number of elements of an array, Countable or Traversable
504
+	 * that is stored in an attribute.
505
+	 *
506
+	 * @param int           $expectedCount
507
+	 * @param string        $haystackAttributeName
508
+	 * @param string|object $haystackClassOrObject
509
+	 * @param string        $message
510
+	 */
511
+	public static function assertAttributeNotCount($expectedCount, $haystackAttributeName, $haystackClassOrObject, $message = '')
512
+	{
513
+		static::assertNotCount(
514
+			$expectedCount,
515
+			static::readAttribute($haystackClassOrObject, $haystackAttributeName),
516
+			$message
517
+		);
518
+	}
519
+
520
+	/**
521
+	 * Asserts that two variables are equal.
522
+	 *
523
+	 * @param mixed  $expected
524
+	 * @param mixed  $actual
525
+	 * @param string $message
526
+	 * @param float  $delta
527
+	 * @param int    $maxDepth
528
+	 * @param bool   $canonicalize
529
+	 * @param bool   $ignoreCase
530
+	 */
531
+	public static function assertEquals($expected, $actual, $message = '', $delta = 0.0, $maxDepth = 10, $canonicalize = false, $ignoreCase = false)
532
+	{
533
+		$constraint = new IsEqual(
534
+			$expected,
535
+			$delta,
536
+			$maxDepth,
537
+			$canonicalize,
538
+			$ignoreCase
539
+		);
540
+
541
+		static::assertThat($actual, $constraint, $message);
542
+	}
543
+
544
+	/**
545
+	 * Asserts that a variable is equal to an attribute of an object.
546
+	 *
547
+	 * @param mixed         $expected
548
+	 * @param string        $actualAttributeName
549
+	 * @param string|object $actualClassOrObject
550
+	 * @param string        $message
551
+	 * @param float         $delta
552
+	 * @param int           $maxDepth
553
+	 * @param bool          $canonicalize
554
+	 * @param bool          $ignoreCase
555
+	 */
556
+	public static function assertAttributeEquals($expected, $actualAttributeName, $actualClassOrObject, $message = '', $delta = 0.0, $maxDepth = 10, $canonicalize = false, $ignoreCase = false)
557
+	{
558
+		static::assertEquals(
559
+			$expected,
560
+			static::readAttribute($actualClassOrObject, $actualAttributeName),
561
+			$message,
562
+			$delta,
563
+			$maxDepth,
564
+			$canonicalize,
565
+			$ignoreCase
566
+		);
567
+	}
568
+
569
+	/**
570
+	 * Asserts that two variables are not equal.
571
+	 *
572
+	 * @param mixed  $expected
573
+	 * @param mixed  $actual
574
+	 * @param string $message
575
+	 * @param float  $delta
576
+	 * @param int    $maxDepth
577
+	 * @param bool   $canonicalize
578
+	 * @param bool   $ignoreCase
579
+	 */
580
+	public static function assertNotEquals($expected, $actual, $message = '', $delta = 0.0, $maxDepth = 10, $canonicalize = false, $ignoreCase = false)
581
+	{
582
+		$constraint = new LogicalNot(
583
+			new IsEqual(
584
+				$expected,
585
+				$delta,
586
+				$maxDepth,
587
+				$canonicalize,
588
+				$ignoreCase
589
+			)
590
+		);
591
+
592
+		static::assertThat($actual, $constraint, $message);
593
+	}
594
+
595
+	/**
596
+	 * Asserts that a variable is not equal to an attribute of an object.
597
+	 *
598
+	 * @param mixed         $expected
599
+	 * @param string        $actualAttributeName
600
+	 * @param string|object $actualClassOrObject
601
+	 * @param string        $message
602
+	 * @param float         $delta
603
+	 * @param int           $maxDepth
604
+	 * @param bool          $canonicalize
605
+	 * @param bool          $ignoreCase
606
+	 */
607
+	public static function assertAttributeNotEquals($expected, $actualAttributeName, $actualClassOrObject, $message = '', $delta = 0.0, $maxDepth = 10, $canonicalize = false, $ignoreCase = false)
608
+	{
609
+		static::assertNotEquals(
610
+			$expected,
611
+			static::readAttribute($actualClassOrObject, $actualAttributeName),
612
+			$message,
613
+			$delta,
614
+			$maxDepth,
615
+			$canonicalize,
616
+			$ignoreCase
617
+		);
618
+	}
619
+
620
+	/**
621
+	 * Asserts that a variable is empty.
622
+	 *
623
+	 * @param mixed  $actual
624
+	 * @param string $message
625
+	 *
626
+	 * @throws AssertionFailedError
627
+	 */
628
+	public static function assertEmpty($actual, $message = '')
629
+	{
630
+		static::assertThat($actual, static::isEmpty(), $message);
631
+	}
632
+
633
+	/**
634
+	 * Asserts that a static attribute of a class or an attribute of an object
635
+	 * is empty.
636
+	 *
637
+	 * @param string        $haystackAttributeName
638
+	 * @param string|object $haystackClassOrObject
639
+	 * @param string        $message
640
+	 */
641
+	public static function assertAttributeEmpty($haystackAttributeName, $haystackClassOrObject, $message = '')
642
+	{
643
+		static::assertEmpty(
644
+			static::readAttribute($haystackClassOrObject, $haystackAttributeName),
645
+			$message
646
+		);
647
+	}
648
+
649
+	/**
650
+	 * Asserts that a variable is not empty.
651
+	 *
652
+	 * @param mixed  $actual
653
+	 * @param string $message
654
+	 *
655
+	 * @throws AssertionFailedError
656
+	 */
657
+	public static function assertNotEmpty($actual, $message = '')
658
+	{
659
+		static::assertThat($actual, static::logicalNot(static::isEmpty()), $message);
660
+	}
661
+
662
+	/**
663
+	 * Asserts that a static attribute of a class or an attribute of an object
664
+	 * is not empty.
665
+	 *
666
+	 * @param string        $haystackAttributeName
667
+	 * @param string|object $haystackClassOrObject
668
+	 * @param string        $message
669
+	 */
670
+	public static function assertAttributeNotEmpty($haystackAttributeName, $haystackClassOrObject, $message = '')
671
+	{
672
+		static::assertNotEmpty(
673
+			static::readAttribute($haystackClassOrObject, $haystackAttributeName),
674
+			$message
675
+		);
676
+	}
677
+
678
+	/**
679
+	 * Asserts that a value is greater than another value.
680
+	 *
681
+	 * @param mixed  $expected
682
+	 * @param mixed  $actual
683
+	 * @param string $message
684
+	 */
685
+	public static function assertGreaterThan($expected, $actual, $message = '')
686
+	{
687
+		static::assertThat($actual, static::greaterThan($expected), $message);
688
+	}
689
+
690
+	/**
691
+	 * Asserts that an attribute is greater than another value.
692
+	 *
693
+	 * @param mixed         $expected
694
+	 * @param string        $actualAttributeName
695
+	 * @param string|object $actualClassOrObject
696
+	 * @param string        $message
697
+	 */
698
+	public static function assertAttributeGreaterThan($expected, $actualAttributeName, $actualClassOrObject, $message = '')
699
+	{
700
+		static::assertGreaterThan(
701
+			$expected,
702
+			static::readAttribute($actualClassOrObject, $actualAttributeName),
703
+			$message
704
+		);
705
+	}
706
+
707
+	/**
708
+	 * Asserts that a value is greater than or equal to another value.
709
+	 *
710
+	 * @param mixed  $expected
711
+	 * @param mixed  $actual
712
+	 * @param string $message
713
+	 */
714
+	public static function assertGreaterThanOrEqual($expected, $actual, $message = '')
715
+	{
716
+		static::assertThat(
717
+			$actual,
718
+			static::greaterThanOrEqual($expected),
719
+			$message
720
+		);
721
+	}
722
+
723
+	/**
724
+	 * Asserts that an attribute is greater than or equal to another value.
725
+	 *
726
+	 * @param mixed         $expected
727
+	 * @param string        $actualAttributeName
728
+	 * @param string|object $actualClassOrObject
729
+	 * @param string        $message
730
+	 */
731
+	public static function assertAttributeGreaterThanOrEqual($expected, $actualAttributeName, $actualClassOrObject, $message = '')
732
+	{
733
+		static::assertGreaterThanOrEqual(
734
+			$expected,
735
+			static::readAttribute($actualClassOrObject, $actualAttributeName),
736
+			$message
737
+		);
738
+	}
739
+
740
+	/**
741
+	 * Asserts that a value is smaller than another value.
742
+	 *
743
+	 * @param mixed  $expected
744
+	 * @param mixed  $actual
745
+	 * @param string $message
746
+	 */
747
+	public static function assertLessThan($expected, $actual, $message = '')
748
+	{
749
+		static::assertThat($actual, static::lessThan($expected), $message);
750
+	}
751
+
752
+	/**
753
+	 * Asserts that an attribute is smaller than another value.
754
+	 *
755
+	 * @param mixed         $expected
756
+	 * @param string        $actualAttributeName
757
+	 * @param string|object $actualClassOrObject
758
+	 * @param string        $message
759
+	 */
760
+	public static function assertAttributeLessThan($expected, $actualAttributeName, $actualClassOrObject, $message = '')
761
+	{
762
+		static::assertLessThan(
763
+			$expected,
764
+			static::readAttribute($actualClassOrObject, $actualAttributeName),
765
+			$message
766
+		);
767
+	}
768
+
769
+	/**
770
+	 * Asserts that a value is smaller than or equal to another value.
771
+	 *
772
+	 * @param mixed  $expected
773
+	 * @param mixed  $actual
774
+	 * @param string $message
775
+	 */
776
+	public static function assertLessThanOrEqual($expected, $actual, $message = '')
777
+	{
778
+		static::assertThat($actual, static::lessThanOrEqual($expected), $message);
779
+	}
780
+
781
+	/**
782
+	 * Asserts that an attribute is smaller than or equal to another value.
783
+	 *
784
+	 * @param mixed         $expected
785
+	 * @param string        $actualAttributeName
786
+	 * @param string|object $actualClassOrObject
787
+	 * @param string        $message
788
+	 */
789
+	public static function assertAttributeLessThanOrEqual($expected, $actualAttributeName, $actualClassOrObject, $message = '')
790
+	{
791
+		static::assertLessThanOrEqual(
792
+			$expected,
793
+			static::readAttribute($actualClassOrObject, $actualAttributeName),
794
+			$message
795
+		);
796
+	}
797
+
798
+	/**
799
+	 * Asserts that the contents of one file is equal to the contents of another
800
+	 * file.
801
+	 *
802
+	 * @param string $expected
803
+	 * @param string $actual
804
+	 * @param string $message
805
+	 * @param bool   $canonicalize
806
+	 * @param bool   $ignoreCase
807
+	 */
808
+	public static function assertFileEquals($expected, $actual, $message = '', $canonicalize = false, $ignoreCase = false)
809
+	{
810
+		static::assertFileExists($expected, $message);
811
+		static::assertFileExists($actual, $message);
812
+
813
+		static::assertEquals(
814
+			\file_get_contents($expected),
815
+			\file_get_contents($actual),
816
+			$message,
817
+			0,
818
+			10,
819
+			$canonicalize,
820
+			$ignoreCase
821
+		);
822
+	}
823
+
824
+	/**
825
+	 * Asserts that the contents of one file is not equal to the contents of
826
+	 * another file.
827
+	 *
828
+	 * @param string $expected
829
+	 * @param string $actual
830
+	 * @param string $message
831
+	 * @param bool   $canonicalize
832
+	 * @param bool   $ignoreCase
833
+	 */
834
+	public static function assertFileNotEquals($expected, $actual, $message = '', $canonicalize = false, $ignoreCase = false)
835
+	{
836
+		static::assertFileExists($expected, $message);
837
+		static::assertFileExists($actual, $message);
838
+
839
+		static::assertNotEquals(
840
+			\file_get_contents($expected),
841
+			\file_get_contents($actual),
842
+			$message,
843
+			0,
844
+			10,
845
+			$canonicalize,
846
+			$ignoreCase
847
+		);
848
+	}
849
+
850
+	/**
851
+	 * Asserts that the contents of a string is equal
852
+	 * to the contents of a file.
853
+	 *
854
+	 * @param string $expectedFile
855
+	 * @param string $actualString
856
+	 * @param string $message
857
+	 * @param bool   $canonicalize
858
+	 * @param bool   $ignoreCase
859
+	 */
860
+	public static function assertStringEqualsFile($expectedFile, $actualString, $message = '', $canonicalize = false, $ignoreCase = false)
861
+	{
862
+		static::assertFileExists($expectedFile, $message);
863
+
864
+		static::assertEquals(
865
+			\file_get_contents($expectedFile),
866
+			$actualString,
867
+			$message,
868
+			0,
869
+			10,
870
+			$canonicalize,
871
+			$ignoreCase
872
+		);
873
+	}
874
+
875
+	/**
876
+	 * Asserts that the contents of a string is not equal
877
+	 * to the contents of a file.
878
+	 *
879
+	 * @param string $expectedFile
880
+	 * @param string $actualString
881
+	 * @param string $message
882
+	 * @param bool   $canonicalize
883
+	 * @param bool   $ignoreCase
884
+	 */
885
+	public static function assertStringNotEqualsFile($expectedFile, $actualString, $message = '', $canonicalize = false, $ignoreCase = false)
886
+	{
887
+		static::assertFileExists($expectedFile, $message);
888
+
889
+		static::assertNotEquals(
890
+			\file_get_contents($expectedFile),
891
+			$actualString,
892
+			$message,
893
+			0,
894
+			10,
895
+			$canonicalize,
896
+			$ignoreCase
897
+		);
898
+	}
899
+
900
+	/**
901
+	 * Asserts that a file/dir is readable.
902
+	 *
903
+	 * @param string $filename
904
+	 * @param string $message
905
+	 */
906
+	public static function assertIsReadable($filename, $message = '')
907
+	{
908
+		if (!\is_string($filename)) {
909
+			throw InvalidArgumentHelper::factory(1, 'string');
910
+		}
911
+
912
+		$constraint = new IsReadable;
913
+
914
+		static::assertThat($filename, $constraint, $message);
915
+	}
916
+
917
+	/**
918
+	 * Asserts that a file/dir exists and is not readable.
919
+	 *
920
+	 * @param string $filename
921
+	 * @param string $message
922
+	 */
923
+	public static function assertNotIsReadable($filename, $message = '')
924
+	{
925
+		if (!\is_string($filename)) {
926
+			throw InvalidArgumentHelper::factory(1, 'string');
927
+		}
928
+
929
+		$constraint = new LogicalNot(
930
+			new IsReadable
931
+		);
932
+
933
+		static::assertThat($filename, $constraint, $message);
934
+	}
935
+
936
+	/**
937
+	 * Asserts that a file/dir exists and is writable.
938
+	 *
939
+	 * @param string $filename
940
+	 * @param string $message
941
+	 */
942
+	public static function assertIsWritable($filename, $message = '')
943
+	{
944
+		if (!\is_string($filename)) {
945
+			throw InvalidArgumentHelper::factory(1, 'string');
946
+		}
947
+
948
+		$constraint = new IsWritable;
949
+
950
+		static::assertThat($filename, $constraint, $message);
951
+	}
952
+
953
+	/**
954
+	 * Asserts that a file/dir exists and is not writable.
955
+	 *
956
+	 * @param string $filename
957
+	 * @param string $message
958
+	 */
959
+	public static function assertNotIsWritable($filename, $message = '')
960
+	{
961
+		if (!\is_string($filename)) {
962
+			throw InvalidArgumentHelper::factory(1, 'string');
963
+		}
964
+
965
+		$constraint = new LogicalNot(
966
+			new IsWritable
967
+		);
968
+
969
+		static::assertThat($filename, $constraint, $message);
970
+	}
971
+
972
+	/**
973
+	 * Asserts that a directory exists.
974
+	 *
975
+	 * @param string $directory
976
+	 * @param string $message
977
+	 */
978
+	public static function assertDirectoryExists($directory, $message = '')
979
+	{
980
+		if (!\is_string($directory)) {
981
+			throw InvalidArgumentHelper::factory(1, 'string');
982
+		}
983
+
984
+		$constraint = new DirectoryExists;
985
+
986
+		static::assertThat($directory, $constraint, $message);
987
+	}
988
+
989
+	/**
990
+	 * Asserts that a directory does not exist.
991
+	 *
992
+	 * @param string $directory
993
+	 * @param string $message
994
+	 */
995
+	public static function assertDirectoryNotExists($directory, $message = '')
996
+	{
997
+		if (!\is_string($directory)) {
998
+			throw InvalidArgumentHelper::factory(1, 'string');
999
+		}
1000
+
1001
+		$constraint = new LogicalNot(
1002
+			new DirectoryExists
1003
+		);
1004
+
1005
+		static::assertThat($directory, $constraint, $message);
1006
+	}
1007
+
1008
+	/**
1009
+	 * Asserts that a directory exists and is readable.
1010
+	 *
1011
+	 * @param string $directory
1012
+	 * @param string $message
1013
+	 */
1014
+	public static function assertDirectoryIsReadable($directory, $message = '')
1015
+	{
1016
+		self::assertDirectoryExists($directory, $message);
1017
+		self::assertIsReadable($directory, $message);
1018
+	}
1019
+
1020
+	/**
1021
+	 * Asserts that a directory exists and is not readable.
1022
+	 *
1023
+	 * @param string $directory
1024
+	 * @param string $message
1025
+	 */
1026
+	public static function assertDirectoryNotIsReadable($directory, $message = '')
1027
+	{
1028
+		self::assertDirectoryExists($directory, $message);
1029
+		self::assertNotIsReadable($directory, $message);
1030
+	}
1031
+
1032
+	/**
1033
+	 * Asserts that a directory exists and is writable.
1034
+	 *
1035
+	 * @param string $directory
1036
+	 * @param string $message
1037
+	 */
1038
+	public static function assertDirectoryIsWritable($directory, $message = '')
1039
+	{
1040
+		self::assertDirectoryExists($directory, $message);
1041
+		self::assertIsWritable($directory, $message);
1042
+	}
1043
+
1044
+	/**
1045
+	 * Asserts that a directory exists and is not writable.
1046
+	 *
1047
+	 * @param string $directory
1048
+	 * @param string $message
1049
+	 */
1050
+	public static function assertDirectoryNotIsWritable($directory, $message = '')
1051
+	{
1052
+		self::assertDirectoryExists($directory, $message);
1053
+		self::assertNotIsWritable($directory, $message);
1054
+	}
1055
+
1056
+	/**
1057
+	 * Asserts that a file exists.
1058
+	 *
1059
+	 * @param string $filename
1060
+	 * @param string $message
1061
+	 */
1062
+	public static function assertFileExists($filename, $message = '')
1063
+	{
1064
+		if (!\is_string($filename)) {
1065
+			throw InvalidArgumentHelper::factory(1, 'string');
1066
+		}
1067
+
1068
+		$constraint = new FileExists;
1069
+
1070
+		static::assertThat($filename, $constraint, $message);
1071
+	}
1072
+
1073
+	/**
1074
+	 * Asserts that a file does not exist.
1075
+	 *
1076
+	 * @param string $filename
1077
+	 * @param string $message
1078
+	 */
1079
+	public static function assertFileNotExists($filename, $message = '')
1080
+	{
1081
+		if (!\is_string($filename)) {
1082
+			throw InvalidArgumentHelper::factory(1, 'string');
1083
+		}
1084
+
1085
+		$constraint = new LogicalNot(
1086
+			new FileExists
1087
+		);
1088
+
1089
+		static::assertThat($filename, $constraint, $message);
1090
+	}
1091
+
1092
+	/**
1093
+	 * Asserts that a file exists and is readable.
1094
+	 *
1095
+	 * @param string $file
1096
+	 * @param string $message
1097
+	 */
1098
+	public static function assertFileIsReadable($file, $message = '')
1099
+	{
1100
+		self::assertFileExists($file, $message);
1101
+		self::assertIsReadable($file, $message);
1102
+	}
1103
+
1104
+	/**
1105
+	 * Asserts that a file exists and is not readable.
1106
+	 *
1107
+	 * @param string $file
1108
+	 * @param string $message
1109
+	 */
1110
+	public static function assertFileNotIsReadable($file, $message = '')
1111
+	{
1112
+		self::assertFileExists($file, $message);
1113
+		self::assertNotIsReadable($file, $message);
1114
+	}
1115
+
1116
+	/**
1117
+	 * Asserts that a file exists and is writable.
1118
+	 *
1119
+	 * @param string $file
1120
+	 * @param string $message
1121
+	 */
1122
+	public static function assertFileIsWritable($file, $message = '')
1123
+	{
1124
+		self::assertFileExists($file, $message);
1125
+		self::assertIsWritable($file, $message);
1126
+	}
1127
+
1128
+	/**
1129
+	 * Asserts that a file exists and is not writable.
1130
+	 *
1131
+	 * @param string $file
1132
+	 * @param string $message
1133
+	 */
1134
+	public static function assertFileNotIsWritable($file, $message = '')
1135
+	{
1136
+		self::assertFileExists($file, $message);
1137
+		self::assertNotIsWritable($file, $message);
1138
+	}
1139
+
1140
+	/**
1141
+	 * Asserts that a condition is true.
1142
+	 *
1143
+	 * @param bool   $condition
1144
+	 * @param string $message
1145
+	 *
1146
+	 * @throws AssertionFailedError
1147
+	 */
1148
+	public static function assertTrue($condition, $message = '')
1149
+	{
1150
+		static::assertThat($condition, static::isTrue(), $message);
1151
+	}
1152
+
1153
+	/**
1154
+	 * Asserts that a condition is not true.
1155
+	 *
1156
+	 * @param bool   $condition
1157
+	 * @param string $message
1158
+	 *
1159
+	 * @throws AssertionFailedError
1160
+	 */
1161
+	public static function assertNotTrue($condition, $message = '')
1162
+	{
1163
+		static::assertThat($condition, static::logicalNot(static::isTrue()), $message);
1164
+	}
1165
+
1166
+	/**
1167
+	 * Asserts that a condition is false.
1168
+	 *
1169
+	 * @param bool   $condition
1170
+	 * @param string $message
1171
+	 *
1172
+	 * @throws AssertionFailedError
1173
+	 */
1174
+	public static function assertFalse($condition, $message = '')
1175
+	{
1176
+		static::assertThat($condition, static::isFalse(), $message);
1177
+	}
1178
+
1179
+	/**
1180
+	 * Asserts that a condition is not false.
1181
+	 *
1182
+	 * @param bool   $condition
1183
+	 * @param string $message
1184
+	 *
1185
+	 * @throws AssertionFailedError
1186
+	 */
1187
+	public static function assertNotFalse($condition, $message = '')
1188
+	{
1189
+		static::assertThat($condition, static::logicalNot(static::isFalse()), $message);
1190
+	}
1191
+
1192
+	/**
1193
+	 * Asserts that a variable is null.
1194
+	 *
1195
+	 * @param mixed  $actual
1196
+	 * @param string $message
1197
+	 */
1198
+	public static function assertNull($actual, $message = '')
1199
+	{
1200
+		static::assertThat($actual, static::isNull(), $message);
1201
+	}
1202
+
1203
+	/**
1204
+	 * Asserts that a variable is not null.
1205
+	 *
1206
+	 * @param mixed  $actual
1207
+	 * @param string $message
1208
+	 */
1209
+	public static function assertNotNull($actual, $message = '')
1210
+	{
1211
+		static::assertThat($actual, static::logicalNot(static::isNull()), $message);
1212
+	}
1213
+
1214
+	/**
1215
+	 * Asserts that a variable is finite.
1216
+	 *
1217
+	 * @param mixed  $actual
1218
+	 * @param string $message
1219
+	 */
1220
+	public static function assertFinite($actual, $message = '')
1221
+	{
1222
+		static::assertThat($actual, static::isFinite(), $message);
1223
+	}
1224
+
1225
+	/**
1226
+	 * Asserts that a variable is infinite.
1227
+	 *
1228
+	 * @param mixed  $actual
1229
+	 * @param string $message
1230
+	 */
1231
+	public static function assertInfinite($actual, $message = '')
1232
+	{
1233
+		static::assertThat($actual, static::isInfinite(), $message);
1234
+	}
1235
+
1236
+	/**
1237
+	 * Asserts that a variable is nan.
1238
+	 *
1239
+	 * @param mixed  $actual
1240
+	 * @param string $message
1241
+	 */
1242
+	public static function assertNan($actual, $message = '')
1243
+	{
1244
+		static::assertThat($actual, static::isNan(), $message);
1245
+	}
1246
+
1247
+	/**
1248
+	 * Asserts that a class has a specified attribute.
1249
+	 *
1250
+	 * @param string $attributeName
1251
+	 * @param string $className
1252
+	 * @param string $message
1253
+	 */
1254
+	public static function assertClassHasAttribute($attributeName, $className, $message = '')
1255
+	{
1256
+		if (!\is_string($attributeName)) {
1257
+			throw InvalidArgumentHelper::factory(1, 'string');
1258
+		}
1259
+
1260
+		if (!\preg_match('/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/', $attributeName)) {
1261
+			throw InvalidArgumentHelper::factory(1, 'valid attribute name');
1262
+		}
1263
+
1264
+		if (!\is_string($className) || !\class_exists($className)) {
1265
+			throw InvalidArgumentHelper::factory(2, 'class name', $className);
1266
+		}
1267
+
1268
+		$constraint = new ClassHasAttribute(
1269
+			$attributeName
1270
+		);
1271
+
1272
+		static::assertThat($className, $constraint, $message);
1273
+	}
1274
+
1275
+	/**
1276
+	 * Asserts that a class does not have a specified attribute.
1277
+	 *
1278
+	 * @param string $attributeName
1279
+	 * @param string $className
1280
+	 * @param string $message
1281
+	 */
1282
+	public static function assertClassNotHasAttribute($attributeName, $className, $message = '')
1283
+	{
1284
+		if (!\is_string($attributeName)) {
1285
+			throw InvalidArgumentHelper::factory(1, 'string');
1286
+		}
1287
+
1288
+		if (!\preg_match('/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/', $attributeName)) {
1289
+			throw InvalidArgumentHelper::factory(1, 'valid attribute name');
1290
+		}
1291
+
1292
+		if (!\is_string($className) || !\class_exists($className)) {
1293
+			throw InvalidArgumentHelper::factory(2, 'class name', $className);
1294
+		}
1295
+
1296
+		$constraint = new LogicalNot(
1297
+			new ClassHasAttribute($attributeName)
1298
+		);
1299
+
1300
+		static::assertThat($className, $constraint, $message);
1301
+	}
1302
+
1303
+	/**
1304
+	 * Asserts that a class has a specified static attribute.
1305
+	 *
1306
+	 * @param string $attributeName
1307
+	 * @param string $className
1308
+	 * @param string $message
1309
+	 */
1310
+	public static function assertClassHasStaticAttribute($attributeName, $className, $message = '')
1311
+	{
1312
+		if (!\is_string($attributeName)) {
1313
+			throw InvalidArgumentHelper::factory(1, 'string');
1314
+		}
1315
+
1316
+		if (!\preg_match('/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/', $attributeName)) {
1317
+			throw InvalidArgumentHelper::factory(1, 'valid attribute name');
1318
+		}
1319
+
1320
+		if (!\is_string($className) || !\class_exists($className)) {
1321
+			throw InvalidArgumentHelper::factory(2, 'class name', $className);
1322
+		}
1323
+
1324
+		$constraint = new ClassHasStaticAttribute(
1325
+			$attributeName
1326
+		);
1327
+
1328
+		static::assertThat($className, $constraint, $message);
1329
+	}
1330
+
1331
+	/**
1332
+	 * Asserts that a class does not have a specified static attribute.
1333
+	 *
1334
+	 * @param string $attributeName
1335
+	 * @param string $className
1336
+	 * @param string $message
1337
+	 */
1338
+	public static function assertClassNotHasStaticAttribute($attributeName, $className, $message = '')
1339
+	{
1340
+		if (!\is_string($attributeName)) {
1341
+			throw InvalidArgumentHelper::factory(1, 'string');
1342
+		}
1343
+
1344
+		if (!\preg_match('/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/', $attributeName)) {
1345
+			throw InvalidArgumentHelper::factory(1, 'valid attribute name');
1346
+		}
1347
+
1348
+		if (!\is_string($className) || !\class_exists($className)) {
1349
+			throw InvalidArgumentHelper::factory(2, 'class name', $className);
1350
+		}
1351
+
1352
+		$constraint = new LogicalNot(
1353
+			new ClassHasStaticAttribute(
1354
+				$attributeName
1355
+			)
1356
+		);
1357
+
1358
+		static::assertThat($className, $constraint, $message);
1359
+	}
1360
+
1361
+	/**
1362
+	 * Asserts that an object has a specified attribute.
1363
+	 *
1364
+	 * @param string $attributeName
1365
+	 * @param object $object
1366
+	 * @param string $message
1367
+	 */
1368
+	public static function assertObjectHasAttribute($attributeName, $object, $message = '')
1369
+	{
1370
+		if (!\is_string($attributeName)) {
1371
+			throw InvalidArgumentHelper::factory(1, 'string');
1372
+		}
1373
+
1374
+		if (!\preg_match('/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/', $attributeName)) {
1375
+			throw InvalidArgumentHelper::factory(1, 'valid attribute name');
1376
+		}
1377
+
1378
+		if (!\is_object($object)) {
1379
+			throw InvalidArgumentHelper::factory(2, 'object');
1380
+		}
1381
+
1382
+		$constraint = new ObjectHasAttribute(
1383
+			$attributeName
1384
+		);
1385
+
1386
+		static::assertThat($object, $constraint, $message);
1387
+	}
1388
+
1389
+	/**
1390
+	 * Asserts that an object does not have a specified attribute.
1391
+	 *
1392
+	 * @param string $attributeName
1393
+	 * @param object $object
1394
+	 * @param string $message
1395
+	 */
1396
+	public static function assertObjectNotHasAttribute($attributeName, $object, $message = '')
1397
+	{
1398
+		if (!\is_string($attributeName)) {
1399
+			throw InvalidArgumentHelper::factory(1, 'string');
1400
+		}
1401
+
1402
+		if (!\preg_match('/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/', $attributeName)) {
1403
+			throw InvalidArgumentHelper::factory(1, 'valid attribute name');
1404
+		}
1405
+
1406
+		if (!\is_object($object)) {
1407
+			throw InvalidArgumentHelper::factory(2, 'object');
1408
+		}
1409
+
1410
+		$constraint = new LogicalNot(
1411
+			new ObjectHasAttribute($attributeName)
1412
+		);
1413
+
1414
+		static::assertThat($object, $constraint, $message);
1415
+	}
1416
+
1417
+	/**
1418
+	 * Asserts that two variables have the same type and value.
1419
+	 * Used on objects, it asserts that two variables reference
1420
+	 * the same object.
1421
+	 *
1422
+	 * @param mixed  $expected
1423
+	 * @param mixed  $actual
1424
+	 * @param string $message
1425
+	 */
1426
+	public static function assertSame($expected, $actual, $message = '')
1427
+	{
1428
+		if (\is_bool($expected) && \is_bool($actual)) {
1429
+			static::assertEquals($expected, $actual, $message);
1430
+		} else {
1431
+			$constraint = new IsIdentical(
1432
+				$expected
1433
+			);
1434
+
1435
+			static::assertThat($actual, $constraint, $message);
1436
+		}
1437
+	}
1438
+
1439
+	/**
1440
+	 * Asserts that a variable and an attribute of an object have the same type
1441
+	 * and value.
1442
+	 *
1443
+	 * @param mixed         $expected
1444
+	 * @param string        $actualAttributeName
1445
+	 * @param string|object $actualClassOrObject
1446
+	 * @param string        $message
1447
+	 */
1448
+	public static function assertAttributeSame($expected, $actualAttributeName, $actualClassOrObject, $message = '')
1449
+	{
1450
+		static::assertSame(
1451
+			$expected,
1452
+			static::readAttribute($actualClassOrObject, $actualAttributeName),
1453
+			$message
1454
+		);
1455
+	}
1456
+
1457
+	/**
1458
+	 * Asserts that two variables do not have the same type and value.
1459
+	 * Used on objects, it asserts that two variables do not reference
1460
+	 * the same object.
1461
+	 *
1462
+	 * @param mixed  $expected
1463
+	 * @param mixed  $actual
1464
+	 * @param string $message
1465
+	 */
1466
+	public static function assertNotSame($expected, $actual, $message = '')
1467
+	{
1468
+		if (\is_bool($expected) && \is_bool($actual)) {
1469
+			static::assertNotEquals($expected, $actual, $message);
1470
+		} else {
1471
+			$constraint = new LogicalNot(
1472
+				new IsIdentical($expected)
1473
+			);
1474
+
1475
+			static::assertThat($actual, $constraint, $message);
1476
+		}
1477
+	}
1478
+
1479
+	/**
1480
+	 * Asserts that a variable and an attribute of an object do not have the
1481
+	 * same type and value.
1482
+	 *
1483
+	 * @param mixed         $expected
1484
+	 * @param string        $actualAttributeName
1485
+	 * @param string|object $actualClassOrObject
1486
+	 * @param string        $message
1487
+	 */
1488
+	public static function assertAttributeNotSame($expected, $actualAttributeName, $actualClassOrObject, $message = '')
1489
+	{
1490
+		static::assertNotSame(
1491
+			$expected,
1492
+			static::readAttribute($actualClassOrObject, $actualAttributeName),
1493
+			$message
1494
+		);
1495
+	}
1496
+
1497
+	/**
1498
+	 * Asserts that a variable is of a given type.
1499
+	 *
1500
+	 * @param string $expected
1501
+	 * @param mixed  $actual
1502
+	 * @param string $message
1503
+	 */
1504
+	public static function assertInstanceOf($expected, $actual, $message = '')
1505
+	{
1506
+		if (!(\is_string($expected) && (\class_exists($expected) || \interface_exists($expected)))) {
1507
+			throw InvalidArgumentHelper::factory(1, 'class or interface name');
1508
+		}
1509
+
1510
+		$constraint = new IsInstanceOf(
1511
+			$expected
1512
+		);
1513
+
1514
+		static::assertThat($actual, $constraint, $message);
1515
+	}
1516
+
1517
+	/**
1518
+	 * Asserts that an attribute is of a given type.
1519
+	 *
1520
+	 * @param string        $expected
1521
+	 * @param string        $attributeName
1522
+	 * @param string|object $classOrObject
1523
+	 * @param string        $message
1524
+	 */
1525
+	public static function assertAttributeInstanceOf($expected, $attributeName, $classOrObject, $message = '')
1526
+	{
1527
+		static::assertInstanceOf(
1528
+			$expected,
1529
+			static::readAttribute($classOrObject, $attributeName),
1530
+			$message
1531
+		);
1532
+	}
1533
+
1534
+	/**
1535
+	 * Asserts that a variable is not of a given type.
1536
+	 *
1537
+	 * @param string $expected
1538
+	 * @param mixed  $actual
1539
+	 * @param string $message
1540
+	 */
1541
+	public static function assertNotInstanceOf($expected, $actual, $message = '')
1542
+	{
1543
+		if (!(\is_string($expected) && (\class_exists($expected) || \interface_exists($expected)))) {
1544
+			throw InvalidArgumentHelper::factory(1, 'class or interface name');
1545
+		}
1546
+
1547
+		$constraint = new LogicalNot(
1548
+			new IsInstanceOf($expected)
1549
+		);
1550
+
1551
+		static::assertThat($actual, $constraint, $message);
1552
+	}
1553
+
1554
+	/**
1555
+	 * Asserts that an attribute is of a given type.
1556
+	 *
1557
+	 * @param string        $expected
1558
+	 * @param string        $attributeName
1559
+	 * @param string|object $classOrObject
1560
+	 * @param string        $message
1561
+	 */
1562
+	public static function assertAttributeNotInstanceOf($expected, $attributeName, $classOrObject, $message = '')
1563
+	{
1564
+		static::assertNotInstanceOf(
1565
+			$expected,
1566
+			static::readAttribute($classOrObject, $attributeName),
1567
+			$message
1568
+		);
1569
+	}
1570
+
1571
+	/**
1572
+	 * Asserts that a variable is of a given type.
1573
+	 *
1574
+	 * @param string $expected
1575
+	 * @param mixed  $actual
1576
+	 * @param string $message
1577
+	 */
1578
+	public static function assertInternalType($expected, $actual, $message = '')
1579
+	{
1580
+		if (!\is_string($expected)) {
1581
+			throw InvalidArgumentHelper::factory(1, 'string');
1582
+		}
1583
+
1584
+		$constraint = new IsType(
1585
+			$expected
1586
+		);
1587
+
1588
+		static::assertThat($actual, $constraint, $message);
1589
+	}
1590
+
1591
+	/**
1592
+	 * Asserts that an attribute is of a given type.
1593
+	 *
1594
+	 * @param string        $expected
1595
+	 * @param string        $attributeName
1596
+	 * @param string|object $classOrObject
1597
+	 * @param string        $message
1598
+	 */
1599
+	public static function assertAttributeInternalType($expected, $attributeName, $classOrObject, $message = '')
1600
+	{
1601
+		static::assertInternalType(
1602
+			$expected,
1603
+			static::readAttribute($classOrObject, $attributeName),
1604
+			$message
1605
+		);
1606
+	}
1607
+
1608
+	/**
1609
+	 * Asserts that a variable is not of a given type.
1610
+	 *
1611
+	 * @param string $expected
1612
+	 * @param mixed  $actual
1613
+	 * @param string $message
1614
+	 */
1615
+	public static function assertNotInternalType($expected, $actual, $message = '')
1616
+	{
1617
+		if (!\is_string($expected)) {
1618
+			throw InvalidArgumentHelper::factory(1, 'string');
1619
+		}
1620
+
1621
+		$constraint = new LogicalNot(
1622
+			new IsType($expected)
1623
+		);
1624
+
1625
+		static::assertThat($actual, $constraint, $message);
1626
+	}
1627
+
1628
+	/**
1629
+	 * Asserts that an attribute is of a given type.
1630
+	 *
1631
+	 * @param string        $expected
1632
+	 * @param string        $attributeName
1633
+	 * @param string|object $classOrObject
1634
+	 * @param string        $message
1635
+	 */
1636
+	public static function assertAttributeNotInternalType($expected, $attributeName, $classOrObject, $message = '')
1637
+	{
1638
+		static::assertNotInternalType(
1639
+			$expected,
1640
+			static::readAttribute($classOrObject, $attributeName),
1641
+			$message
1642
+		);
1643
+	}
1644
+
1645
+	/**
1646
+	 * Asserts that a string matches a given regular expression.
1647
+	 *
1648
+	 * @param string $pattern
1649
+	 * @param string $string
1650
+	 * @param string $message
1651
+	 */
1652
+	public static function assertRegExp($pattern, $string, $message = '')
1653
+	{
1654
+		if (!\is_string($pattern)) {
1655
+			throw InvalidArgumentHelper::factory(1, 'string');
1656
+		}
1657
+
1658
+		if (!\is_string($string)) {
1659
+			throw InvalidArgumentHelper::factory(2, 'string');
1660
+		}
1661
+
1662
+		$constraint = new RegularExpression($pattern);
1663
+
1664
+		static::assertThat($string, $constraint, $message);
1665
+	}
1666
+
1667
+	/**
1668
+	 * Asserts that a string does not match a given regular expression.
1669
+	 *
1670
+	 * @param string $pattern
1671
+	 * @param string $string
1672
+	 * @param string $message
1673
+	 */
1674
+	public static function assertNotRegExp($pattern, $string, $message = '')
1675
+	{
1676
+		if (!\is_string($pattern)) {
1677
+			throw InvalidArgumentHelper::factory(1, 'string');
1678
+		}
1679
+
1680
+		if (!\is_string($string)) {
1681
+			throw InvalidArgumentHelper::factory(2, 'string');
1682
+		}
1683
+
1684
+		$constraint = new LogicalNot(
1685
+			new RegularExpression($pattern)
1686
+		);
1687
+
1688
+		static::assertThat($string, $constraint, $message);
1689
+	}
1690
+
1691
+	/**
1692
+	 * Assert that the size of two arrays (or `Countable` or `Traversable` objects)
1693
+	 * is the same.
1694
+	 *
1695
+	 * @param array|\Countable|\Traversable $expected
1696
+	 * @param array|\Countable|\Traversable $actual
1697
+	 * @param string                        $message
1698
+	 */
1699
+	public static function assertSameSize($expected, $actual, $message = '')
1700
+	{
1701
+		if (!$expected instanceof Countable &&
1702
+			!$expected instanceof Traversable &&
1703
+			!\is_array($expected)) {
1704
+			throw InvalidArgumentHelper::factory(1, 'countable or traversable');
1705
+		}
1706
+
1707
+		if (!$actual instanceof Countable &&
1708
+			!$actual instanceof Traversable &&
1709
+			!\is_array($actual)) {
1710
+			throw InvalidArgumentHelper::factory(2, 'countable or traversable');
1711
+		}
1712
+
1713
+		static::assertThat(
1714
+			$actual,
1715
+			new SameSize($expected),
1716
+			$message
1717
+		);
1718
+	}
1719
+
1720
+	/**
1721
+	 * Assert that the size of two arrays (or `Countable` or `Traversable` objects)
1722
+	 * is not the same.
1723
+	 *
1724
+	 * @param array|\Countable|\Traversable $expected
1725
+	 * @param array|\Countable|\Traversable $actual
1726
+	 * @param string                        $message
1727
+	 */
1728
+	public static function assertNotSameSize($expected, $actual, $message = '')
1729
+	{
1730
+		if (!$expected instanceof Countable &&
1731
+			!$expected instanceof Traversable &&
1732
+			!\is_array($expected)) {
1733
+			throw InvalidArgumentHelper::factory(1, 'countable or traversable');
1734
+		}
1735
+
1736
+		if (!$actual instanceof Countable &&
1737
+			!$actual instanceof Traversable &&
1738
+			!\is_array($actual)) {
1739
+			throw InvalidArgumentHelper::factory(2, 'countable or traversable');
1740
+		}
1741
+
1742
+		$constraint = new LogicalNot(
1743
+			new SameSize($expected)
1744
+		);
1745
+
1746
+		static::assertThat($actual, $constraint, $message);
1747
+	}
1748
+
1749
+	/**
1750
+	 * Asserts that a string matches a given format string.
1751
+	 *
1752
+	 * @param string $format
1753
+	 * @param string $string
1754
+	 * @param string $message
1755
+	 */
1756
+	public static function assertStringMatchesFormat($format, $string, $message = '')
1757
+	{
1758
+		if (!\is_string($format)) {
1759
+			throw InvalidArgumentHelper::factory(1, 'string');
1760
+		}
1761
+
1762
+		if (!\is_string($string)) {
1763
+			throw InvalidArgumentHelper::factory(2, 'string');
1764
+		}
1765
+
1766
+		$constraint = new StringMatchesFormatDescription($format);
1767
+
1768
+		static::assertThat($string, $constraint, $message);
1769
+	}
1770
+
1771
+	/**
1772
+	 * Asserts that a string does not match a given format string.
1773
+	 *
1774
+	 * @param string $format
1775
+	 * @param string $string
1776
+	 * @param string $message
1777
+	 */
1778
+	public static function assertStringNotMatchesFormat($format, $string, $message = '')
1779
+	{
1780
+		if (!\is_string($format)) {
1781
+			throw InvalidArgumentHelper::factory(1, 'string');
1782
+		}
1783
+
1784
+		if (!\is_string($string)) {
1785
+			throw InvalidArgumentHelper::factory(2, 'string');
1786
+		}
1787
+
1788
+		$constraint = new LogicalNot(
1789
+			new StringMatchesFormatDescription($format)
1790
+		);
1791
+
1792
+		static::assertThat($string, $constraint, $message);
1793
+	}
1794
+
1795
+	/**
1796
+	 * Asserts that a string matches a given format file.
1797
+	 *
1798
+	 * @param string $formatFile
1799
+	 * @param string $string
1800
+	 * @param string $message
1801
+	 */
1802
+	public static function assertStringMatchesFormatFile($formatFile, $string, $message = '')
1803
+	{
1804
+		static::assertFileExists($formatFile, $message);
1805
+
1806
+		if (!\is_string($string)) {
1807
+			throw InvalidArgumentHelper::factory(2, 'string');
1808
+		}
1809
+
1810
+		$constraint = new StringMatchesFormatDescription(
1811
+			\file_get_contents($formatFile)
1812
+		);
1813
+
1814
+		static::assertThat($string, $constraint, $message);
1815
+	}
1816
+
1817
+	/**
1818
+	 * Asserts that a string does not match a given format string.
1819
+	 *
1820
+	 * @param string $formatFile
1821
+	 * @param string $string
1822
+	 * @param string $message
1823
+	 */
1824
+	public static function assertStringNotMatchesFormatFile($formatFile, $string, $message = '')
1825
+	{
1826
+		static::assertFileExists($formatFile, $message);
1827
+
1828
+		if (!\is_string($string)) {
1829
+			throw InvalidArgumentHelper::factory(2, 'string');
1830
+		}
1831
+
1832
+		$constraint = new LogicalNot(
1833
+			new StringMatchesFormatDescription(
1834
+				\file_get_contents($formatFile)
1835
+			)
1836
+		);
1837
+
1838
+		static::assertThat($string, $constraint, $message);
1839
+	}
1840
+
1841
+	/**
1842
+	 * Asserts that a string starts with a given prefix.
1843
+	 *
1844
+	 * @param string $prefix
1845
+	 * @param string $string
1846
+	 * @param string $message
1847
+	 */
1848
+	public static function assertStringStartsWith($prefix, $string, $message = '')
1849
+	{
1850
+		if (!\is_string($prefix)) {
1851
+			throw InvalidArgumentHelper::factory(1, 'string');
1852
+		}
1853
+
1854
+		if (!\is_string($string)) {
1855
+			throw InvalidArgumentHelper::factory(2, 'string');
1856
+		}
1857
+
1858
+		$constraint = new StringStartsWith(
1859
+			$prefix
1860
+		);
1861
+
1862
+		static::assertThat($string, $constraint, $message);
1863
+	}
1864
+
1865
+	/**
1866
+	 * Asserts that a string starts not with a given prefix.
1867
+	 *
1868
+	 * @param string $prefix
1869
+	 * @param string $string
1870
+	 * @param string $message
1871
+	 */
1872
+	public static function assertStringStartsNotWith($prefix, $string, $message = '')
1873
+	{
1874
+		if (!\is_string($prefix)) {
1875
+			throw InvalidArgumentHelper::factory(1, 'string');
1876
+		}
1877
+
1878
+		if (!\is_string($string)) {
1879
+			throw InvalidArgumentHelper::factory(2, 'string');
1880
+		}
1881
+
1882
+		$constraint = new LogicalNot(
1883
+			new StringStartsWith($prefix)
1884
+		);
1885
+
1886
+		static::assertThat($string, $constraint, $message);
1887
+	}
1888
+
1889
+	/**
1890
+	 * Asserts that a string ends with a given suffix.
1891
+	 *
1892
+	 * @param string $suffix
1893
+	 * @param string $string
1894
+	 * @param string $message
1895
+	 */
1896
+	public static function assertStringEndsWith($suffix, $string, $message = '')
1897
+	{
1898
+		if (!\is_string($suffix)) {
1899
+			throw InvalidArgumentHelper::factory(1, 'string');
1900
+		}
1901
+
1902
+		if (!\is_string($string)) {
1903
+			throw InvalidArgumentHelper::factory(2, 'string');
1904
+		}
1905
+
1906
+		$constraint = new StringEndsWith($suffix);
1907
+
1908
+		static::assertThat($string, $constraint, $message);
1909
+	}
1910
+
1911
+	/**
1912
+	 * Asserts that a string ends not with a given suffix.
1913
+	 *
1914
+	 * @param string $suffix
1915
+	 * @param string $string
1916
+	 * @param string $message
1917
+	 */
1918
+	public static function assertStringEndsNotWith($suffix, $string, $message = '')
1919
+	{
1920
+		if (!\is_string($suffix)) {
1921
+			throw InvalidArgumentHelper::factory(1, 'string');
1922
+		}
1923
+
1924
+		if (!\is_string($string)) {
1925
+			throw InvalidArgumentHelper::factory(2, 'string');
1926
+		}
1927
+
1928
+		$constraint = new LogicalNot(
1929
+			new StringEndsWith($suffix)
1930
+		);
1931
+
1932
+		static::assertThat($string, $constraint, $message);
1933
+	}
1934
+
1935
+	/**
1936
+	 * Asserts that two XML files are equal.
1937
+	 *
1938
+	 * @param string $expectedFile
1939
+	 * @param string $actualFile
1940
+	 * @param string $message
1941
+	 */
1942
+	public static function assertXmlFileEqualsXmlFile($expectedFile, $actualFile, $message = '')
1943
+	{
1944
+		$expected = Xml::loadFile($expectedFile);
1945
+		$actual   = Xml::loadFile($actualFile);
1946
+
1947
+		static::assertEquals($expected, $actual, $message);
1948
+	}
1949
+
1950
+	/**
1951
+	 * Asserts that two XML files are not equal.
1952
+	 *
1953
+	 * @param string $expectedFile
1954
+	 * @param string $actualFile
1955
+	 * @param string $message
1956
+	 */
1957
+	public static function assertXmlFileNotEqualsXmlFile($expectedFile, $actualFile, $message = '')
1958
+	{
1959
+		$expected = Xml::loadFile($expectedFile);
1960
+		$actual   = Xml::loadFile($actualFile);
1961
+
1962
+		static::assertNotEquals($expected, $actual, $message);
1963
+	}
1964
+
1965
+	/**
1966
+	 * Asserts that two XML documents are equal.
1967
+	 *
1968
+	 * @param string             $expectedFile
1969
+	 * @param string|DOMDocument $actualXml
1970
+	 * @param string             $message
1971
+	 */
1972
+	public static function assertXmlStringEqualsXmlFile($expectedFile, $actualXml, $message = '')
1973
+	{
1974
+		$expected = Xml::loadFile($expectedFile);
1975
+		$actual   = Xml::load($actualXml);
1976
+
1977
+		static::assertEquals($expected, $actual, $message);
1978
+	}
1979
+
1980
+	/**
1981
+	 * Asserts that two XML documents are not equal.
1982
+	 *
1983
+	 * @param string             $expectedFile
1984
+	 * @param string|DOMDocument $actualXml
1985
+	 * @param string             $message
1986
+	 */
1987
+	public static function assertXmlStringNotEqualsXmlFile($expectedFile, $actualXml, $message = '')
1988
+	{
1989
+		$expected = Xml::loadFile($expectedFile);
1990
+		$actual   = Xml::load($actualXml);
1991
+
1992
+		static::assertNotEquals($expected, $actual, $message);
1993
+	}
1994
+
1995
+	/**
1996
+	 * Asserts that two XML documents are equal.
1997
+	 *
1998
+	 * @param string|DOMDocument $expectedXml
1999
+	 * @param string|DOMDocument $actualXml
2000
+	 * @param string             $message
2001
+	 */
2002
+	public static function assertXmlStringEqualsXmlString($expectedXml, $actualXml, $message = '')
2003
+	{
2004
+		$expected = Xml::load($expectedXml);
2005
+		$actual   = Xml::load($actualXml);
2006
+
2007
+		static::assertEquals($expected, $actual, $message);
2008
+	}
2009
+
2010
+	/**
2011
+	 * Asserts that two XML documents are not equal.
2012
+	 *
2013
+	 * @param string|DOMDocument $expectedXml
2014
+	 * @param string|DOMDocument $actualXml
2015
+	 * @param string             $message
2016
+	 */
2017
+	public static function assertXmlStringNotEqualsXmlString($expectedXml, $actualXml, $message = '')
2018
+	{
2019
+		$expected = Xml::load($expectedXml);
2020
+		$actual   = Xml::load($actualXml);
2021
+
2022
+		static::assertNotEquals($expected, $actual, $message);
2023
+	}
2024
+
2025
+	/**
2026
+	 * Asserts that a hierarchy of DOMElements matches.
2027
+	 *
2028
+	 * @param DOMElement $expectedElement
2029
+	 * @param DOMElement $actualElement
2030
+	 * @param bool       $checkAttributes
2031
+	 * @param string     $message
2032
+	 */
2033
+	public static function assertEqualXMLStructure(DOMElement $expectedElement, DOMElement $actualElement, $checkAttributes = false, $message = '')
2034
+	{
2035
+		$tmp             = new DOMDocument;
2036
+		$expectedElement = $tmp->importNode($expectedElement, true);
2037
+
2038
+		$tmp           = new DOMDocument;
2039
+		$actualElement = $tmp->importNode($actualElement, true);
2040
+
2041
+		unset($tmp);
2042
+
2043
+		static::assertEquals(
2044
+			$expectedElement->tagName,
2045
+			$actualElement->tagName,
2046
+			$message
2047
+		);
2048
+
2049
+		if ($checkAttributes) {
2050
+			static::assertEquals(
2051
+				$expectedElement->attributes->length,
2052
+				$actualElement->attributes->length,
2053
+				\sprintf(
2054
+					'%s%sNumber of attributes on node "%s" does not match',
2055
+					$message,
2056
+					!empty($message) ? "\n" : '',
2057
+					$expectedElement->tagName
2058
+				)
2059
+			);
2060
+
2061
+			for ($i = 0; $i < $expectedElement->attributes->length; $i++) {
2062
+				$expectedAttribute = $expectedElement->attributes->item($i);
2063
+				$actualAttribute   = $actualElement->attributes->getNamedItem(
2064
+					$expectedAttribute->name
2065
+				);
2066
+
2067
+				if (!$actualAttribute) {
2068
+					static::fail(
2069
+						\sprintf(
2070
+							'%s%sCould not find attribute "%s" on node "%s"',
2071
+							$message,
2072
+							!empty($message) ? "\n" : '',
2073
+							$expectedAttribute->name,
2074
+							$expectedElement->tagName
2075
+						)
2076
+					);
2077
+				}
2078
+			}
2079
+		}
2080
+
2081
+		Xml::removeCharacterDataNodes($expectedElement);
2082
+		Xml::removeCharacterDataNodes($actualElement);
2083
+
2084
+		static::assertEquals(
2085
+			$expectedElement->childNodes->length,
2086
+			$actualElement->childNodes->length,
2087
+			\sprintf(
2088
+				'%s%sNumber of child nodes of "%s" differs',
2089
+				$message,
2090
+				!empty($message) ? "\n" : '',
2091
+				$expectedElement->tagName
2092
+			)
2093
+		);
2094
+
2095
+		for ($i = 0; $i < $expectedElement->childNodes->length; $i++) {
2096
+			static::assertEqualXMLStructure(
2097
+				$expectedElement->childNodes->item($i),
2098
+				$actualElement->childNodes->item($i),
2099
+				$checkAttributes,
2100
+				$message
2101
+			);
2102
+		}
2103
+	}
2104
+
2105
+	/**
2106
+	 * Evaluates a PHPUnit\Framework\Constraint matcher object.
2107
+	 *
2108
+	 * @param mixed      $value
2109
+	 * @param Constraint $constraint
2110
+	 * @param string     $message
2111
+	 */
2112
+	public static function assertThat($value, Constraint $constraint, $message = '')
2113
+	{
2114
+		self::$count += \count($constraint);
2115
+
2116
+		$constraint->evaluate($value, $message);
2117
+	}
2118
+
2119
+	/**
2120
+	 * Asserts that a string is a valid JSON string.
2121
+	 *
2122
+	 * @param string $actualJson
2123
+	 * @param string $message
2124
+	 */
2125
+	public static function assertJson($actualJson, $message = '')
2126
+	{
2127
+		if (!\is_string($actualJson)) {
2128
+			throw InvalidArgumentHelper::factory(1, 'string');
2129
+		}
2130
+
2131
+		static::assertThat($actualJson, static::isJson(), $message);
2132
+	}
2133
+
2134
+	/**
2135
+	 * Asserts that two given JSON encoded objects or arrays are equal.
2136
+	 *
2137
+	 * @param string $expectedJson
2138
+	 * @param string $actualJson
2139
+	 * @param string $message
2140
+	 */
2141
+	public static function assertJsonStringEqualsJsonString($expectedJson, $actualJson, $message = '')
2142
+	{
2143
+		static::assertJson($expectedJson, $message);
2144
+		static::assertJson($actualJson, $message);
2145
+
2146
+		$constraint = new JsonMatches(
2147
+			$expectedJson
2148
+		);
2149
+
2150
+		static::assertThat($actualJson, $constraint, $message);
2151
+	}
2152
+
2153
+	/**
2154
+	 * Asserts that two given JSON encoded objects or arrays are not equal.
2155
+	 *
2156
+	 * @param string $expectedJson
2157
+	 * @param string $actualJson
2158
+	 * @param string $message
2159
+	 */
2160
+	public static function assertJsonStringNotEqualsJsonString($expectedJson, $actualJson, $message = '')
2161
+	{
2162
+		static::assertJson($expectedJson, $message);
2163
+		static::assertJson($actualJson, $message);
2164
+
2165
+		$constraint = new JsonMatches(
2166
+			$expectedJson
2167
+		);
2168
+
2169
+		static::assertThat($actualJson, new LogicalNot($constraint), $message);
2170
+	}
2171
+
2172
+	/**
2173
+	 * Asserts that the generated JSON encoded object and the content of the given file are equal.
2174
+	 *
2175
+	 * @param string $expectedFile
2176
+	 * @param string $actualJson
2177
+	 * @param string $message
2178
+	 */
2179
+	public static function assertJsonStringEqualsJsonFile($expectedFile, $actualJson, $message = '')
2180
+	{
2181
+		static::assertFileExists($expectedFile, $message);
2182
+		$expectedJson = \file_get_contents($expectedFile);
2183
+
2184
+		static::assertJson($expectedJson, $message);
2185
+		static::assertJson($actualJson, $message);
2186
+
2187
+		$constraint = new JsonMatches(
2188
+			$expectedJson
2189
+		);
2190
+
2191
+		static::assertThat($actualJson, $constraint, $message);
2192
+	}
2193
+
2194
+	/**
2195
+	 * Asserts that the generated JSON encoded object and the content of the given file are not equal.
2196
+	 *
2197
+	 * @param string $expectedFile
2198
+	 * @param string $actualJson
2199
+	 * @param string $message
2200
+	 */
2201
+	public static function assertJsonStringNotEqualsJsonFile($expectedFile, $actualJson, $message = '')
2202
+	{
2203
+		static::assertFileExists($expectedFile, $message);
2204
+		$expectedJson = \file_get_contents($expectedFile);
2205
+
2206
+		static::assertJson($expectedJson, $message);
2207
+		static::assertJson($actualJson, $message);
2208
+
2209
+		$constraint = new JsonMatches(
2210
+			$expectedJson
2211
+		);
2212
+
2213
+		static::assertThat($actualJson, new LogicalNot($constraint), $message);
2214
+	}
2215
+
2216
+	/**
2217
+	 * Asserts that two JSON files are equal.
2218
+	 *
2219
+	 * @param string $expectedFile
2220
+	 * @param string $actualFile
2221
+	 * @param string $message
2222
+	 */
2223
+	public static function assertJsonFileEqualsJsonFile($expectedFile, $actualFile, $message = '')
2224
+	{
2225
+		static::assertFileExists($expectedFile, $message);
2226
+		static::assertFileExists($actualFile, $message);
2227
+
2228
+		$actualJson   = \file_get_contents($actualFile);
2229
+		$expectedJson = \file_get_contents($expectedFile);
2230
+
2231
+		static::assertJson($expectedJson, $message);
2232
+		static::assertJson($actualJson, $message);
2233
+
2234
+		$constraintExpected = new JsonMatches(
2235
+			$expectedJson
2236
+		);
2237
+
2238
+		$constraintActual = new JsonMatches($actualJson);
2239
+
2240
+		static::assertThat($expectedJson, $constraintActual, $message);
2241
+		static::assertThat($actualJson, $constraintExpected, $message);
2242
+	}
2243
+
2244
+	/**
2245
+	 * Asserts that two JSON files are not equal.
2246
+	 *
2247
+	 * @param string $expectedFile
2248
+	 * @param string $actualFile
2249
+	 * @param string $message
2250
+	 */
2251
+	public static function assertJsonFileNotEqualsJsonFile($expectedFile, $actualFile, $message = '')
2252
+	{
2253
+		static::assertFileExists($expectedFile, $message);
2254
+		static::assertFileExists($actualFile, $message);
2255
+
2256
+		$actualJson   = \file_get_contents($actualFile);
2257
+		$expectedJson = \file_get_contents($expectedFile);
2258
+
2259
+		static::assertJson($expectedJson, $message);
2260
+		static::assertJson($actualJson, $message);
2261
+
2262
+		$constraintExpected = new JsonMatches(
2263
+			$expectedJson
2264
+		);
2265
+
2266
+		$constraintActual = new JsonMatches($actualJson);
2267
+
2268
+		static::assertThat($expectedJson, new LogicalNot($constraintActual), $message);
2269
+		static::assertThat($actualJson, new LogicalNot($constraintExpected), $message);
2270
+	}
2271
+
2272
+	/**
2273
+	 * @return LogicalAnd
2274
+	 */
2275
+	public static function logicalAnd()
2276
+	{
2277
+		$constraints = \func_get_args();
2278
+
2279
+		$constraint = new LogicalAnd;
2280
+		$constraint->setConstraints($constraints);
2281
+
2282
+		return $constraint;
2283
+	}
2284
+
2285
+	/**
2286
+	 * @return LogicalOr
2287
+	 */
2288
+	public static function logicalOr()
2289
+	{
2290
+		$constraints = \func_get_args();
2291
+
2292
+		$constraint = new LogicalOr;
2293
+		$constraint->setConstraints($constraints);
2294
+
2295
+		return $constraint;
2296
+	}
2297
+
2298
+	/**
2299
+	 * @param Constraint $constraint
2300
+	 *
2301
+	 * @return LogicalNot
2302
+	 */
2303
+	public static function logicalNot(Constraint $constraint)
2304
+	{
2305
+		return new LogicalNot($constraint);
2306
+	}
2307
+
2308
+	/**
2309
+	 * @return LogicalXor
2310
+	 */
2311
+	public static function logicalXor()
2312
+	{
2313
+		$constraints = \func_get_args();
2314
+
2315
+		$constraint = new LogicalXor;
2316
+		$constraint->setConstraints($constraints);
2317
+
2318
+		return $constraint;
2319
+	}
2320
+
2321
+	/**
2322
+	 * @return IsAnything
2323
+	 */
2324
+	public static function anything()
2325
+	{
2326
+		return new IsAnything;
2327
+	}
2328
+
2329
+	/**
2330
+	 * @return IsTrue
2331
+	 */
2332
+	public static function isTrue()
2333
+	{
2334
+		return new IsTrue;
2335
+	}
2336
+
2337
+	/**
2338
+	 * @param callable $callback
2339
+	 *
2340
+	 * @return Callback
2341
+	 */
2342
+	public static function callback($callback)
2343
+	{
2344
+		return new Callback($callback);
2345
+	}
2346
+
2347
+	/**
2348
+	 * @return IsFalse
2349
+	 */
2350
+	public static function isFalse()
2351
+	{
2352
+		return new IsFalse;
2353
+	}
2354
+
2355
+	/**
2356
+	 * @return IsJson
2357
+	 */
2358
+	public static function isJson()
2359
+	{
2360
+		return new IsJson;
2361
+	}
2362
+
2363
+	/**
2364
+	 * @return IsNull
2365
+	 */
2366
+	public static function isNull()
2367
+	{
2368
+		return new IsNull;
2369
+	}
2370
+
2371
+	/**
2372
+	 * @return IsFinite
2373
+	 */
2374
+	public static function isFinite()
2375
+	{
2376
+		return new IsFinite;
2377
+	}
2378
+
2379
+	/**
2380
+	 * @return IsInfinite
2381
+	 */
2382
+	public static function isInfinite()
2383
+	{
2384
+		return new IsInfinite;
2385
+	}
2386
+
2387
+	/**
2388
+	 * @return IsNan
2389
+	 */
2390
+	public static function isNan()
2391
+	{
2392
+		return new IsNan;
2393
+	}
2394
+
2395
+	/**
2396
+	 * @param Constraint $constraint
2397
+	 * @param string     $attributeName
2398
+	 *
2399
+	 * @return Attribute
2400
+	 */
2401
+	public static function attribute(Constraint $constraint, $attributeName)
2402
+	{
2403
+		return new Attribute(
2404
+			$constraint,
2405
+			$attributeName
2406
+		);
2407
+	}
2408
+
2409
+	/**
2410
+	 * @param mixed $value
2411
+	 * @param bool  $checkForObjectIdentity
2412
+	 * @param bool  $checkForNonObjectIdentity
2413
+	 *
2414
+	 * @return TraversableContains
2415
+	 */
2416
+	public static function contains($value, $checkForObjectIdentity = true, $checkForNonObjectIdentity = false)
2417
+	{
2418
+		return new TraversableContains($value, $checkForObjectIdentity, $checkForNonObjectIdentity);
2419
+	}
2420
+
2421
+	/**
2422
+	 * @param string $type
2423
+	 *
2424
+	 * @return TraversableContainsOnly
2425
+	 */
2426
+	public static function containsOnly($type)
2427
+	{
2428
+		return new TraversableContainsOnly($type);
2429
+	}
2430
+
2431
+	/**
2432
+	 * @param string $classname
2433
+	 *
2434
+	 * @return TraversableContainsOnly
2435
+	 */
2436
+	public static function containsOnlyInstancesOf($classname)
2437
+	{
2438
+		return new TraversableContainsOnly($classname, false);
2439
+	}
2440
+
2441
+	/**
2442
+	 * @param mixed $key
2443
+	 *
2444
+	 * @return ArrayHasKey
2445
+	 */
2446
+	public static function arrayHasKey($key)
2447
+	{
2448
+		return new ArrayHasKey($key);
2449
+	}
2450
+
2451
+	/**
2452
+	 * @param mixed $value
2453
+	 * @param float $delta
2454
+	 * @param int   $maxDepth
2455
+	 * @param bool  $canonicalize
2456
+	 * @param bool  $ignoreCase
2457
+	 *
2458
+	 * @return IsEqual
2459
+	 */
2460
+	public static function equalTo($value, $delta = 0.0, $maxDepth = 10, $canonicalize = false, $ignoreCase = false)
2461
+	{
2462
+		return new IsEqual(
2463
+			$value,
2464
+			$delta,
2465
+			$maxDepth,
2466
+			$canonicalize,
2467
+			$ignoreCase
2468
+		);
2469
+	}
2470
+
2471
+	/**
2472
+	 * @param string $attributeName
2473
+	 * @param mixed  $value
2474
+	 * @param float  $delta
2475
+	 * @param int    $maxDepth
2476
+	 * @param bool   $canonicalize
2477
+	 * @param bool   $ignoreCase
2478
+	 *
2479
+	 * @return Attribute
2480
+	 */
2481
+	public static function attributeEqualTo($attributeName, $value, $delta = 0.0, $maxDepth = 10, $canonicalize = false, $ignoreCase = false)
2482
+	{
2483
+		return static::attribute(
2484
+			static::equalTo(
2485
+				$value,
2486
+				$delta,
2487
+				$maxDepth,
2488
+				$canonicalize,
2489
+				$ignoreCase
2490
+			),
2491
+			$attributeName
2492
+		);
2493
+	}
2494
+
2495
+	/**
2496
+	 * @return IsEmpty
2497
+	 */
2498
+	public static function isEmpty()
2499
+	{
2500
+		return new IsEmpty;
2501
+	}
2502
+
2503
+	/**
2504
+	 * @return IsWritable
2505
+	 */
2506
+	public static function isWritable()
2507
+	{
2508
+		return new IsWritable;
2509
+	}
2510
+
2511
+	/**
2512
+	 * @return IsReadable
2513
+	 */
2514
+	public static function isReadable()
2515
+	{
2516
+		return new IsReadable;
2517
+	}
2518
+
2519
+	/**
2520
+	 * @return DirectoryExists
2521
+	 */
2522
+	public static function directoryExists()
2523
+	{
2524
+		return new DirectoryExists;
2525
+	}
2526
+
2527
+	/**
2528
+	 * @return FileExists
2529
+	 */
2530
+	public static function fileExists()
2531
+	{
2532
+		return new FileExists;
2533
+	}
2534
+
2535
+	/**
2536
+	 * @param mixed $value
2537
+	 *
2538
+	 * @return GreaterThan
2539
+	 */
2540
+	public static function greaterThan($value)
2541
+	{
2542
+		return new GreaterThan($value);
2543
+	}
2544
+
2545
+	/**
2546
+	 * @param mixed $value
2547
+	 *
2548
+	 * @return LogicalOr
2549
+	 */
2550
+	public static function greaterThanOrEqual($value)
2551
+	{
2552
+		return static::logicalOr(
2553
+			new IsEqual($value),
2554
+			new GreaterThan($value)
2555
+		);
2556
+	}
2557
+
2558
+	/**
2559
+	 * @param string $attributeName
2560
+	 *
2561
+	 * @return ClassHasAttribute
2562
+	 */
2563
+	public static function classHasAttribute($attributeName)
2564
+	{
2565
+		return new ClassHasAttribute(
2566
+			$attributeName
2567
+		);
2568
+	}
2569
+
2570
+	/**
2571
+	 * @param string $attributeName
2572
+	 *
2573
+	 * @return ClassHasStaticAttribute
2574
+	 */
2575
+	public static function classHasStaticAttribute($attributeName)
2576
+	{
2577
+		return new ClassHasStaticAttribute(
2578
+			$attributeName
2579
+		);
2580
+	}
2581
+
2582
+	/**
2583
+	 * @param string $attributeName
2584
+	 *
2585
+	 * @return ObjectHasAttribute
2586
+	 */
2587
+	public static function objectHasAttribute($attributeName)
2588
+	{
2589
+		return new ObjectHasAttribute(
2590
+			$attributeName
2591
+		);
2592
+	}
2593
+
2594
+	/**
2595
+	 * @param mixed $value
2596
+	 *
2597
+	 * @return IsIdentical
2598
+	 */
2599
+	public static function identicalTo($value)
2600
+	{
2601
+		return new IsIdentical($value);
2602
+	}
2603
+
2604
+	/**
2605
+	 * @param string $className
2606
+	 *
2607
+	 * @return IsInstanceOf
2608
+	 */
2609
+	public static function isInstanceOf($className)
2610
+	{
2611
+		return new IsInstanceOf($className);
2612
+	}
2613
+
2614
+	/**
2615
+	 * @param string $type
2616
+	 *
2617
+	 * @return IsType
2618
+	 */
2619
+	public static function isType($type)
2620
+	{
2621
+		return new IsType($type);
2622
+	}
2623
+
2624
+	/**
2625
+	 * @param mixed $value
2626
+	 *
2627
+	 * @return LessThan
2628
+	 */
2629
+	public static function lessThan($value)
2630
+	{
2631
+		return new LessThan($value);
2632
+	}
2633
+
2634
+	/**
2635
+	 * @param mixed $value
2636
+	 *
2637
+	 * @return LogicalOr
2638
+	 */
2639
+	public static function lessThanOrEqual($value)
2640
+	{
2641
+		return static::logicalOr(
2642
+			new IsEqual($value),
2643
+			new LessThan($value)
2644
+		);
2645
+	}
2646
+
2647
+	/**
2648
+	 * @param string $pattern
2649
+	 *
2650
+	 * @return RegularExpression
2651
+	 */
2652
+	public static function matchesRegularExpression($pattern)
2653
+	{
2654
+		return new RegularExpression($pattern);
2655
+	}
2656
+
2657
+	/**
2658
+	 * @param string $string
2659
+	 *
2660
+	 * @return StringMatchesFormatDescription
2661
+	 */
2662
+	public static function matches($string)
2663
+	{
2664
+		return new StringMatchesFormatDescription($string);
2665
+	}
2666
+
2667
+	/**
2668
+	 * @param mixed $prefix
2669
+	 *
2670
+	 * @return StringStartsWith
2671
+	 */
2672
+	public static function stringStartsWith($prefix)
2673
+	{
2674
+		return new StringStartsWith($prefix);
2675
+	}
2676
+
2677
+	/**
2678
+	 * @param string $string
2679
+	 * @param bool   $case
2680
+	 *
2681
+	 * @return StringContains
2682
+	 */
2683
+	public static function stringContains($string, $case = true)
2684
+	{
2685
+		return new StringContains($string, $case);
2686
+	}
2687
+
2688
+	/**
2689
+	 * @param mixed $suffix
2690
+	 *
2691
+	 * @return StringEndsWith
2692
+	 */
2693
+	public static function stringEndsWith($suffix)
2694
+	{
2695
+		return new StringEndsWith($suffix);
2696
+	}
2697
+
2698
+	/**
2699
+	 * @param int $count
2700
+	 *
2701
+	 * @return Count
2702
+	 */
2703
+	public static function countOf($count)
2704
+	{
2705
+		return new Count($count);
2706
+	}
2707
+
2708
+	/**
2709
+	 * Fails a test with the given message.
2710
+	 *
2711
+	 * @param string $message
2712
+	 *
2713
+	 * @throws AssertionFailedError
2714
+	 */
2715
+	public static function fail($message = '')
2716
+	{
2717
+		self::$count++;
2718
+
2719
+		throw new AssertionFailedError($message);
2720
+	}
2721
+
2722
+	/**
2723
+	 * Returns the value of an attribute of a class or an object.
2724
+	 * This also works for attributes that are declared protected or private.
2725
+	 *
2726
+	 * @param string|object $classOrObject
2727
+	 * @param string        $attributeName
2728
+	 *
2729
+	 * @return mixed
2730
+	 *
2731
+	 * @throws Exception
2732
+	 */
2733
+	public static function readAttribute($classOrObject, $attributeName)
2734
+	{
2735
+		if (!\is_string($attributeName)) {
2736
+			throw InvalidArgumentHelper::factory(2, 'string');
2737
+		}
2738
+
2739
+		if (!\preg_match('/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/', $attributeName)) {
2740
+			throw InvalidArgumentHelper::factory(2, 'valid attribute name');
2741
+		}
2742
+
2743
+		if (\is_string($classOrObject)) {
2744
+			if (!\class_exists($classOrObject)) {
2745
+				throw InvalidArgumentHelper::factory(
2746
+					1,
2747
+					'class name'
2748
+				);
2749
+			}
2750
+
2751
+			return static::getStaticAttribute(
2752
+				$classOrObject,
2753
+				$attributeName
2754
+			);
2755
+		}
2756
+
2757
+		if (\is_object($classOrObject)) {
2758
+			return static::getObjectAttribute(
2759
+				$classOrObject,
2760
+				$attributeName
2761
+			);
2762
+		}
2763
+
2764
+		throw InvalidArgumentHelper::factory(
2765
+			1,
2766
+			'class name or object'
2767
+		);
2768
+	}
2769
+
2770
+	/**
2771
+	 * Returns the value of a static attribute.
2772
+	 * This also works for attributes that are declared protected or private.
2773
+	 *
2774
+	 * @param string $className
2775
+	 * @param string $attributeName
2776
+	 *
2777
+	 * @return mixed
2778
+	 *
2779
+	 * @throws Exception
2780
+	 */
2781
+	public static function getStaticAttribute($className, $attributeName)
2782
+	{
2783
+		if (!\is_string($className)) {
2784
+			throw InvalidArgumentHelper::factory(1, 'string');
2785
+		}
2786
+
2787
+		if (!\class_exists($className)) {
2788
+			throw InvalidArgumentHelper::factory(1, 'class name');
2789
+		}
2790
+
2791
+		if (!\is_string($attributeName)) {
2792
+			throw InvalidArgumentHelper::factory(2, 'string');
2793
+		}
2794
+
2795
+		if (!\preg_match('/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/', $attributeName)) {
2796
+			throw InvalidArgumentHelper::factory(2, 'valid attribute name');
2797
+		}
2798
+
2799
+		$class = new ReflectionClass($className);
2800
+
2801
+		while ($class) {
2802
+			$attributes = $class->getStaticProperties();
2803
+
2804
+			if (\array_key_exists($attributeName, $attributes)) {
2805
+				return $attributes[$attributeName];
2806
+			}
2807
+
2808
+			$class = $class->getParentClass();
2809
+		}
2810
+
2811
+		throw new Exception(
2812
+			\sprintf(
2813
+				'Attribute "%s" not found in class.',
2814
+				$attributeName
2815
+			)
2816
+		);
2817
+	}
2818
+
2819
+	/**
2820
+	 * Returns the value of an object's attribute.
2821
+	 * This also works for attributes that are declared protected or private.
2822
+	 *
2823
+	 * @param object $object
2824
+	 * @param string $attributeName
2825
+	 *
2826
+	 * @return mixed
2827
+	 *
2828
+	 * @throws Exception
2829
+	 */
2830
+	public static function getObjectAttribute($object, $attributeName)
2831
+	{
2832
+		if (!\is_object($object)) {
2833
+			throw InvalidArgumentHelper::factory(1, 'object');
2834
+		}
2835
+
2836
+		if (!\is_string($attributeName)) {
2837
+			throw InvalidArgumentHelper::factory(2, 'string');
2838
+		}
2839
+
2840
+		if (!\preg_match('/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/', $attributeName)) {
2841
+			throw InvalidArgumentHelper::factory(2, 'valid attribute name');
2842
+		}
2843
+
2844
+		try {
2845
+			$attribute = new ReflectionProperty($object, $attributeName);
2846
+		} catch (ReflectionException $e) {
2847
+			$reflector = new ReflectionObject($object);
2848
+
2849
+			while ($reflector = $reflector->getParentClass()) {
2850
+				try {
2851
+					$attribute = $reflector->getProperty($attributeName);
2852
+
2853
+					break;
2854
+				} catch (ReflectionException $e) {
2855
+				}
2856
+			}
2857
+		}
2858
+
2859
+		if (isset($attribute)) {
2860
+			if (!$attribute || $attribute->isPublic()) {
2861
+				return $object->$attributeName;
2862
+			}
2863
+
2864
+			$attribute->setAccessible(true);
2865
+			$value = $attribute->getValue($object);
2866
+			$attribute->setAccessible(false);
2867
+
2868
+			return $value;
2869
+		}
2870
+
2871
+		throw new Exception(
2872
+			\sprintf(
2873
+				'Attribute "%s" not found in object.',
2874
+				$attributeName
2875
+			)
2876
+		);
2877
+	}
2878
+
2879
+	/**
2880
+	 * Mark the test as incomplete.
2881
+	 *
2882
+	 * @param string $message
2883
+	 *
2884
+	 * @throws IncompleteTestError
2885
+	 */
2886
+	public static function markTestIncomplete($message = '')
2887
+	{
2888
+		throw new IncompleteTestError($message);
2889
+	}
2890
+
2891
+	/**
2892
+	 * Mark the test as skipped.
2893
+	 *
2894
+	 * @param string $message
2895
+	 *
2896
+	 * @throws SkippedTestError
2897
+	 */
2898
+	public static function markTestSkipped($message = '')
2899
+	{
2900
+		throw new SkippedTestError($message);
2901
+	}
2902
+
2903
+	/**
2904
+	 * Return the current assertion count.
2905
+	 *
2906
+	 * @return int
2907
+	 */
2908
+	public static function getCount()
2909
+	{
2910
+		return self::$count;
2911
+	}
2912
+
2913
+	/**
2914
+	 * Reset the assertion counter.
2915
+	 */
2916
+	public static function resetCount()
2917
+	{
2918
+		self::$count = 0;
2919
+	}
2920 2920
 }
Please login to merge, or discard this patch.
vendor/phpunit/phpunit/src/Framework/TestResult.php 2 patches
Indentation   +1273 added lines, -1273 removed lines patch added patch discarded remove patch
@@ -34,1277 +34,1277 @@
 block discarded – undo
34 34
  */
35 35
 class TestResult implements Countable
36 36
 {
37
-    /**
38
-     * @var array
39
-     */
40
-    protected $passed = [];
41
-
42
-    /**
43
-     * @var array
44
-     */
45
-    protected $errors = [];
46
-
47
-    /**
48
-     * @var array
49
-     */
50
-    protected $failures = [];
51
-
52
-    /**
53
-     * @var array
54
-     */
55
-    protected $warnings = [];
56
-
57
-    /**
58
-     * @var array
59
-     */
60
-    protected $notImplemented = [];
61
-
62
-    /**
63
-     * @var array
64
-     */
65
-    protected $risky = [];
66
-
67
-    /**
68
-     * @var array
69
-     */
70
-    protected $skipped = [];
71
-
72
-    /**
73
-     * @var array
74
-     */
75
-    protected $listeners = [];
76
-
77
-    /**
78
-     * @var int
79
-     */
80
-    protected $runTests = 0;
81
-
82
-    /**
83
-     * @var float
84
-     */
85
-    protected $time = 0;
86
-
87
-    /**
88
-     * @var TestSuite
89
-     */
90
-    protected $topTestSuite;
91
-
92
-    /**
93
-     * Code Coverage information.
94
-     *
95
-     * @var CodeCoverage
96
-     */
97
-    protected $codeCoverage;
98
-
99
-    /**
100
-     * @var bool
101
-     */
102
-    protected $convertErrorsToExceptions = true;
103
-
104
-    /**
105
-     * @var bool
106
-     */
107
-    protected $stop = false;
108
-
109
-    /**
110
-     * @var bool
111
-     */
112
-    protected $stopOnError = false;
113
-
114
-    /**
115
-     * @var bool
116
-     */
117
-    protected $stopOnFailure = false;
118
-
119
-    /**
120
-     * @var bool
121
-     */
122
-    protected $stopOnWarning = false;
123
-
124
-    /**
125
-     * @var bool
126
-     */
127
-    protected $beStrictAboutTestsThatDoNotTestAnything = true;
128
-
129
-    /**
130
-     * @var bool
131
-     */
132
-    protected $beStrictAboutOutputDuringTests = false;
133
-
134
-    /**
135
-     * @var bool
136
-     */
137
-    protected $beStrictAboutTodoAnnotatedTests = false;
138
-
139
-    /**
140
-     * @var bool
141
-     */
142
-    protected $beStrictAboutResourceUsageDuringSmallTests = false;
143
-
144
-    /**
145
-     * @var bool
146
-     */
147
-    protected $enforceTimeLimit = false;
148
-
149
-    /**
150
-     * @var int
151
-     */
152
-    protected $timeoutForSmallTests = 1;
153
-
154
-    /**
155
-     * @var int
156
-     */
157
-    protected $timeoutForMediumTests = 10;
158
-
159
-    /**
160
-     * @var int
161
-     */
162
-    protected $timeoutForLargeTests = 60;
163
-
164
-    /**
165
-     * @var bool
166
-     */
167
-    protected $stopOnRisky = false;
168
-
169
-    /**
170
-     * @var bool
171
-     */
172
-    protected $stopOnIncomplete = false;
173
-
174
-    /**
175
-     * @var bool
176
-     */
177
-    protected $stopOnSkipped = false;
178
-
179
-    /**
180
-     * @var bool
181
-     */
182
-    protected $lastTestFailed = false;
183
-
184
-    /**
185
-     * @var bool
186
-     */
187
-    private $registerMockObjectsFromTestArgumentsRecursively = false;
188
-
189
-    /**
190
-     * Registers a TestListener.
191
-     *
192
-     * @param TestListener $listener
193
-     */
194
-    public function addListener(TestListener $listener)
195
-    {
196
-        $this->listeners[] = $listener;
197
-    }
198
-
199
-    /**
200
-     * Unregisters a TestListener.
201
-     *
202
-     * @param TestListener $listener
203
-     */
204
-    public function removeListener(TestListener $listener)
205
-    {
206
-        foreach ($this->listeners as $key => $_listener) {
207
-            if ($listener === $_listener) {
208
-                unset($this->listeners[$key]);
209
-            }
210
-        }
211
-    }
212
-
213
-    /**
214
-     * Flushes all flushable TestListeners.
215
-     */
216
-    public function flushListeners()
217
-    {
218
-        foreach ($this->listeners as $listener) {
219
-            if ($listener instanceof Printer) {
220
-                $listener->flush();
221
-            }
222
-        }
223
-    }
224
-
225
-    /**
226
-     * Adds an error to the list of errors.
227
-     *
228
-     * @param Test      $test
229
-     * @param Throwable $t
230
-     * @param float     $time
231
-     */
232
-    public function addError(Test $test, Throwable $t, $time)
233
-    {
234
-        if ($t instanceof RiskyTest) {
235
-            $this->risky[] = new TestFailure($test, $t);
236
-            $notifyMethod  = 'addRiskyTest';
237
-
238
-            if ($test instanceof TestCase) {
239
-                $test->markAsRisky();
240
-            }
241
-
242
-            if ($this->stopOnRisky) {
243
-                $this->stop();
244
-            }
245
-        } elseif ($t instanceof IncompleteTest) {
246
-            $this->notImplemented[] = new TestFailure($test, $t);
247
-            $notifyMethod           = 'addIncompleteTest';
248
-
249
-            if ($this->stopOnIncomplete) {
250
-                $this->stop();
251
-            }
252
-        } elseif ($t instanceof SkippedTest) {
253
-            $this->skipped[] = new TestFailure($test, $t);
254
-            $notifyMethod    = 'addSkippedTest';
255
-
256
-            if ($this->stopOnSkipped) {
257
-                $this->stop();
258
-            }
259
-        } else {
260
-            $this->errors[] = new TestFailure($test, $t);
261
-            $notifyMethod   = 'addError';
262
-
263
-            if ($this->stopOnError || $this->stopOnFailure) {
264
-                $this->stop();
265
-            }
266
-        }
267
-
268
-        // @see https://github.com/sebastianbergmann/phpunit/issues/1953
269
-        if ($t instanceof Error) {
270
-            $t = new ExceptionWrapper($t);
271
-        }
272
-
273
-        foreach ($this->listeners as $listener) {
274
-            $listener->$notifyMethod($test, $t, $time);
275
-        }
276
-
277
-        $this->lastTestFailed = true;
278
-        $this->time += $time;
279
-    }
280
-
281
-    /**
282
-     * Adds a warning to the list of warnings.
283
-     * The passed in exception caused the warning.
284
-     *
285
-     * @param Test    $test
286
-     * @param Warning $e
287
-     * @param float   $time
288
-     */
289
-    public function addWarning(Test $test, Warning $e, $time)
290
-    {
291
-        if ($this->stopOnWarning) {
292
-            $this->stop();
293
-        }
294
-
295
-        $this->warnings[] = new TestFailure($test, $e);
296
-
297
-        foreach ($this->listeners as $listener) {
298
-            $listener->addWarning($test, $e, $time);
299
-        }
300
-
301
-        $this->time += $time;
302
-    }
303
-
304
-    /**
305
-     * Adds a failure to the list of failures.
306
-     * The passed in exception caused the failure.
307
-     *
308
-     * @param Test                 $test
309
-     * @param AssertionFailedError $e
310
-     * @param float                $time
311
-     */
312
-    public function addFailure(Test $test, AssertionFailedError $e, $time)
313
-    {
314
-        if ($e instanceof RiskyTest || $e instanceof OutputError) {
315
-            $this->risky[] = new TestFailure($test, $e);
316
-            $notifyMethod  = 'addRiskyTest';
317
-
318
-            if ($test instanceof TestCase) {
319
-                $test->markAsRisky();
320
-            }
321
-
322
-            if ($this->stopOnRisky) {
323
-                $this->stop();
324
-            }
325
-        } elseif ($e instanceof IncompleteTest) {
326
-            $this->notImplemented[] = new TestFailure($test, $e);
327
-            $notifyMethod           = 'addIncompleteTest';
328
-
329
-            if ($this->stopOnIncomplete) {
330
-                $this->stop();
331
-            }
332
-        } elseif ($e instanceof SkippedTest) {
333
-            $this->skipped[] = new TestFailure($test, $e);
334
-            $notifyMethod    = 'addSkippedTest';
335
-
336
-            if ($this->stopOnSkipped) {
337
-                $this->stop();
338
-            }
339
-        } else {
340
-            $this->failures[] = new TestFailure($test, $e);
341
-            $notifyMethod     = 'addFailure';
342
-
343
-            if ($this->stopOnFailure) {
344
-                $this->stop();
345
-            }
346
-        }
347
-
348
-        foreach ($this->listeners as $listener) {
349
-            $listener->$notifyMethod($test, $e, $time);
350
-        }
351
-
352
-        $this->lastTestFailed = true;
353
-        $this->time += $time;
354
-    }
355
-
356
-    /**
357
-     * Informs the result that a testsuite will be started.
358
-     *
359
-     * @param TestSuite $suite
360
-     */
361
-    public function startTestSuite(TestSuite $suite)
362
-    {
363
-        if ($this->topTestSuite === null) {
364
-            $this->topTestSuite = $suite;
365
-        }
366
-
367
-        foreach ($this->listeners as $listener) {
368
-            $listener->startTestSuite($suite);
369
-        }
370
-    }
371
-
372
-    /**
373
-     * Informs the result that a testsuite was completed.
374
-     *
375
-     * @param TestSuite $suite
376
-     */
377
-    public function endTestSuite(TestSuite $suite)
378
-    {
379
-        foreach ($this->listeners as $listener) {
380
-            $listener->endTestSuite($suite);
381
-        }
382
-    }
383
-
384
-    /**
385
-     * Informs the result that a test will be started.
386
-     *
387
-     * @param Test $test
388
-     */
389
-    public function startTest(Test $test)
390
-    {
391
-        $this->lastTestFailed = false;
392
-        $this->runTests += \count($test);
393
-
394
-        foreach ($this->listeners as $listener) {
395
-            $listener->startTest($test);
396
-        }
397
-    }
398
-
399
-    /**
400
-     * Informs the result that a test was completed.
401
-     *
402
-     * @param Test  $test
403
-     * @param float $time
404
-     */
405
-    public function endTest(Test $test, $time)
406
-    {
407
-        foreach ($this->listeners as $listener) {
408
-            $listener->endTest($test, $time);
409
-        }
410
-
411
-        if (!$this->lastTestFailed && $test instanceof TestCase) {
412
-            $class = \get_class($test);
413
-            $key   = $class . '::' . $test->getName();
414
-
415
-            $this->passed[$key] = [
416
-                'result' => $test->getResult(),
417
-                'size'   => \PHPUnit\Util\Test::getSize(
418
-                    $class,
419
-                    $test->getName(false)
420
-                )
421
-            ];
422
-
423
-            $this->time += $time;
424
-        }
425
-    }
426
-
427
-    /**
428
-     * Returns true if no risky test occurred.
429
-     *
430
-     * @return bool
431
-     */
432
-    public function allHarmless()
433
-    {
434
-        return $this->riskyCount() == 0;
435
-    }
436
-
437
-    /**
438
-     * Gets the number of risky tests.
439
-     *
440
-     * @return int
441
-     */
442
-    public function riskyCount()
443
-    {
444
-        return \count($this->risky);
445
-    }
446
-
447
-    /**
448
-     * Returns true if no incomplete test occurred.
449
-     *
450
-     * @return bool
451
-     */
452
-    public function allCompletelyImplemented()
453
-    {
454
-        return $this->notImplementedCount() == 0;
455
-    }
456
-
457
-    /**
458
-     * Gets the number of incomplete tests.
459
-     *
460
-     * @return int
461
-     */
462
-    public function notImplementedCount()
463
-    {
464
-        return \count($this->notImplemented);
465
-    }
466
-
467
-    /**
468
-     * Returns an Enumeration for the risky tests.
469
-     *
470
-     * @return array
471
-     */
472
-    public function risky()
473
-    {
474
-        return $this->risky;
475
-    }
476
-
477
-    /**
478
-     * Returns an Enumeration for the incomplete tests.
479
-     *
480
-     * @return array
481
-     */
482
-    public function notImplemented()
483
-    {
484
-        return $this->notImplemented;
485
-    }
486
-
487
-    /**
488
-     * Returns true if no test has been skipped.
489
-     *
490
-     * @return bool
491
-     */
492
-    public function noneSkipped()
493
-    {
494
-        return $this->skippedCount() == 0;
495
-    }
496
-
497
-    /**
498
-     * Gets the number of skipped tests.
499
-     *
500
-     * @return int
501
-     */
502
-    public function skippedCount()
503
-    {
504
-        return \count($this->skipped);
505
-    }
506
-
507
-    /**
508
-     * Returns an Enumeration for the skipped tests.
509
-     *
510
-     * @return array
511
-     */
512
-    public function skipped()
513
-    {
514
-        return $this->skipped;
515
-    }
516
-
517
-    /**
518
-     * Gets the number of detected errors.
519
-     *
520
-     * @return int
521
-     */
522
-    public function errorCount()
523
-    {
524
-        return \count($this->errors);
525
-    }
526
-
527
-    /**
528
-     * Returns an Enumeration for the errors.
529
-     *
530
-     * @return array
531
-     */
532
-    public function errors()
533
-    {
534
-        return $this->errors;
535
-    }
536
-
537
-    /**
538
-     * Gets the number of detected failures.
539
-     *
540
-     * @return int
541
-     */
542
-    public function failureCount()
543
-    {
544
-        return \count($this->failures);
545
-    }
546
-
547
-    /**
548
-     * Returns an Enumeration for the failures.
549
-     *
550
-     * @return array
551
-     */
552
-    public function failures()
553
-    {
554
-        return $this->failures;
555
-    }
556
-
557
-    /**
558
-     * Gets the number of detected warnings.
559
-     *
560
-     * @return int
561
-     */
562
-    public function warningCount()
563
-    {
564
-        return \count($this->warnings);
565
-    }
566
-
567
-    /**
568
-     * Returns an Enumeration for the warnings.
569
-     *
570
-     * @return array
571
-     */
572
-    public function warnings()
573
-    {
574
-        return $this->warnings;
575
-    }
576
-
577
-    /**
578
-     * Returns the names of the tests that have passed.
579
-     *
580
-     * @return array
581
-     */
582
-    public function passed()
583
-    {
584
-        return $this->passed;
585
-    }
586
-
587
-    /**
588
-     * Returns the (top) test suite.
589
-     *
590
-     * @return TestSuite
591
-     */
592
-    public function topTestSuite()
593
-    {
594
-        return $this->topTestSuite;
595
-    }
596
-
597
-    /**
598
-     * Returns whether code coverage information should be collected.
599
-     *
600
-     * @return bool If code coverage should be collected
601
-     */
602
-    public function getCollectCodeCoverageInformation()
603
-    {
604
-        return $this->codeCoverage !== null;
605
-    }
606
-
607
-    /**
608
-     * Runs a TestCase.
609
-     *
610
-     * @param Test $test
611
-     */
612
-    public function run(Test $test)
613
-    {
614
-        Assert::resetCount();
615
-
616
-        $coversNothing = false;
617
-
618
-        if ($test instanceof TestCase) {
619
-            $test->setRegisterMockObjectsFromTestArgumentsRecursively(
620
-                $this->registerMockObjectsFromTestArgumentsRecursively
621
-            );
622
-
623
-            $annotations = $test->getAnnotations();
624
-
625
-            if (isset($annotations['class']['coversNothing']) || isset($annotations['method']['coversNothing'])) {
626
-                $coversNothing = true;
627
-            }
628
-        }
629
-
630
-        $error      = false;
631
-        $failure    = false;
632
-        $warning    = false;
633
-        $incomplete = false;
634
-        $risky      = false;
635
-        $skipped    = false;
636
-
637
-        $this->startTest($test);
638
-
639
-        $errorHandlerSet = false;
640
-
641
-        if ($this->convertErrorsToExceptions) {
642
-            $oldErrorHandler = \set_error_handler(
643
-                [\PHPUnit\Util\ErrorHandler::class, 'handleError'],
644
-                E_ALL | E_STRICT
645
-            );
646
-
647
-            if ($oldErrorHandler === null) {
648
-                $errorHandlerSet = true;
649
-            } else {
650
-                \restore_error_handler();
651
-            }
652
-        }
653
-
654
-        $collectCodeCoverage = $this->codeCoverage !== null &&
655
-                               !$test instanceof WarningTestCase &&
656
-                               !$coversNothing;
657
-
658
-        if ($collectCodeCoverage) {
659
-            $this->codeCoverage->start($test);
660
-        }
661
-
662
-        $monitorFunctions = $this->beStrictAboutResourceUsageDuringSmallTests &&
663
-            !$test instanceof WarningTestCase &&
664
-            $test->getSize() == \PHPUnit\Util\Test::SMALL &&
665
-            \function_exists('xdebug_start_function_monitor');
666
-
667
-        if ($monitorFunctions) {
668
-            \xdebug_start_function_monitor(ResourceOperations::getFunctions());
669
-        }
670
-
671
-        PHP_Timer::start();
672
-
673
-        try {
674
-            if (!$test instanceof WarningTestCase &&
675
-                $test->getSize() != \PHPUnit\Util\Test::UNKNOWN &&
676
-                $this->enforceTimeLimit &&
677
-                \extension_loaded('pcntl') && \class_exists('PHP_Invoker')) {
678
-                switch ($test->getSize()) {
679
-                    case \PHPUnit\Util\Test::SMALL:
680
-                        $_timeout = $this->timeoutForSmallTests;
681
-
682
-                        break;
683
-
684
-                    case \PHPUnit\Util\Test::MEDIUM:
685
-                        $_timeout = $this->timeoutForMediumTests;
686
-
687
-                        break;
688
-
689
-                    case \PHPUnit\Util\Test::LARGE:
690
-                        $_timeout = $this->timeoutForLargeTests;
691
-
692
-                        break;
693
-                }
694
-
695
-                $invoker = new PHP_Invoker;
696
-                $invoker->invoke([$test, 'runBare'], [], $_timeout);
697
-            } else {
698
-                $test->runBare();
699
-            }
700
-        } catch (PHP_Invoker_TimeoutException $e) {
701
-            $this->addFailure(
702
-                $test,
703
-                new RiskyTestError(
704
-                    $e->getMessage()
705
-                ),
706
-                $_timeout
707
-            );
708
-
709
-            $risky = true;
710
-        } catch (PHPUnit_Framework_MockObject_Exception $e) {
711
-            $e = new Warning(
712
-                $e->getMessage()
713
-            );
714
-
715
-            $warning = true;
716
-        } catch (AssertionFailedError $e) {
717
-            $failure = true;
718
-
719
-            if ($e instanceof RiskyTestError) {
720
-                $risky = true;
721
-            } elseif ($e instanceof IncompleteTestError) {
722
-                $incomplete = true;
723
-            } elseif ($e instanceof SkippedTestError) {
724
-                $skipped = true;
725
-            }
726
-        } catch (AssertionError $e) {
727
-            $test->addToAssertionCount(1);
728
-
729
-            $failure = true;
730
-            $frame   = $e->getTrace()[0];
731
-
732
-            $e = new AssertionFailedError(
733
-                \sprintf(
734
-                    '%s in %s:%s',
735
-                    $e->getMessage(),
736
-                    $frame['file'],
737
-                    $frame['line']
738
-                )
739
-            );
740
-        } catch (Warning $e) {
741
-            $warning = true;
742
-        } catch (Exception $e) {
743
-            $error = true;
744
-        } catch (Throwable $e) {
745
-            $e     = new ExceptionWrapper($e);
746
-            $error = true;
747
-        }
748
-
749
-        $time = PHP_Timer::stop();
750
-        $test->addToAssertionCount(Assert::getCount());
751
-
752
-        if ($monitorFunctions) {
753
-            $blacklist = new Blacklist;
754
-            $functions = \xdebug_get_monitored_functions();
755
-            \xdebug_stop_function_monitor();
756
-
757
-            foreach ($functions as $function) {
758
-                if (!$blacklist->isBlacklisted($function['filename'])) {
759
-                    $this->addFailure(
760
-                        $test,
761
-                        new RiskyTestError(
762
-                            \sprintf(
763
-                                '%s() used in %s:%s',
764
-                                $function['function'],
765
-                                $function['filename'],
766
-                                $function['lineno']
767
-                            )
768
-                        ),
769
-                        $time
770
-                    );
771
-                }
772
-            }
773
-        }
774
-
775
-        if ($this->beStrictAboutTestsThatDoNotTestAnything &&
776
-            $test->getNumAssertions() == 0) {
777
-            $risky = true;
778
-        }
779
-
780
-        if ($collectCodeCoverage) {
781
-            $append           = !$risky && !$incomplete && !$skipped;
782
-            $linesToBeCovered = [];
783
-            $linesToBeUsed    = [];
784
-
785
-            if ($append && $test instanceof TestCase) {
786
-                try {
787
-                    $linesToBeCovered = \PHPUnit\Util\Test::getLinesToBeCovered(
788
-                        \get_class($test),
789
-                        $test->getName(false)
790
-                    );
791
-
792
-                    $linesToBeUsed = \PHPUnit\Util\Test::getLinesToBeUsed(
793
-                        \get_class($test),
794
-                        $test->getName(false)
795
-                    );
796
-                } catch (InvalidCoversTargetException $cce) {
797
-                    $this->addWarning(
798
-                        $test,
799
-                        new Warning(
800
-                            $cce->getMessage()
801
-                        ),
802
-                        $time
803
-                    );
804
-                }
805
-            }
806
-
807
-            try {
808
-                $this->codeCoverage->stop(
809
-                    $append,
810
-                    $linesToBeCovered,
811
-                    $linesToBeUsed
812
-                );
813
-            } catch (UnintentionallyCoveredCodeException $cce) {
814
-                $this->addFailure(
815
-                    $test,
816
-                    new UnintentionallyCoveredCodeError(
817
-                        'This test executed code that is not listed as code to be covered or used:' .
818
-                        PHP_EOL . $cce->getMessage()
819
-                    ),
820
-                    $time
821
-                );
822
-            } catch (OriginalCoveredCodeNotExecutedException $cce) {
823
-                $this->addFailure(
824
-                    $test,
825
-                    new CoveredCodeNotExecutedException(
826
-                        'This test did not execute all the code that is listed as code to be covered:' .
827
-                        PHP_EOL . $cce->getMessage()
828
-                    ),
829
-                    $time
830
-                );
831
-            } catch (OriginalMissingCoversAnnotationException $cce) {
832
-                if ($linesToBeCovered !== false) {
833
-                    $this->addFailure(
834
-                        $test,
835
-                        new MissingCoversAnnotationException(
836
-                            'This test does not have a @covers annotation but is expected to have one'
837
-                        ),
838
-                        $time
839
-                    );
840
-                }
841
-            } catch (OriginalCodeCoverageException $cce) {
842
-                $error = true;
843
-
844
-                if (!isset($e)) {
845
-                    $e = $cce;
846
-                }
847
-            }
848
-        }
849
-
850
-        if ($errorHandlerSet === true) {
851
-            \restore_error_handler();
852
-        }
853
-
854
-        if ($error === true) {
855
-            $this->addError($test, $e, $time);
856
-        } elseif ($failure === true) {
857
-            $this->addFailure($test, $e, $time);
858
-        } elseif ($warning === true) {
859
-            $this->addWarning($test, $e, $time);
860
-        } elseif ($this->beStrictAboutTestsThatDoNotTestAnything &&
861
-            !$test->doesNotPerformAssertions() &&
862
-            $test->getNumAssertions() == 0) {
863
-            $this->addFailure(
864
-                $test,
865
-                new RiskyTestError(
866
-                    'This test did not perform any assertions'
867
-                ),
868
-                $time
869
-            );
870
-        } elseif ($this->beStrictAboutOutputDuringTests && $test->hasOutput()) {
871
-            $this->addFailure(
872
-                $test,
873
-                new OutputError(
874
-                    \sprintf(
875
-                        'This test printed output: %s',
876
-                        $test->getActualOutput()
877
-                    )
878
-                ),
879
-                $time
880
-            );
881
-        } elseif ($this->beStrictAboutTodoAnnotatedTests && $test instanceof TestCase) {
882
-            $annotations = $test->getAnnotations();
883
-
884
-            if (isset($annotations['method']['todo'])) {
885
-                $this->addFailure(
886
-                    $test,
887
-                    new RiskyTestError(
888
-                        'Test method is annotated with @todo'
889
-                    ),
890
-                    $time
891
-                );
892
-            }
893
-        }
894
-
895
-        $this->endTest($test, $time);
896
-    }
897
-
898
-    /**
899
-     * Gets the number of run tests.
900
-     *
901
-     * @return int
902
-     */
903
-    public function count()
904
-    {
905
-        return $this->runTests;
906
-    }
907
-
908
-    /**
909
-     * Checks whether the test run should stop.
910
-     *
911
-     * @return bool
912
-     */
913
-    public function shouldStop()
914
-    {
915
-        return $this->stop;
916
-    }
917
-
918
-    /**
919
-     * Marks that the test run should stop.
920
-     */
921
-    public function stop()
922
-    {
923
-        $this->stop = true;
924
-    }
925
-
926
-    /**
927
-     * Returns the code coverage object.
928
-     *
929
-     * @return CodeCoverage
930
-     */
931
-    public function getCodeCoverage()
932
-    {
933
-        return $this->codeCoverage;
934
-    }
935
-
936
-    /**
937
-     * Sets the code coverage object.
938
-     *
939
-     * @param CodeCoverage $codeCoverage
940
-     */
941
-    public function setCodeCoverage(CodeCoverage $codeCoverage)
942
-    {
943
-        $this->codeCoverage = $codeCoverage;
944
-    }
945
-
946
-    /**
947
-     * Enables or disables the error-to-exception conversion.
948
-     *
949
-     * @param bool $flag
950
-     *
951
-     * @throws Exception
952
-     */
953
-    public function convertErrorsToExceptions($flag)
954
-    {
955
-        if (!\is_bool($flag)) {
956
-            throw InvalidArgumentHelper::factory(1, 'boolean');
957
-        }
958
-
959
-        $this->convertErrorsToExceptions = $flag;
960
-    }
961
-
962
-    /**
963
-     * Returns the error-to-exception conversion setting.
964
-     *
965
-     * @return bool
966
-     */
967
-    public function getConvertErrorsToExceptions()
968
-    {
969
-        return $this->convertErrorsToExceptions;
970
-    }
971
-
972
-    /**
973
-     * Enables or disables the stopping when an error occurs.
974
-     *
975
-     * @param bool $flag
976
-     *
977
-     * @throws Exception
978
-     */
979
-    public function stopOnError($flag)
980
-    {
981
-        if (!\is_bool($flag)) {
982
-            throw InvalidArgumentHelper::factory(1, 'boolean');
983
-        }
984
-
985
-        $this->stopOnError = $flag;
986
-    }
987
-
988
-    /**
989
-     * Enables or disables the stopping when a failure occurs.
990
-     *
991
-     * @param bool $flag
992
-     *
993
-     * @throws Exception
994
-     */
995
-    public function stopOnFailure($flag)
996
-    {
997
-        if (!\is_bool($flag)) {
998
-            throw InvalidArgumentHelper::factory(1, 'boolean');
999
-        }
1000
-
1001
-        $this->stopOnFailure = $flag;
1002
-    }
1003
-
1004
-    /**
1005
-     * Enables or disables the stopping when a warning occurs.
1006
-     *
1007
-     * @param bool $flag
1008
-     *
1009
-     * @throws Exception
1010
-     */
1011
-    public function stopOnWarning($flag)
1012
-    {
1013
-        if (!\is_bool($flag)) {
1014
-            throw InvalidArgumentHelper::factory(1, 'boolean');
1015
-        }
1016
-
1017
-        $this->stopOnWarning = $flag;
1018
-    }
1019
-
1020
-    /**
1021
-     * @param bool $flag
1022
-     *
1023
-     * @throws Exception
1024
-     */
1025
-    public function beStrictAboutTestsThatDoNotTestAnything($flag)
1026
-    {
1027
-        if (!\is_bool($flag)) {
1028
-            throw InvalidArgumentHelper::factory(1, 'boolean');
1029
-        }
1030
-
1031
-        $this->beStrictAboutTestsThatDoNotTestAnything = $flag;
1032
-    }
1033
-
1034
-    /**
1035
-     * @return bool
1036
-     */
1037
-    public function isStrictAboutTestsThatDoNotTestAnything()
1038
-    {
1039
-        return $this->beStrictAboutTestsThatDoNotTestAnything;
1040
-    }
1041
-
1042
-    /**
1043
-     * @param bool $flag
1044
-     *
1045
-     * @throws Exception
1046
-     */
1047
-    public function beStrictAboutOutputDuringTests($flag)
1048
-    {
1049
-        if (!\is_bool($flag)) {
1050
-            throw InvalidArgumentHelper::factory(1, 'boolean');
1051
-        }
1052
-
1053
-        $this->beStrictAboutOutputDuringTests = $flag;
1054
-    }
1055
-
1056
-    /**
1057
-     * @return bool
1058
-     */
1059
-    public function isStrictAboutOutputDuringTests()
1060
-    {
1061
-        return $this->beStrictAboutOutputDuringTests;
1062
-    }
1063
-
1064
-    /**
1065
-     * @param bool $flag
1066
-     *
1067
-     * @throws Exception
1068
-     */
1069
-    public function beStrictAboutResourceUsageDuringSmallTests($flag)
1070
-    {
1071
-        if (!\is_bool($flag)) {
1072
-            throw InvalidArgumentHelper::factory(1, 'boolean');
1073
-        }
1074
-
1075
-        $this->beStrictAboutResourceUsageDuringSmallTests = $flag;
1076
-    }
1077
-
1078
-    /**
1079
-     * @return bool
1080
-     */
1081
-    public function isStrictAboutResourceUsageDuringSmallTests()
1082
-    {
1083
-        return $this->beStrictAboutResourceUsageDuringSmallTests;
1084
-    }
1085
-
1086
-    /**
1087
-     * @param bool $flag
1088
-     *
1089
-     * @throws Exception
1090
-     */
1091
-    public function enforceTimeLimit($flag)
1092
-    {
1093
-        if (!\is_bool($flag)) {
1094
-            throw InvalidArgumentHelper::factory(1, 'boolean');
1095
-        }
1096
-
1097
-        $this->enforceTimeLimit = $flag;
1098
-    }
1099
-
1100
-    /**
1101
-     * @return bool
1102
-     */
1103
-    public function enforcesTimeLimit()
1104
-    {
1105
-        return $this->enforceTimeLimit;
1106
-    }
1107
-
1108
-    /**
1109
-     * @param bool $flag
1110
-     *
1111
-     * @throws Exception
1112
-     */
1113
-    public function beStrictAboutTodoAnnotatedTests($flag)
1114
-    {
1115
-        if (!\is_bool($flag)) {
1116
-            throw InvalidArgumentHelper::factory(1, 'boolean');
1117
-        }
1118
-
1119
-        $this->beStrictAboutTodoAnnotatedTests = $flag;
1120
-    }
1121
-
1122
-    /**
1123
-     * @return bool
1124
-     */
1125
-    public function isStrictAboutTodoAnnotatedTests()
1126
-    {
1127
-        return $this->beStrictAboutTodoAnnotatedTests;
1128
-    }
1129
-
1130
-    /**
1131
-     * Enables or disables the stopping for risky tests.
1132
-     *
1133
-     * @param bool $flag
1134
-     *
1135
-     * @throws Exception
1136
-     */
1137
-    public function stopOnRisky($flag)
1138
-    {
1139
-        if (!\is_bool($flag)) {
1140
-            throw InvalidArgumentHelper::factory(1, 'boolean');
1141
-        }
1142
-
1143
-        $this->stopOnRisky = $flag;
1144
-    }
1145
-
1146
-    /**
1147
-     * Enables or disables the stopping for incomplete tests.
1148
-     *
1149
-     * @param bool $flag
1150
-     *
1151
-     * @throws Exception
1152
-     */
1153
-    public function stopOnIncomplete($flag)
1154
-    {
1155
-        if (!\is_bool($flag)) {
1156
-            throw InvalidArgumentHelper::factory(1, 'boolean');
1157
-        }
1158
-
1159
-        $this->stopOnIncomplete = $flag;
1160
-    }
1161
-
1162
-    /**
1163
-     * Enables or disables the stopping for skipped tests.
1164
-     *
1165
-     * @param bool $flag
1166
-     *
1167
-     * @throws Exception
1168
-     */
1169
-    public function stopOnSkipped($flag)
1170
-    {
1171
-        if (!\is_bool($flag)) {
1172
-            throw InvalidArgumentHelper::factory(1, 'boolean');
1173
-        }
1174
-
1175
-        $this->stopOnSkipped = $flag;
1176
-    }
1177
-
1178
-    /**
1179
-     * Returns the time spent running the tests.
1180
-     *
1181
-     * @return float
1182
-     */
1183
-    public function time()
1184
-    {
1185
-        return $this->time;
1186
-    }
1187
-
1188
-    /**
1189
-     * Returns whether the entire test was successful or not.
1190
-     *
1191
-     * @return bool
1192
-     */
1193
-    public function wasSuccessful()
1194
-    {
1195
-        return empty($this->errors) && empty($this->failures) && empty($this->warnings);
1196
-    }
1197
-
1198
-    /**
1199
-     * Sets the timeout for small tests.
1200
-     *
1201
-     * @param int $timeout
1202
-     *
1203
-     * @throws Exception
1204
-     */
1205
-    public function setTimeoutForSmallTests($timeout)
1206
-    {
1207
-        if (!\is_int($timeout)) {
1208
-            throw InvalidArgumentHelper::factory(1, 'integer');
1209
-        }
1210
-
1211
-        $this->timeoutForSmallTests = $timeout;
1212
-    }
1213
-
1214
-    /**
1215
-     * Sets the timeout for medium tests.
1216
-     *
1217
-     * @param int $timeout
1218
-     *
1219
-     * @throws Exception
1220
-     */
1221
-    public function setTimeoutForMediumTests($timeout)
1222
-    {
1223
-        if (!\is_int($timeout)) {
1224
-            throw InvalidArgumentHelper::factory(1, 'integer');
1225
-        }
1226
-
1227
-        $this->timeoutForMediumTests = $timeout;
1228
-    }
1229
-
1230
-    /**
1231
-     * Sets the timeout for large tests.
1232
-     *
1233
-     * @param int $timeout
1234
-     *
1235
-     * @throws Exception
1236
-     */
1237
-    public function setTimeoutForLargeTests($timeout)
1238
-    {
1239
-        if (!\is_int($timeout)) {
1240
-            throw InvalidArgumentHelper::factory(1, 'integer');
1241
-        }
1242
-
1243
-        $this->timeoutForLargeTests = $timeout;
1244
-    }
1245
-
1246
-    /**
1247
-     * Returns the set timeout for large tests.
1248
-     *
1249
-     * @return int
1250
-     */
1251
-    public function getTimeoutForLargeTests()
1252
-    {
1253
-        return $this->timeoutForLargeTests;
1254
-    }
1255
-
1256
-    /**
1257
-     * @param bool $flag
1258
-     */
1259
-    public function setRegisterMockObjectsFromTestArgumentsRecursively($flag)
1260
-    {
1261
-        if (!\is_bool($flag)) {
1262
-            throw InvalidArgumentHelper::factory(1, 'boolean');
1263
-        }
1264
-
1265
-        $this->registerMockObjectsFromTestArgumentsRecursively = $flag;
1266
-    }
1267
-
1268
-    /**
1269
-     * Returns the class hierarchy for a given class.
1270
-     *
1271
-     * @param string $className
1272
-     * @param bool   $asReflectionObjects
1273
-     *
1274
-     * @return array
1275
-     */
1276
-    protected function getHierarchy($className, $asReflectionObjects = false)
1277
-    {
1278
-        if ($asReflectionObjects) {
1279
-            $classes = [new ReflectionClass($className)];
1280
-        } else {
1281
-            $classes = [$className];
1282
-        }
1283
-
1284
-        $done = false;
1285
-
1286
-        while (!$done) {
1287
-            if ($asReflectionObjects) {
1288
-                $class = new ReflectionClass(
1289
-                    $classes[\count($classes) - 1]->getName()
1290
-                );
1291
-            } else {
1292
-                $class = new ReflectionClass($classes[\count($classes) - 1]);
1293
-            }
1294
-
1295
-            $parent = $class->getParentClass();
1296
-
1297
-            if ($parent !== false) {
1298
-                if ($asReflectionObjects) {
1299
-                    $classes[] = $parent;
1300
-                } else {
1301
-                    $classes[] = $parent->getName();
1302
-                }
1303
-            } else {
1304
-                $done = true;
1305
-            }
1306
-        }
1307
-
1308
-        return $classes;
1309
-    }
37
+	/**
38
+	 * @var array
39
+	 */
40
+	protected $passed = [];
41
+
42
+	/**
43
+	 * @var array
44
+	 */
45
+	protected $errors = [];
46
+
47
+	/**
48
+	 * @var array
49
+	 */
50
+	protected $failures = [];
51
+
52
+	/**
53
+	 * @var array
54
+	 */
55
+	protected $warnings = [];
56
+
57
+	/**
58
+	 * @var array
59
+	 */
60
+	protected $notImplemented = [];
61
+
62
+	/**
63
+	 * @var array
64
+	 */
65
+	protected $risky = [];
66
+
67
+	/**
68
+	 * @var array
69
+	 */
70
+	protected $skipped = [];
71
+
72
+	/**
73
+	 * @var array
74
+	 */
75
+	protected $listeners = [];
76
+
77
+	/**
78
+	 * @var int
79
+	 */
80
+	protected $runTests = 0;
81
+
82
+	/**
83
+	 * @var float
84
+	 */
85
+	protected $time = 0;
86
+
87
+	/**
88
+	 * @var TestSuite
89
+	 */
90
+	protected $topTestSuite;
91
+
92
+	/**
93
+	 * Code Coverage information.
94
+	 *
95
+	 * @var CodeCoverage
96
+	 */
97
+	protected $codeCoverage;
98
+
99
+	/**
100
+	 * @var bool
101
+	 */
102
+	protected $convertErrorsToExceptions = true;
103
+
104
+	/**
105
+	 * @var bool
106
+	 */
107
+	protected $stop = false;
108
+
109
+	/**
110
+	 * @var bool
111
+	 */
112
+	protected $stopOnError = false;
113
+
114
+	/**
115
+	 * @var bool
116
+	 */
117
+	protected $stopOnFailure = false;
118
+
119
+	/**
120
+	 * @var bool
121
+	 */
122
+	protected $stopOnWarning = false;
123
+
124
+	/**
125
+	 * @var bool
126
+	 */
127
+	protected $beStrictAboutTestsThatDoNotTestAnything = true;
128
+
129
+	/**
130
+	 * @var bool
131
+	 */
132
+	protected $beStrictAboutOutputDuringTests = false;
133
+
134
+	/**
135
+	 * @var bool
136
+	 */
137
+	protected $beStrictAboutTodoAnnotatedTests = false;
138
+
139
+	/**
140
+	 * @var bool
141
+	 */
142
+	protected $beStrictAboutResourceUsageDuringSmallTests = false;
143
+
144
+	/**
145
+	 * @var bool
146
+	 */
147
+	protected $enforceTimeLimit = false;
148
+
149
+	/**
150
+	 * @var int
151
+	 */
152
+	protected $timeoutForSmallTests = 1;
153
+
154
+	/**
155
+	 * @var int
156
+	 */
157
+	protected $timeoutForMediumTests = 10;
158
+
159
+	/**
160
+	 * @var int
161
+	 */
162
+	protected $timeoutForLargeTests = 60;
163
+
164
+	/**
165
+	 * @var bool
166
+	 */
167
+	protected $stopOnRisky = false;
168
+
169
+	/**
170
+	 * @var bool
171
+	 */
172
+	protected $stopOnIncomplete = false;
173
+
174
+	/**
175
+	 * @var bool
176
+	 */
177
+	protected $stopOnSkipped = false;
178
+
179
+	/**
180
+	 * @var bool
181
+	 */
182
+	protected $lastTestFailed = false;
183
+
184
+	/**
185
+	 * @var bool
186
+	 */
187
+	private $registerMockObjectsFromTestArgumentsRecursively = false;
188
+
189
+	/**
190
+	 * Registers a TestListener.
191
+	 *
192
+	 * @param TestListener $listener
193
+	 */
194
+	public function addListener(TestListener $listener)
195
+	{
196
+		$this->listeners[] = $listener;
197
+	}
198
+
199
+	/**
200
+	 * Unregisters a TestListener.
201
+	 *
202
+	 * @param TestListener $listener
203
+	 */
204
+	public function removeListener(TestListener $listener)
205
+	{
206
+		foreach ($this->listeners as $key => $_listener) {
207
+			if ($listener === $_listener) {
208
+				unset($this->listeners[$key]);
209
+			}
210
+		}
211
+	}
212
+
213
+	/**
214
+	 * Flushes all flushable TestListeners.
215
+	 */
216
+	public function flushListeners()
217
+	{
218
+		foreach ($this->listeners as $listener) {
219
+			if ($listener instanceof Printer) {
220
+				$listener->flush();
221
+			}
222
+		}
223
+	}
224
+
225
+	/**
226
+	 * Adds an error to the list of errors.
227
+	 *
228
+	 * @param Test      $test
229
+	 * @param Throwable $t
230
+	 * @param float     $time
231
+	 */
232
+	public function addError(Test $test, Throwable $t, $time)
233
+	{
234
+		if ($t instanceof RiskyTest) {
235
+			$this->risky[] = new TestFailure($test, $t);
236
+			$notifyMethod  = 'addRiskyTest';
237
+
238
+			if ($test instanceof TestCase) {
239
+				$test->markAsRisky();
240
+			}
241
+
242
+			if ($this->stopOnRisky) {
243
+				$this->stop();
244
+			}
245
+		} elseif ($t instanceof IncompleteTest) {
246
+			$this->notImplemented[] = new TestFailure($test, $t);
247
+			$notifyMethod           = 'addIncompleteTest';
248
+
249
+			if ($this->stopOnIncomplete) {
250
+				$this->stop();
251
+			}
252
+		} elseif ($t instanceof SkippedTest) {
253
+			$this->skipped[] = new TestFailure($test, $t);
254
+			$notifyMethod    = 'addSkippedTest';
255
+
256
+			if ($this->stopOnSkipped) {
257
+				$this->stop();
258
+			}
259
+		} else {
260
+			$this->errors[] = new TestFailure($test, $t);
261
+			$notifyMethod   = 'addError';
262
+
263
+			if ($this->stopOnError || $this->stopOnFailure) {
264
+				$this->stop();
265
+			}
266
+		}
267
+
268
+		// @see https://github.com/sebastianbergmann/phpunit/issues/1953
269
+		if ($t instanceof Error) {
270
+			$t = new ExceptionWrapper($t);
271
+		}
272
+
273
+		foreach ($this->listeners as $listener) {
274
+			$listener->$notifyMethod($test, $t, $time);
275
+		}
276
+
277
+		$this->lastTestFailed = true;
278
+		$this->time += $time;
279
+	}
280
+
281
+	/**
282
+	 * Adds a warning to the list of warnings.
283
+	 * The passed in exception caused the warning.
284
+	 *
285
+	 * @param Test    $test
286
+	 * @param Warning $e
287
+	 * @param float   $time
288
+	 */
289
+	public function addWarning(Test $test, Warning $e, $time)
290
+	{
291
+		if ($this->stopOnWarning) {
292
+			$this->stop();
293
+		}
294
+
295
+		$this->warnings[] = new TestFailure($test, $e);
296
+
297
+		foreach ($this->listeners as $listener) {
298
+			$listener->addWarning($test, $e, $time);
299
+		}
300
+
301
+		$this->time += $time;
302
+	}
303
+
304
+	/**
305
+	 * Adds a failure to the list of failures.
306
+	 * The passed in exception caused the failure.
307
+	 *
308
+	 * @param Test                 $test
309
+	 * @param AssertionFailedError $e
310
+	 * @param float                $time
311
+	 */
312
+	public function addFailure(Test $test, AssertionFailedError $e, $time)
313
+	{
314
+		if ($e instanceof RiskyTest || $e instanceof OutputError) {
315
+			$this->risky[] = new TestFailure($test, $e);
316
+			$notifyMethod  = 'addRiskyTest';
317
+
318
+			if ($test instanceof TestCase) {
319
+				$test->markAsRisky();
320
+			}
321
+
322
+			if ($this->stopOnRisky) {
323
+				$this->stop();
324
+			}
325
+		} elseif ($e instanceof IncompleteTest) {
326
+			$this->notImplemented[] = new TestFailure($test, $e);
327
+			$notifyMethod           = 'addIncompleteTest';
328
+
329
+			if ($this->stopOnIncomplete) {
330
+				$this->stop();
331
+			}
332
+		} elseif ($e instanceof SkippedTest) {
333
+			$this->skipped[] = new TestFailure($test, $e);
334
+			$notifyMethod    = 'addSkippedTest';
335
+
336
+			if ($this->stopOnSkipped) {
337
+				$this->stop();
338
+			}
339
+		} else {
340
+			$this->failures[] = new TestFailure($test, $e);
341
+			$notifyMethod     = 'addFailure';
342
+
343
+			if ($this->stopOnFailure) {
344
+				$this->stop();
345
+			}
346
+		}
347
+
348
+		foreach ($this->listeners as $listener) {
349
+			$listener->$notifyMethod($test, $e, $time);
350
+		}
351
+
352
+		$this->lastTestFailed = true;
353
+		$this->time += $time;
354
+	}
355
+
356
+	/**
357
+	 * Informs the result that a testsuite will be started.
358
+	 *
359
+	 * @param TestSuite $suite
360
+	 */
361
+	public function startTestSuite(TestSuite $suite)
362
+	{
363
+		if ($this->topTestSuite === null) {
364
+			$this->topTestSuite = $suite;
365
+		}
366
+
367
+		foreach ($this->listeners as $listener) {
368
+			$listener->startTestSuite($suite);
369
+		}
370
+	}
371
+
372
+	/**
373
+	 * Informs the result that a testsuite was completed.
374
+	 *
375
+	 * @param TestSuite $suite
376
+	 */
377
+	public function endTestSuite(TestSuite $suite)
378
+	{
379
+		foreach ($this->listeners as $listener) {
380
+			$listener->endTestSuite($suite);
381
+		}
382
+	}
383
+
384
+	/**
385
+	 * Informs the result that a test will be started.
386
+	 *
387
+	 * @param Test $test
388
+	 */
389
+	public function startTest(Test $test)
390
+	{
391
+		$this->lastTestFailed = false;
392
+		$this->runTests += \count($test);
393
+
394
+		foreach ($this->listeners as $listener) {
395
+			$listener->startTest($test);
396
+		}
397
+	}
398
+
399
+	/**
400
+	 * Informs the result that a test was completed.
401
+	 *
402
+	 * @param Test  $test
403
+	 * @param float $time
404
+	 */
405
+	public function endTest(Test $test, $time)
406
+	{
407
+		foreach ($this->listeners as $listener) {
408
+			$listener->endTest($test, $time);
409
+		}
410
+
411
+		if (!$this->lastTestFailed && $test instanceof TestCase) {
412
+			$class = \get_class($test);
413
+			$key   = $class . '::' . $test->getName();
414
+
415
+			$this->passed[$key] = [
416
+				'result' => $test->getResult(),
417
+				'size'   => \PHPUnit\Util\Test::getSize(
418
+					$class,
419
+					$test->getName(false)
420
+				)
421
+			];
422
+
423
+			$this->time += $time;
424
+		}
425
+	}
426
+
427
+	/**
428
+	 * Returns true if no risky test occurred.
429
+	 *
430
+	 * @return bool
431
+	 */
432
+	public function allHarmless()
433
+	{
434
+		return $this->riskyCount() == 0;
435
+	}
436
+
437
+	/**
438
+	 * Gets the number of risky tests.
439
+	 *
440
+	 * @return int
441
+	 */
442
+	public function riskyCount()
443
+	{
444
+		return \count($this->risky);
445
+	}
446
+
447
+	/**
448
+	 * Returns true if no incomplete test occurred.
449
+	 *
450
+	 * @return bool
451
+	 */
452
+	public function allCompletelyImplemented()
453
+	{
454
+		return $this->notImplementedCount() == 0;
455
+	}
456
+
457
+	/**
458
+	 * Gets the number of incomplete tests.
459
+	 *
460
+	 * @return int
461
+	 */
462
+	public function notImplementedCount()
463
+	{
464
+		return \count($this->notImplemented);
465
+	}
466
+
467
+	/**
468
+	 * Returns an Enumeration for the risky tests.
469
+	 *
470
+	 * @return array
471
+	 */
472
+	public function risky()
473
+	{
474
+		return $this->risky;
475
+	}
476
+
477
+	/**
478
+	 * Returns an Enumeration for the incomplete tests.
479
+	 *
480
+	 * @return array
481
+	 */
482
+	public function notImplemented()
483
+	{
484
+		return $this->notImplemented;
485
+	}
486
+
487
+	/**
488
+	 * Returns true if no test has been skipped.
489
+	 *
490
+	 * @return bool
491
+	 */
492
+	public function noneSkipped()
493
+	{
494
+		return $this->skippedCount() == 0;
495
+	}
496
+
497
+	/**
498
+	 * Gets the number of skipped tests.
499
+	 *
500
+	 * @return int
501
+	 */
502
+	public function skippedCount()
503
+	{
504
+		return \count($this->skipped);
505
+	}
506
+
507
+	/**
508
+	 * Returns an Enumeration for the skipped tests.
509
+	 *
510
+	 * @return array
511
+	 */
512
+	public function skipped()
513
+	{
514
+		return $this->skipped;
515
+	}
516
+
517
+	/**
518
+	 * Gets the number of detected errors.
519
+	 *
520
+	 * @return int
521
+	 */
522
+	public function errorCount()
523
+	{
524
+		return \count($this->errors);
525
+	}
526
+
527
+	/**
528
+	 * Returns an Enumeration for the errors.
529
+	 *
530
+	 * @return array
531
+	 */
532
+	public function errors()
533
+	{
534
+		return $this->errors;
535
+	}
536
+
537
+	/**
538
+	 * Gets the number of detected failures.
539
+	 *
540
+	 * @return int
541
+	 */
542
+	public function failureCount()
543
+	{
544
+		return \count($this->failures);
545
+	}
546
+
547
+	/**
548
+	 * Returns an Enumeration for the failures.
549
+	 *
550
+	 * @return array
551
+	 */
552
+	public function failures()
553
+	{
554
+		return $this->failures;
555
+	}
556
+
557
+	/**
558
+	 * Gets the number of detected warnings.
559
+	 *
560
+	 * @return int
561
+	 */
562
+	public function warningCount()
563
+	{
564
+		return \count($this->warnings);
565
+	}
566
+
567
+	/**
568
+	 * Returns an Enumeration for the warnings.
569
+	 *
570
+	 * @return array
571
+	 */
572
+	public function warnings()
573
+	{
574
+		return $this->warnings;
575
+	}
576
+
577
+	/**
578
+	 * Returns the names of the tests that have passed.
579
+	 *
580
+	 * @return array
581
+	 */
582
+	public function passed()
583
+	{
584
+		return $this->passed;
585
+	}
586
+
587
+	/**
588
+	 * Returns the (top) test suite.
589
+	 *
590
+	 * @return TestSuite
591
+	 */
592
+	public function topTestSuite()
593
+	{
594
+		return $this->topTestSuite;
595
+	}
596
+
597
+	/**
598
+	 * Returns whether code coverage information should be collected.
599
+	 *
600
+	 * @return bool If code coverage should be collected
601
+	 */
602
+	public function getCollectCodeCoverageInformation()
603
+	{
604
+		return $this->codeCoverage !== null;
605
+	}
606
+
607
+	/**
608
+	 * Runs a TestCase.
609
+	 *
610
+	 * @param Test $test
611
+	 */
612
+	public function run(Test $test)
613
+	{
614
+		Assert::resetCount();
615
+
616
+		$coversNothing = false;
617
+
618
+		if ($test instanceof TestCase) {
619
+			$test->setRegisterMockObjectsFromTestArgumentsRecursively(
620
+				$this->registerMockObjectsFromTestArgumentsRecursively
621
+			);
622
+
623
+			$annotations = $test->getAnnotations();
624
+
625
+			if (isset($annotations['class']['coversNothing']) || isset($annotations['method']['coversNothing'])) {
626
+				$coversNothing = true;
627
+			}
628
+		}
629
+
630
+		$error      = false;
631
+		$failure    = false;
632
+		$warning    = false;
633
+		$incomplete = false;
634
+		$risky      = false;
635
+		$skipped    = false;
636
+
637
+		$this->startTest($test);
638
+
639
+		$errorHandlerSet = false;
640
+
641
+		if ($this->convertErrorsToExceptions) {
642
+			$oldErrorHandler = \set_error_handler(
643
+				[\PHPUnit\Util\ErrorHandler::class, 'handleError'],
644
+				E_ALL | E_STRICT
645
+			);
646
+
647
+			if ($oldErrorHandler === null) {
648
+				$errorHandlerSet = true;
649
+			} else {
650
+				\restore_error_handler();
651
+			}
652
+		}
653
+
654
+		$collectCodeCoverage = $this->codeCoverage !== null &&
655
+							   !$test instanceof WarningTestCase &&
656
+							   !$coversNothing;
657
+
658
+		if ($collectCodeCoverage) {
659
+			$this->codeCoverage->start($test);
660
+		}
661
+
662
+		$monitorFunctions = $this->beStrictAboutResourceUsageDuringSmallTests &&
663
+			!$test instanceof WarningTestCase &&
664
+			$test->getSize() == \PHPUnit\Util\Test::SMALL &&
665
+			\function_exists('xdebug_start_function_monitor');
666
+
667
+		if ($monitorFunctions) {
668
+			\xdebug_start_function_monitor(ResourceOperations::getFunctions());
669
+		}
670
+
671
+		PHP_Timer::start();
672
+
673
+		try {
674
+			if (!$test instanceof WarningTestCase &&
675
+				$test->getSize() != \PHPUnit\Util\Test::UNKNOWN &&
676
+				$this->enforceTimeLimit &&
677
+				\extension_loaded('pcntl') && \class_exists('PHP_Invoker')) {
678
+				switch ($test->getSize()) {
679
+					case \PHPUnit\Util\Test::SMALL:
680
+						$_timeout = $this->timeoutForSmallTests;
681
+
682
+						break;
683
+
684
+					case \PHPUnit\Util\Test::MEDIUM:
685
+						$_timeout = $this->timeoutForMediumTests;
686
+
687
+						break;
688
+
689
+					case \PHPUnit\Util\Test::LARGE:
690
+						$_timeout = $this->timeoutForLargeTests;
691
+
692
+						break;
693
+				}
694
+
695
+				$invoker = new PHP_Invoker;
696
+				$invoker->invoke([$test, 'runBare'], [], $_timeout);
697
+			} else {
698
+				$test->runBare();
699
+			}
700
+		} catch (PHP_Invoker_TimeoutException $e) {
701
+			$this->addFailure(
702
+				$test,
703
+				new RiskyTestError(
704
+					$e->getMessage()
705
+				),
706
+				$_timeout
707
+			);
708
+
709
+			$risky = true;
710
+		} catch (PHPUnit_Framework_MockObject_Exception $e) {
711
+			$e = new Warning(
712
+				$e->getMessage()
713
+			);
714
+
715
+			$warning = true;
716
+		} catch (AssertionFailedError $e) {
717
+			$failure = true;
718
+
719
+			if ($e instanceof RiskyTestError) {
720
+				$risky = true;
721
+			} elseif ($e instanceof IncompleteTestError) {
722
+				$incomplete = true;
723
+			} elseif ($e instanceof SkippedTestError) {
724
+				$skipped = true;
725
+			}
726
+		} catch (AssertionError $e) {
727
+			$test->addToAssertionCount(1);
728
+
729
+			$failure = true;
730
+			$frame   = $e->getTrace()[0];
731
+
732
+			$e = new AssertionFailedError(
733
+				\sprintf(
734
+					'%s in %s:%s',
735
+					$e->getMessage(),
736
+					$frame['file'],
737
+					$frame['line']
738
+				)
739
+			);
740
+		} catch (Warning $e) {
741
+			$warning = true;
742
+		} catch (Exception $e) {
743
+			$error = true;
744
+		} catch (Throwable $e) {
745
+			$e     = new ExceptionWrapper($e);
746
+			$error = true;
747
+		}
748
+
749
+		$time = PHP_Timer::stop();
750
+		$test->addToAssertionCount(Assert::getCount());
751
+
752
+		if ($monitorFunctions) {
753
+			$blacklist = new Blacklist;
754
+			$functions = \xdebug_get_monitored_functions();
755
+			\xdebug_stop_function_monitor();
756
+
757
+			foreach ($functions as $function) {
758
+				if (!$blacklist->isBlacklisted($function['filename'])) {
759
+					$this->addFailure(
760
+						$test,
761
+						new RiskyTestError(
762
+							\sprintf(
763
+								'%s() used in %s:%s',
764
+								$function['function'],
765
+								$function['filename'],
766
+								$function['lineno']
767
+							)
768
+						),
769
+						$time
770
+					);
771
+				}
772
+			}
773
+		}
774
+
775
+		if ($this->beStrictAboutTestsThatDoNotTestAnything &&
776
+			$test->getNumAssertions() == 0) {
777
+			$risky = true;
778
+		}
779
+
780
+		if ($collectCodeCoverage) {
781
+			$append           = !$risky && !$incomplete && !$skipped;
782
+			$linesToBeCovered = [];
783
+			$linesToBeUsed    = [];
784
+
785
+			if ($append && $test instanceof TestCase) {
786
+				try {
787
+					$linesToBeCovered = \PHPUnit\Util\Test::getLinesToBeCovered(
788
+						\get_class($test),
789
+						$test->getName(false)
790
+					);
791
+
792
+					$linesToBeUsed = \PHPUnit\Util\Test::getLinesToBeUsed(
793
+						\get_class($test),
794
+						$test->getName(false)
795
+					);
796
+				} catch (InvalidCoversTargetException $cce) {
797
+					$this->addWarning(
798
+						$test,
799
+						new Warning(
800
+							$cce->getMessage()
801
+						),
802
+						$time
803
+					);
804
+				}
805
+			}
806
+
807
+			try {
808
+				$this->codeCoverage->stop(
809
+					$append,
810
+					$linesToBeCovered,
811
+					$linesToBeUsed
812
+				);
813
+			} catch (UnintentionallyCoveredCodeException $cce) {
814
+				$this->addFailure(
815
+					$test,
816
+					new UnintentionallyCoveredCodeError(
817
+						'This test executed code that is not listed as code to be covered or used:' .
818
+						PHP_EOL . $cce->getMessage()
819
+					),
820
+					$time
821
+				);
822
+			} catch (OriginalCoveredCodeNotExecutedException $cce) {
823
+				$this->addFailure(
824
+					$test,
825
+					new CoveredCodeNotExecutedException(
826
+						'This test did not execute all the code that is listed as code to be covered:' .
827
+						PHP_EOL . $cce->getMessage()
828
+					),
829
+					$time
830
+				);
831
+			} catch (OriginalMissingCoversAnnotationException $cce) {
832
+				if ($linesToBeCovered !== false) {
833
+					$this->addFailure(
834
+						$test,
835
+						new MissingCoversAnnotationException(
836
+							'This test does not have a @covers annotation but is expected to have one'
837
+						),
838
+						$time
839
+					);
840
+				}
841
+			} catch (OriginalCodeCoverageException $cce) {
842
+				$error = true;
843
+
844
+				if (!isset($e)) {
845
+					$e = $cce;
846
+				}
847
+			}
848
+		}
849
+
850
+		if ($errorHandlerSet === true) {
851
+			\restore_error_handler();
852
+		}
853
+
854
+		if ($error === true) {
855
+			$this->addError($test, $e, $time);
856
+		} elseif ($failure === true) {
857
+			$this->addFailure($test, $e, $time);
858
+		} elseif ($warning === true) {
859
+			$this->addWarning($test, $e, $time);
860
+		} elseif ($this->beStrictAboutTestsThatDoNotTestAnything &&
861
+			!$test->doesNotPerformAssertions() &&
862
+			$test->getNumAssertions() == 0) {
863
+			$this->addFailure(
864
+				$test,
865
+				new RiskyTestError(
866
+					'This test did not perform any assertions'
867
+				),
868
+				$time
869
+			);
870
+		} elseif ($this->beStrictAboutOutputDuringTests && $test->hasOutput()) {
871
+			$this->addFailure(
872
+				$test,
873
+				new OutputError(
874
+					\sprintf(
875
+						'This test printed output: %s',
876
+						$test->getActualOutput()
877
+					)
878
+				),
879
+				$time
880
+			);
881
+		} elseif ($this->beStrictAboutTodoAnnotatedTests && $test instanceof TestCase) {
882
+			$annotations = $test->getAnnotations();
883
+
884
+			if (isset($annotations['method']['todo'])) {
885
+				$this->addFailure(
886
+					$test,
887
+					new RiskyTestError(
888
+						'Test method is annotated with @todo'
889
+					),
890
+					$time
891
+				);
892
+			}
893
+		}
894
+
895
+		$this->endTest($test, $time);
896
+	}
897
+
898
+	/**
899
+	 * Gets the number of run tests.
900
+	 *
901
+	 * @return int
902
+	 */
903
+	public function count()
904
+	{
905
+		return $this->runTests;
906
+	}
907
+
908
+	/**
909
+	 * Checks whether the test run should stop.
910
+	 *
911
+	 * @return bool
912
+	 */
913
+	public function shouldStop()
914
+	{
915
+		return $this->stop;
916
+	}
917
+
918
+	/**
919
+	 * Marks that the test run should stop.
920
+	 */
921
+	public function stop()
922
+	{
923
+		$this->stop = true;
924
+	}
925
+
926
+	/**
927
+	 * Returns the code coverage object.
928
+	 *
929
+	 * @return CodeCoverage
930
+	 */
931
+	public function getCodeCoverage()
932
+	{
933
+		return $this->codeCoverage;
934
+	}
935
+
936
+	/**
937
+	 * Sets the code coverage object.
938
+	 *
939
+	 * @param CodeCoverage $codeCoverage
940
+	 */
941
+	public function setCodeCoverage(CodeCoverage $codeCoverage)
942
+	{
943
+		$this->codeCoverage = $codeCoverage;
944
+	}
945
+
946
+	/**
947
+	 * Enables or disables the error-to-exception conversion.
948
+	 *
949
+	 * @param bool $flag
950
+	 *
951
+	 * @throws Exception
952
+	 */
953
+	public function convertErrorsToExceptions($flag)
954
+	{
955
+		if (!\is_bool($flag)) {
956
+			throw InvalidArgumentHelper::factory(1, 'boolean');
957
+		}
958
+
959
+		$this->convertErrorsToExceptions = $flag;
960
+	}
961
+
962
+	/**
963
+	 * Returns the error-to-exception conversion setting.
964
+	 *
965
+	 * @return bool
966
+	 */
967
+	public function getConvertErrorsToExceptions()
968
+	{
969
+		return $this->convertErrorsToExceptions;
970
+	}
971
+
972
+	/**
973
+	 * Enables or disables the stopping when an error occurs.
974
+	 *
975
+	 * @param bool $flag
976
+	 *
977
+	 * @throws Exception
978
+	 */
979
+	public function stopOnError($flag)
980
+	{
981
+		if (!\is_bool($flag)) {
982
+			throw InvalidArgumentHelper::factory(1, 'boolean');
983
+		}
984
+
985
+		$this->stopOnError = $flag;
986
+	}
987
+
988
+	/**
989
+	 * Enables or disables the stopping when a failure occurs.
990
+	 *
991
+	 * @param bool $flag
992
+	 *
993
+	 * @throws Exception
994
+	 */
995
+	public function stopOnFailure($flag)
996
+	{
997
+		if (!\is_bool($flag)) {
998
+			throw InvalidArgumentHelper::factory(1, 'boolean');
999
+		}
1000
+
1001
+		$this->stopOnFailure = $flag;
1002
+	}
1003
+
1004
+	/**
1005
+	 * Enables or disables the stopping when a warning occurs.
1006
+	 *
1007
+	 * @param bool $flag
1008
+	 *
1009
+	 * @throws Exception
1010
+	 */
1011
+	public function stopOnWarning($flag)
1012
+	{
1013
+		if (!\is_bool($flag)) {
1014
+			throw InvalidArgumentHelper::factory(1, 'boolean');
1015
+		}
1016
+
1017
+		$this->stopOnWarning = $flag;
1018
+	}
1019
+
1020
+	/**
1021
+	 * @param bool $flag
1022
+	 *
1023
+	 * @throws Exception
1024
+	 */
1025
+	public function beStrictAboutTestsThatDoNotTestAnything($flag)
1026
+	{
1027
+		if (!\is_bool($flag)) {
1028
+			throw InvalidArgumentHelper::factory(1, 'boolean');
1029
+		}
1030
+
1031
+		$this->beStrictAboutTestsThatDoNotTestAnything = $flag;
1032
+	}
1033
+
1034
+	/**
1035
+	 * @return bool
1036
+	 */
1037
+	public function isStrictAboutTestsThatDoNotTestAnything()
1038
+	{
1039
+		return $this->beStrictAboutTestsThatDoNotTestAnything;
1040
+	}
1041
+
1042
+	/**
1043
+	 * @param bool $flag
1044
+	 *
1045
+	 * @throws Exception
1046
+	 */
1047
+	public function beStrictAboutOutputDuringTests($flag)
1048
+	{
1049
+		if (!\is_bool($flag)) {
1050
+			throw InvalidArgumentHelper::factory(1, 'boolean');
1051
+		}
1052
+
1053
+		$this->beStrictAboutOutputDuringTests = $flag;
1054
+	}
1055
+
1056
+	/**
1057
+	 * @return bool
1058
+	 */
1059
+	public function isStrictAboutOutputDuringTests()
1060
+	{
1061
+		return $this->beStrictAboutOutputDuringTests;
1062
+	}
1063
+
1064
+	/**
1065
+	 * @param bool $flag
1066
+	 *
1067
+	 * @throws Exception
1068
+	 */
1069
+	public function beStrictAboutResourceUsageDuringSmallTests($flag)
1070
+	{
1071
+		if (!\is_bool($flag)) {
1072
+			throw InvalidArgumentHelper::factory(1, 'boolean');
1073
+		}
1074
+
1075
+		$this->beStrictAboutResourceUsageDuringSmallTests = $flag;
1076
+	}
1077
+
1078
+	/**
1079
+	 * @return bool
1080
+	 */
1081
+	public function isStrictAboutResourceUsageDuringSmallTests()
1082
+	{
1083
+		return $this->beStrictAboutResourceUsageDuringSmallTests;
1084
+	}
1085
+
1086
+	/**
1087
+	 * @param bool $flag
1088
+	 *
1089
+	 * @throws Exception
1090
+	 */
1091
+	public function enforceTimeLimit($flag)
1092
+	{
1093
+		if (!\is_bool($flag)) {
1094
+			throw InvalidArgumentHelper::factory(1, 'boolean');
1095
+		}
1096
+
1097
+		$this->enforceTimeLimit = $flag;
1098
+	}
1099
+
1100
+	/**
1101
+	 * @return bool
1102
+	 */
1103
+	public function enforcesTimeLimit()
1104
+	{
1105
+		return $this->enforceTimeLimit;
1106
+	}
1107
+
1108
+	/**
1109
+	 * @param bool $flag
1110
+	 *
1111
+	 * @throws Exception
1112
+	 */
1113
+	public function beStrictAboutTodoAnnotatedTests($flag)
1114
+	{
1115
+		if (!\is_bool($flag)) {
1116
+			throw InvalidArgumentHelper::factory(1, 'boolean');
1117
+		}
1118
+
1119
+		$this->beStrictAboutTodoAnnotatedTests = $flag;
1120
+	}
1121
+
1122
+	/**
1123
+	 * @return bool
1124
+	 */
1125
+	public function isStrictAboutTodoAnnotatedTests()
1126
+	{
1127
+		return $this->beStrictAboutTodoAnnotatedTests;
1128
+	}
1129
+
1130
+	/**
1131
+	 * Enables or disables the stopping for risky tests.
1132
+	 *
1133
+	 * @param bool $flag
1134
+	 *
1135
+	 * @throws Exception
1136
+	 */
1137
+	public function stopOnRisky($flag)
1138
+	{
1139
+		if (!\is_bool($flag)) {
1140
+			throw InvalidArgumentHelper::factory(1, 'boolean');
1141
+		}
1142
+
1143
+		$this->stopOnRisky = $flag;
1144
+	}
1145
+
1146
+	/**
1147
+	 * Enables or disables the stopping for incomplete tests.
1148
+	 *
1149
+	 * @param bool $flag
1150
+	 *
1151
+	 * @throws Exception
1152
+	 */
1153
+	public function stopOnIncomplete($flag)
1154
+	{
1155
+		if (!\is_bool($flag)) {
1156
+			throw InvalidArgumentHelper::factory(1, 'boolean');
1157
+		}
1158
+
1159
+		$this->stopOnIncomplete = $flag;
1160
+	}
1161
+
1162
+	/**
1163
+	 * Enables or disables the stopping for skipped tests.
1164
+	 *
1165
+	 * @param bool $flag
1166
+	 *
1167
+	 * @throws Exception
1168
+	 */
1169
+	public function stopOnSkipped($flag)
1170
+	{
1171
+		if (!\is_bool($flag)) {
1172
+			throw InvalidArgumentHelper::factory(1, 'boolean');
1173
+		}
1174
+
1175
+		$this->stopOnSkipped = $flag;
1176
+	}
1177
+
1178
+	/**
1179
+	 * Returns the time spent running the tests.
1180
+	 *
1181
+	 * @return float
1182
+	 */
1183
+	public function time()
1184
+	{
1185
+		return $this->time;
1186
+	}
1187
+
1188
+	/**
1189
+	 * Returns whether the entire test was successful or not.
1190
+	 *
1191
+	 * @return bool
1192
+	 */
1193
+	public function wasSuccessful()
1194
+	{
1195
+		return empty($this->errors) && empty($this->failures) && empty($this->warnings);
1196
+	}
1197
+
1198
+	/**
1199
+	 * Sets the timeout for small tests.
1200
+	 *
1201
+	 * @param int $timeout
1202
+	 *
1203
+	 * @throws Exception
1204
+	 */
1205
+	public function setTimeoutForSmallTests($timeout)
1206
+	{
1207
+		if (!\is_int($timeout)) {
1208
+			throw InvalidArgumentHelper::factory(1, 'integer');
1209
+		}
1210
+
1211
+		$this->timeoutForSmallTests = $timeout;
1212
+	}
1213
+
1214
+	/**
1215
+	 * Sets the timeout for medium tests.
1216
+	 *
1217
+	 * @param int $timeout
1218
+	 *
1219
+	 * @throws Exception
1220
+	 */
1221
+	public function setTimeoutForMediumTests($timeout)
1222
+	{
1223
+		if (!\is_int($timeout)) {
1224
+			throw InvalidArgumentHelper::factory(1, 'integer');
1225
+		}
1226
+
1227
+		$this->timeoutForMediumTests = $timeout;
1228
+	}
1229
+
1230
+	/**
1231
+	 * Sets the timeout for large tests.
1232
+	 *
1233
+	 * @param int $timeout
1234
+	 *
1235
+	 * @throws Exception
1236
+	 */
1237
+	public function setTimeoutForLargeTests($timeout)
1238
+	{
1239
+		if (!\is_int($timeout)) {
1240
+			throw InvalidArgumentHelper::factory(1, 'integer');
1241
+		}
1242
+
1243
+		$this->timeoutForLargeTests = $timeout;
1244
+	}
1245
+
1246
+	/**
1247
+	 * Returns the set timeout for large tests.
1248
+	 *
1249
+	 * @return int
1250
+	 */
1251
+	public function getTimeoutForLargeTests()
1252
+	{
1253
+		return $this->timeoutForLargeTests;
1254
+	}
1255
+
1256
+	/**
1257
+	 * @param bool $flag
1258
+	 */
1259
+	public function setRegisterMockObjectsFromTestArgumentsRecursively($flag)
1260
+	{
1261
+		if (!\is_bool($flag)) {
1262
+			throw InvalidArgumentHelper::factory(1, 'boolean');
1263
+		}
1264
+
1265
+		$this->registerMockObjectsFromTestArgumentsRecursively = $flag;
1266
+	}
1267
+
1268
+	/**
1269
+	 * Returns the class hierarchy for a given class.
1270
+	 *
1271
+	 * @param string $className
1272
+	 * @param bool   $asReflectionObjects
1273
+	 *
1274
+	 * @return array
1275
+	 */
1276
+	protected function getHierarchy($className, $asReflectionObjects = false)
1277
+	{
1278
+		if ($asReflectionObjects) {
1279
+			$classes = [new ReflectionClass($className)];
1280
+		} else {
1281
+			$classes = [$className];
1282
+		}
1283
+
1284
+		$done = false;
1285
+
1286
+		while (!$done) {
1287
+			if ($asReflectionObjects) {
1288
+				$class = new ReflectionClass(
1289
+					$classes[\count($classes) - 1]->getName()
1290
+				);
1291
+			} else {
1292
+				$class = new ReflectionClass($classes[\count($classes) - 1]);
1293
+			}
1294
+
1295
+			$parent = $class->getParentClass();
1296
+
1297
+			if ($parent !== false) {
1298
+				if ($asReflectionObjects) {
1299
+					$classes[] = $parent;
1300
+				} else {
1301
+					$classes[] = $parent->getName();
1302
+				}
1303
+			} else {
1304
+				$done = true;
1305
+			}
1306
+		}
1307
+
1308
+		return $classes;
1309
+	}
1310 1310
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
 
411 411
         if (!$this->lastTestFailed && $test instanceof TestCase) {
412 412
             $class = \get_class($test);
413
-            $key   = $class . '::' . $test->getName();
413
+            $key   = $class.'::'.$test->getName();
414 414
 
415 415
             $this->passed[$key] = [
416 416
                 'result' => $test->getResult(),
@@ -814,8 +814,8 @@  discard block
 block discarded – undo
814 814
                 $this->addFailure(
815 815
                     $test,
816 816
                     new UnintentionallyCoveredCodeError(
817
-                        'This test executed code that is not listed as code to be covered or used:' .
818
-                        PHP_EOL . $cce->getMessage()
817
+                        'This test executed code that is not listed as code to be covered or used:'.
818
+                        PHP_EOL.$cce->getMessage()
819 819
                     ),
820 820
                     $time
821 821
                 );
@@ -823,8 +823,8 @@  discard block
 block discarded – undo
823 823
                 $this->addFailure(
824 824
                     $test,
825 825
                     new CoveredCodeNotExecutedException(
826
-                        'This test did not execute all the code that is listed as code to be covered:' .
827
-                        PHP_EOL . $cce->getMessage()
826
+                        'This test did not execute all the code that is listed as code to be covered:'.
827
+                        PHP_EOL.$cce->getMessage()
828 828
                     ),
829 829
                     $time
830 830
                 );
Please login to merge, or discard this patch.
vendor/phpunit/phpunit/src/Framework/Warning.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -14,13 +14,13 @@
 block discarded – undo
14 14
  */
15 15
 class Warning extends Exception implements SelfDescribing
16 16
 {
17
-    /**
18
-     * Wrapper for getMessage() which is declared as final.
19
-     *
20
-     * @return string
21
-     */
22
-    public function toString()
23
-    {
24
-        return $this->getMessage();
25
-    }
17
+	/**
18
+	 * Wrapper for getMessage() which is declared as final.
19
+	 *
20
+	 * @return string
21
+	 */
22
+	public function toString()
23
+	{
24
+		return $this->getMessage();
25
+	}
26 26
 }
Please login to merge, or discard this patch.
vendor/phpunit/phpunit/src/Framework/IncompleteTestCase.php 2 patches
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -14,70 +14,70 @@
 block discarded – undo
14 14
  */
15 15
 class IncompleteTestCase extends TestCase
16 16
 {
17
-    /**
18
-     * @var string
19
-     */
20
-    protected $message = '';
17
+	/**
18
+	 * @var string
19
+	 */
20
+	protected $message = '';
21 21
 
22
-    /**
23
-     * @var bool
24
-     */
25
-    protected $backupGlobals = false;
22
+	/**
23
+	 * @var bool
24
+	 */
25
+	protected $backupGlobals = false;
26 26
 
27
-    /**
28
-     * @var bool
29
-     */
30
-    protected $backupStaticAttributes = false;
27
+	/**
28
+	 * @var bool
29
+	 */
30
+	protected $backupStaticAttributes = false;
31 31
 
32
-    /**
33
-     * @var bool
34
-     */
35
-    protected $runTestInSeparateProcess = false;
32
+	/**
33
+	 * @var bool
34
+	 */
35
+	protected $runTestInSeparateProcess = false;
36 36
 
37
-    /**
38
-     * @var bool
39
-     */
40
-    protected $useErrorHandler = false;
37
+	/**
38
+	 * @var bool
39
+	 */
40
+	protected $useErrorHandler = false;
41 41
 
42
-    /**
43
-     * @var bool
44
-     */
45
-    protected $useOutputBuffering = false;
42
+	/**
43
+	 * @var bool
44
+	 */
45
+	protected $useOutputBuffering = false;
46 46
 
47
-    /**
48
-     * @param string $className
49
-     * @param string $methodName
50
-     * @param string $message
51
-     */
52
-    public function __construct($className, $methodName, $message = '')
53
-    {
54
-        $this->message = $message;
55
-        parent::__construct($className . '::' . $methodName);
56
-    }
47
+	/**
48
+	 * @param string $className
49
+	 * @param string $methodName
50
+	 * @param string $message
51
+	 */
52
+	public function __construct($className, $methodName, $message = '')
53
+	{
54
+		$this->message = $message;
55
+		parent::__construct($className . '::' . $methodName);
56
+	}
57 57
 
58
-    /**
59
-     * @throws Exception
60
-     */
61
-    protected function runTest()
62
-    {
63
-        $this->markTestIncomplete($this->message);
64
-    }
58
+	/**
59
+	 * @throws Exception
60
+	 */
61
+	protected function runTest()
62
+	{
63
+		$this->markTestIncomplete($this->message);
64
+	}
65 65
 
66
-    /**
67
-     * @return string
68
-     */
69
-    public function getMessage()
70
-    {
71
-        return $this->message;
72
-    }
66
+	/**
67
+	 * @return string
68
+	 */
69
+	public function getMessage()
70
+	{
71
+		return $this->message;
72
+	}
73 73
 
74
-    /**
75
-     * Returns a string representation of the test case.
76
-     *
77
-     * @return string
78
-     */
79
-    public function toString()
80
-    {
81
-        return $this->getName();
82
-    }
74
+	/**
75
+	 * Returns a string representation of the test case.
76
+	 *
77
+	 * @return string
78
+	 */
79
+	public function toString()
80
+	{
81
+		return $this->getName();
82
+	}
83 83
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@
 block discarded – undo
52 52
     public function __construct($className, $methodName, $message = '')
53 53
     {
54 54
         $this->message = $message;
55
-        parent::__construct($className . '::' . $methodName);
55
+        parent::__construct($className.'::'.$methodName);
56 56
     }
57 57
 
58 58
     /**
Please login to merge, or discard this patch.
vendor/phpunit/phpunit/src/Framework/DataProviderTestSuite.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -11,15 +11,15 @@
 block discarded – undo
11 11
 
12 12
 class DataProviderTestSuite extends TestSuite
13 13
 {
14
-    /**
15
-     * Sets the dependencies of a TestCase.
16
-     *
17
-     * @param string[] $dependencies
18
-     */
19
-    public function setDependencies(array $dependencies)
20
-    {
21
-        foreach ($this->tests as $test) {
22
-            $test->setDependencies($dependencies);
23
-        }
24
-    }
14
+	/**
15
+	 * Sets the dependencies of a TestCase.
16
+	 *
17
+	 * @param string[] $dependencies
18
+	 */
19
+	public function setDependencies(array $dependencies)
20
+	{
21
+		foreach ($this->tests as $test) {
22
+			$test->setDependencies($dependencies);
23
+		}
24
+	}
25 25
 }
Please login to merge, or discard this patch.
vendor/phpunit/phpunit/src/Framework/Error/Notice.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,5 +11,5 @@
 block discarded – undo
11 11
 
12 12
 class Notice extends Error
13 13
 {
14
-    public static $enabled = true;
14
+	public static $enabled = true;
15 15
 }
Please login to merge, or discard this patch.
vendor/phpunit/phpunit/src/Framework/Error/Deprecated.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,5 +11,5 @@
 block discarded – undo
11 11
 
12 12
 class Deprecated extends Error
13 13
 {
14
-    public static $enabled = true;
14
+	public static $enabled = true;
15 15
 }
Please login to merge, or discard this patch.
vendor/phpunit/phpunit/src/Framework/Error/Warning.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,5 +11,5 @@
 block discarded – undo
11 11
 
12 12
 class Warning extends Error
13 13
 {
14
-    public static $enabled = true;
14
+	public static $enabled = true;
15 15
 }
Please login to merge, or discard this patch.