bearsunday /
BEAR.Package
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace BEAR\Package\Module; |
||
| 6 | |||
| 7 | use BEAR\Package\Injector; |
||
| 8 | use BEAR\Package\Module\Import\ImportApp; |
||
| 9 | use BEAR\Resource\Annotation\ImportAppConfig; |
||
| 10 | use BEAR\Resource\AppAdapter; |
||
|
0 ignored issues
–
show
|
|||
| 11 | use BEAR\Resource\SchemeCollectionInterface; |
||
| 12 | use Override; |
||
| 13 | use Ray\Di\Di\Named; |
||
| 14 | use Ray\Di\ProviderInterface; |
||
| 15 | |||
| 16 | /** @implements ProviderInterface<SchemeCollectionInterface> */ |
||
| 17 | final class ImportSchemeCollectionProvider implements ProviderInterface |
||
| 18 | { |
||
| 19 | /** @param ImportApp[] $importAppConfig */ |
||
| 20 | #[Named('importAppConfig=BEAR\Resource\Annotation\ImportAppConfig,schemeCollection=original')] |
||
| 21 | public function __construct( |
||
| 22 | #[Named(ImportAppConfig::class)] |
||
| 23 | private array $importAppConfig, |
||
| 24 | #[Named('original')] |
||
| 25 | private SchemeCollectionInterface $schemeCollection, |
||
| 26 | ) { |
||
| 27 | } |
||
| 28 | |||
| 29 | /** |
||
| 30 | * {@inheritDoc} |
||
| 31 | */ |
||
| 32 | #[Override] |
||
| 33 | public function get(): SchemeCollectionInterface |
||
| 34 | { |
||
| 35 | foreach ($this->importAppConfig as $app) { |
||
| 36 | $injector = Injector::getInstance($app->appName, $app->context, $app->appDir); |
||
| 37 | $adapter = new AppAdapter($injector, $app->appName); |
||
| 38 | $this->schemeCollection |
||
| 39 | ->scheme('page')->host($app->host)->toAdapter($adapter) |
||
| 40 | ->scheme('app')->host($app->host)->toAdapter($adapter); |
||
| 41 | } |
||
| 42 | |||
| 43 | return $this->schemeCollection; |
||
|
0 ignored issues
–
show
The expression
return $this->schemeCollection returns the type BEAR\Resource\SchemeCollectionInterface which is incompatible with the return type mandated by Ray\Di\ProviderInterface::get() of Ray\Di\T.
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...
|
|||
| 44 | } |
||
| 45 | } |
||
| 46 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths