mirror of
https://github.com/shlinkio/shlink.git
synced 2024-11-25 02:10:18 -06:00
Installed phpstan-dcotrine and fixed more static analysis errors
This commit is contained in:
parent
95770ac104
commit
02fd28edec
@ -67,6 +67,7 @@
|
|||||||
"infection/infection": "^0.23.0",
|
"infection/infection": "^0.23.0",
|
||||||
"phpspec/prophecy-phpunit": "^2.0",
|
"phpspec/prophecy-phpunit": "^2.0",
|
||||||
"phpstan/phpstan": "^0.12.92",
|
"phpstan/phpstan": "^0.12.92",
|
||||||
|
"phpstan/phpstan-doctrine": "^0.12.42",
|
||||||
"phpstan/phpstan-symfony": "^0.12.41",
|
"phpstan/phpstan-symfony": "^0.12.41",
|
||||||
"phpunit/php-code-coverage": "^9.2",
|
"phpunit/php-code-coverage": "^9.2",
|
||||||
"phpunit/phpunit": "^9.5",
|
"phpunit/phpunit": "^9.5",
|
||||||
|
@ -4,12 +4,9 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
use Doctrine\ORM\EntityManager;
|
use Doctrine\ORM\EntityManager;
|
||||||
use Doctrine\ORM\Tools\Console\ConsoleRunner;
|
use Doctrine\ORM\Tools\Console\ConsoleRunner;
|
||||||
use Psr\Container\ContainerInterface;
|
|
||||||
|
|
||||||
return (static function () {
|
return (static function () {
|
||||||
/** @var ContainerInterface $container */
|
/** @var EntityManager $em */
|
||||||
$container = include __DIR__ . '/container.php';
|
$em = include __DIR__ . '/entity-manager.php';
|
||||||
$em = $container->get(EntityManager::class);
|
|
||||||
|
|
||||||
return ConsoleRunner::createHelperSet($em);
|
return ConsoleRunner::createHelperSet($em);
|
||||||
})();
|
})();
|
||||||
|
12
config/entity-manager.php
Normal file
12
config/entity-manager.php
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use Doctrine\ORM\EntityManager;
|
||||||
|
use Psr\Container\ContainerInterface;
|
||||||
|
|
||||||
|
return (static function () {
|
||||||
|
/** @var ContainerInterface $container */
|
||||||
|
$container = include __DIR__ . '/container.php';
|
||||||
|
return $container->get(EntityManager::class);
|
||||||
|
})();
|
@ -32,6 +32,6 @@ abstract class AbstractDatabaseCommand extends AbstractLockedCommand
|
|||||||
|
|
||||||
protected function getLockConfig(): LockedCommandConfig
|
protected function getLockConfig(): LockedCommandConfig
|
||||||
{
|
{
|
||||||
return LockedCommandConfig::blocking($this->getName());
|
return LockedCommandConfig::blocking($this->getName() ?? static::class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,8 +45,8 @@ class DownloadGeoLiteDbCommand extends Command
|
|||||||
$io->text(sprintf('<fg=blue>%s GeoLite2 db file...</>', $olderDbExists ? 'Updating' : 'Downloading'));
|
$io->text(sprintf('<fg=blue>%s GeoLite2 db file...</>', $olderDbExists ? 'Updating' : 'Downloading'));
|
||||||
$this->progressBar = new ProgressBar($io);
|
$this->progressBar = new ProgressBar($io);
|
||||||
}, function (int $total, int $downloaded): void {
|
}, function (int $total, int $downloaded): void {
|
||||||
$this->progressBar->setMaxSteps($total);
|
$this->progressBar?->setMaxSteps($total);
|
||||||
$this->progressBar->setProgress($downloaded);
|
$this->progressBar?->setProgress($downloaded);
|
||||||
});
|
});
|
||||||
|
|
||||||
if ($this->progressBar === null) {
|
if ($this->progressBar === null) {
|
||||||
|
@ -139,7 +139,7 @@ class LocateVisitsCommand extends AbstractLockedCommand implements VisitGeolocat
|
|||||||
throw IpCannotBeLocatedException::forEmptyAddress();
|
throw IpCannotBeLocatedException::forEmptyAddress();
|
||||||
}
|
}
|
||||||
|
|
||||||
$ipAddr = $visit->getRemoteAddr();
|
$ipAddr = $visit->getRemoteAddr() ?? '';
|
||||||
$this->io->write(sprintf('Processing IP <fg=blue>%s</>', $ipAddr));
|
$this->io->write(sprintf('Processing IP <fg=blue>%s</>', $ipAddr));
|
||||||
if ($ipAddr === IpAddress::LOCALHOST) {
|
if ($ipAddr === IpAddress::LOCALHOST) {
|
||||||
$this->io->writeln(' [<comment>Ignored localhost address</comment>]');
|
$this->io->writeln(' [<comment>Ignored localhost address</comment>]');
|
||||||
@ -168,7 +168,12 @@ class LocateVisitsCommand extends AbstractLockedCommand implements VisitGeolocat
|
|||||||
|
|
||||||
private function checkDbUpdate(InputInterface $input): void
|
private function checkDbUpdate(InputInterface $input): void
|
||||||
{
|
{
|
||||||
$downloadDbCommand = $this->getApplication()->find(DownloadGeoLiteDbCommand::NAME);
|
$cliApp = $this->getApplication();
|
||||||
|
if ($cliApp === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$downloadDbCommand = $cliApp->find(DownloadGeoLiteDbCommand::NAME);
|
||||||
$exitCode = $downloadDbCommand->run($input, $this->io);
|
$exitCode = $downloadDbCommand->run($input, $this->io);
|
||||||
|
|
||||||
if ($exitCode === ExitCodes::EXIT_FAILURE) {
|
if ($exitCode === ExitCodes::EXIT_FAILURE) {
|
||||||
@ -178,6 +183,6 @@ class LocateVisitsCommand extends AbstractLockedCommand implements VisitGeolocat
|
|||||||
|
|
||||||
protected function getLockConfig(): LockedCommandConfig
|
protected function getLockConfig(): LockedCommandConfig
|
||||||
{
|
{
|
||||||
return LockedCommandConfig::nonBlocking($this->getName());
|
return LockedCommandConfig::nonBlocking(self::NAME);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,6 @@ class DomainService implements DomainServiceInterface
|
|||||||
public function getOrCreate(string $authority): Domain
|
public function getOrCreate(string $authority): Domain
|
||||||
{
|
{
|
||||||
$repo = $this->em->getRepository(Domain::class);
|
$repo = $this->em->getRepository(Domain::class);
|
||||||
/** @var Domain|null $domain */
|
|
||||||
$domain = $repo->findOneBy(['authority' => $authority]) ?? new Domain($authority);
|
$domain = $repo->findOneBy(['authority' => $authority]) ?? new Domain($authority);
|
||||||
|
|
||||||
$this->em->persist($domain);
|
$this->em->persist($domain);
|
||||||
|
@ -28,7 +28,7 @@ class ImportedLinksProcessor implements ImportedLinksProcessorInterface
|
|||||||
private ShortCodeHelperInterface $shortCodeHelper,
|
private ShortCodeHelperInterface $shortCodeHelper,
|
||||||
private DoctrineBatchHelperInterface $batchHelper
|
private DoctrineBatchHelperInterface $batchHelper
|
||||||
) {
|
) {
|
||||||
$this->shortUrlRepo = $this->em->getRepository(ShortUrl::class); // @phpstan-ignore-line
|
$this->shortUrlRepo = $this->em->getRepository(ShortUrl::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
includes:
|
includes:
|
||||||
|
- vendor/phpstan/phpstan-doctrine/extension.neon
|
||||||
- vendor/phpstan/phpstan-symfony/extension.neon
|
- vendor/phpstan/phpstan-symfony/extension.neon
|
||||||
parameters:
|
parameters:
|
||||||
checkMissingIterableValueType: false
|
checkMissingIterableValueType: false
|
||||||
checkGenericClassInNonGenericObjectType: false
|
checkGenericClassInNonGenericObjectType: false
|
||||||
symfony:
|
symfony:
|
||||||
console_application_loader: 'config/cli-app.php'
|
console_application_loader: 'config/cli-app.php'
|
||||||
|
doctrine:
|
||||||
|
repositoryClass: Happyr\DoctrineSpecification\Repository\EntitySpecificationRepository
|
||||||
|
objectManagerLoader: 'config/entity-manager.php'
|
||||||
|
Loading…
Reference in New Issue
Block a user