Issues (13)

src/Sources/ProjectSource.php (1 issue)

1
<?php
2
/**
3
 * Copyright © Vaimo Group. All rights reserved.
4
 * See LICENSE_VAIMO.txt for license details.
5
 */
6
namespace Vaimo\ComposerPatches\Sources;
7
8
class ProjectSource implements \Vaimo\ComposerPatches\Interfaces\PatchSourceListInterface
9
{
10
    /**
11
     * @var \Composer\Package\RootPackageInterface
12
     */
13
    private $rootPackage;
14
15
    /**
16
     * @param \Composer\Package\RootPackageInterface $rootPackage
17
     */
18
    public function __construct(
19
        \Composer\Package\RootPackageInterface $rootPackage
20
    ) {
21
        $this->rootPackage = $rootPackage;
22
    }
23
24
    public function getItems(\Composer\Repository\WritableRepositoryInterface $repository)
25
    {
26
        return array($this->rootPackage);
0 ignored issues
show
Bug Best Practice introduced by
The expression return array($this->rootPackage) returns the type array<integer,Composer\P...e\RootPackageInterface> which is incompatible with the return type mandated by Vaimo\ComposerPatches\In...stInterface::getItems() of array<mixed,string[]>.

In the issue above, the returned value is violating the contract defined by the mentioned interface.

Let's take a look at an example:

interface HasName {
    /** @return string */
    public function getName();
}

class Name {
    public $name;
}

class User implements HasName {
    /** @return string|Name */
    public function getName() {
        return new Name('foo'); // This is a violation of the ``HasName`` interface
                                // which only allows a string value to be returned.
    }
}
Loading history...
27
    }
28
}
29