This repository was archived by the owner on Feb 6, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -668,6 +668,12 @@ private function getFactory($name)
668
668
if ($ lazyLoaded ) {
669
669
$ this ->factories [$ name ] = $ factory ;
670
670
}
671
+ // PHP 5.6 fails on 'class::method' callables unless we explode them:
672
+ if (PHP_MAJOR_VERSION < 7
673
+ && is_string ($ factory ) && strpos ($ factory , ':: ' ) !== false
674
+ ) {
675
+ $ factory = explode (':: ' , $ factory );
676
+ }
671
677
return $ factory ;
672
678
}
673
679
Original file line number Diff line number Diff line change @@ -267,4 +267,20 @@ public function testSetAliasShouldWorkWithRecursiveAlias()
267
267
$ this ->assertSame ($ service , $ alias );
268
268
$ this ->assertSame ($ service , $ headAlias );
269
269
}
270
+
271
+ public static function sampleFactory ()
272
+ {
273
+ return new stdClass ();
274
+ }
275
+
276
+ public function testFactoryMayBeStaticMethodDescribedByCallableString ()
277
+ {
278
+ $ config = [
279
+ 'factories ' => [
280
+ stdClass::class => 'ZendTest\ServiceManager\ServiceManagerTest::sampleFactory ' ,
281
+ ]
282
+ ];
283
+ $ serviceManager = new SimpleServiceManager ($ config );
284
+ $ this ->assertEquals (stdClass::class, get_class ($ serviceManager ->get (stdClass::class)));
285
+ }
270
286
}
You can’t perform that action at this time.
0 commit comments