Pimple just introduce container builder principe. If you understand it, you don't need Pimple any more:
class Container{ private $shared = array(); public function getService() { return new Service( this->getFirstDependence(), this->getSecondDependence() ); } protected function getFirstDependence() { return new FirstDependence( this->getSecondDependence() ); } protected function getSecondDependence() { return isset($this->shared[__METHOD__]) ? $this->shared[__METHOD__] : $this->shared[__METHOD__] = new SecondDependence( ); }}
This way Pimple does not hide type of object in mixed $c['some key']. You would have autocomplete suggestions when edit your container. Phpstorm is able to autoresolve method return type from your code. And you would have clear container. You can ever override container:
class TestContainer extends Container{ protected function getFirstDependence() { return new FirstDependenceMock( ); }}
To be honest container written in 'programming' lanuage is wrong way to go. Container responsibility is to bring initialized graph of objects to caller. Having access to 'programming language' allows to violate that responsibility with easy. Some DSL for configuring dependency is better. Moreover most of original dependency information (argument typehints of constructors) is just ignored by Pimple and sfDepenencyContainer making your configuration bloated and fragile.