私はこの特性を持っています
use Pimple\Container;
trait ContainerAwareTrait
{
protected $container;
public function setContainer(Container $container = null)
{
if (null !== $this->container) {
$this->container = $container;
}
}
public function getContainer()
{
return $this->container;
}
}
このコードを使用しています(App
クラスを介して)
$container = new Pimple\Container();
$app = new App($container); // uses ContainerAwareTrait, constructor calls `setContainer`
var_dump($app->getContainer(), $container);die;
私が見ているのは、最初のvar_dump
結果がarray
であり、2 番目の結果が のインスタンスであることPimple\Container
です。
私はそれらが両方とも同じインスタンスであることを期待していました。誰かがここで何が起こっているのか教えてもらえますか?