Skip to content

Commit

Permalink
Prefer phpstan annotation for CategoryInterface (#2463)
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentLanglet authored Sep 12, 2024
1 parent 28eb711 commit 9c7b3c8
Show file tree
Hide file tree
Showing 44 changed files with 46 additions and 46 deletions.
2 changes: 1 addition & 1 deletion src/Action/MediaDownloadAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ final class MediaDownloadAction
{
public function __construct(
private MediaManagerInterface $mediaManager,
private Pool $pool
private Pool $pool,
) {
}

Expand Down
2 changes: 1 addition & 1 deletion src/Admin/BaseMediaAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function __construct(
$contextManager = null,
?Pool $deprecatedPool = null,
?CategoryManagerInterface $deprecatedCategoryManager = null,
?ContextManagerInterface $deprecatedContextManager = null
?ContextManagerInterface $deprecatedContextManager = null,
) {
// NEXT_MAJOR: Keep the if part.
if ($pool instanceof Pool) {
Expand Down
2 changes: 1 addition & 1 deletion src/Block/FeatureMediaBlockService.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function __construct(
Environment $twig,
private Pool $pool,
private ?AdminInterface $mediaAdmin,
private MediaManagerInterface $mediaManager
private MediaManagerInterface $mediaManager,
) {
parent::__construct($twig);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Block/GalleryBlockService.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function __construct(
Environment $twig,
private Pool $pool,
private ?AdminInterface $galleryAdmin,
private GalleryManagerInterface $galleryManager
private GalleryManagerInterface $galleryManager,
) {
parent::__construct($twig);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Block/GalleryListBlockService.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ final class GalleryListBlockService extends AbstractBlockService implements Edit
public function __construct(
Environment $twig,
private GalleryManagerInterface $galleryManager,
private Pool $pool
private Pool $pool,
) {
parent::__construct($twig);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Block/MediaBlockService.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function __construct(
Environment $twig,
private Pool $pool,
private ?AdminInterface $mediaAdmin,
private MediaManagerInterface $mediaManager
private MediaManagerInterface $mediaManager,
) {
parent::__construct($twig);
}
Expand Down
2 changes: 1 addition & 1 deletion src/CDN/CloudFrontVersion3.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ final class CloudFrontVersion3 implements CDNInterface
public function __construct(
private CloudFrontClient $client,
private string $distributionId,
string $path
string $path,
) {
$this->path = rtrim($path, '/');
}
Expand Down
2 changes: 1 addition & 1 deletion src/CDN/Fallback.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ final class Fallback implements CDNInterface
{
public function __construct(
private CDNInterface $cdn,
private CDNInterface $fallback
private CDNInterface $fallback,
) {
}

Expand Down
2 changes: 1 addition & 1 deletion src/Command/CleanMediaCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ final class CleanMediaCommand extends Command
public function __construct(
private Local $filesystemLocal,
private Pool $mediaPool,
private MediaManagerInterface $mediaManager
private MediaManagerInterface $mediaManager,
) {
parent::__construct();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Command/FixMediaContextCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ final class FixMediaContextCommand extends Command
public function __construct(
private Pool $mediaPool,
private ?CategoryManagerInterface $categoryManager = null,
private ?ContextManagerInterface $contextManager = null
private ?ContextManagerInterface $contextManager = null,
) {
parent::__construct();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Command/RefreshMetadataCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ final class RefreshMetadataCommand extends Command
*/
public function __construct(
private Pool $mediaPool,
private MediaManagerInterface $mediaManager
private MediaManagerInterface $mediaManager,
) {
parent::__construct();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Command/RemoveThumbsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ final class RemoveThumbsCommand extends Command
*/
public function __construct(
private Pool $mediaPool,
private MediaManagerInterface $mediaManager
private MediaManagerInterface $mediaManager,
) {
parent::__construct();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Command/SyncThumbsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ final class SyncThumbsCommand extends Command
*/
public function __construct(
private Pool $mediaPool,
private MediaManagerInterface $mediaManager
private MediaManagerInterface $mediaManager,
) {
parent::__construct();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Command/UpdateCdnStatusCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ final class UpdateCdnStatusCommand extends Command
*/
public function __construct(
private Pool $mediaPool,
private MediaManagerInterface $mediaManager
private MediaManagerInterface $mediaManager,
) {
parent::__construct();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Filesystem/Replicate.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ final class Replicate implements Adapter, FileFactory, StreamFactory, MetadataSu
public function __construct(
private Adapter $primary,
private Adapter $secondary,
?LoggerInterface $logger = null
?LoggerInterface $logger = null,
) {
$this->logger = $logger ?? new NullLogger();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Form/DataTransformer/ProviderDataTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ final class ProviderDataTransformer implements DataTransformerInterface, LoggerA
public function __construct(
private Pool $pool,
private string $class,
array $options = []
array $options = [],
) {
$this->options = $this->getOptions($options);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Form/Type/MediaType.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ final class MediaType extends AbstractType implements LoggerAwareInterface
*/
public function __construct(
private Pool $pool,
private string $class
private string $class,
) {
}

Expand Down
2 changes: 1 addition & 1 deletion src/Generator/IdGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ final class IdGenerator implements GeneratorInterface
{
public function __construct(
private int $firstLevel = 100000,
private int $secondLevel = 1000
private int $secondLevel = 1000,
) {
}

Expand Down
2 changes: 1 addition & 1 deletion src/Listener/ORM/MediaEventSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ final class MediaEventSubscriber extends BaseMediaEventSubscriber

public function __construct(
Pool $pool,
private ?CategoryManagerInterface $categoryManager = null
private ?CategoryManagerInterface $categoryManager = null,
) {
parent::__construct($pool);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Messenger/GenerateThumbnailsHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ final class GenerateThumbnailsHandler implements BackwardCompatibleMessageHandle
public function __construct(
private GenerableThumbnailInterface $thumbnail,
private MediaManagerInterface $mediaManager,
private Pool $pool
private Pool $pool,
) {
}

Expand Down
2 changes: 1 addition & 1 deletion src/Metadata/AmazonMetadataBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ final class AmazonMetadataBuilder implements MetadataBuilderInterface
*/
public function __construct(
private array $settings,
?MimeTypesInterface $mimeTypes = null
?MimeTypesInterface $mimeTypes = null,
) {
$this->mimeTypes = $mimeTypes ?? new MimeTypes();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Metadata/ProxyMetadataBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ final class ProxyMetadataBuilder implements MetadataBuilderInterface
public function __construct(
private Pool $pool,
private ?MetadataBuilderInterface $noopMetadataBuilder = null,
private ?MetadataBuilderInterface $amazonMetadataBuilder = null
private ?MetadataBuilderInterface $amazonMetadataBuilder = null,
) {
}

Expand Down
2 changes: 1 addition & 1 deletion src/Model/Media.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ abstract class Media implements MediaInterface, \Stringable
protected Collection $galleryItems;

/**
* @var CategoryInterface|null
* @phpstan-var CategoryInterface|null
*/
protected ?object $category = null;

Expand Down
4 changes: 2 additions & 2 deletions src/Model/MediaInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,12 @@ public function setSize(?int $size): void;
public function getSize(): ?int;

/**
* @return CategoryInterface|null
* @phpstan-return CategoryInterface|null
*/
public function getCategory(): ?object;

/**
* @param CategoryInterface|null $category
* @phpstan-param CategoryInterface|null $category
*/
public function setCategory(?object $category = null): void;

Expand Down
2 changes: 1 addition & 1 deletion src/Provider/BaseProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function __construct(
protected Filesystem $filesystem,
protected CDNInterface $cdn,
protected GeneratorInterface $pathGenerator,
protected ThumbnailInterface $thumbnail
protected ThumbnailInterface $thumbnail,
) {
}

Expand Down
2 changes: 1 addition & 1 deletion src/Provider/BaseVideoProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function __construct(
ThumbnailInterface $thumbnail,
private ClientInterface $client,
private RequestFactoryInterface $requestFactory,
protected ?MetadataBuilderInterface $metadata = null
protected ?MetadataBuilderInterface $metadata = null,
) {
parent::__construct($name, $filesystem, $cdn, $pathGenerator, $thumbnail);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Provider/FileProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function __construct(
ThumbnailInterface $thumbnail,
protected array $allowedExtensions = [],
protected array $allowedMimeTypes = [],
protected ?MetadataBuilderInterface $metadata = null
protected ?MetadataBuilderInterface $metadata = null,
) {
parent::__construct($name, $filesystem, $cdn, $pathGenerator, $thumbnail);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Provider/ImageProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function __construct(
array $allowedExtensions,
array $allowedMimeTypes,
private ImagineInterface $imagineAdapter,
?MetadataBuilderInterface $metadata = null
?MetadataBuilderInterface $metadata = null,
) {
parent::__construct($name, $filesystem, $cdn, $pathGenerator, $thumbnail, $allowedExtensions, $allowedMimeTypes, $metadata);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Provider/Metadata.php

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/Provider/YouTubeProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function __construct(
ClientInterface $client,
RequestFactoryInterface $requestFactory,
?MetadataBuilderInterface $metadata = null,
private bool $html5 = false
private bool $html5 = false,
) {
parent::__construct($name, $filesystem, $cdn, $pathGenerator, $thumbnail, $client, $requestFactory, $metadata);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Resizer/CropResizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ final class CropResizer implements ResizerInterface
{
public function __construct(
private ImagineInterface $adapter,
private MetadataBuilderInterface $metadata
private MetadataBuilderInterface $metadata,
) {
}

Expand Down
2 changes: 1 addition & 1 deletion src/Resizer/SimpleResizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ final class SimpleResizer implements ResizerInterface
public function __construct(
private ImagineInterface $adapter,
private int $mode,
private MetadataBuilderInterface $metadata
private MetadataBuilderInterface $metadata,
) {
}

Expand Down
2 changes: 1 addition & 1 deletion src/Resizer/SquareResizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ final class SquareResizer implements ResizerInterface
public function __construct(
private ImagineInterface $adapter,
private int $mode,
private MetadataBuilderInterface $metadata
private MetadataBuilderInterface $metadata,
) {
}

Expand Down
2 changes: 1 addition & 1 deletion src/Security/RolesDownloadStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ final class RolesDownloadStrategy implements DownloadStrategyInterface
public function __construct(
private TranslatorInterface $translator,
private AuthorizationCheckerInterface $security,
private array $roles = []
private array $roles = [],
) {
}

Expand Down
2 changes: 1 addition & 1 deletion src/Security/SessionDownloadStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ final class SessionDownloadStrategy implements DownloadStrategyInterface
public function __construct(
private TranslatorInterface $translator,
private RequestStack $requestStack,
private int $times
private int $times,
) {
}

Expand Down
2 changes: 1 addition & 1 deletion src/Thumbnail/MessengerThumbnail.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ final class MessengerThumbnail implements ThumbnailInterface, GenerableThumbnail
{
public function __construct(
private ThumbnailInterface $thumbnail,
private MessageBusInterface $bus
private MessageBusInterface $bus,
) {
}

Expand Down
2 changes: 1 addition & 1 deletion src/Twig/MediaRuntime.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ final class MediaRuntime implements RuntimeExtensionInterface
public function __construct(
private Pool $pool,
private MediaManagerInterface $mediaManager,
private Environment $twig
private Environment $twig,
) {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ final class ImageUploadDimensionValidator extends ConstraintValidator
{
public function __construct(
private ImagineInterface $imagineAdapter,
private ImageProviderInterface $imageProvider
private ImageProviderInterface $imageProvider,
) {
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Action/MediaDownloadActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function testDownloadActionBinaryFile(): void
private function configureDownloadSecurity(
Media $media,
Request $request,
bool $isGranted
bool $isGranted,
): void {
$strategy = $this->createMock(DownloadStrategyInterface::class);
$strategy->method('isGranted')->with($media, $request)->willReturn($isGranted);
Expand Down
2 changes: 1 addition & 1 deletion tests/CDN/CloudFrontVersion3Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function testCloudFront(
string $relativePath,
string $invalidationId,
int $expectedStatus,
string $invalidationStatus
string $invalidationStatus,
): void {
$client = $this->getMockBuilder(CloudFrontClient::class)
->addMethods(['createInvalidation', 'getInvalidation'])
Expand Down
2 changes: 1 addition & 1 deletion tests/Command/CleanMediaCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ public function testExecute(): void
private function assertOutputFoundInContext(
string $extractor,
array $expected,
string $output
string $output,
): void {
preg_match_all($extractor, $output, $matches);

Expand Down
2 changes: 1 addition & 1 deletion tests/Command/RemoveThumbsCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public function testExecuteWithoutArguments(): void
array $criteria,
?array $orderBy = null,
?int $limit = null,
?int $offset = null
?int $offset = null,
) use ($medias): array {
if (null !== $offset && $offset > 0) {
return [];
Expand Down
2 changes: 1 addition & 1 deletion tests/DependencyInjection/SonataMediaExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ public function testLoadWithSonataAdminCustomConfiguration(): void
*/
public function testLoadWithFilesystemConfigurationV3(
array $expected,
array $configs
array $configs,
): void {
if (!class_exists(Sdk::class)) {
static::markTestSkipped('This test requires aws/aws-sdk-php 3.x.');
Expand Down
Loading

0 comments on commit 9c7b3c8

Please sign in to comment.