Skip to content

Commit

Permalink
Merge pull request #491 from greg0ire/ensure-totally-typed
Browse files Browse the repository at this point in the history
Ensure the codebase is totally typed
  • Loading branch information
greg0ire authored Nov 4, 2024
2 parents ea5b37c + 0cbf07c commit c24b184
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 24 deletions.
4 changes: 2 additions & 2 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ awareness about deprecated code.

You need PHP 8.1 or newer to use this library.

## BC BREAK: Add return types to all the methods
## BC BREAK: Add native types declarations to all the methods

All return types defined in phpdoc `@return` are now defined in the method signature,
All types defined in phpdoc annotations are now defined natively,
they must be added to your code if you extend the classes or implement the interfaces.

## Loggers have to implement the PSR-3 contracts
Expand Down
10 changes: 2 additions & 8 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,12 @@
</rule>

<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint">
<!-- Adding parameter types is a BC break in most cases because of strict types. -->
<exclude-pattern>src/*</exclude-pattern>

<!-- ORM 3 compatibility -->
<exclude-pattern>src/Purger/ORMPurger.php</exclude-pattern>
<!-- Don't add parameter types to overridden methods -->
<exclude-pattern>tests/Common/DataFixtures/TestTypes/UuidType.php</exclude-pattern>
</rule>

<rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingNativeTypeHint">
<!-- Adding property types is a BC break in most cases. -->
<exclude-pattern>src/*</exclude-pattern>
</rule>

<rule ref="Squiz.Classes.ClassFileName.NoMatch">
<exclude-pattern>tests/*</exclude-pattern>
</rule>
Expand Down
4 changes: 1 addition & 3 deletions src/AbstractFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@ abstract class AbstractFixture implements SharedFixtureInterface
{
/**
* Fixture reference repository
*
* @var ReferenceRepository|null
*/
protected $referenceRepository;
protected ReferenceRepository|null $referenceRepository = null;

public function setReferenceRepository(ReferenceRepository $referenceRepository): void
{
Expand Down
8 changes: 2 additions & 6 deletions src/Executor/AbstractExecutor.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,13 @@ abstract class AbstractExecutor implements LoggerAwareInterface

/**
* Purger instance for purging database before loading data fixtures
*
* @var PurgerInterface|null
*/
protected $purger;
protected PurgerInterface|null $purger = null;

/**
* Fixture reference repository
*
* @var ReferenceRepository
*/
protected $referenceRepository;
protected ReferenceRepository $referenceRepository;

public function __construct(ObjectManager $manager)
{
Expand Down
4 changes: 1 addition & 3 deletions src/Purger/ORMPurger.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,8 @@ class ORMPurger implements PurgerInterface, ORMPurgerInterface

/**
* If the purge should be done through DELETE or TRUNCATE statements
*
* @var int
*/
private $purgeMode = self::PURGE_MODE_DELETE;
private int $purgeMode = self::PURGE_MODE_DELETE;

/**
* Table/view names to be excluded from purge
Expand Down
3 changes: 1 addition & 2 deletions src/ReferenceRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,9 @@ public function setReference(string $name, object $reference): void
/**
* Store the identifier of a reference
*
* @param mixed $identity
* @param class-string $class
*/
public function setReferenceIdentity(string $name, $identity, string $class): void
public function setReferenceIdentity(string $name, mixed $identity, string $class): void
{
$this->identitiesByClass[$class][$name] = $identity;
}
Expand Down

0 comments on commit c24b184

Please sign in to comment.