Skip to content

Commit

Permalink
Fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
GromNaN committed Dec 9, 2023
1 parent 6e0800b commit 6f7a9a1
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 26 deletions.
20 changes: 3 additions & 17 deletions Command/DoctrineODMCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Doctrine\ODM\MongoDB\Tools\Console\Helper\DocumentManagerHelper;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
* Base class for Doctrine ODM console commands to extend.
Expand All @@ -17,32 +16,19 @@
*/
abstract class DoctrineODMCommand extends Command
{
/** @var ContainerInterface|null */
protected $container;

private ?ManagerRegistry $managerRegistry;

public function __construct(?ManagerRegistry $registry = null)
public function __construct(private ManagerRegistry $managerRegistry)
{
parent::__construct();

$this->managerRegistry = $registry;
}

/** @param string $dmName */
public static function setApplicationDocumentManager(Application $application, $dmName)
public static function setApplicationDocumentManager(Application $application, string $dmName): void
{
$dm = $application->getKernel()->getContainer()->get('doctrine_mongodb')->getManager($dmName);
$helperSet = $application->getHelperSet();
$helperSet->set(new DocumentManagerHelper($dm), 'dm');
}

/**
* @internal
*
* @return ManagerRegistry
*/
protected function getManagerRegistry()
protected function getManagerRegistry(): ManagerRegistry
{
return $this->managerRegistry;
}
Expand Down
12 changes: 7 additions & 5 deletions DependencyInjection/DoctrineMongoDBExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ protected function overrideParameters($options, ContainerBuilder $container)
* @param string $defaultDB The default db name
* @param ContainerBuilder $container A ContainerBuilder instance
*/
protected function loadDocumentManagers(array $dmConfigs, $defaultDM, $defaultDB, ContainerBuilder $container)
protected function loadDocumentManagers(array $dmConfigs, $defaultDM, $defaultDB, ContainerBuilder $container): void
{
$dms = [];
foreach ($dmConfigs as $name => $documentManager) {
Expand All @@ -213,6 +213,8 @@ protected function loadDocumentManagers(array $dmConfigs, $defaultDM, $defaultDB
* @param string $defaultDM The default document manager name
* @param string $defaultDB The default db name
* @param ContainerBuilder $container A ContainerBuilder instance
*
* @return void
*/
protected function loadDocumentManager(array $documentManager, $defaultDM, $defaultDB, ContainerBuilder $container)
{
Expand Down Expand Up @@ -347,7 +349,7 @@ protected function loadDocumentManager(array $documentManager, $defaultDM, $defa
* @param array $config An array of connections configurations
* @param ContainerBuilder $container A ContainerBuilder instance
*/
protected function loadConnections(array $connections, ContainerBuilder $container)
protected function loadConnections(array $connections, ContainerBuilder $container): void
{
$cons = [];
foreach ($connections as $name => $connection) {
Expand Down Expand Up @@ -469,7 +471,7 @@ private function normalizeDriverOptions(array $connection): array
* @param ContainerBuilder $container A ContainerBuilder instance
*
* @example
*
* doctrine_mongodb:
* mappings:
* MyBundle1: ~
Expand All @@ -485,11 +487,11 @@ private function normalizeDriverOptions(array $connection): array
* dir: %kernel.dir%/../src/vendor/DoctrineExtensions/lib/DoctrineExtensions/Documents
* prefix: DoctrineExtensions\Documents\
* alias: DExt
*
* In the case of bundles everything is really optional (which leads to autodetection for this bundle) but
* in the mappings key everything except alias is a required argument.
*/
protected function loadDocumentManagerBundlesMappingInformation(array $documentManager, Definition $odmConfigDef, ContainerBuilder $container)
protected function loadDocumentManagerBundlesMappingInformation(array $documentManager, Definition $odmConfigDef, ContainerBuilder $container): void
{
// reset state of drivers and alias map. They are only used by this methods and children.
$this->drivers = [];
Expand Down
2 changes: 1 addition & 1 deletion Form/DoctrineMongoDBTypeGuesser.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public function guessMaxLength(string $class, string $property): ?ValueGuess
/**
* {@inheritDoc}
*/
public function guessMinLength($class, $property)
public function guessMinLength($class, $property): void
{
}

Expand Down
2 changes: 1 addition & 1 deletion Form/Type/DocumentType.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function configureOptions(OptionsResolver $resolver): void
$resolver->setDefaults(['document_manager' => null]);

$registry = $this->registry;
$normalizer = static function (Options $options, $manager) use ($registry) {
$normalizer = static function (Options $options, $manager) use ($registry): ObjectManager|null {
if (isset($options['document_manager']) && $manager) {
throw new InvalidArgumentException('You cannot set both an "em" and "document_manager" option.');
}
Expand Down
6 changes: 5 additions & 1 deletion Loader/SymfonyFixturesLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,11 @@ private function addGroupsFixtureMapping(string $className, array $groups): void
}
}

/** @param array<class-string<FixtureInterface>, FixtureInterface> $fixtures An array of fixtures with class names as keys */
/**
* @param array<class-string<FixtureInterface>, FixtureInterface> $fixtures An array of fixtures with class names as keys
*
* @return void
*/
private function validateDependencies(array $fixtures, FixtureInterface $fixture)
{
if (! $fixture instanceof DependentFixtureInterface) {
Expand Down
5 changes: 5 additions & 0 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
<code>children</code>
</UndefinedMethod>
</file>
<file src="Form/DoctrineMongoDBTypeGuesser.php">
<InvalidReturnType>
<code>?TypeGuess</code>
</InvalidReturnType>
</file>
<file src="Loader/SymfonyFixturesLoader.php">
<ContainerDependency>
<code>private ContainerInterface $container</code>
Expand Down
1 change: 0 additions & 1 deletion psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
<directory name="APM"/>
<directory name="CacheWarmer"/>
<directory name="Command"/>
<directory name="Cursor"/>
<directory name="DataCollector"/>
<directory name="DependencyInjection"/>
<directory name="EventSubscriber"/>
Expand Down

0 comments on commit 6f7a9a1

Please sign in to comment.