for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Habemus\Definition\Build;
use Closure;
use Habemus\Definition\Definition;
use Habemus\Definition\Identifiable\IdentifiableTrait;
use Habemus\Definition\MethodCall\CallableMethod;
use Habemus\Definition\MethodCall\CallableMethodTrait;
use Habemus\Definition\Sharing\Shareable;
use Habemus\Definition\Sharing\ShareableTrait;
use Habemus\Definition\Tag\Taggable;
use Habemus\Definition\Tag\TaggableTrait;
use Psr\Container\ContainerInterface;
class ReferenceDefinition implements Definition, Shareable, CallableMethod, Taggable
{
use IdentifiableTrait;
use ShareableTrait;
use CallableMethodTrait;
use TaggableTrait;
/**
* @var string
*/
protected $id;
* @var Closure
protected $fn;
public function __construct(string $id, Closure $fn = null)
$this->id = $id;
$this->fn = $fn;
if (! $this->fn instanceof Closure) {
$this->fn = function ($instance, ContainerInterface $c) {
$c
If this is a false-positive, you can also ignore this issue in your code via the ignore-unused annotation
ignore-unused
$this->fn = function ($instance, /** @scrutinizer ignore-unused */ ContainerInterface $c) {
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
return $instance;
};
}
public function id(): string
return $this->id;
public function getConcrete(ContainerInterface $container)
return ($this->fn)($container->get($this->id), $container);
public function __toString(): string
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.