File tree 3 files changed +93
-14
lines changed
Filter options
src/Symfony/Bridge/PhpUnit 3 files changed +93
-14
lines changed
Original file line number Diff line number Diff line change 11
11
12
12
namespace Symfony \Bridge \PhpUnit ;
13
13
14
- use Symfony \Bridge \PhpUnit \Legacy \SymfonyTestsListenerTrait ;
14
+ use Symfony \Bridge \PhpUnit \Legacy \ExpectDeprecationTraitBeforeV8_4 ;
15
15
16
- trait ExpectDeprecationTrait
17
- {
18
- /**
19
- * @param string $message
20
- *
21
- * @return void
22
- */
23
- protected function expectDeprecation ($ message )
16
+ if (version_compare (\PHPUnit \Runner \Version::id (), '8.4.0 ' , '< ' )) {
17
+ trait ExpectDeprecationTrait
24
18
{
25
- if (!SymfonyTestsListenerTrait::$ previousErrorHandler ) {
26
- SymfonyTestsListenerTrait::$ previousErrorHandler = set_error_handler ([SymfonyTestsListenerTrait::class, 'handleError ' ]);
27
- }
28
-
29
- SymfonyTestsListenerTrait::$ expectedDeprecations [] = $ message ;
19
+ use ExpectDeprecationTraitBeforeV8_4;
20
+ }
21
+ } else {
22
+ trait ExpectDeprecationTrait
23
+ {
24
+ use \Symfony \Bridge \PhpUnit \Legacy \ExpectDeprecationTrait;
30
25
}
31
26
}
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Symfony package.
5
+ *
6
+ * (c) Fabien Potencier <fabien@symfony.com>
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Symfony \Bridge \PhpUnit \Legacy ;
13
+
14
+ /**
15
+ * @internal use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait instead.
16
+ */
17
+ trait ExpectDeprecationTrait
18
+ {
19
+ /**
20
+ * @param string $message
21
+ */
22
+ public function expectDeprecation (): void
23
+ {
24
+ if (1 > func_num_args () || !\is_string ($ message = func_get_arg (0 ))) {
25
+ throw new \InvalidArgumentException (sprintf ('The "%s()" method requires the string $message argument. ' , __FUNCTION__ ));
26
+ }
27
+
28
+ \Closure::bind (function (string $ message ): void {
29
+ $ this ->expectDeprecation ($ message );
30
+ }, $ o = new class () {
31
+ use ExpectDeprecationTraitBeforeV8_4 {
32
+ expectDeprecation as public ;
33
+ }
34
+ })($ message );
35
+ }
36
+
37
+ /**
38
+ * @internal use expectDeprecation() instead.
39
+ */
40
+ public function expectDeprecationMessage (string $ message ): void
41
+ {
42
+ throw new \BadMethodCallException (sprintf ("The " %s ()" method is not supported by Symfony's PHPUnit Bridge ExpectDeprecationTrait. " , __FUNCTION__ ));
43
+ }
44
+
45
+ /**
46
+ * @internal use expectDeprecation() instead.
47
+ */
48
+ public function expectDeprecationMessageMatches (string $ regularExpression ): void
49
+ {
50
+ throw new \BadMethodCallException (sprintf ("The " %s ()" method is not supported by Symfony's PHPUnit Bridge ExpectDeprecationTrait. " , __FUNCTION__ ));
51
+ }
52
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Symfony package.
5
+ *
6
+ * (c) Fabien Potencier <fabien@symfony.com>
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Symfony \Bridge \PhpUnit \Legacy ;
13
+
14
+ /**
15
+ * @internal, use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait instead.
16
+ */
17
+ trait ExpectDeprecationTraitBeforeV8_4
18
+ {
19
+ /**
20
+ * @param string $message
21
+ *
22
+ * @return void
23
+ */
24
+ protected function expectDeprecation ($ message )
25
+ {
26
+ if (!SymfonyTestsListenerTrait::$ previousErrorHandler ) {
27
+ SymfonyTestsListenerTrait::$ previousErrorHandler = set_error_handler ([SymfonyTestsListenerTrait::class, 'handleError ' ]);
28
+ }
29
+
30
+ SymfonyTestsListenerTrait::$ expectedDeprecations [] = $ message ;
31
+ }
32
+ }
You can’t perform that action at this time.
0 commit comments