Skip to content

Commit

Permalink
Add PHP 8.3
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobdekeizer committed Mar 12, 2024
1 parent 19b13ed commit 1163539
Show file tree
Hide file tree
Showing 48 changed files with 2,310 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/dto/Settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export const supportsReadonlyClasses = (settings: Settings): boolean => {

export const createDefaultSettings = (): Settings => {
return {
phpVersion: PhpVersion.PHP82,
phpVersion: PhpVersion.PHP83,

classCase: StringCase.PascalCase,
propertyCase: StringCase.CamelCase,
Expand Down
1 change: 1 addition & 0 deletions src/enums/PhpVersion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ export enum PhpVersion {
PHP80 = 'PHP 8.0',
PHP81 = 'PHP 8.1',
PHP82 = 'PHP 8.2',
PHP83 = 'PHP 8.3',
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

class RootObject
{
/** @var string[] */
public array $stringArray;
/** @var (string|int|null)[] */
public array $mixedArray;
public array $nullArray;
public array $unknownArray;
public bool $boolean;
public float $float;
public int $int;
public null $null;
public NestedClass $nestedClass;
public string $string;

/**
* @param string[] $stringArray
* @param (string|int|null)[] $mixedArray
*/
public function __construct(
array $stringArray,
array $mixedArray,
array $nullArray,
array $unknownArray,
bool $boolean,
float $float,
int $int,
null $null,
NestedClass $nestedClass,
string $string
) {
$this->stringArray = $stringArray;
$this->mixedArray = $mixedArray;
$this->nullArray = $nullArray;
$this->unknownArray = $unknownArray;
$this->boolean = $boolean;
$this->float = $float;
$this->int = $int;
$this->null = $null;
$this->nestedClass = $nestedClass;
$this->string = $string;
}
}

<?php

class NestedClass
{
public int $var;

public function __construct(int $var)
{
$this->var = $var;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

class RootObject
{
/** @var string[] */
public readonly array $stringArray;
/** @var (string|int|null)[] */
public readonly array $mixedArray;
public readonly array $nullArray;
public readonly array $unknownArray;
public readonly bool $boolean;
public readonly float $float;
public readonly int $int;
public readonly null $null;
public readonly NestedClass $nestedClass;
public readonly string $string;

/**
* @param string[] $stringArray
* @param (string|int|null)[] $mixedArray
*/
public function __construct(
array $stringArray,
array $mixedArray,
array $nullArray,
array $unknownArray,
bool $boolean,
float $float,
int $int,
null $null,
NestedClass $nestedClass,
string $string
) {
$this->stringArray = $stringArray;
$this->mixedArray = $mixedArray;
$this->nullArray = $nullArray;
$this->unknownArray = $unknownArray;
$this->boolean = $boolean;
$this->float = $float;
$this->int = $int;
$this->null = $null;
$this->nestedClass = $nestedClass;
$this->string = $string;
}
}

<?php

class NestedClass
{
public readonly int $var;

public function __construct(int $var)
{
$this->var = $var;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
<?php

class RootObject
{
/**
* @param string[] $stringArray
* @param (string|int|null)[] $mixedArray
*/
public function __construct(
public array $stringArray,
public array $mixedArray,
public array $nullArray,
public array $unknownArray,
public bool $boolean,
public float $float,
public int $int,
public null $null,
public NestedClass $nestedClass,
public string $string
) {
}

/**
* @return string[]
*/
public function getStringArray(): array
{
return $this->stringArray;
}

/**
* @return (string|int|null)[]
*/
public function getMixedArray(): array
{
return $this->mixedArray;
}

public function getNullArray(): array
{
return $this->nullArray;
}

public function getUnknownArray(): array
{
return $this->unknownArray;
}

public function getBoolean(): bool
{
return $this->boolean;
}

public function getFloat(): float
{
return $this->float;
}

public function getInt(): int
{
return $this->int;
}

public function getNull(): null
{
return $this->null;
}

public function getNestedClass(): NestedClass
{
return $this->nestedClass;
}

public function getString(): string
{
return $this->string;
}

/**
* @param string[] $stringArray
*/
public function setStringArray(array $stringArray): void
{
$this->stringArray = $stringArray;
}

/**
* @param (string|int|null)[] $mixedArray
*/
public function setMixedArray(array $mixedArray): void
{
$this->mixedArray = $mixedArray;
}

public function setNullArray(array $nullArray): void
{
$this->nullArray = $nullArray;
}

public function setUnknownArray(array $unknownArray): void
{
$this->unknownArray = $unknownArray;
}

public function setBoolean(bool $boolean): void
{
$this->boolean = $boolean;
}

public function setFloat(float $float): void
{
$this->float = $float;
}

public function setInt(int $int): void
{
$this->int = $int;
}

public function setNull(null $null): void
{
$this->null = $null;
}

public function setNestedClass(NestedClass $nestedClass): void
{
$this->nestedClass = $nestedClass;
}

public function setString(string $string): void
{
$this->string = $string;
}
}

<?php

class NestedClass
{
public function __construct(public int $var)
{
}

public function getVar(): int
{
return $this->var;
}

public function setVar(int $var): void
{
$this->var = $var;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

class RootObject
{
/**
* @param string[] $stringArray
* @param (string|int|null)[] $mixedArray
*/
public function __construct(
public readonly array $stringArray,
public readonly array $mixedArray,
public readonly array $nullArray,
public readonly array $unknownArray,
public readonly bool $boolean,
public readonly float $float,
public readonly int $int,
public readonly null $null,
public readonly NestedClass $nestedClass,
public readonly string $string
) {
}
}

<?php

class NestedClass
{
public function __construct(public readonly int $var)
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php

class RootObject
{
/**
* @param string[] $stringArray
* @param (string|int|null)[] $mixedArray
*/
public function __construct(
public readonly array $stringArray,
public readonly array $mixedArray,
public readonly array $nullArray,
public readonly array $unknownArray,
public readonly bool $boolean,
public readonly float $float,
public readonly int $int,
public readonly null $null,
public readonly NestedClass $nestedClass,
public readonly string $string
) {
}

public static function fromJson(array $data): self
{
return new self(
$data['string_array'],
$data['mixed_array'],
$data['null_array'],
$data['unknown_array'],
$data['boolean'],
$data['float'],
$data['int'],
$data['null'] ?? null,
NestedClass::fromJson($data['nested_class']),
$data['string']
);
}
}

<?php

class NestedClass
{
public function __construct(public readonly int $var)
{
}

public static function fromJson(array $data): self
{
return new self(
$data['var']
);
}
}
Loading

0 comments on commit 1163539

Please sign in to comment.