Thanks to visit codestin.com
Credit goes to github.com

Skip to content
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
13 changes: 4 additions & 9 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,22 @@

$config = new PhpCsFixer\Config();
return $config->setRules([
'@PSR12' => true,
'array_syntax' => ['syntax' => 'short'],

// imports
'@PER-CS2.0' => true,
'@PER-CS2.0:risky' => true,
'fully_qualified_strict_types' => true,
'global_namespace_import' => [
'import_classes' => false,
'import_constants' => false,
'import_functions' => false,
],
'no_leading_import_slash' => true,
'no_unneeded_import_alias' => true,
'no_unused_imports' => true,
'ordered_imports' => [
'sort_algorithm' => 'alpha',
'imports_order' => ['const', 'class', 'function']
'imports_order' => ['class', 'function', 'const']
],
'single_line_after_imports' => true,
'no_useless_else' => true,
'no_useless_return' => true,
'declare_strict_types' => true,
'native_function_invocation' => ['include' => ['@compiler_optimized']],
'header_comment' => [
'header' => <<<EOF
This file is part of rekalogika/file-src package.
Expand Down
6 changes: 3 additions & 3 deletions packages/file-association-entity/src/EmbeddedMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private function getOther(string $key): int|string|bool|null
$this->other = [];
}

if (!array_key_exists($key, $this->other)) {
if (!\array_key_exists($key, $this->other)) {
throw new MetadataNotFoundException($key);
}

Expand Down Expand Up @@ -172,7 +172,7 @@ public function delete(string $key): void
Constants::FILE_MODIFICATION_TIME => $this->modificationTime = null,
Constants::MEDIA_WIDTH => $this->width = null,
Constants::MEDIA_HEIGHT => $this->height = null,
default => $this->unsetOther($key)
default => $this->unsetOther($key),
};
}

Expand All @@ -187,6 +187,6 @@ public function merge(iterable $metadata): void
#[\Override]
public function count(): int
{
return count($this->getOthers()) + 6;
return \count($this->getOthers()) + 6;
}
}
2 changes: 1 addition & 1 deletion packages/file-association-entity/src/FileCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ final class FileCollection extends CollectionDecorator implements DirectoryInter
*/
public function __construct(
Collection $files,
private readonly null|string|(TranslatableInterface&\Stringable) $name = null
private readonly null|string|(TranslatableInterface&\Stringable) $name = null,
) {
parent::__construct($files);
}
Expand Down
17 changes: 8 additions & 9 deletions packages/file-association-entity/src/FileDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class FileDecorator implements FileInterface

