forked from zendframework/zend-servicemanager
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from fhein/TEST-Prefconfiguration-gets-applied
Merge zend-servicemanager PR zendframework#242
- Loading branch information
Showing
16 changed files
with
648 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
/** | ||
* @link https://github.com/zendframework/zend-servicemanager for the canonical source repository | ||
* @copyright Copyright (c) 2018 Zend Technologies USA Inc. (http://www.zend.com) | ||
* @license http://framework.zend.com/license/new-bsd New BSD License | ||
*/ | ||
|
||
namespace ZendBench\ServiceManager\BenchAsset; | ||
|
||
use Interop\Container\ContainerInterface; | ||
use Zend\ServiceManager\Factory\DelegatorFactoryInterface; | ||
|
||
class DelegatorFactoryFoo implements DelegatorFactoryInterface | ||
{ | ||
/** | ||
* {@inheritDoc} | ||
* @see \Zend\ServiceManager\Factory\DelegatorFactoryInterface::__invoke() | ||
*/ | ||
public function __invoke(ContainerInterface $container, $name, callable $callback, array $options = null) | ||
{ | ||
return ($options !== null) ? $callback($options) : $callback(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
/** | ||
* @link https://github.com/zendframework/zend-servicemanager for the canonical source repository | ||
* @copyright Copyright (c) 2018 Zend Technologies USA Inc. (http://www.zend.com) | ||
* @license http://framework.zend.com/license/new-bsd New BSD License | ||
*/ | ||
|
||
namespace ZendBench\ServiceManager\BenchAsset; | ||
|
||
use Zend\ServiceManager\Initializer\InitializerInterface; | ||
|
||
class InitializerFoo implements InitializerInterface | ||
{ | ||
protected $options; | ||
|
||
/** | ||
* {@inheritDoc} | ||
* @see \Zend\ServiceManager\Initializer\InitializerInterface::__invoke() | ||
*/ | ||
public function __invoke(\Interop\Container\ContainerInterface $container, $instance) | ||
{ | ||
} | ||
|
||
public function __construct($options = null) | ||
{ | ||
$this->options = $options; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
<?php | ||
/** | ||
* @link http://github.com/zendframework/zend-servicemanager for the canonical source repository | ||
* @copyright Copyright (c) 2016 Zend Technologies USA Inc. (http://www.zend.com) | ||
* @license http://framework.zend.com/license/new-bsd New BSD License | ||
*/ | ||
|
||
namespace ZendBench\ServiceManager; | ||
|
||
use PhpBench\Benchmark\Metadata\Annotations\Iterations; | ||
use PhpBench\Benchmark\Metadata\Annotations\Revs; | ||
use PhpBench\Benchmark\Metadata\Annotations\Warmup; | ||
use Zend\ServiceManager\ServiceManager; | ||
|
||
/** | ||
* @Revs(1000) | ||
* @Iterations(20) | ||
* @Warmup(2) | ||
*/ | ||
class HasBench | ||
{ | ||
/** | ||
* @var ServiceManager | ||
*/ | ||
private $sm; | ||
|
||
public function __construct() | ||
{ | ||
$this->sm = new ServiceManager([ | ||
'factories' => [ | ||
'factory1' => BenchAsset\FactoryFoo::class, | ||
], | ||
'invokables' => [ | ||
'invokable1' => BenchAsset\Foo::class, | ||
], | ||
'services' => [ | ||
'service1' => new \stdClass(), | ||
], | ||
'aliases' => [ | ||
'alias1' => 'service1', | ||
'recursiveAlias1' => 'alias1', | ||
'recursiveAlias2' => 'recursiveAlias1', | ||
], | ||
'abstract_factories' => [ | ||
BenchAsset\AbstractFactoryFoo::class | ||
] | ||
]); | ||
} | ||
|
||
public function benchHasFactory1() | ||
{ | ||
// @todo @link https://github.com/phpbench/phpbench/issues/304 | ||
$sm = clone $this->sm; | ||
|
||
$sm->has('factory1'); | ||
} | ||
|
||
public function benchHasInvokable1() | ||
{ | ||
// @todo @link https://github.com/phpbench/phpbench/issues/304 | ||
$sm = clone $this->sm; | ||
|
||
$sm->has('invokable1'); | ||
} | ||
|
||
public function benchHasService1() | ||
{ | ||
// @todo @link https://github.com/phpbench/phpbench/issues/304 | ||
$sm = clone $this->sm; | ||
|
||
$sm->has('service1'); | ||
} | ||
|
||
public function benchHasAlias1() | ||
{ | ||
// @todo @link https://github.com/phpbench/phpbench/issues/304 | ||
$sm = clone $this->sm; | ||
|
||
$sm->has('alias1'); | ||
} | ||
|
||
public function benchHasRecursiveAlias1() | ||
{ | ||
// @todo @link https://github.com/phpbench/phpbench/issues/304 | ||
$sm = clone $this->sm; | ||
|
||
$sm->has('recursiveAlias1'); | ||
} | ||
|
||
public function benchHasRecursiveAlias2() | ||
{ | ||
// @todo @link https://github.com/phpbench/phpbench/issues/304 | ||
$sm = clone $this->sm; | ||
|
||
$sm->has('recursiveAlias2'); | ||
} | ||
|
||
public function benchHasAbstractFactory() | ||
{ | ||
// @todo @link https://github.com/phpbench/phpbench/issues/304 | ||
$sm = clone $this->sm; | ||
|
||
$sm->has('foo'); | ||
} | ||
|
||
public function benchHasNot() | ||
{ | ||
// @todo @link https://github.com/phpbench/phpbench/issues/304 | ||
$sm = clone $this->sm; | ||
|
||
$sm->has('42'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.