for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* @author : Jagepard <[email protected]">
* @license https://mit-license.org/ MIT
*/
namespace Rudra\Container\Traits;
trait InstantiationsTrait
{
private array $instances = [];
private function instantiate(string $name, string $instance, $data = [])
if (!array_key_exists($name, $this->instances)) {
$this->instances[$name] = new $instance($data);
}
return $this->instances[$name];
private function containerize(string $name, string $instance = null, $data = [])
$instance ??= $name;
if (!array_key_exists($name, $this->data)) {
$this->set([$name, [$instance, $data]]);
set()
If this is a false-positive, you can also ignore this issue in your code via the ignore-call annotation
ignore-call
$this->/** @scrutinizer ignore-call */
set([$name, [$instance, $data]]);
return $this->get($instance);
get()
return $this->/** @scrutinizer ignore-call */ get($instance);