Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add missing trigger_deprecation calls to deprecated classes, methods #2265

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
CHANGELOG
=========

4.28.1
-----
* Calling `DocumentationExtension::getExtendedType()` has been deprecated in favor of `DocumentationExtension::getExtendedTypes()` to align with the deprecation introduced with `symfony/symfony` version `4.2`.

4.26.0
-----
* Add ability to configure UI through configuration
Expand Down Expand Up @@ -135,6 +139,10 @@ doc-api:
* Added Redocly as an alternative to Swagger UI. https://github.com/Redocly/redoc.
* Added support for describing dictionary types in OpenAPI 3.0.

4.17.0
-----
* Passing groups to `PropertyDescriberInterface::describe()` via the `$groups` parameter is deprecated, the parameter will get removed in a future version. Pass groups via `$context['groups']` instead.

4.0.0
-----
* Added support of OpenAPI 3.0. The internals were completely reworked and this version introduces BC breaks.
Expand Down Expand Up @@ -162,7 +170,7 @@ doc-api:

* Add a documentation form extension. Use the ``documentation`` option to define how a form field is documented.
* Allow references to config definitions in controllers.
* Using `@Model` implicitely in `@SWG\Schema`, `@SWG\Items` and `@SWG\Property` is deprecated. Use `ref=@Model()` instead.
* Using `@Model` implicitly in `@SWG\Schema`, `@SWG\Items` and `@SWG\Property` is deprecated. Use `ref=@Model()` instead.

Before:
```php
Expand Down
7,319 changes: 607 additions & 6,712 deletions phpunit-baseline.json

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions src/Exception/UndocumentedArrayItemsException.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@

namespace Nelmio\ApiDocBundle\Exception;

trigger_deprecation(
'nelmio/api-doc-bundle',
'4.17.0',
'The "%s" class is deprecated and will be removed in a future version',
UndocumentedArrayItemsException::class,
);

/**
* @deprecated since 4.17, this exception is not used anymore
*/
Expand Down
8 changes: 8 additions & 0 deletions src/Form/Extension/DocumentationExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ public function configureOptions(OptionsResolver $resolver): void
*/
public function getExtendedType()
{
trigger_deprecation(
'nelmio/api-doc-bundle',
'4.28.1',
'Calling %s is deprecated since Symfony 4.2, call %s instead',
__METHOD__,
'DocumentationExtension::getExtendedTypes()',
);

return self::getExtendedTypes()[0];
}

Expand Down
18 changes: 18 additions & 0 deletions src/PropertyDescriber/ArrayPropertyDescriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,24 @@ class ArrayPropertyDescriber implements PropertyDescriberInterface, ModelRegistr
*/
public function describe(array $types, OA\Schema $property, ?array $groups = null, ?OA\Schema $schema = null, array $context = [])
DominicLuidold marked this conversation as resolved.
Show resolved Hide resolved
{
if (null === $schema) {
trigger_deprecation(
'nelmio/api-doc-bundle',
'4.15.0',
'"%s()" will have a new "OA\Schema $schema" argument in a future version. Not defining it or passing null is deprecated',
__METHOD__
);
}

if (null !== $groups) {
trigger_deprecation(
'nelmio/api-doc-bundle',
'4.17.0',
'Using the $groups parameter of "%s()" is deprecated and will be removed in a future version. Pass groups via $context[\'groups\']',
__METHOD__
);
}

$property->type = 'array';
/** @var OA\Items $property */
$property = Util::getChild($property, OA\Items::class);
Expand Down
18 changes: 18 additions & 0 deletions src/PropertyDescriber/BooleanPropertyDescriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,24 @@ class BooleanPropertyDescriber implements PropertyDescriberInterface
*/
public function describe(array $types, OA\Schema $property, ?array $groups = null, ?OA\Schema $schema = null, array $context = [])
{
if (null === $schema) {
trigger_deprecation(
'nelmio/api-doc-bundle',
'4.15.0',
'"%s()" will have a new "OA\Schema $schema" argument in a future version. Not defining it or passing null is deprecated',
__METHOD__
);
}

if (null !== $groups) {
trigger_deprecation(
'nelmio/api-doc-bundle',
'4.17.0',
'Using the $groups parameter of "%s()" is deprecated and will be removed in a future version. Pass groups via $context[\'groups\']',
__METHOD__
);
}

$property->type = 'boolean';
}

Expand Down
18 changes: 18 additions & 0 deletions src/PropertyDescriber/CompoundPropertyDescriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,24 @@ class CompoundPropertyDescriber implements PropertyDescriberInterface, ModelRegi
*/
public function describe(array $types, OA\Schema $property, ?array $groups = null, ?OA\Schema $schema = null, array $context = [])
{
if (null === $schema) {
trigger_deprecation(
'nelmio/api-doc-bundle',
'4.15.0',
'"%s()" will have a new "OA\Schema $schema" argument in a future version. Not defining it or passing null is deprecated',
__METHOD__
);
}

if (null !== $groups) {
trigger_deprecation(
'nelmio/api-doc-bundle',
'4.17.0',
'Using the $groups parameter of "%s()" is deprecated and will be removed in a future version. Pass groups via $context[\'groups\']',
__METHOD__
);
}

$property->oneOf = Generator::UNDEFINED !== $property->oneOf ? $property->oneOf : [];

foreach ($types as $type) {
Expand Down
18 changes: 18 additions & 0 deletions src/PropertyDescriber/DateTimePropertyDescriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,24 @@ class DateTimePropertyDescriber implements PropertyDescriberInterface
*/
public function describe(array $types, OA\Schema $property, ?array $groups = null, ?OA\Schema $schema = null, array $context = [])
{
if (null === $schema) {
trigger_deprecation(
'nelmio/api-doc-bundle',
'4.15.0',
'"%s()" will have a new "OA\Schema $schema" argument in a future version. Not defining it or passing null is deprecated',
__METHOD__
);
}

if (null !== $groups) {
trigger_deprecation(
'nelmio/api-doc-bundle',
'4.17.0',
'Using the $groups parameter of "%s()" is deprecated and will be removed in a future version. Pass groups via $context[\'groups\']',
__METHOD__
);
}

$property->type = 'string';
$property->format = 'date-time';
}
Expand Down
18 changes: 18 additions & 0 deletions src/PropertyDescriber/DictionaryPropertyDescriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,24 @@ final class DictionaryPropertyDescriber implements PropertyDescriberInterface, M
*/
public function describe(array $types, OA\Schema $property, ?array $groups = null, ?OA\Schema $schema = null, array $context = [])
{
if (null === $schema) {
trigger_deprecation(
'nelmio/api-doc-bundle',
'4.15.0',
'"%s()" will have a new "OA\Schema $schema" argument in a future version. Not defining it or passing null is deprecated',
__METHOD__
);
}

if (null !== $groups) {
trigger_deprecation(
'nelmio/api-doc-bundle',
'4.17.0',
'Using the $groups parameter of "%s()" is deprecated and will be removed in a future version. Pass groups via $context[\'groups\']',
__METHOD__
);
}

$property->type = 'object';
/** @var OA\AdditionalProperties $additionalProperties */
$additionalProperties = Util::getChild($property, OA\AdditionalProperties::class);
Expand Down
18 changes: 18 additions & 0 deletions src/PropertyDescriber/FloatPropertyDescriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,24 @@ class FloatPropertyDescriber implements PropertyDescriberInterface
*/
public function describe(array $types, OA\Schema $property, ?array $groups = null, ?OA\Schema $schema = null, array $context = [])
{
if (null === $schema) {
trigger_deprecation(
'nelmio/api-doc-bundle',
'4.15.0',
'"%s()" will have a new "OA\Schema $schema" argument in a future version. Not defining it or passing null is deprecated',
__METHOD__
);
}

if (null !== $groups) {
trigger_deprecation(
'nelmio/api-doc-bundle',
'4.17.0',
'Using the $groups parameter of "%s()" is deprecated and will be removed in a future version. Pass groups via $context[\'groups\']',
__METHOD__
);
}

$property->type = 'number';
$property->format = 'float';
}
Expand Down
18 changes: 18 additions & 0 deletions src/PropertyDescriber/IntegerPropertyDescriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,24 @@ class IntegerPropertyDescriber implements PropertyDescriberInterface
*/
public function describe(array $types, OA\Schema $property, ?array $groups = null, ?OA\Schema $schema = null, array $context = [])
{
if (null === $schema) {
trigger_deprecation(
'nelmio/api-doc-bundle',
'4.15.0',
'"%s()" will have a new "OA\Schema $schema" argument in a future version. Not defining it or passing null is deprecated',
__METHOD__
);
}

if (null !== $groups) {
trigger_deprecation(
'nelmio/api-doc-bundle',
'4.17.0',
'Using the $groups parameter of "%s()" is deprecated and will be removed in a future version. Pass groups via $context[\'groups\']',
__METHOD__
);
}

$property->type = 'integer';
}

Expand Down
18 changes: 18 additions & 0 deletions src/PropertyDescriber/NullablePropertyDescriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,24 @@ final class NullablePropertyDescriber implements PropertyDescriberInterface, Pro
*/
public function describe(array $types, OA\Schema $property, ?array $groups = null, ?OA\Schema $schema = null, array $context = [])
{
if (null === $schema) {
trigger_deprecation(
'nelmio/api-doc-bundle',
'4.15.0',
'"%s()" will have a new "OA\Schema $schema" argument in a future version. Not defining it or passing null is deprecated',
__METHOD__
);
}

if (null !== $groups) {
trigger_deprecation(
'nelmio/api-doc-bundle',
'4.17.0',
'Using the $groups parameter of "%s()" is deprecated and will be removed in a future version. Pass groups via $context[\'groups\']',
__METHOD__
);
}

if (Generator::UNDEFINED === $property->nullable) {
$property->nullable = true;
}
Expand Down
9 changes: 8 additions & 1 deletion src/PropertyDescriber/NullablePropertyTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,19 @@
use Symfony\Component\PropertyInfo\Type;

/**
* @deprecated Since 4.17, {@see NullablePropertyDescriber} instead.
* @deprecated Since 4.17.0, {@see NullablePropertyDescriber} instead.
*/
trait NullablePropertyTrait
{
protected function setNullableProperty(Type $type, OA\Schema $property, ?OA\Schema $schema, array $context = []): void
{
trigger_deprecation(
'nelmio/api-doc-bundle',
'4.17.0',
'Use %s instead',
NullablePropertyDescriber::class,
);

if (Generator::UNDEFINED !== $property->nullable) {
if (!$property->nullable) {
// if already false mark it as undefined (so it does not show up as `nullable: false`)
Expand Down
18 changes: 18 additions & 0 deletions src/PropertyDescriber/ObjectPropertyDescriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,24 @@ class ObjectPropertyDescriber implements PropertyDescriberInterface, ModelRegist
*/
public function describe(array $types, OA\Schema $property, ?array $groups = null, ?OA\Schema $schema = null, array $context = [])
{
if (null === $schema) {
trigger_deprecation(
'nelmio/api-doc-bundle',
'4.15.0',
'"%s()" will have a new "OA\Schema $schema" argument in a future version. Not defining it or passing null is deprecated',
__METHOD__
);
}

if (null !== $groups) {
trigger_deprecation(
'nelmio/api-doc-bundle',
'4.17.0',
'Using the $groups parameter of "%s()" is deprecated and will be removed in a future version. Pass groups via $context[\'groups\']',
__METHOD__
);
}

$type = new Type(
$types[0]->getBuiltinType(),
false,
Expand Down
18 changes: 18 additions & 0 deletions src/PropertyDescriber/PropertyDescriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,24 @@ public function __construct(
*/
public function describe(array $types, OA\Schema $property, ?array $groups = null, ?OA\Schema $schema = null, array $context = []): void
{
if (null === $schema) {
trigger_deprecation(
'nelmio/api-doc-bundle',
'4.15.0',
'"%s()" will have a new "OA\Schema $schema" argument in a future version. Not defining it or passing null is deprecated',
__METHOD__
);
}

if (null !== $groups) {
trigger_deprecation(
'nelmio/api-doc-bundle',
'4.17.0',
'Using the $groups parameter of "%s()" is deprecated and will be removed in a future version. Pass groups via $context[\'groups\']',
__METHOD__
);
}

if (null === $propertyDescriber = $this->getPropertyDescriber($types)) {
return;
}
Expand Down
18 changes: 18 additions & 0 deletions src/PropertyDescriber/RequiredPropertyDescriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,24 @@ final class RequiredPropertyDescriber implements PropertyDescriberInterface, Pro
*/
public function describe(array $types, OA\Schema $property, ?array $groups = null, ?OA\Schema $schema = null, array $context = [])
{
if (null === $schema) {
trigger_deprecation(
'nelmio/api-doc-bundle',
'4.15.0',
'"%s()" will have a new "OA\Schema $schema" argument in a future version. Not defining it or passing null is deprecated',
__METHOD__
);
}

if (null !== $groups) {
trigger_deprecation(
'nelmio/api-doc-bundle',
'4.17.0',
'Using the $groups parameter of "%s()" is deprecated and will be removed in a future version. Pass groups via $context[\'groups\']',
__METHOD__
);
}

$this->propertyDescriber->describe($types, $property, $groups, $schema, $context);

if (!$property instanceof OA\Property) {
Expand Down
18 changes: 18 additions & 0 deletions src/PropertyDescriber/StringPropertyDescriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,24 @@ class StringPropertyDescriber implements PropertyDescriberInterface
*/
public function describe(array $types, OA\Schema $property, ?array $groups = null, ?OA\Schema $schema = null, array $context = [])
{
if (null === $schema) {
trigger_deprecation(
'nelmio/api-doc-bundle',
'4.15.0',
'"%s()" will have a new "OA\Schema $schema" argument in a future version. Not defining it or passing null is deprecated',
__METHOD__
);
}

if (null !== $groups) {
trigger_deprecation(
'nelmio/api-doc-bundle',
'4.17.0',
'Using the $groups parameter of "%s()" is deprecated and will be removed in a future version. Pass groups via $context[\'groups\']',
__METHOD__
);
}

$property->type = 'string';
}

Expand Down