Completed
Push — develop ( 2c1e6b...179509 )
by Peter
01:59
created

Factory/AbstractPluginManagerFactory.php (1 issue)

Labels
Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * Webino (http://webino.sk)
4
 *
5
 * @link        https://github.com/webino/WebinoDraw for the canonical source repository
6
 * @copyright   Copyright (c) 2012-2017 Webino, s. r. o. (http://webino.sk)
7
 * @author      Peter Bačinský <[email protected]>
8
 * @license     BSD-3-Clause
9
 */
10
11
namespace WebinoDraw\Factory;
12
13
use Zend\Mvc\Exception;
14
use Zend\Mvc\Service\AbstractPluginManagerFactory as BaseAbstractPluginManagerFactory;
15
use Zend\ServiceManager\ConfigInterface;
16
use Zend\ServiceManager\ServiceLocatorInterface;
17
use Zend\View\Helper\HelperInterface as ViewHelperInterface;
18
19
/**
20
 * Class AbstractPluginManagerFactory
21
 */
22
abstract class AbstractPluginManagerFactory extends BaseAbstractPluginManagerFactory
23
{
24
    /**
25
     * An array of helper configuration classes to ensure are on the helper_map stack.
26
     *
27
     * @var array
28
     */
29
    protected $defaultHelperMapClasses = [];
30
31
    /**
32
     * Create and return the draw loop helper manager
33
     *
34
     * @param ServiceLocatorInterface $services
35
     * @return ViewHelperInterface
36
     * @throws Exception\RuntimeException
37
     */
38
    public function createService(ServiceLocatorInterface $services)
39
    {
40
        $plugins = parent::createService($services);
41
42
        foreach ($this->defaultHelperMapClasses as $configClass) {
43
            if (!is_string($configClass) || !class_exists($configClass)) {
44
                continue;
45
            }
46
            $config = new $configClass;
47
48
            if (!$config instanceof ConfigInterface) {
0 ignored issues
show
The class Zend\ServiceManager\ConfigInterface does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
49
                throw new Exception\RuntimeException(sprintf(
50
                    'Invalid service manager configuration class provided; received "%s",'
51
                    . ' expected class implementing %s',
52
                    $configClass,
53
                    'Zend\ServiceManager\ConfigInterface'
54
                ));
55
            }
56
57
            $config->configureServiceManager($plugins);
58
        }
59
60
        /** @var \Zend\ServiceManager\ServiceManager $services */
61
        $plugins->addPeeringServiceManager($services);
62
        return $plugins;
63
    }
64
}
65