for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php declare(strict_types = 1);
/**
* Created by Vitaly Iegorov <[email protected]>.
* on 03.09.16 at 11:37
*/
namespace samsonphp\generator;
* Class GenericGenerator
*
* @author Vitaly Egorov <[email protected]>
class GenericGenerator extends AbstractGenerator
{
/** @var ClassGenerator[] Collection of classes */
protected $classes = [];
/** @var FunctionGenerator[] Collection of functions */
protected $functions = [];
* Set function.
* @param string $name Function
* @param bool $isStatic Flag that function is static
$isStatic
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.
* @return FunctionGenerator New function generator instance
public function defFunction(string $name) : FunctionGenerator
return $this->functions[] = new FunctionGenerator($name, $this);
}
* Set class.
* @param string $name Class name
* @return ClassGenerator
public function defClass(string $name) : ClassGenerator
return $this->classes[] = new ClassGenerator($this, $name);
$this
this<samsonphp\generator\GenericGenerator>
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:
function acceptsInteger($int) { } $x = '123'; // string "123" // Instead of acceptsInteger($x); // we recommend to use acceptsInteger((integer) $x);
$name
object<samsonphp\generator\GenericGenerator>
* Generate code.
* @param int $indentation Code level
* @return string Generated code
public function code(int $indentation = 0) : string
foreach ($this->classes as $classGenerator) {
$this->code[] = $classGenerator->code($indentation);
foreach ($this->functions as $functionGenerator) {
$this->code[] = $functionGenerator->code($indentation);
return implode("\n".$this->indentation($indentation), $this->code);
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 methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.