for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/* @description Dice - A minimal Dependency Injection Container for PHP
* @author Tom Butler [email protected]
* @copyright 2012-2014 Tom Butler <[email protected]>
* @link http://r.je/dice.html
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
* @version 2.0
*/
namespace Dice\Loader;
class Json
{
public function load($json, \Dice\Dice $dice = null)
if ($dice === null) {
$dice = new \Dice\Dice();
}
if (trim($json)[0] != '{') {
$path = dirname(realpath($json));
$json = str_replace('__DIR__', $path, file_get_contents($json));
$map = json_decode($json, true);
if (!is_array($map)) {
throw new \Exception('Could not decode json: ' . json_last_error_msg());
if (isset($map['rules'])) {
foreach ($map['rules'] as $rule) {
$name = $rule['name'];
unset($rule['name']);
$dice->addRule($name, $rule);
return $dice;
foreach ($map as $name => $rule) {
$rule
null
array
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);
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: