for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Simply\Container;
/**
* Abstract entry provider that provides the most basic provider initialization functionality.
*
* @author Riikka Kalliomäki <[email protected]>
* @copyright Copyright (c) 2018 Riikka Kalliomäki
* @license http://opensource.org/licenses/mit-license.php MIT License
*/
abstract class AbstractEntryProvider implements EntryProvider
{
* Returns a new instance of the entry provider.
* @return EntryProvider New entry provider instance initialized with default constructor
public static function initialize(): EntryProvider
return new static();
}
* Returns provided list of all classes returned by the container methods.
* @return string[] Provided list of all classes returned by the container methods
public function getMethods(): array
$methods = [];
$reflection = new \ReflectionClass($this);
foreach ($reflection->getMethods() as $method) {
$identifier = $this->getMethodIdentifier($method);
if (!\is_null($identifier)) {
$methods[$identifier] = $method->getName();
return $methods;
* Tells the identifier to use for the given provider method.
* @param \ReflectionMethod $method The provider method
* @return string|null The identifier for the method or null if not applicable
private function getMethodIdentifier(\ReflectionMethod $method): ?string
if (!$method->isPublic() || $method->isStatic()) {
return null;
if (preg_match('/^__[^_]/', $method->getName())) {
$type = $method->getReturnType();
if (!$type instanceof \ReflectionType || $type->isBuiltin()) {
return $type->getName();