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

Commit 90221a9

Browse files
committed
Merge branch 'hotfix/3'
Close #3
2 parents b4e2bd2 + 2837987 commit 90221a9

File tree

6 files changed

+38
-25
lines changed

6 files changed

+38
-25
lines changed

CHANGELOG.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file, in reverse chronological order by release.
4+
5+
## 2.5.2 - TBD
6+
7+
### Added
8+
9+
- Nothing.
10+
11+
### Deprecated
12+
13+
- Nothing.
14+
15+
### Removed
16+
17+
- Nothing.
18+
19+
### Fixed
20+
21+
- [#3](https://github.com/zendframework/zend-servicemanager/pull/3) properly updates the
22+
codebase to PHP 5.5, by taking advantage of the default closure binding
23+
(`$this` in a closure is the invoking object when created within a method). It
24+
also removes several `@requires PHP 5.4.0` annotations.

src/AbstractPluginManager.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,9 @@ abstract class AbstractPluginManager extends ServiceManager implements ServiceLo
6262
public function __construct(ConfigInterface $configuration = null)
6363
{
6464
parent::__construct($configuration);
65-
$self = $this;
66-
$this->addInitializer(function ($instance) use ($self) {
65+
$this->addInitializer(function ($instance) {
6766
if ($instance instanceof ServiceLocatorAwareInterface) {
68-
$instance->setServiceLocator($self);
67+
$instance->setServiceLocator($this);
6968
}
7069
});
7170
}

src/ServiceManager.php

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -610,12 +610,10 @@ public function create($name)
610610
*/
611611
private function createDelegatorCallback($delegatorFactory, $rName, $cName, $creationCallback)
612612
{
613-
$serviceManager = $this;
614-
615-
return function () use ($serviceManager, $delegatorFactory, $rName, $cName, $creationCallback) {
613+
return function () use ($delegatorFactory, $rName, $cName, $creationCallback) {
616614
return $delegatorFactory instanceof DelegatorFactoryInterface
617-
? $delegatorFactory->createDelegatorWithName($serviceManager, $cName, $rName, $creationCallback)
618-
: $delegatorFactory($serviceManager, $cName, $rName, $creationCallback);
615+
? $delegatorFactory->createDelegatorWithName($this, $cName, $rName, $creationCallback)
616+
: $delegatorFactory($this, $cName, $rName, $creationCallback);
619617
};
620618
}
621619

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

@@ -1188,10 +1185,9 @@ protected function checkNestedContextStop($force = false)
11881185
*/
11891186
protected function createDelegatorFromFactory($canonicalName, $requestedName)
11901187
{
1191-
$serviceManager = $this;
11921188
$delegatorsCount = count($this->delegators[$canonicalName]);
1193-
$creationCallback = function () use ($serviceManager, $requestedName, $canonicalName) {
1194-
return $serviceManager->doCreate($requestedName, $canonicalName);
1189+
$creationCallback = function () use ($requestedName, $canonicalName) {
1190+
return $this->doCreate($requestedName, $canonicalName);
11951191
};
11961192

11971193
for ($i = 0; $i < $delegatorsCount; $i += 1) {
@@ -1220,7 +1216,7 @@ protected function createDelegatorFromFactory($canonicalName, $requestedName)
12201216
);
12211217
}
12221218

1223-
return $creationCallback($serviceManager, $canonicalName, $requestedName, $creationCallback);
1219+
return $creationCallback($this, $canonicalName, $requestedName, $creationCallback);
12241220
}
12251221

12261222
/**

test/MutableCreationOptionsTraitTest.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111

1212
use PHPUnit_Framework_TestCase as TestCase;
1313

14-
/**
15-
* @requires PHP 5.4.0
16-
*/
1714
class MutableCreationOptionsTraitTest extends TestCase
1815
{
1916
protected $stub;

test/ServiceLocatorAwareTraitTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
use Zend\ServiceManager\ServiceManager;
1414

1515
/**
16-
* @requires PHP 5.4
1716
* @group Zend_ServiceManager
1817
*/
1918
class ServiceLocatorAwareTraitTest extends TestCase

test/ServiceManagerTest.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -714,15 +714,13 @@ public function testGetGlobIteratorServiceWorksProperly()
714714

715715
public function duplicateService()
716716
{
717-
$self = $this;
718-
719717
return [
720718
[
721719
'setFactory',
722-
function ($services) use ($self) {
723-
return $self;
720+
function ($services) {
721+
return $this;
724722
},
725-
$self,
723+
$this,
726724
'assertSame',
727725
],
728726
[
@@ -733,8 +731,8 @@ function ($services) use ($self) {
733731
],
734732
[
735733
'setService',
736-
$self,
737-
$self,
734+
$this,
735+
$this,
738736
'assertSame',
739737
],
740738
];

0 commit comments

Comments
 (0)