-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: deprecations * chore: deprecations
- Loading branch information
Showing
15 changed files
with
1,845 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/.gitignore export-ignore | ||
/Tests export-ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/composer.lock | ||
/vendor | ||
/.phpunit.result.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the API Platform project. | ||
* | ||
* (c) Kévin Dunglas <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ApiPlatform\JsonApi\Tests\Fixtures; | ||
|
||
class CircularReference | ||
{ | ||
public $id; | ||
public CircularReference $parent; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the API Platform project. | ||
* | ||
* (c) Kévin Dunglas <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ApiPlatform\JsonApi\Tests\Fixtures; | ||
|
||
use Symfony\Component\Serializer\NameConverter\AdvancedNameConverterInterface; | ||
use Symfony\Component\Serializer\NameConverter\CamelCaseToSnakeCaseNameConverter; | ||
use Symfony\Component\Serializer\NameConverter\NameConverterInterface; | ||
|
||
/** | ||
* Custom converter that will only convert a property named "nameConverted" | ||
* with the same logic as Symfony\Component\Serializer\NameConverter\CamelCaseToSnakeCaseNameConverter. | ||
*/ | ||
class CustomConverter implements AdvancedNameConverterInterface | ||
{ | ||
private NameConverterInterface $nameConverter; | ||
|
||
public function __construct() | ||
{ | ||
$this->nameConverter = new CamelCaseToSnakeCaseNameConverter(); | ||
} | ||
|
||
public function normalize(string $propertyName, ?string $class = null, ?string $format = null, array $context = []): string | ||
{ | ||
return 'nameConverted' === $propertyName ? $this->nameConverter->normalize($propertyName) : $propertyName; | ||
} | ||
|
||
public function denormalize(string $propertyName, ?string $class = null, ?string $format = null, array $context = []): string | ||
{ | ||
return 'name_converted' === $propertyName ? $this->nameConverter->denormalize($propertyName) : $propertyName; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,206 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the API Platform project. | ||
* | ||
* (c) Kévin Dunglas <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ApiPlatform\JsonApi\Tests\Fixtures; | ||
|
||
use ApiPlatform\Metadata\ApiProperty; | ||
use ApiPlatform\Metadata\ApiResource; | ||
use Symfony\Component\Validator\Constraints as Assert; | ||
|
||
/** | ||
* Dummy. | ||
* | ||
* @author Kévin Dunglas <[email protected]> | ||
*/ | ||
#[ApiResource(filters: ['my_dummy.boolean', 'my_dummy.date', 'my_dummy.exists', 'my_dummy.numeric', 'my_dummy.order', 'my_dummy.range', 'my_dummy.search', 'my_dummy.property'], extraProperties: ['standard_put' => false])] | ||
class Dummy | ||
{ | ||
/** | ||
* @var int|null The id | ||
*/ | ||
private $id; | ||
|
||
/** | ||
* @var string The dummy name | ||
*/ | ||
#[ApiProperty(iris: ['https://schema.org/name'])] | ||
#[Assert\NotBlank] | ||
private string $name; | ||
|
||
/** | ||
* @var string|null The dummy name alias | ||
*/ | ||
#[ApiProperty(iris: ['https://schema.org/alternateName'])] | ||
private $alias; | ||
|
||
/** | ||
* @var array foo | ||
*/ | ||
private ?array $foo = null; | ||
|
||
/** | ||
* @var string|null A short description of the item | ||
*/ | ||
#[ApiProperty(iris: ['https://schema.org/description'])] | ||
public $description; | ||
|
||
/** | ||
* @var string|null A dummy | ||
*/ | ||
public $dummy; | ||
|
||
/** | ||
* @var bool|null A dummy boolean | ||
*/ | ||
public ?bool $dummyBoolean = null; | ||
/** | ||
* @var \DateTime|null A dummy date | ||
*/ | ||
#[ApiProperty(iris: ['https://schema.org/DateTime'])] | ||
public $dummyDate; | ||
|
||
/** | ||
* @var float|null A dummy float | ||
*/ | ||
public $dummyFloat; | ||
|
||
/** | ||
* @var string|null A dummy price | ||
*/ | ||
public $dummyPrice; | ||
|
||
/** | ||
* @var array|null serialize data | ||
*/ | ||
public $jsonData = []; | ||
|
||
/** | ||
* @var array|null | ||
*/ | ||
public $arrayData = []; | ||
|
||
/** | ||
* @var string|null | ||
*/ | ||
public $nameConverted; | ||
|
||
public static function staticMethod(): void | ||
{ | ||
} | ||
|
||
public function getId() | ||
{ | ||
return $this->id; | ||
} | ||
|
||
public function setId($id): void | ||
{ | ||
$this->id = $id; | ||
} | ||
|
||
public function setName(string $name): void | ||
{ | ||
$this->name = $name; | ||
} | ||
|
||
public function getName(): string | ||
{ | ||
return $this->name; | ||
} | ||
|
||
public function setAlias($alias): void | ||
{ | ||
$this->alias = $alias; | ||
} | ||
|
||
public function getAlias() | ||
{ | ||
return $this->alias; | ||
} | ||
|
||
public function setDescription($description): void | ||
{ | ||
$this->description = $description; | ||
} | ||
|
||
public function getDescription() | ||
{ | ||
return $this->description; | ||
} | ||
|
||
public function fooBar($baz): void | ||
{ | ||
} | ||
|
||
public function getFoo(): ?array | ||
{ | ||
return $this->foo; | ||
} | ||
|
||
public function setFoo(?array $foo = null): void | ||
{ | ||
$this->foo = $foo; | ||
} | ||
|
||
public function setDummyDate(?\DateTime $dummyDate = null): void | ||
{ | ||
$this->dummyDate = $dummyDate; | ||
} | ||
|
||
public function getDummyDate() | ||
{ | ||
return $this->dummyDate; | ||
} | ||
|
||
public function setDummyPrice($dummyPrice) | ||
{ | ||
$this->dummyPrice = $dummyPrice; | ||
|
||
return $this; | ||
} | ||
|
||
public function getDummyPrice() | ||
{ | ||
return $this->dummyPrice; | ||
} | ||
|
||
public function setJsonData($jsonData): void | ||
{ | ||
$this->jsonData = $jsonData; | ||
} | ||
|
||
public function getJsonData() | ||
{ | ||
return $this->jsonData; | ||
} | ||
|
||
public function setArrayData($arrayData): void | ||
{ | ||
$this->arrayData = $arrayData; | ||
} | ||
|
||
public function getArrayData() | ||
{ | ||
return $this->arrayData; | ||
} | ||
|
||
public function setDummy($dummy = null): void | ||
{ | ||
$this->dummy = $dummy; | ||
} | ||
|
||
public function getDummy() | ||
{ | ||
return $this->dummy; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the API Platform project. | ||
* | ||
* (c) Kévin Dunglas <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ApiPlatform\JsonApi\Tests\Fixtures; | ||
|
||
use ApiPlatform\Metadata\ApiProperty; | ||
use ApiPlatform\Metadata\ApiResource; | ||
use Symfony\Component\Serializer\Annotation\Groups; | ||
|
||
/** | ||
* Related Dummy. | ||
* | ||
* @author Kévin Dunglas <[email protected]> | ||
*/ | ||
#[ApiResource] | ||
class RelatedDummy implements \Stringable | ||
{ | ||
#[ApiProperty(writable: false)] | ||
#[Groups(['chicago', 'friends'])] | ||
private $id; | ||
|
||
/** | ||
* @var string|null A name | ||
*/ | ||
#[ApiProperty(iris: ['RelatedDummy.name'])] | ||
#[Groups(['friends'])] | ||
public $name; | ||
|
||
#[ApiProperty(deprecationReason: 'This property is deprecated for upgrade test')] | ||
#[Groups(['barcelona', 'chicago', 'friends'])] | ||
protected $symfony = 'symfony'; | ||
|
||
/** | ||
* @var \DateTime|null A dummy date | ||
*/ | ||
#[Groups(['friends'])] | ||
public $dummyDate; | ||
|
||
/** | ||
* @var bool|null A dummy bool | ||
*/ | ||
#[Groups(['friends'])] | ||
public ?bool $dummyBoolean = null; | ||
|
||
public function __construct() | ||
{ | ||
} | ||
|
||
public function getId() | ||
{ | ||
return $this->id; | ||
} | ||
|
||
public function setId($id): void | ||
{ | ||
$this->id = $id; | ||
} | ||
|
||
public function setName($name): void | ||
{ | ||
$this->name = $name; | ||
} | ||
|
||
public function getName() | ||
{ | ||
return $this->name; | ||
} | ||
|
||
public function getSymfony() | ||
{ | ||
return $this->symfony; | ||
} | ||
|
||
public function setSymfony($symfony): void | ||
{ | ||
$this->symfony = $symfony; | ||
} | ||
|
||
public function setDummyDate(\DateTime $dummyDate): void | ||
{ | ||
$this->dummyDate = $dummyDate; | ||
} | ||
|
||
public function getDummyDate() | ||
{ | ||
return $this->dummyDate; | ||
} | ||
|
||
public function isDummyBoolean(): ?bool | ||
{ | ||
return $this->dummyBoolean; | ||
} | ||
|
||
/** | ||
* @param bool $dummyBoolean | ||
*/ | ||
public function setDummyBoolean($dummyBoolean): void | ||
{ | ||
$this->dummyBoolean = $dummyBoolean; | ||
} | ||
|
||
public function __toString(): string | ||
{ | ||
return (string) $this->getId(); | ||
} | ||
} |
Oops, something went wrong.