for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Kata\Lonja\Domain\Service;
use Kata\Lonja\Domain\Model\Destination;
use Kata\Lonja\Domain\Model\Load;
use Kata\Lonja\Domain\PriceRule;
final class CalculateLoadBenefit
{
/**
* @param Load $a_load
* @param Destination $a_destination
* @param PriceRule[] $some_price_rules
*
* @return float
*/
public function __invoke(Load $a_load, Destination $a_destination, array $some_price_rules): float
$load_lines = $a_load->lines();
$benefits = 0;
foreach ($load_lines as $load_line)
foreach ($some_price_rules as $price_rule)
if ($load_line->product()->equals($price_rule->product()) && $a_destination->city() === $price_rule->city())
$price_rule->product()
object<Kata\Lonja\Domain\Model\Product>
object<self>
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);
$benefits += $price_rule->price() * $load_line->kilograms();
}
return $benefits;
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: