Skip to content

Commit

Permalink
feat: deprecate annotation namespace in favor of attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
DjordyKoert committed Oct 25, 2024
1 parent 4c5072c commit c2daf9b
Show file tree
Hide file tree
Showing 9 changed files with 95 additions and 6 deletions.
22 changes: 22 additions & 0 deletions src/Annotation/Areas.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

/*
* This file is part of the NelmioApiDocBundle package.
*
* (c) Nelmio
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Nelmio\ApiDocBundle\Annotation;

trigger_deprecation('nelmio/api-doc-bundle', '4.32.3', 'The "%s" class is deprecated and will be removed in 4.0. Use the \Nelmio\ApiDocBundle\Attribute\Areas attribute instead.', Areas::class);

/**
* @Annotation
*/
#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::TARGET_METHOD)]

Check failure on line 19 in src/Annotation/Areas.php

View workflow job for this annotation

GitHub Actions / PHPStan

Class Nelmio\ApiDocBundle\Annotation\Areas extends @Final class Nelmio\ApiDocBundle\Attribute\Areas.

Check failure on line 19 in src/Annotation/Areas.php

View workflow job for this annotation

GitHub Actions / PHPStan

Class Nelmio\ApiDocBundle\Annotation\Areas extends @Final class Nelmio\ApiDocBundle\Attribute\Areas.
final class Areas extends \Nelmio\ApiDocBundle\Attribute\Areas
{
}
22 changes: 22 additions & 0 deletions src/Annotation/Model.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

/*
* This file is part of the NelmioApiDocBundle package.
*
* (c) Nelmio
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Nelmio\ApiDocBundle\Annotation;

trigger_deprecation('nelmio/api-doc-bundle', '4.32.3', 'The "%s" class is deprecated and will be removed in 4.0. Use the \Nelmio\ApiDocBundle\Attribute\Model attribute instead.', Model::class);

/**
* @Annotation
*/
#[\Attribute(\Attribute::TARGET_METHOD)]

Check failure on line 19 in src/Annotation/Model.php

View workflow job for this annotation

GitHub Actions / PHPStan

Class Nelmio\ApiDocBundle\Annotation\Model extends @Final class Nelmio\ApiDocBundle\Attribute\Model.

Check failure on line 19 in src/Annotation/Model.php

View workflow job for this annotation

GitHub Actions / PHPStan

Class Nelmio\ApiDocBundle\Annotation\Model extends @Final class Nelmio\ApiDocBundle\Attribute\Model.
final class Model extends \Nelmio\ApiDocBundle\Attribute\Model
{
}
22 changes: 22 additions & 0 deletions src/Annotation/Operation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

/*
* This file is part of the NelmioApiDocBundle package.
*
* (c) Nelmio
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Nelmio\ApiDocBundle\Annotation;

trigger_deprecation('nelmio/api-doc-bundle', '4.32.3', 'The "%s" class is deprecated and will be removed in 4.0. Use the \Nelmio\ApiDocBundle\Attribute\Operation attribute instead.', Operation::class);

/**
* @Annotation
*/
#[\Attribute(\Attribute::TARGET_METHOD)]

Check failure on line 19 in src/Annotation/Operation.php

View workflow job for this annotation

GitHub Actions / PHPStan

Class Nelmio\ApiDocBundle\Annotation\Operation extends @Final class Nelmio\ApiDocBundle\Attribute\Operation.

Check failure on line 19 in src/Annotation/Operation.php

View workflow job for this annotation

GitHub Actions / PHPStan

Class Nelmio\ApiDocBundle\Annotation\Operation extends @Final class Nelmio\ApiDocBundle\Attribute\Operation.
class Operation extends \Nelmio\ApiDocBundle\Attribute\Operation
{
}
22 changes: 22 additions & 0 deletions src/Annotation/Security.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

/*
* This file is part of the NelmioApiDocBundle package.
*
* (c) Nelmio
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Nelmio\ApiDocBundle\Annotation;

trigger_deprecation('nelmio/api-doc-bundle', '4.32.3', 'The "%s" class is deprecated and will be removed in 4.0. Use the \Nelmio\ApiDocBundle\Attribute\Security attribute instead.', Security::class);

/**
* @Annotation
*/
#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]

Check failure on line 19 in src/Annotation/Security.php

View workflow job for this annotation

GitHub Actions / PHPStan

Class Nelmio\ApiDocBundle\Annotation\Security extends @Final class Nelmio\ApiDocBundle\Attribute\Security.

Check failure on line 19 in src/Annotation/Security.php

View workflow job for this annotation

GitHub Actions / PHPStan

Class Nelmio\ApiDocBundle\Annotation\Security extends @Final class Nelmio\ApiDocBundle\Attribute\Security.
class Security extends \Nelmio\ApiDocBundle\Attribute\Security
{
}
4 changes: 2 additions & 2 deletions src/Attribute/Areas.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
namespace Nelmio\ApiDocBundle\Attribute;

/**
* @Annotation
* @final
*/
#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::TARGET_METHOD)]
final class Areas
class Areas
{
/** @var string[] */
private array $areas;
Expand Down
4 changes: 2 additions & 2 deletions src/Attribute/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
use OpenApi\Generator;

/**
* @Annotation
* @final
*/
#[\Attribute(\Attribute::TARGET_METHOD)]
final class Model extends Attachable
class Model extends Attachable
{
public static $_types = [
'type' => 'string',
Expand Down
2 changes: 1 addition & 1 deletion src/Attribute/Operation.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use OpenApi\Annotations\Operation as BaseOperation;

/**
* @Annotation
* @final
*/
#[\Attribute(\Attribute::TARGET_METHOD)]
class Operation extends BaseOperation
Expand Down
2 changes: 1 addition & 1 deletion src/Attribute/Security.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use OpenApi\Annotations\AbstractAnnotation;

/**
* @Annotation
* @final
*/
#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
class Security extends AbstractAnnotation
Expand Down
1 change: 1 addition & 0 deletions src/Routing/FilteredRouteCollectionBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ private function defaultRouteDisabled(Route $route): bool

foreach ($annotations as $annotation) {
if (false !== strpos(get_class($annotation), 'Nelmio\\ApiDocBundle\\Annotation')
|| false !== strpos(get_class($annotation), 'Nelmio\\ApiDocBundle\\Attribute')
|| false !== strpos(get_class($annotation), 'OpenApi\\Annotations')
|| false !== strpos(get_class($annotation), 'OpenApi\\Attributes')
) {
Expand Down

0 comments on commit c2daf9b

Please sign in to comment.