1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
4
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
5
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
6
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
7
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
8
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
9
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
10
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
11
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
12
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
13
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
14
|
|
|
* |
15
|
|
|
* This software consists of voluntary contributions made by many individuals |
16
|
|
|
* and is licensed under the LGPL. For more information, see |
17
|
|
|
* <http://www.doctrine-project.org>. |
18
|
|
|
*/ |
19
|
|
|
namespace DoctrineFixturesModule\Loader; |
20
|
|
|
|
21
|
|
|
use Doctrine\Common\DataFixtures\Loader as BaseLoader; |
22
|
|
|
use Zend\ServiceManager\ServiceLocatorAwareInterface; |
23
|
|
|
use Zend\ServiceManager\ServiceLocatorInterface; |
24
|
|
|
use Doctrine\Common\DataFixtures\FixtureInterface; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Doctrine fixture loader which is ZF2 Service Locator-aware |
28
|
|
|
* Will inject the service locator instance into all SL-aware fixtures on add |
29
|
|
|
* |
30
|
|
|
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL |
31
|
|
|
* @link www.doctrine-project.org |
32
|
|
|
* @author Adam Lundrigan <[email protected]> |
33
|
|
|
*/ |
34
|
|
|
class ServiceLocatorAwareLoader extends BaseLoader |
35
|
|
|
{ |
36
|
|
|
/** |
37
|
|
|
* @var ServiceLocatorInterface |
38
|
|
|
*/ |
39
|
|
|
protected $serviceLocator; |
40
|
|
|
|
41
|
|
|
public function __construct(ServiceLocatorInterface $serviceLocator) |
42
|
|
|
{ |
43
|
|
|
$this->serviceLocator = $serviceLocator; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Add a fixture object instance to the loader. |
48
|
|
|
* |
49
|
|
|
* @param FixtureInterface $fixture |
50
|
|
|
*/ |
51
|
|
|
public function addFixture(FixtureInterface $fixture) |
52
|
|
|
{ |
53
|
|
|
if ($fixture instanceof ServiceLocatorAwareInterface) { |
|
|
|
|
54
|
|
|
$fixture->setServiceLocator($this->serviceLocator); |
55
|
|
|
} |
56
|
|
|
parent::addFixture($fixture); |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
|
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 thecomposer.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
orrequire-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 you have not tested against this specific condition, such errors might go unnoticed.