Skip to content

Commit

Permalink
Fix CS
Browse files Browse the repository at this point in the history
  • Loading branch information
jdreesen committed Mar 1, 2024
1 parent 3bd1ed7 commit e7ffb1d
Show file tree
Hide file tree
Showing 16 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/Converter.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ interface Converter
*
* @throws ConverterException
*/
public function convert(object $source, object $ctx = null): object;
public function convert(object $source, ?object $ctx = null): object;
}
2 changes: 1 addition & 1 deletion src/Converter/GenericConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function __construct(
*
* @return TTarget
*/
public function convert(object $source, object $ctx = null): object
public function convert(object $source, ?object $ctx = null): object
{
$target = $this->factory->create($ctx);

Expand Down
2 changes: 1 addition & 1 deletion src/Converter/StrategicConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function __construct(
*
* @return TTarget
*/
public function convert(object $source, object $ctx = null): object
public function convert(object $source, ?object $ctx = null): object
{
$selectedConverterKey = $this->selector->selectConverter($source, $ctx);
if (\array_key_exists($selectedConverterKey, $this->converters)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Converter/Strategy/ConverterSelector.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ interface ConverterSelector
* @param TSource $source
* @param TContext $ctx
*/
public function selectConverter(object $source, object $ctx = null): string;
public function selectConverter(object $source, ?object $ctx = null): string;
}
2 changes: 1 addition & 1 deletion src/Populator.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ interface Populator
* @param TSource $source
* @param TContext $ctx
*/
public function populate(object $target, object $source, object $ctx = null): void;
public function populate(object $target, object $source, ?object $ctx = null): void;
}
8 changes: 4 additions & 4 deletions src/Populator/ArrayConvertingPopulator.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ public function __construct(
Converter $converter,
string $sourceArrayPropertyName,
string $targetPropertyName,
string $sourceArrayItemPropertyName = null,
PropertyAccessorInterface $arrayItemAccessor = null,
PropertyAccessorInterface $accessor = null,
?string $sourceArrayItemPropertyName = null,
?PropertyAccessorInterface $arrayItemAccessor = null,
?PropertyAccessorInterface $accessor = null,
) {
$this->populator = new ArrayPropertyMappingPopulator(
$targetPropertyName,
Expand All @@ -50,7 +50,7 @@ public function __construct(
/**
* @throws PopulationException
*/
public function populate(object $target, object $source, object $ctx = null): void
public function populate(object $target, object $source, ?object $ctx = null): void
{
$this->populator->populate($target, $source, $ctx);
}
Expand Down
8 changes: 4 additions & 4 deletions src/Populator/ArrayPropertyMappingPopulator.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ public function __construct(
private string $targetProperty,
private string $sourceArrayProperty,
private ?string $sourceArrayItemProperty = null,
\Closure $mapper = null,
PropertyAccessorInterface $arrayItemAccessor = null,
PropertyAccessorInterface $accessor = null,
?\Closure $mapper = null,
?PropertyAccessorInterface $arrayItemAccessor = null,
?PropertyAccessorInterface $accessor = null,
) {
$this->mapper = $mapper ?? static fn ($v) => $v;
$this->arrayItemAccessor = $arrayItemAccessor ?? PropertyAccess::createPropertyAccessor();
Expand All @@ -42,7 +42,7 @@ public function __construct(
/**
* @throws PopulationException
*/
public function populate(object $target, object $source, object $ctx = null): void
public function populate(object $target, object $source, ?object $ctx = null): void
{
try {
$unwrappedArray = array_map(
Expand Down
6 changes: 3 additions & 3 deletions src/Populator/ContextMappingPopulator.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ final class ContextMappingPopulator implements Populator
public function __construct(
private string $targetProperty,
private string $contextProperty,
\Closure $mapper = null,
PropertyAccessorInterface $accessor = null,
?\Closure $mapper = null,
?PropertyAccessorInterface $accessor = null,
) {
$this->mapper = $mapper ?? static fn ($v) => $v;
$this->accessor = $accessor ?? PropertyAccess::createPropertyAccessor();
Expand All @@ -39,7 +39,7 @@ public function __construct(
/**
* @throws PopulationException
*/
public function populate(object $target, object $source, object $ctx = null): void
public function populate(object $target, object $source, ?object $ctx = null): void
{
if (!$ctx || !$ctx->hasKey($this->contextProperty)) {
return;
Expand Down
4 changes: 2 additions & 2 deletions src/Populator/ConvertingPopulator.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function __construct(
Converter $converter,
string $sourcePropertyName,
string $targetPropertyName,
PropertyAccessorInterface $accessor = null,
?PropertyAccessorInterface $accessor = null,
) {
$this->populator = new PropertyMappingPopulator(
$targetPropertyName,
Expand All @@ -47,7 +47,7 @@ public function __construct(
/**
* @throws PopulationException
*/
public function populate(object $target, object $source, object $ctx = null): void
public function populate(object $target, object $source, ?object $ctx = null): void
{
$this->populator->populate($target, $source, $ctx);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Populator/PropertyMappingPopulator.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public function __construct(
private string $targetProperty,
private string $sourceProperty,
private mixed $defaultValue = null,
\Closure $mapper = null,
PropertyAccessorInterface $accessor = null,
?\Closure $mapper = null,
?PropertyAccessorInterface $accessor = null,
) {
$this->mapper = $mapper ?? static fn ($v) => $v;
$this->accessor = $accessor ?? PropertyAccess::createPropertyAccessor();
Expand All @@ -39,7 +39,7 @@ public function __construct(
/**
* @throws PopulationException
*/
public function populate(object $target, object $source, object $ctx = null): void
public function populate(object $target, object $source, ?object $ctx = null): void
{
try {
$value = $this->accessor->getValue($source, $this->sourceProperty) ?? $this->defaultValue;
Expand Down
2 changes: 1 addition & 1 deletion src/TargetFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ interface TargetFactory
*
* @return TTarget
*/
public function create(object $ctx = null): object;
public function create(?object $ctx = null): object;
}
2 changes: 1 addition & 1 deletion tests/Fixtures/Model/AddressFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
class AddressFactory implements TargetFactory
{
public function create(object $ctx = null): PersonAddress
public function create(?object $ctx = null): PersonAddress
{
return new PersonAddress();
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixtures/Model/ContactNumberFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
class ContactNumberFactory implements TargetFactory
{
public function create(object $ctx = null): ContactNumber
public function create(?object $ctx = null): ContactNumber
{
return new ContactNumber();
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixtures/Model/PersonFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
class PersonFactory implements TargetFactory
{
public function create(object $ctx = null): Person
public function create(?object $ctx = null): Person
{
return new Person();
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixtures/Populator/AddressPopulator.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
class AddressPopulator implements Populator
{
public function populate(object $target, object $source, object $ctx = null): void
public function populate(object $target, object $source, ?object $ctx = null): void
{
$target->setStreet($source->getStreet());
$target->setStreetNo($source->getStreetNo());
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixtures/Populator/PersonNamePopulator.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
class PersonNamePopulator implements Populator
{
public function populate(object $target, object $source, object $ctx = null): void
public function populate(object $target, object $source, ?object $ctx = null): void
{
$separator = ' ';
if ($ctx?->hasKey('separator')) {
Expand Down

0 comments on commit e7ffb1d

Please sign in to comment.