Type fixes relating to DI phpstan stubs.
This commit is contained in:
parent
bbf8d56b46
commit
89b1d913a1
|
@ -336,6 +336,7 @@ return [
|
|||
*/
|
||||
foreach ($receivers as $messageClass => $handlerClass) {
|
||||
$handlers[$messageClass][] = static function ($message) use ($handlerClass, $di) {
|
||||
/** @var callable $obj */
|
||||
$obj = $di->get($handlerClass);
|
||||
return $obj($message);
|
||||
};
|
||||
|
|
|
@ -31,6 +31,10 @@ parameters:
|
|||
scanDirectories:
|
||||
- ./vendor/zircote/swagger-php/src/Annotations
|
||||
|
||||
stubFiles:
|
||||
- util/phpstan_di.stub
|
||||
- util/phpstan_phpdi.stub
|
||||
|
||||
universalObjectCratesClasses:
|
||||
- App\Session\NamespaceInterface
|
||||
- App\View
|
||||
|
|
|
@ -85,6 +85,9 @@ final class CallableEventDispatcher extends EventDispatcher implements CallableE
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param class-string $className
|
||||
*/
|
||||
public function addCallableListener(
|
||||
string $eventName,
|
||||
string $className,
|
||||
|
@ -98,6 +101,9 @@ final class CallableEventDispatcher extends EventDispatcher implements CallableE
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param class-string $className
|
||||
*/
|
||||
public function removeCallableListener(
|
||||
string $eventName,
|
||||
string $className,
|
||||
|
@ -109,6 +115,9 @@ final class CallableEventDispatcher extends EventDispatcher implements CallableE
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param class-string $className
|
||||
*/
|
||||
private function getCallable(
|
||||
string $className,
|
||||
?string $method = '__invoke'
|
||||
|
|
|
@ -8,6 +8,7 @@ use App\Container\ContainerAwareTrait;
|
|||
use App\Container\EntityManagerAwareTrait;
|
||||
use App\Container\EnvironmentAwareTrait;
|
||||
use Doctrine\Common\DataFixtures\Executor\ORMExecutor;
|
||||
use Doctrine\Common\DataFixtures\FixtureInterface;
|
||||
use Doctrine\Common\DataFixtures\Loader;
|
||||
use Doctrine\Common\DataFixtures\Purger\ORMPurger;
|
||||
use RecursiveDirectoryIterator;
|
||||
|
@ -46,7 +47,10 @@ final class SetupFixturesCommand extends CommandAbstract
|
|||
continue;
|
||||
}
|
||||
|
||||
/** @var class-string $className */
|
||||
$className = 'App\\Entity\\Fixture\\' . $fileName;
|
||||
|
||||
/** @var FixtureInterface $fixture */
|
||||
$fixture = $this->di->get($className);
|
||||
|
||||
$loader->addFixture($fixture);
|
||||
|
|
|
@ -114,7 +114,7 @@ final class NowPlayingCommand extends AbstractSyncRunnerCommand
|
|||
$lookupRaw = $this->nowPlayingCache->getLookup();
|
||||
$lookup = [];
|
||||
foreach ($lookupRaw as $stationRow) {
|
||||
$lookup[$stationRow['short_name']] = (int)($stationRow['updated_at'] ?? 0);
|
||||
$lookup[$stationRow['short_name']] = $stationRow['updated_at'];
|
||||
}
|
||||
|
||||
$allStations = $this->em->createQuery(
|
||||
|
|
|
@ -59,7 +59,7 @@ final class ListAction implements SingleActionInterface
|
|||
|
||||
[$searchPhrase, $playlist, $special] = $this->parseSearchQuery(
|
||||
$station,
|
||||
$searchPhraseFull
|
||||
$searchPhraseFull ?? ''
|
||||
);
|
||||
|
||||
$cacheKeyParts = [
|
||||
|
|
|
@ -17,6 +17,12 @@ use App\Radio\Enums\RemoteAdapters;
|
|||
|
||||
/**
|
||||
* Manager class for radio adapters.
|
||||
*
|
||||
* @phpstan-type AdapterInfo array<string, array{
|
||||
* enum: AdapterTypeInterface,
|
||||
* name: string,
|
||||
* class: class-string|null
|
||||
* }>
|
||||
*/
|
||||
final class Adapters
|
||||
{
|
||||
|
@ -109,10 +115,11 @@ final class Adapters
|
|||
/**
|
||||
* @param array<AdapterTypeInterface> $cases
|
||||
* @param bool $checkInstalled
|
||||
* @return mixed[]
|
||||
* @return AdapterInfo
|
||||
*/
|
||||
private function listAdaptersFromEnum(array $cases, bool $checkInstalled = false): array
|
||||
{
|
||||
/** @var AdapterInfo $adapters */
|
||||
$adapters = [];
|
||||
foreach ($cases as $adapter) {
|
||||
$adapters[$adapter->getValue()] = [
|
||||
|
@ -130,9 +137,10 @@ final class Adapters
|
|||
return true;
|
||||
}
|
||||
|
||||
/** @var AbstractLocalAdapter $adapter */
|
||||
$adapter = $this->di->get($adapterInfo['class']);
|
||||
return $adapter->isInstalled();
|
||||
return ($adapter instanceof AbstractLocalAdapter)
|
||||
? $adapter->isInstalled()
|
||||
: true;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
@ -10,5 +10,6 @@ interface AdapterTypeInterface
|
|||
|
||||
public function getName(): string;
|
||||
|
||||
/** @return class-string|null */
|
||||
public function getClass(): ?string;
|
||||
}
|
||||
|
|
|
@ -24,6 +24,9 @@ enum BackendAdapters: string implements AdapterTypeInterface
|
|||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @return class-string<Liquidsoap>|null
|
||||
*/
|
||||
public function getClass(): ?string
|
||||
{
|
||||
return match ($this) {
|
||||
|
|
|
@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Radio\Enums;
|
||||
|
||||
use App\Radio\Frontend\AbstractFrontend;
|
||||
use App\Radio\Frontend\Icecast;
|
||||
use App\Radio\Frontend\Shoutcast;
|
||||
|
||||
|
@ -27,6 +28,9 @@ enum FrontendAdapters: string implements AdapterTypeInterface
|
|||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @return class-string<AbstractFrontend>|null
|
||||
*/
|
||||
public function getClass(): ?string
|
||||
{
|
||||
return match ($this) {
|
||||
|
|
|
@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Radio\Enums;
|
||||
|
||||
use App\Radio\Remote\AbstractRemote;
|
||||
use App\Radio\Remote\AzuraRelay;
|
||||
use App\Radio\Remote\Icecast;
|
||||
use App\Radio\Remote\Shoutcast1;
|
||||
|
@ -31,6 +32,9 @@ enum RemoteAdapters: string implements AdapterTypeInterface
|
|||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @return class-string<AbstractRemote>
|
||||
*/
|
||||
public function getClass(): string
|
||||
{
|
||||
return match ($this) {
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
|
||||
namespace Psr\Container;
|
||||
|
||||
interface ContainerInterface
|
||||
{
|
||||
/**
|
||||
* Finds an entry of the container by its identifier and returns it.
|
||||
*
|
||||
* @template T
|
||||
* @param class-string<T> $id Identifier of the entry to look for.
|
||||
* @return T Entry.
|
||||
*/
|
||||
public function get(string $id);
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
|
||||
namespace DI;
|
||||
|
||||
class Container
|
||||
{
|
||||
/**
|
||||
* Finds an entry of the container by its identifier and returns it.
|
||||
*
|
||||
* @template T
|
||||
* @param class-string<T> $id Identifier of the entry to look for.
|
||||
* @return T Entry.
|
||||
*/
|
||||
public function get(string $id);
|
||||
}
|
Loading…
Reference in New Issue