public static function getFile(
?FileInterface $file,
EmbeddedMetadata $metadata
EmbeddedMetadata $metadata,
): ?FileInterface {
if ($metadata->isFilePresent() === false) {
// metadata says the file does not exist, and the file does not
Expand Down Expand Up @@ -70,7 +70,7 @@ public static function getFile(
public static function setFile(
?FileInterface $input,
?FileInterface &$file,
EmbeddedMetadata $metadata
EmbeddedMetadata $metadata,
): void {
$metadata->clear();

Expand All @@ -87,7 +87,7 @@ public static function setFile(
public static function setFileMandatory(
FileInterface $input,
FileInterface &$file,
EmbeddedMetadata $metadata
EmbeddedMetadata $metadata,
): void {
$metadata->clear();
$file = $input;
Expand All @@ -100,9 +100,8 @@ public static function setFileMandatory(

private function __construct(
private FileInterface $file,
private EmbeddedMetadata $metadata
) {
}
private EmbeddedMetadata $metadata,
) {}

//
// other methods
Expand All @@ -115,13 +114,13 @@ public static function syncMetadata(FileInterface $file): void
{
if (!$file instanceof self) {
throw new \InvalidArgumentException(
sprintf('"syncMetadata()" only accepts %s', static::class)
\sprintf('"syncMetadata()" only accepts %s', static::class),
);
}

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

Expand All @@ -143,7 +142,7 @@ public function get(string $id)

/** @psalm-suppress MixedReturnStatement */
return MetadataFactory::create(
$this->get(RawMetadataInterface::class) ?? new RawMetadata()
$this->get(RawMetadataInterface::class) ?? new RawMetadata(),
)
->get($id);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ class FileMetadataDecorator implements RawMetadataInterface, \IteratorAggregate
public function __construct(
private readonly RawMetadataInterface $embeddedMetadata,
private readonly RawMetadataInterface $fileMetadata,
) {
}
) {}

#[\Override]
public function getIterator(): \Traversable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ final class ReadableFileCollection extends ReadableCollectionDecorator implement
*/
public function __construct(
ReadableCollection $files,
private readonly null|string|(TranslatableInterface&\Stringable) $name = null
private readonly null|string|(TranslatableInterface&\Stringable) $name = null,
) {
parent::__construct($files);
}
Expand Down
4 changes: 2 additions & 2 deletions packages/file-association-entity/src/UnsetFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ class UnsetFile extends \Exception implements NullFileInterface
*/
public function __construct(string $className, string $propertyName)
{
parent::__construct(sprintf(
parent::__construct(\sprintf(
'File property "%s" in class "%s" is unset. This might be caused by the use of `AbstractQuery::toIterable()`. If that is the case, you can: 1. stop involving "%s" in the query; 2. pre-hydrate the file entities before the query; or 3. use other means to iterate the query.',
$propertyName,
$className,
$className
$className,
));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class AsFileAssociation
public function __construct(
string $fetch = 'EAGER',
) {
if (!in_array($fetch, ['EAGER', 'LAZY'])) {
if (!\in_array($fetch, ['EAGER', 'LAZY'])) {
throw new \InvalidArgumentException('Fetch mode can only be EAGER or LAZY.');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,4 @@
namespace Rekalogika\File\Association\Attribute;

#[\Attribute(\Attribute::TARGET_CLASS)]
class WithFileAssociation
{
}
class WithFileAssociation {}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ interface FileLocationResolverInterface
{
public function getFileLocation(
object $object,
string $propertyName
string $propertyName,
): FilePointerInterface;
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,4 @@

namespace Rekalogika\File\Association\Exception;

abstract class FileAssociationException extends \Exception
{
}
abstract class FileAssociationException extends \Exception {}
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ class ChainedObjectNotSupportedException extends FileLocationResolverException
public function __construct(
object $object,
private readonly iterable $exceptions,
\Throwable $previous = null
\Throwable $previous = null,
) {
\Exception::__construct(
\sprintf(
'Cannot find a resolver that supports the object "%s"',
$object::class,
),
0,
$previous
$previous,
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,4 @@

use Rekalogika\File\Association\Exception\FileAssociationException;

class FileLocationResolverException extends FileAssociationException
{
}
class FileLocationResolverException extends FileAssociationException {}
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ public function __construct(
string $class,
object $object,
string $message,
\Throwable $previous = null
\Throwable $previous = null,
) {
parent::__construct(
\sprintf(
'File location resolver "%s" does not support object "%s": %s',
$class,
$object::class,
$message
$message,
),
0,
$previous
$previous,
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ class ChainedObjectIdResolverException extends ObjectIdResolverException
public function __construct(
object $object,
private readonly iterable $exceptions,
\Throwable $previous = null
\Throwable $previous = null,
) {
\Exception::__construct(
\sprintf(
'None of the object ID resolvers registered in the system supports the object "%s"',
$object::class,
),
0,
$previous
$previous,
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ class EmptyIdException extends ObjectIdResolverException
public function __construct(
object $object,
string $method,
\Throwable $previous = null
\Throwable $previous = null,
) {
parent::__construct(
\sprintf(
"Method '%s' in object '%s' returned an empty id",
$method,
$object::class
$object::class,
),
0,
$previous
$previous,
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ public function __construct(
object $object,
string $method,
mixed $id,
\Throwable $previous = null
\Throwable $previous = null,
) {
parent::__construct(
\sprintf(
'Method "%s" of object "%s" returned an unsupported identifier "%s"',
$method,
$object::class,
\get_debug_type($id)
get_debug_type($id),
),
0,
$previous
$previous,
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ class MethodNotFoundException extends ObjectIdResolverException
public function __construct(
object $object,
string $method,
\Throwable $previous = null
\Throwable $previous = null,
) {
parent::__construct(
\sprintf(
"Method '%s' not found in object '%s'",
$method,
$object::class
$object::class,
),
0,
$previous
$previous,
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,4 @@

use Rekalogika\File\Association\Exception\FileAssociationException;

class ObjectIdResolverException extends FileAssociationException
{
}
class ObjectIdResolverException extends FileAssociationException {}
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ class ObjectNotSupportedException extends ObjectIdResolverException
{
public function __construct(
object $object,
\Throwable $previous = null
\Throwable $previous = null,
) {
parent::__construct(
\sprintf(
'Object "%s" is not supported.',
$object::class,
),
0,
$previous
$previous,
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function __construct(
object $object,
) {
parent::__construct(
sprintf(
\sprintf(
'Property "%s" not found in object "%s"',
$propertyName,
$object::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,4 @@

use Rekalogika\File\Association\Exception\FileAssociationException;

abstract class PropertyInspectorException extends FileAssociationException
{
}
abstract class PropertyInspectorException extends FileAssociationException {}
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ class PropertyReaderException extends FileAssociationException
public function __construct(
object $object,
string $property,
\Throwable $previous = null
\Throwable $previous = null,
) {
$message = sprintf('Unable to read property "%s" in object "%s"', $property, \get_debug_type($object));
$message = \sprintf('Unable to read property "%s" in object "%s"', $property, get_debug_type($object));

parent::__construct($message, 0, $previous);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ public function __construct(
object|array $object,
string $property,
mixed $value,
\Throwable $previous = null
\Throwable $previous = null,
) {
$message = sprintf('Unable to write "%s" to property "%s" in object "%s"', \get_debug_type($value), $property, \get_debug_type($object));
$message = \sprintf('Unable to write "%s" to property "%s" in object "%s"', get_debug_type($value), $property, get_debug_type($object));

parent::__construct($message, 0, $previous);
}
Expand Down
Loading
Loading