Skip to content
This repository has been archived by the owner on Feb 6, 2020. It is now read-only.

Commit

Permalink
use PHP 5.5, remove $self = $this
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Jun 6, 2015
1 parent b4e2bd2 commit 3e4a512
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/AbstractPluginManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ public function __construct(ConfigInterface $configuration = null)
{
parent::__construct($configuration);
$self = $this;
$this->addInitializer(function ($instance) use ($self) {
$this->addInitializer(function ($instance) {
if ($instance instanceof ServiceLocatorAwareInterface) {
$instance->setServiceLocator($self);
$instance->setServiceLocator($this);
}
});
}
Expand Down
18 changes: 7 additions & 11 deletions src/ServiceManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -610,12 +610,10 @@ public function create($name)
*/
private function createDelegatorCallback($delegatorFactory, $rName, $cName, $creationCallback)
{
$serviceManager = $this;

return function () use ($serviceManager, $delegatorFactory, $rName, $cName, $creationCallback) {
return function () use ($delegatorFactory, $rName, $cName, $creationCallback) {
return $delegatorFactory instanceof DelegatorFactoryInterface
? $delegatorFactory->createDelegatorWithName($serviceManager, $cName, $rName, $creationCallback)
: $delegatorFactory($serviceManager, $cName, $rName, $creationCallback);
? $delegatorFactory->createDelegatorWithName($this, $cName, $rName, $creationCallback)
: $delegatorFactory($this, $cName, $rName, $creationCallback);
};
}

Expand All @@ -628,9 +626,8 @@ private function createDelegatorCallback($delegatorFactory, $rName, $cName, $cre
* @return bool|mixed|null|object
* @throws Exception\ServiceNotFoundException
*
* @internal this method is internal because of PHP 5.3 compatibility - do not explicitly use it
*/
public function doCreate($rName, $cName)
protected function doCreate($rName, $cName)
{
$instance = null;

Expand Down Expand Up @@ -1188,10 +1185,9 @@ protected function checkNestedContextStop($force = false)
*/
protected function createDelegatorFromFactory($canonicalName, $requestedName)
{
$serviceManager = $this;
$delegatorsCount = count($this->delegators[$canonicalName]);
$creationCallback = function () use ($serviceManager, $requestedName, $canonicalName) {
return $serviceManager->doCreate($requestedName, $canonicalName);
$creationCallback = function () use ($requestedName, $canonicalName) {
return $this->doCreate($requestedName, $canonicalName);
};

for ($i = 0; $i < $delegatorsCount; $i += 1) {
Expand Down Expand Up @@ -1220,7 +1216,7 @@ protected function createDelegatorFromFactory($canonicalName, $requestedName)
);
}

return $creationCallback($serviceManager, $canonicalName, $requestedName, $creationCallback);
return $creationCallback($this, $canonicalName, $requestedName, $creationCallback);
}

/**
Expand Down

0 comments on commit 3e4a512

Please sign in to comment.