Skip to content

Commit

Permalink
Reproducer issue with constructor models no isset check
Browse files Browse the repository at this point in the history
  • Loading branch information
Korbeil committed Jun 26, 2024
1 parent d3029fc commit 1ae4ff4
Show file tree
Hide file tree
Showing 54 changed files with 823 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/AutoMapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use AutoMapper\Tests\Fixtures\ClassWithMapToContextAttribute;
use AutoMapper\Tests\Fixtures\ClassWithNullablePropertyInConstructor;
use AutoMapper\Tests\Fixtures\ClassWithPrivateProperty;
use AutoMapper\Tests\Fixtures\ComposeModels\Compose;
use AutoMapper\Tests\Fixtures\ConstructorWithDefaultValues;
use AutoMapper\Tests\Fixtures\DifferentSetterGetterType;
use AutoMapper\Tests\Fixtures\Dog;
Expand Down Expand Up @@ -64,6 +65,7 @@
use Symfony\Component\Serializer\NameConverter\AdvancedNameConverterInterface;
use Symfony\Component\Uid\Ulid;
use Symfony\Component\Uid\Uuid;
use Symfony\Component\Yaml\Yaml;

/**
* @author Joel Wurtz <[email protected]>
Expand Down Expand Up @@ -1563,4 +1565,14 @@ public function testParamDocBlock(): void
'foo' => ['foo1', 'foo2'],
], $array);
}

public function testComposeSpec(): void
{
$this->buildAutoMapper();

$data = Yaml::parse(file_get_contents(__DIR__ . '/Fixtures/ComposeModels/docker-starter-compose.yaml'));
$dockerStarter = $this->autoMapper->map($data, Compose::class);

dd($dockerStarter);
}
}
10 changes: 10 additions & 0 deletions tests/Fixtures/ComposeModels/BlkioLimit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace AutoMapper\Tests\Fixtures\ComposeModels;

class BlkioLimit
{
public function __construct(public string|null $path = NULL, public int|string|null $rate = NULL)
{
}
}
10 changes: 10 additions & 0 deletions tests/Fixtures/ComposeModels/BlkioWeight.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace AutoMapper\Tests\Fixtures\ComposeModels;

class BlkioWeight
{
public function __construct(public string|null $path = NULL, public int|null $weight = NULL)
{
}
}
20 changes: 20 additions & 0 deletions tests/Fixtures/ComposeModels/Compose.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace AutoMapper\Tests\Fixtures\ComposeModels;

class Compose
{
public function __construct(
public string|null $version = NULL,
public string|null $name = NULL,
/** @var string|null|_Include[]|null */
public array|null $include = NULL,
public Service|null $services = NULL,
public Network|null $networks = NULL,
public Volume|null $volumes = NULL,
public Secret|null $secrets = NULL,
public Config|null $configs = NULL
)
{
}
}
10 changes: 10 additions & 0 deletions tests/Fixtures/ComposeModels/Config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace AutoMapper\Tests\Fixtures\ComposeModels;

class Config
{
public function __construct(public string|null $name = NULL, public string|null $content = NULL, public string|null $environment = NULL, public string|null $file = NULL, public bool|ConfigExternal|null $external = NULL, public string|float|bool|null|array $labels = NULL, public string|null $templateDriver = NULL)
{
}
}
13 changes: 13 additions & 0 deletions tests/Fixtures/ComposeModels/ConfigExternal.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace AutoMapper\Tests\Fixtures\ComposeModels;

class ConfigExternal
{
public function __construct(
/** @deprecated */
public string|null $name = NULL
)
{
}
}
10 changes: 10 additions & 0 deletions tests/Fixtures/ComposeModels/Deployment.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace AutoMapper\Tests\Fixtures\ComposeModels;

