Skip to content

Commit

Permalink
Add missing type declarations and phpdoc
Browse files Browse the repository at this point in the history
This implies bumping the PHP version to 8.2, otherwise it does not
understand that a signature using mixed as a parameter type declaration
is compatible with a signature using no paramater type declaration for
the same argument.
  • Loading branch information
greg0ire committed Nov 30, 2024
1 parent 347d92d commit 67f01c4
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 38 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ jobs:
strategy:
matrix:
php-version:
- "8.1"
- "8.2"
- "8.3"
dependencies:
Expand All @@ -32,7 +31,7 @@ jobs:
- "stable"
include:
- dependencies: "lowest"
php-version: "8.1"
php-version: "8.2"
- dependencies: "highest"
stability: "dev"
php-version: "8.3"
Expand Down
9 changes: 7 additions & 2 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
UPGRADE to 4.0
==============

## Type declarations

Type declarations have been added everywhere. Types extending or implementing
types from this bundle need to be updated to match the new signatures.

## Mandatory ManagerRegistry argument

It is now mandatory to pass a `ManagerRegistry` instance to the constructor of
Expand Down Expand Up @@ -34,7 +39,7 @@ services:
and so no longer have a ``$this->container`` property. You *can* manually
implement this interface. Or, a better idea is to update your fixtures
to use dependency injection:
```diff
class MyFixture extends Fixture
{
Expand All @@ -56,7 +61,7 @@ class MyFixture extends Fixture
* The base ``Fixture`` class no longer implements ``DependentFixtureInterface``.
If you want to have a ``getDependencies()`` method, be sure to implement
this interface explicitly:

```diff
+ use Doctrine\Common\DataFixtures\DependentFixtureInterface;

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
],
"homepage": "https://www.doctrine-project.org",
"require": {
"php": "^8.1",
"php": "^8.2",
"doctrine/data-fixtures": "^2.0",
"doctrine/doctrine-bundle": "^2.2",
"doctrine/orm": "^2.14.0 || ^3.0",
Expand Down
25 changes: 0 additions & 25 deletions phpstan-baseline.neon

This file was deleted.

6 changes: 0 additions & 6 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,3 @@ parameters:
paths:
- src
- tests
excludePaths:
# Contains an issue that cannot be ignored
- tests/IntegrationTest.php

includes:
- phpstan-baseline.neon
3 changes: 2 additions & 1 deletion src/Command/LoadDataFixturesDoctrineCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\Persistence\ManagerRegistry;
use Psr\Log\AbstractLogger;
use Stringable;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
Expand Down Expand Up @@ -123,7 +124,7 @@ public function __construct(private SymfonyStyle $ui)
}

/** {@inheritDoc} */
public function log($level, $message, array $context = []): void
public function log(mixed $level, string|Stringable $message, array $context = []): void
{
$this->ui->text(sprintf(' <comment>></comment> <info>%s</info>', $message));
}
Expand Down
2 changes: 1 addition & 1 deletion src/Loader/SymfonyFixturesLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function addFixture(FixtureInterface $fixture): void
* Overridden to not allow new fixture classes to be instantiated.
* {@inheritDoc}
*/
protected function createFixture($class): FixtureInterface
protected function createFixture(string $class): FixtureInterface
{
/*
* We don't actually need to create the fixture. We just
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

class RequiredConstructorArgsFixtures implements ORMFixtureInterface
{
/** @phpstan-ignore constructor.unusedParameter */
public function __construct(string $fooRequiredArg)
{
}
Expand Down
3 changes: 3 additions & 0 deletions tests/IntegrationTestKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\BundleInterface;
use Symfony\Component\HttpKernel\Kernel;

use function rand;
Expand All @@ -35,6 +36,8 @@ protected function getContainerClass(): string

/**
* {@inheritDoc}
*
* @return array<mixed, BundleInterface>
*/
public function registerBundles(): array
{
Expand Down

0 comments on commit 67f01c4

Please sign in to comment.