for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* This file is part of the Composite Utils package.
*
* (c) Emily Shepherd <[email protected]>
* For the full copyright and license information, please view the
* LICENSE.md file that was distributed with this source code.
* @package spaark/composite-utils
* @author Emily Shepherd <[email protected]>
* @license MIT
*/
namespace Spaark\CompositeUtils\Model\Reflection\Type;
use Spaark\CompositeUtils\Model\Collection\ListCollection\FlexibleList;
use Spaark\CompositeUtils\Model\ClassName;
* Represents a data type which must be an instance of an object
* @property-read string $classname
class ObjectType extends AbstractType
{
* The name of the class this must be an instance of
* @readable
* @var ClassName
protected $classname;
* Creates this ObjectType with the given classname
* @param mixed $class The name of the class this must be an
$class
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.
* instance of
public function __construct($classname)
$this->classname = $classname instanceof ClassName
? $classname
: new ClassName($classname);
}
* {@inheritDoc}
public function equals($type) : bool
if
(
$type instanceof ObjectType &&
$type->classname->equals($this->classname)
$this->classname
object<Spaark\CompositeUtils\Model\ClassName>
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);
)
return true;
return false;
* Returns a string representation of the object
* @return string
public function __toString() : string
$return = (string)$this->classname;
return $return;
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.