Skip to content

Commit

Permalink
NewlineAfterStatementRector
Browse files Browse the repository at this point in the history
  • Loading branch information
priyadi committed Jul 19, 2024
1 parent 6a0a6a3 commit 2012a9e
Show file tree
Hide file tree
Showing 25 changed files with 54 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/file-association-entity/src/EmbeddedMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,15 @@
class EmbeddedMetadata implements RawMetadataInterface, \IteratorAggregate
{
private ?string $name = null;

private ?int $size = null;

private ?string $type = null;

private ?\DateTimeInterface $modificationTime = null;

private ?int $width = null;

private ?int $height = null;

/**
Expand Down
1 change: 1 addition & 0 deletions packages/file-association-entity/src/FileCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public function getName(): FileNameInterface
if ($this->name instanceof TranslatableInterface) {
return new TranslatableFileName($this->name);
}

return new FileName($this->name);

}
Expand Down
1 change: 1 addition & 0 deletions packages/file-association-entity/src/FileDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public static function getFile(
// any chance the caller calls `flush()`, the metadata will be
// persisted.
}

$metadata->clear();
$metadata->merge($file->get(RawMetadataInterface::class) ?? []);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public function getName(): FileNameInterface
if ($this->name instanceof TranslatableInterface) {
return new TranslatableFileName($this->name);
}

return new FileName($this->name);

}
Expand Down
1 change: 1 addition & 0 deletions packages/file-contracts/src/FileProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public static function getFile(
//

private bool $isFileMissing = false;

private ?FileInterface $wrapped = null;

//
Expand Down
1 change: 1 addition & 0 deletions packages/file-contracts/src/FileRepositoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public function tryGet(FilePointerInterface $filePointer): ?FileInterface;
* Gets a lazy-loading proxy to the file specified by the pointer.
*/
public function getReference(FilePointerInterface $filePointer): FileInterface;

/**
* Clears the repository's cache
*/
Expand Down
1 change: 1 addition & 0 deletions packages/file-contracts/src/Trait/EqualityTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
trait EqualityTrait
{
abstract public function getFilesystemIdentifier(): ?string;

abstract public function getKey(): string;

public function isEqualTo(FilePointerInterface|FileInterface $other): bool
Expand Down
2 changes: 2 additions & 0 deletions packages/file-derivation/src/Filter/AbstractFileFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
abstract class AbstractFileFilter implements FileFilterInterface
{
private FileRepositoryInterface $fileRepository;

private FileInterface $sourceFile;

/**
Expand Down Expand Up @@ -117,6 +118,7 @@ public function getResult(): FileInterface
if ($result->isEqualTo($derivationFilePointer)) {
return $result;
}

return $this->fileRepository->copy($result, $derivationFilePointer);

}
Expand Down
1 change: 1 addition & 0 deletions packages/file-filepond/src/FilePondType.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
if (!$options['allow_delete']) {
$event->setData($event->getForm()->getData());
}

return;
}

Expand Down
2 changes: 2 additions & 0 deletions packages/file-image/src/ImageResizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@ class ImageResizer extends AbstractFileFilter
//

final public const ASPECTRATIO_ORIGINAL = 'original';

final public const ASPECTRATIO_SQUARE = 'square';

//
// properties
//

private int $maxWidthOrHeight = 512;

private string $aspect = self::ASPECTRATIO_ORIGINAL;

//
Expand Down
8 changes: 8 additions & 0 deletions packages/file-metadata/src/Constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,20 @@
class Constants
{
public const HTTP_CACHE_CONTROL = 'http.cacheControl';

public const HTTP_DISPOSITION = 'http._disposition';

public const HTTP_ETAG = 'http.eTag';

public const FILE_NAME = 'file.name';

public const FILE_SIZE = 'file.size';

public const FILE_TYPE = 'file.type';

public const FILE_MODIFICATION_TIME = 'file.modificationTime';

public const MEDIA_WIDTH = 'media.width';

public const MEDIA_HEIGHT = 'media.height';
}
1 change: 1 addition & 0 deletions packages/file-metadata/src/Metadata/FileMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public function getName(): FileNameInterface
if ($result === null) {
return new FileName(null, $this->getType()->getExtension());
}

return new FileName((string) $result);
}

Expand Down
5 changes: 5 additions & 0 deletions packages/file-metadata/src/Model/FileName.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
final class FileName implements FileNameInterface
{
private ?string $name = null;

private ?string $extension = null;

public function __construct(
Expand Down Expand Up @@ -49,6 +50,7 @@ public function __toString(): string
if ($this->extension !== null && $this->extension !== '') {
return 'Untitled.' . $this->extension;
}

return 'Untitled';

}
Expand Down Expand Up @@ -80,6 +82,7 @@ public function getFull(): \Stringable&TranslatableInterface
]
);
}

return new TranslatableMessage('Untitled', 'Untitled');

}
Expand All @@ -94,6 +97,7 @@ public function getFull(): \Stringable&TranslatableInterface
]
);
}

return new TranslatableMessage(
$this->name,
'{name}',
Expand All @@ -114,6 +118,7 @@ public function getBase(): \Stringable&TranslatableInterface
if ($this->name === null) {
return new TranslatableMessage('Untitled', 'Untitled');
}

return new TranslatableMessage(
$this->name,
'{name}',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
final class MimeMapFileTypeAdapter implements FileTypeInterface
{
private readonly string $type;

private ?Type $parsedType = null;

public function __construct(string $type)
Expand Down
1 change: 1 addition & 0 deletions packages/file-metadata/src/Model/TranslatableFileName.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public function getFull(): \Stringable&TranslatableInterface
]
);
}

return new TranslatableMessage(
(string) $this->base,
'{name}',
Expand Down
1 change: 1 addition & 0 deletions packages/file-null/src/NullFileTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ private function throwException(string $message): never
if ($this instanceof \Throwable) {
throw new NullFileOperationException($message, 0, $this);
}

throw new NullFileOperationException($message);

}
Expand Down
5 changes: 5 additions & 0 deletions packages/file-zip/src/ZipDirectory.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@ final class ZipDirectory
* @var DirectoryInterface<array-key,NodeInterface>
*/
private DirectoryInterface $directory;

private string $directoryName = '';

private ?self $parent = null;

private ?string $directoryPathCache = null;

public function __construct(
Expand Down Expand Up @@ -76,6 +79,7 @@ public function process(): void
if ($file === null) {
continue;
}

$this->processFile($file);
} elseif ($node instanceof FileInterface) {
$this->processFile($node);
Expand Down Expand Up @@ -160,6 +164,7 @@ private function translate(TranslatableInterface&\Stringable $message): string
if ($this->translator !== null) {
return $message->trans($this->translator, $this->translator->getLocale());
}

return (string) $message;

}
Expand Down
3 changes: 3 additions & 0 deletions packages/file/src/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,11 @@ class File implements FileInterface
use MetadataTrait;

private ?RawMetadata $metadataCache = null;

private FilesystemOperator $filesystem;

private bool $isAdHocFilesystem = false;

private bool $isLocalFilesystem;

/**
Expand Down
1 change: 1 addition & 0 deletions packages/file/src/Filesystem/RemoteFilesystemDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ public function writeStream(
$this->metadataGenerator
->generateMetadataFromStream($rawMetadata, $contents);
}

fseek($contents, 0);
$this->getWrapped()->writeStream($location, $contents, $config);
} else {
Expand Down
5 changes: 5 additions & 0 deletions packages/file/src/MetadataSerializer/MetadataSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,15 @@ private function convertLegacyData(array $inputArray): array
if (!is_string($file) && !is_null($file)) {
$file = null;
}

$newArray[Constants::FILE_NAME] = $file;
break;

case 'content-length':
if (!is_int($value)) {
continue 2;
}

$newArray[Constants::FILE_SIZE] = $value;
break;

Expand All @@ -94,6 +96,7 @@ private function convertLegacyData(array $inputArray): array
if (!is_string($value)) {
continue 2;
}

$datetime = new \DateTimeImmutable($value);
$newArray[Constants::FILE_MODIFICATION_TIME] = (int) $datetime->format('U');

Expand All @@ -102,13 +105,15 @@ private function convertLegacyData(array $inputArray): array
if (!is_int($value)) {
continue 2;
}

$newArray[Constants::MEDIA_WIDTH] = $value;
break;

case 'height':
if (!is_int($value)) {
continue 2;
}

$newArray[Constants::MEDIA_HEIGHT] = $value;
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@
interface MetadataSerializerInterface
{
public function serialize(RawMetadataInterface $metadata): string;

public function deserialize(string $serialized): RawMetadataInterface;
}
2 changes: 2 additions & 0 deletions packages/file/src/Repository/FileRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ private function getFilesystemFromPointerOrFile(
if ($file instanceof FileInterface) {
throw new AdHocFilesystemException($file, $e);
}

throw $e;
}
}
Expand Down Expand Up @@ -144,6 +145,7 @@ public function get(FilePointerInterface $filePointer): FileInterface
$filePointer->getKey(),
);
}

return $this->fileCache[$hash] = new File(
$filePointer->getKey(),
$this->getFilesystemFromPointerOrFile($filePointer),
Expand Down
2 changes: 2 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Rector\CodeQuality\Rector\If_\CombineIfRector;
use Rector\CodeQuality\Rector\If_\SimplifyIfElseToTernaryRector;
use Rector\CodingStyle\Rector\Catch_\CatchExceptionNameMatchingTypeRector;
use Rector\CodingStyle\Rector\Stmt\NewlineAfterStatementRector;
use Rector\CodingStyle\Rector\Use_\SeparateMultiUseImportsRector;
use Rector\Config\RectorConfig;
use Rector\DeadCode\Rector\Assign\RemoveUnusedVariableAssignRector;
Expand Down Expand Up @@ -43,6 +44,7 @@
)
->withPhpSets(php81: true)
->withRules([
NewlineAfterStatementRector::class,
// AddOverrideAttributeToOverriddenMethodsRector::class,
])
->withSkip([
Expand Down
1 change: 1 addition & 0 deletions tests/FileAssociation/FileAssociationManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class FileAssociationManagerTest extends TestCase
use FileTestTrait;

private ?FileAssociationManager $fileAssociationManager = null;

private ?FileRepositoryInterface $fileRepository = null;

public function setUp(): void
Expand Down
1 change: 1 addition & 0 deletions tests/FileZip/ZipTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
class ZipTest extends TestCase
{
private ?FileRepositoryInterface $fileRepository = null;

private ?FileZip $fileZip = null;

public function setUp(): void
Expand Down

0 comments on commit 2012a9e

Please sign in to comment.