class Deployment
{
public function __construct(public string|null $mode = NULL, public string|null $endpointMode = NULL, public int|null $replicas = NULL, public DeploymentRollbackConfig|null $rollbackConfig = NULL, public DeploymentUpdateConfig|null $updateConfig = NULL, public DeploymentResources|null $resources = NULL, public DeploymentRestartPolicy|null $restartPolicy = NULL, public DeploymentPlacement|null $placement = NULL)
{
}
}
16 changes: 16 additions & 0 deletions tests/Fixtures/ComposeModels/DeploymentPlacement.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace AutoMapper\Tests\Fixtures\ComposeModels;

class DeploymentPlacement
{
public function __construct(
/** @var string|null[]|null */
public array|null $constraints = NULL,
/** @var DeploymentPlacementPreferencesItem|null[]|null */
public array|null $preferences = NULL,
public int|null $maxReplicasPerNode = NULL
)
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace AutoMapper\Tests\Fixtures\ComposeModels;

class DeploymentPlacementPreferencesItem
{
public function __construct(public string|null $spread = NULL)
{
}
}
10 changes: 10 additions & 0 deletions tests/Fixtures/ComposeModels/DeploymentResources.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace AutoMapper\Tests\Fixtures\ComposeModels;

class DeploymentResources
{
public function __construct(public DeploymentResourcesLimits|null $limits = NULL, public DeploymentResourcesReservations|null $reservations = NULL)
{
}
}
10 changes: 10 additions & 0 deletions tests/Fixtures/ComposeModels/DeploymentResourcesLimits.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace AutoMapper\Tests\Fixtures\ComposeModels;

class DeploymentResourcesLimits
{
public function __construct(public float|string|null $cpus = NULL, public string|null $memory = NULL, public int|null $pids = NULL)
{
}
}
10 changes: 10 additions & 0 deletions tests/Fixtures/ComposeModels/DeploymentResourcesReservations.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace AutoMapper\Tests\Fixtures\ComposeModels;

class DeploymentResourcesReservations
{
public function __construct(public float|string|null $cpus = NULL, public string|null $memory = NULL)
{
}
}
10 changes: 10 additions & 0 deletions tests/Fixtures/ComposeModels/DeploymentRestartPolicy.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace AutoMapper\Tests\Fixtures\ComposeModels;

class DeploymentRestartPolicy
{
public function __construct(public string|null $condition = NULL, public string|null $delay = NULL, public int|null $maxAttempts = NULL, public string|null $window = NULL)
{
}
}
10 changes: 10 additions & 0 deletions tests/Fixtures/ComposeModels/DeploymentRollbackConfig.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace AutoMapper\Tests\Fixtures\ComposeModels;

class DeploymentRollbackConfig
{
public function __construct(public int|null $parallelism = NULL, public string|null $delay = NULL, public string|null $failureAction = NULL, public string|null $monitor = NULL, public float|null $maxFailureRatio = NULL, public DeploymentRollbackConfigOrderEnum|null $order = NULL)
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace AutoMapper\Tests\Fixtures\ComposeModels;

enum DeploymentRollbackConfigOrderEnum : string
{
case START_FIRST = 'start-first';
case STOP_FIRST = 'stop-first';
}
10 changes: 10 additions & 0 deletions tests/Fixtures/ComposeModels/DeploymentUpdateConfig.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace AutoMapper\Tests\Fixtures\ComposeModels;

class DeploymentUpdateConfig
{
public function __construct(public int|null $parallelism = NULL, public string|null $delay = NULL, public string|null $failureAction = NULL, public string|null $monitor = NULL, public float|null $maxFailureRatio = NULL, public DeploymentUpdateConfigOrderEnum|null $order = NULL)
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace AutoMapper\Tests\Fixtures\ComposeModels;

enum DeploymentUpdateConfigOrderEnum : string
{
case START_FIRST = 'start-first';
case STOP_FIRST = 'stop-first';
}
13 changes: 13 additions & 0 deletions tests/Fixtures/ComposeModels/Development.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace AutoMapper\Tests\Fixtures\ComposeModels;

class Development
{
public function __construct(
/** @var DevelopmentWatchItem|null[]|null */
public array|null $watch = NULL
)
{
}
}
16 changes: 16 additions & 0 deletions tests/Fixtures/ComposeModels/DevelopmentWatchItem.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace AutoMapper\Tests\Fixtures\ComposeModels;

class DevelopmentWatchItem
{
public function __construct(
/** @var string|null[]|null */
public array|null $ignore = NULL,
public string|null $path = NULL,
public DevelopmentWatchItemActionEnum|null $action = NULL,
public string|null $target = NULL
)
{
}
}
10 changes: 10 additions & 0 deletions tests/Fixtures/ComposeModels/DevelopmentWatchItemActionEnum.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace AutoMapper\Tests\Fixtures\ComposeModels;

enum DevelopmentWatchItemActionEnum : string
{
case REBUILD = 'rebuild';
case SYNC = 'sync';
case SYNC_RESTART = 'sync+restart';
}
18 changes: 18 additions & 0 deletions tests/Fixtures/ComposeModels/DevicesItem.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace AutoMapper\Tests\Fixtures\ComposeModels;

class DevicesItem
{
public function __construct(
/** @var string|null[]|null */
public array|null $capabilities = NULL,
public string|int|null $count = NULL,
/** @var string|null[]|null */
public array|null $deviceIds = NULL,
public string|null $driver = NULL,
public string|float|bool|null|array $options = NULL
)
{
}
}
10 changes: 10 additions & 0 deletions tests/Fixtures/ComposeModels/EnvFileItem.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace AutoMapper\Tests\Fixtures\ComposeModels;

class EnvFileItem
{
public function __construct(public string|null $path = NULL, public bool|null $required = true)
{
}
}
10 changes: 10 additions & 0 deletions tests/Fixtures/ComposeModels/GenericResourcesItem.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace AutoMapper\Tests\Fixtures\ComposeModels;

class GenericResourcesItem
{
public function __construct(public GenericResourcesItemDiscreteResourceSpec|null $discreteResourceSpec = NULL)
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace AutoMapper\Tests\Fixtures\ComposeModels;

class GenericResourcesItemDiscreteResourceSpec
{
public function __construct(public string|null $kind = NULL, public float|null $value = NULL)
{
}
}
10 changes: 10 additions & 0 deletions tests/Fixtures/ComposeModels/Healthcheck.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace AutoMapper\Tests\Fixtures\ComposeModels;

class Healthcheck
{
public function __construct(public bool|null $disable = NULL, public string|null $interval = NULL, public float|null $retries = NULL, public string|null|array $test = NULL, public string|null $timeout = NULL, public string|null $startPeriod = NULL, public string|null $startInterval = NULL)
{
}
}
10 changes: 10 additions & 0 deletions tests/Fixtures/ComposeModels/Network.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace AutoMapper\Tests\Fixtures\ComposeModels;

class Network
{
public function __construct(public string|null $name = NULL, public string|null $driver = NULL, public string|float|null $driverOpts = NULL, public NetworkIpam|null $ipam = NULL, public bool|NetworkExternal|null $external = NULL, public bool|null $internal = NULL, public bool|null $enableIpv6 = NULL, public bool|null $attachable = NULL, public string|float|bool|null|array $labels = NULL)
{
}
}
13 changes: 13 additions & 0 deletions tests/Fixtures/ComposeModels/NetworkExternal.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace AutoMapper\Tests\Fixtures\ComposeModels;

class NetworkExternal
{
public function __construct(
/** @deprecated */
public string|null $name = NULL
)
{
}
}
15 changes: 15 additions & 0 deletions tests/Fixtures/ComposeModels/NetworkIpam.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace AutoMapper\Tests\Fixtures\ComposeModels;

class NetworkIpam
{
public function __construct(
public string|null $driver = NULL,
/** @var NetworkIpamConfigItem|null[]|null */
public array|null $config = NULL,
public string|null $options = NULL
)
{
}
}
Loading

0 comments on commit 1ae4ff4

Please sign in to comment.