for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Tests\PHPSA;
use PHPSA\CompiledExpression;
use PHPSA\Variable;
class ContextTest extends TestCase
{
public function testModifyReferencedVariables()
$context = $this->getContext();
/**
* This variable is not needed for change
*/
$context->addVariable(
new Variable('a', null, CompiledExpression::INTEGER, 1)
);
* $b = true;
$variableB = new Variable('b', null, CompiledExpression::BOOLEAN, true)
true
boolean
integer
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);
* $c = &$b;
$variableC = new Variable('c');
$variableC->setReferencedTo($variableB);
$variableC
$newType = CompiledExpression::INTEGER;
$newValue = 55;
* $b = {$newValue};
* After it variable $c will change type and value
$context->modifyReferencedVariables($variableB, $newType, $newValue);
self::assertSame($newValue, $variableC->getValue());
self::assertSame($newType, $variableC->getType());
}
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: