8000 Enable PHPCS rules for PHP 8.0 by derrabus · Pull Request #9293 · doctrine/orm · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Enable PHPCS rules for PHP 8.0 #9293

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<!-- Ignore warnings, show progress of the run and show sniff names -->
<arg value="nps"/>

<config name="php_version" value="70400"/>
<config name="php_version" value="80000"/>

<file>lib</file>
<file>tests</file>
Expand All @@ -26,6 +26,7 @@
<exclude name="SlevomatCodingStandard.ControlStructures.EarlyExit"/>
<exclude name="SlevomatCodingStandard.Classes.SuperfluousAbstractClassNaming"/>
<exclude name="SlevomatCodingStandard.Classes.SuperfluousExceptionNaming"/>
<exclude name="SlevomatCodingStandard.Classes.ModernClassNameReference.ClassNameReferencedViaFunctionCall"/>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've deactivated the rule for now because the discussion around it seems to block the merge. I can activate it again in a follow-up.

</rule>

<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint">
Expand Down
3 changes: 1 addition & 2 deletions tests/Doctrine/StaticAnalysis/get-metadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@
abstract class GetMetadata
{
/**
* @param string|object $class
* @psalm-param class-string|object $class
*/
abstract public function getEntityManager($class): EntityManagerInterface;
abstract public function getEntityManager(string|object $class): EntityManagerInterface;

/**
* @psalm-param class-string<TObject> $class
Expand Down
8 changes: 2 additions & 6 deletions tests/Doctrine/Tests/DoctrineTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@ abstract class DoctrineTestCase extends TestCase

/**
* @param array<mixed> $arguments
*
* @return mixed
*/
public static function __callStatic(string $method, array $arguments)
public static function __callStatic(string $method, array $arguments): mixed
{
if (isset(self::$phpunitMethodRenames[$method])) {
$method = self::$phpunitMethodRenames[$method];
Expand All @@ -41,10 +39,8 @@ public static function __callStatic(string $method, array $arguments)

/**
* @param array<mixed> $arguments
*
* @return mixed
*/
public function __call(string $method, array $arguments)
public function __call(string $method, array $arguments): mixed
{
if ($method === 'createStub') {
return $this->getMockBuilder(...$arguments)
Expand Down
10 changes: 2 additions & 8 deletions tests/Doctrine/Tests/Mocks/CacheRegionMock.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,16 @@ class CacheRegionMock implements Region

/**
* Queue a return value for a specific method invocation
*
* @param mixed $value
*/
public function addReturn(string $method, $value): void
public function addReturn(string $method, mixed $value): void
{
$this->returns[$method][] = $value;
}

/**
* Dequeue a value for a specific method invocation
*
* @param mixed $default
*
* @return mixed
*/
private function getReturn(string $method, $default)
private function getReturn(string $method, mixed $default): mixed
{
if (isset($this->returns[$method]) && ! empty($this->returns[$method])) {
return array_shift($this->returns[$method]);
Expand Down
7 changes: 1 addition & 6 deletions tests/Doctrine/Tests/Mocks/ConnectionMock.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,7 @@ public function quote($input, $type = null)
return $input;
}

/* Mock API */

/**
* @param mixed $fetchOneResult
*/
public function setFetchOneResult($fetchOneResult): void
public function setFetchOneResult(mixed $fetchOneResult): void
{
$this->_fetchOneResult = $fetchOneResult;
}
Expand Down
5 changes: 1 addition & 4 deletions tests/Doctrine/Tests/Mocks/EntityPersisterMock.php
9E88
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@ class EntityPersisterMock extends BasicEntityPersister
/** @var bool */
private $existsCalled = false;

/**
* @return mixed
*/
public function addInsert($entity)
public function addInsert($entity): mixed
{
$this->inserts[] = $entity;
if (
Expand Down
20 changes: 4 additions & 16 deletions tests/Doctrine/Tests/Models/DDC3711/DDC3711EntityA.php
F438
Original file line number Diff line number Diff line change
Expand Up @@ -17,34 +17,22 @@ class DDC3711EntityA
/** @var ArrayCollection */
private $entityB;

/**
* @return mixed
*/
public function getId1()
public function getId1(): mixed
{
return $this->id1;
}

/**
* @param mixed $id1
*/
public function setId1($id1): void
public function setId1(mixed $id1): void
{
$this->id1 = $id1;
}

/**
* @return mixed
*/
public function getId2()
public function getId2(): mixed
{
return $this->id2;
}

/**
* @param mixed $id2
*/
public function setId2($id2): void
public function setId2(mixed $id2): void
{
$this->id2 = $id2;
}
Expand Down
10 changes: 2 additions & 8 deletions tests/Doctrine/Tests/Models/ECommerce/ECommerceShipping.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,12 @@ public function getId(): int
return $this->id;
}

/**
* @return int|string
*/
public function getDays()
public function getDays(): int|string
{
return $this->days;
}

/**
* @param int|string $days
*/
public function setDays($days): void
public function setDays(int|string $days): void
{
$this->days = $days;
}
Expand Down
4 changes: 1 addition & 3 deletions tests/Doctrine/Tests/ORM/EntityManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,10 @@ public function dataToBeReturnedByWrapInTransaction(): Generator
}

/**
* @param mixed $expectedValue
*
* @dataProvider dataToBeReturnedByWrapInTransaction
* @group DDC-1125
*/
public function testWrapInTransactionAcceptsReturn($expectedValue): void
public function testWrapInTransactionAcceptsReturn(mixed $expectedValue): void
{
$return = $this->entityManager->wrapInTransaction(
/** @return mixed */
Expand Down
10 changes: 2 additions & 8 deletions tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2895Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,18 +105,12 @@ class DDC2895 extends AbstractDDC2895
*/
public $id;

/**
* @param mixed $id
*/
public function setId($id): void
public function setId(mixed $id): void
{
$this->id = $id;
}

/**
* @return mixed
*/
public function getId()
public function getId(): mixed
{
return $this->id;
}
Expand Down
3 changes: 1 addition & 2 deletions tests/Doctrine/Tests/ORM/Functional/Ticket/DDC5684Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ class DDC5684ObjectId
/** @var mixed */
public $value;

/** @param mixed $value */
public function __construct($value)
public function __construct(mixed $value)
{
$this->value = $value;
}
Expand Down
5 changes: 1 addition & 4 deletions tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6303Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,7 @@ class DDC6303ChildA extends DDC6303BaseClass
*/
private $originalData;

/**
* @param mixed $originalData
*/
public function __construct(string $id, $originalData)
public function __construct(string $id, mixed $originalData)
{
$this->id = $id;
$this->originalData = $originalData;
Expand Down
5 changes: 1 addition & 4 deletions tests/Doctrine/Tests/ORM/Functional/Ticket/GH5762Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,7 @@ public function testIssue(): void
self::assertContains('Volvo', $cars);
}

/**
* @return mixed
*/
private function fetchData()
private function fetchData(): mixed
{
$this->createData();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,10 @@ public static function validResultSetProvider(): Generator

/**
* @param list<array<string, mixed>> $resultSet
* @param mixed $expectedResult
*
* @dataProvider validResultSetProvider
*/
public function testHydrateSingleScalarFromFieldMappingWithValidResultSet(array $resultSet, $expectedResult): void
public function testHydrateSingleScalarFromFieldMappingWithValidResultSet(array $resultSet, mixed $expectedResult): void
{
$rsm = new ResultSetMapping();
$rsm->addEntityResult(CmsUser::class, 'u');
Expand All @@ -72,11 +71,10 @@ public function testHydrateSingleScalarFromFieldMappingWithValidResultSet(array

/**
* @param list<array<string, mixed>> $resultSet
* @param mixed $expectedResult
*
* @dataProvider validResultSetProvider
*/
public function testHydrateSingleScalarFromScalarMappingWithValidResultSet(array $resultSet, $expectedResult): void
public function testHydrateSingleScalarFromScalarMappingWithValidResultSet(array $resultSet, mixed $expectedResult): void
{
$rsm = new ResultSetMapping();
$rsm->addScalarResult('u__id', 'id', 'string');
Expand Down
4 changes: 1 addition & 3 deletions tests/Doctrine/Tests/ORM/ORMInvalidArgumentExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@
class ORMInvalidArgumentExceptionTest extends TestCase
{
/**
* @param mixed $value
*
* @dataProvider invalidEntityNames
*/
public function testInvalidEntityName($value, string $expectedMessage): void
public function testInvalidEntityName(mixed $value, string $expectedMessage): void
{
$exception = ORMInvalidArgumentException::invalidEntityName($value);

Expand Down
5 changes: 1 addition & 4 deletions tests/Doctrine/Tests/ORM/Query/ParameterTypeInfererTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,9 @@ public function providerParameterTypeInferer(): array
}

/**
* @param mixed $value
* @param int|string $expected
*
* @dataProvider providerParameterTypeInferer
*/
public function testParameterTypeInferer($value, $expected): void
public function testParameterTypeInferer(mixed $value, int|string $expected): void
{
self::assertEquals($expected, ParameterTypeInferer::inferType($value));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,9 @@ protected function setUp(): void
}

/**
* @param QueryBuilder\Comparison|QueryBuilder\Func|string $queryExpr
*
* @dataProvider comparisonData
*/
public function testWalkComparison(CriteriaComparison $criteriaExpr, $queryExpr, ?Parameter $parameter = null): void
public function testWalkComparison(CriteriaComparison $criteriaExpr, QueryBuilder\Comparison|QueryBuilder\Func|string $queryExpr, ?Parameter $parameter = null): void
{
self::assertEquals($queryExpr, $this->visitor->walkComparison($criteriaExpr));
if ($parameter) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,7 @@ public function testWillReplaceBoundQueryIdentifiersWithConvertedTypesAsPerAssoc
);
}

/** @param mixed $parameter */
private function assertPaginatorWhereInParameterToBe(Query $query, $parameter): void
private function assertPaginatorWhereInParameterToBe(Query $query, mixed $parameter): void
{
$query->getSQL(); // forces walker to process the query

Expand Down
25 changes: 5 additions & 20 deletions tests/Doctrine/Tests/ORM/UnitOfWorkTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -308,12 +308,10 @@ public function testNoUndefinedIndexNoticeOnScheduleForUpdateWithoutChanges(): v
}

/**
* @param mixed $invalidValue
*
* @group DDC-3490
* @dataProvider invalidAssociationValuesDataProvider
*/
public function testRejectsPersistenceOfObjectsWithInvalidAssociationValue($invalidValue): void
public function testRejectsPersistenceOfObjectsWithInvalidAssociationValue(mixed $invalidValue): void
{
$this->_unitOfWork->setEntityPersister(
ForumUser::class,
Expand All @@ -333,12 +331,10 @@ public function testRejectsPersistenceOfObjectsWithInvalidAssociationValue($inva
}

/**
* @param mixed $invalidValue
*
* @group DDC-3490
* @dataProvider invalidAssociationValuesDataProvider
*/
public function testRejectsChangeSetComputationForObjectsWithInvalidAssociationValue($invalidValue): void
public function testRejectsChangeSetComputationForObjectsWithInvalidAssociationValue(mixed $invalidValue): void
{
$metadata = $this->_emMock->getClassMetadata(ForumUser::class);

Expand Down Expand Up @@ -880,18 +876,12 @@ public function setTransient($value): void
}
}

/**
* @return mixed
*/
public function getData()
public function getData(): mixed
{
return $this->data;
}

/**
* @param mixed $data
*/
public function setData($data): void
public function setData(mixed $data): void
{
if ($data !== $this->data) {
$this->onPropertyChanged('data', $this->data, $data);
Expand All @@ -904,12 +894,7 @@ public function addPropertyChangedListener(PropertyChangedListener $listener): v
$this->_listeners[] = $listener;
}

/**
* @param mixed $propName
* @param mixed $oldValue
* @param mixed $newValue
*/
protected function onPropertyChanged($propName, $oldValue, $newValue): void
protected function onPropertyChanged(mixed $propName, mixed $oldValue, mixed $newValue): void
{
if ($this->_listeners) {
foreach ($this->_listeners as $listener) {
Expand Down
7 changes: 2 additions & 5 deletions tests/Doctrine/Tests/OrmTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,10 @@ protected function createAnnotationDriver(array $paths = []): AnnotationDriver
* mocked out using a DriverMock, ConnectionMock, etc. These mocks can then
* be configured in the tests to simulate the DBAL behavior that is desired
* for a particular test,
*
* @param Connection|array $conn
* @param mixed $conf
*/
protected function getTestEntityManager(
$conn = null,
$conf = null,
Connection|array|null $conn = null,
mixed $conf = null,
?EventManager $eventManager = null,
bool $withSharedMetadata = true
): EntityManagerMock {
Expand Down
0