These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | /** |
||
4 | * Assert |
||
5 | * |
||
6 | * LICENSE |
||
7 | * |
||
8 | * This source file is subject to the MIT license that is bundled |
||
9 | * with this package in the file LICENSE.txt. |
||
10 | * If you did not receive a copy of the license and are unable to |
||
11 | * obtain it through the world-wide-web, please send an email |
||
12 | * to [email protected] so I can send you a copy immediately. |
||
13 | */ |
||
14 | |||
15 | namespace Assert\Tests; |
||
16 | |||
17 | use Assert\Assertion; |
||
18 | use Assert\AssertionFailedException; |
||
19 | |||
20 | class AssertionExceptionCallbackTest extends \PHPUnit_Framework_TestCase |
||
21 | { |
||
22 | public function testMessageCallback() |
||
23 | { |
||
24 | $this->setExpectedException(AssertionFailedException::class, 'The value of M_PI is not regarded as a string'); |
||
25 | Assertion::string(M_PI, function ($value, $propertyPath = null) { |
||
0 ignored issues
–
show
|
|||
26 | return 'The value of M_PI is not regarded as a string'; |
||
27 | }); |
||
28 | } |
||
29 | } |
||
30 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: