for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types = 1);
/**
* Micro
*
* @author Raffael Sahli <[email protected]>
* @copyright Copyright (c) 2017 gyselroth GmbH (https://gyselroth.com)
* @license MIT https://opensource.org/licenses/MIT
*/
namespace Micro\Config;
use \Micro\Config;
class Struct implements ConfigInterface
{
* Store
* @var Config
private $store;
* Load config
* @param array $config
public function __construct(array $config)
$this->store = $config;
$config
array
object<Micro\Config>
$store
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..
}
* Get from config
* @param string $name
* @return mixed
public function __get(string $name)
return $this->store[$name];
* Return map
* @return Config
public function map(): Config
return $this->mapArray($this->store);
$this->store
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);
* map Array
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter $italy is not defined by the method finale(...).
$italy
finale(...)
/** * @param array $germany * @param array $island * @param array $italy */ function finale($germany, $island) { return "2:1"; }
The most likely cause is that the parameter was removed, but the annotation was not.
protected function mapArray(array $array): Config
$config = new Config();
foreach($array as $key => $value) {
if(is_array($value)) {
$config[$key] = $this->mapArray($value);
} else {
$config[$key] = $value;
return $config;
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..