for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Assert
*
* LICENSE
* This source file is subject to the MIT license that is bundled
* with this package in the file LICENSE.txt.
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so I can send you a copy immediately.
*/
namespace Assert\Tests;
use Assert\Assertion;
use Assert\AssertionFailedException;
class AssertionExceptionCallbackTest extends \PHPUnit_Framework_TestCase
{
public function testMessageCallback()
$this->setExpectedException(AssertionFailedException::class, 'The value of M_PI is not regarded as a string');
Assertion::string(M_PI, function ($value, $propertyPath = null) {
function ($value, $prope...egarded as a string'; }
object<Closure>
string|null
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:
function acceptsInteger($int) { } $x = '123'; // string "123" // Instead of acceptsInteger($x); // we recommend to use acceptsInteger((integer) $x);
return 'The value of M_PI is not regarded as a string';
});
}
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: