Skip to content

Commit

Permalink
fix: add missing trigger_deprecation calls to deprecated classes, met…
Browse files Browse the repository at this point in the history
…hods (#2265)

| Q             | A   |
|---------------|-----|
| Bug fix?      | no  |
| New feature?  | no  |
| Deprecations? | yes |
| Issues        | /   |

Adds missing deprecation triggers to classes and methods that have been
deprecated with a `@deprecated` annotation.

---------

Co-authored-by: djordy <[email protected]>
  • Loading branch information
DominicLuidold and DjordyKoert authored Oct 17, 2024
1 parent be67a3a commit 9587aa7
Show file tree
Hide file tree
Showing 19 changed files with 253 additions and 7,320 deletions.
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
## 4.30.0
* Create top level OpenApi Tag from Tags top level annotations/attributes

## 4.25.3

* 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 @@ -149,6 +154,11 @@ 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 All @@ -175,7 +185,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,317 changes: 0 additions & 7,317 deletions phpunit-baseline.json

This file was deleted.

2 changes: 2 additions & 0 deletions phpunit-ignore.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Ignoring deprecations from Nelmio\ApiDocBundle 4.17.0
/^Since nelmio\/api-doc-bundle 4\.17\.0: Using the \$groups parameter of "Nelmio\\ApiDocBundle\\PropertyDescriber\\(PropertyDescriber|IntegerPropertyDescriber|NullablePropertyDescriber|StringPropertyDescriber|ObjectPropertyDescriber)::describe\(\)" is deprecated/
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<ini name="memory_limit" value="512M" />

<!-- add "generateBaseline=true&amp;" to the value to generate a new baseline. Keep in mind to clear the test cache before. -->
<env name="SYMFONY_DEPRECATIONS_HELPER" value="baselineFile=./phpunit-baseline.json&amp;max[self]=0" />
<env name="SYMFONY_DEPRECATIONS_HELPER" value="ignoreFile=./phpunit-ignore.txt&amp;max[self]=0" />
</php>

<testsuites>
Expand Down
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 = [])
{
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 @@ -28,6 +28,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

0 comments on commit 9587aa7

Please sign in to comment.