Skip to content

Commit

Permalink
Update PHP-CS-Fixer (#59)
Browse files Browse the repository at this point in the history
Co-authored-by: mpdude <[email protected]>
  • Loading branch information
mpdude and mpdude authored Apr 19, 2024
1 parent c212eb4 commit 642c759
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/fix-cs-php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
ref: ${{ github.head_ref }}

- name: Run PHP-CS-Fixer
uses: docker://oskarstark/php-cs-fixer-ga:3.26.0
uses: docker://oskarstark/php-cs-fixer-ga

- name: Commit and push back changes
uses: stefanzweifel/git-auto-commit-action@v5
Expand Down
2 changes: 1 addition & 1 deletion src/Attribute/Locale.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ final class Locale
{
private ?string $primary;

public function __construct(string $primary = null)
public function __construct(?string $primary = null)
{
$this->primary = $primary;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Attribute/Translatable.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ final class Translatable
{
private ?string $translationFieldname;

public function __construct(string $translationFieldname = null)
public function __construct(?string $translationFieldname = null)
{
$this->translationFieldname = $translationFieldname;
}
Expand Down
6 changes: 3 additions & 3 deletions src/Doctrine/PersistentTranslatable.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function __construct(
private readonly ReflectionProperty $localeField,
private readonly ReflectionProperty $translationMapping,
private readonly ReflectionProperty $translatedProperty,
LoggerInterface $logger = null,
?LoggerInterface $logger = null,
) {
$this->oid = spl_object_id($entity);
$this->logger = $logger ?? new NullLogger();
Expand Down Expand Up @@ -158,7 +158,7 @@ private function createTranslationEntity(string $locale): object
return $entity;
}

public function setTranslation(mixed $value, string $locale = null): void
public function setTranslation(mixed $value, ?string $locale = null): void
{
$locale = $locale ?: $this->getDefaultLocale();
if ($locale === $this->primaryLocale) {
Expand All @@ -175,7 +175,7 @@ public function setTranslation(mixed $value, string $locale = null): void
/**
* @throws TranslationException
*/
public function translate(string $locale = null): mixed
public function translate(?string $locale = null): mixed
{
$locale = $locale ?: $this->getDefaultLocale();
try {
Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/TranslatableClassMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public static function parseFromClass(string $class, ClassMetadataFactory $class
return $tm;
}

public function setLogger(LoggerInterface $logger = null): void
public function setLogger(?LoggerInterface $logger = null): void
{
$this->logger = $logger;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Doctrine/UninitializedPersistentTranslatable.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ public function __construct(private readonly string $primaryValue)
{
}

public function translate(string $locale = null): mixed
public function translate(?string $locale = null): mixed
{
throw new LogicException('this method is not supposed to be called');
}

public function setTranslation(mixed $value, string $locale = null): void
public function setTranslation(mixed $value, ?string $locale = null): void
{
throw new LogicException('this method is not supposed to be called');
}
Expand Down
4 changes: 2 additions & 2 deletions src/Translatable.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ public function setDefaultLocale(string $locale): void
$this->defaultLocale = $locale;
}

public function translate(string $locale = null): mixed
public function translate(?string $locale = null): mixed
{
$locale = $locale ?: $this->getDefaultLocale();

return $this->translations[$locale] ?? null;
}

public function setTranslation(mixed $value, string $locale = null): void
public function setTranslation(mixed $value, ?string $locale = null): void
{
$locale = $locale ?: $this->getDefaultLocale();

Expand Down
4 changes: 2 additions & 2 deletions src/TranslatableChain.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ private function __construct(
$this->translatables = $translatables;
}

public function translate(string $locale = null): mixed
public function translate(?string $locale = null): mixed
{
$c = $this->comparator;
foreach ($this->translatables as $translation) {
Expand All @@ -51,7 +51,7 @@ public function translate(string $locale = null): mixed
return null;
}

public function setTranslation(mixed $value, string $locale = null): void
public function setTranslation(mixed $value, ?string $locale = null): void
{
$this->translatables[0]->setTranslation($value, $locale);
}
Expand Down
4 changes: 2 additions & 2 deletions src/TranslatableInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ interface TranslatableInterface
*
* @return TTranslatedValue The translation or null if not available.
*/
public function translate(string $locale = null): mixed;
public function translate(?string $locale = null): mixed;

/**
* Overwrites the translation for the given locale.
*
* @param TTranslatedValue $value The value to set for the particular locale
* @param string|null $locale The target locale or null for the current locale.
*/
public function setTranslation(mixed $value, string $locale = null): void;
public function setTranslation(mixed $value, ?string $locale = null): void;

/**
* Returns wether the text is translated into the target locale.
Expand Down
2 changes: 1 addition & 1 deletion tests/Doctrine/PersistentTranslatableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public function isTranslatedInto_returns_false_if_translation_is_not_set()
/**
* @return PersistentTranslatable
*/
private function createProxy(TestEntity $entity, LoggerInterface $logger = null)
private function createProxy(TestEntity $entity, ?LoggerInterface $logger = null)
{
$localeProvider = new DefaultLocaleProvider();
$localeProvider->setDefaultLocale('de');
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixtures/Entity/TestEntityTranslation.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class TestEntityTranslation extends BaseTranslation
/**
* @param string|null $text
*/
public function __construct($locale = null, $text = null, TestEntity $entity = null)
public function __construct($locale = null, $text = null, ?TestEntity $entity = null)
{
$this->locale = $locale;
$this->text = $text;
Expand Down

0 comments on commit 642c759

Please sign in to comment.