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\Service;
use Spaark\CompositeUtils\Model\Reflection\ReflectionComposite;
use Spaark\CompositeUtils\Factory\Reflection\ReflectionCompositeFactory;
use Spaark\CompositeUtils\Model\Collection\HashMap;
class ReflectionCompositeProvider
implements ReflectionCompositeProviderInterface
{
* @var ReflectionCompositeProviderInterface
protected static $default;
public static function getDefault()
: ReflectionCompositeProviderInterface
if (!static::$default)
static::$default = new static();
}
return static::$default;
public static function setDefault
(
ReflectionCompositeProviderInterface $default
)
static::$default = $default;
private $cache;
public function __construct()
$this->cache = new HashMap();
public function get(string $classname) : ReflectionComposite
if (!$this->cache->containsKey($classname))
$classname
string
object<Spaark\CompositeU...del\Collection\KeyType>
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);
$this->cache[$classname] =
ReflectionCompositeFactory::fromClassName
->build();
return $this->cache[$classname];