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

Tweak CS rules around global imports and enforce #1305

Merged
merged 4 commits into from
Sep 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/security-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ jobs:
path: ~/.symfony/cache
key: security-checker-db

- uses: symfonycorp/security-checker-action@v2
- uses: symfonycorp/security-checker-action@v3
16 changes: 13 additions & 3 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
<?php
<?php declare(strict_types=1);

use OpenApi\Tools\CSFixer\ScopedLicenseFixer;
use OpenApi\Tools\CSFixer\ScopedDeclareStrictTypesFixer;

$finder = PhpCsFixer\Finder::create()
->path('src')->name('*.php')
->path('tests')->name('*.php')
// ContextTest::testFullyQualifiedName relies on the 'use Exception' statement...
->filter(function (\SplFileInfo $file) {
return !strpos($file->getPathname(), 'tests/Fixtures/Customer.php');
})
->path('Examples')->name('*.php')
->filter(function (\SplFileInfo $file) {
return !strpos($file->getPathname(), 'Examples/petstore-3.0/Petstore.php')
&& !strpos($file->getPathname(), 'Examples/misc/OpenApiSpec.php');
})
->path('tools')->name('*.php')
->in(__DIR__)
;

return (new PhpCsFixer\Config())
->registerCustomFixers([
(new ScopedLicenseFixer())->scope(['/src/']),
(new ScopedDeclareStrictTypesFixer())->scope(['/src/']),
(new ScopedLicenseFixer())->scope(['/src/', '/tests/']), //, '/Examples/']),
(new ScopedDeclareStrictTypesFixer())->scope(['/src/', '/tests/']),
])
->setRules([
'@PSR2' => true,
Expand Down Expand Up @@ -52,6 +60,8 @@
'trim_array_spaces' => true,
'single_space_after_construct' => true,
'single_line_comment_spacing' => true,
'fully_qualified_strict_types' => true,
'global_namespace_import' => ['import_classes' => false, 'import_constants' => null, 'import_functions' => null],

'no_empty_phpdoc' => true,
// 7.3 only 'no_superfluous_phpdoc_tags' => true,
Expand Down
9 changes: 6 additions & 3 deletions Examples/misc/OpenApiSpec.php
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
<?php

/**
* @license Apache 2.0
*/

namespace OpenApi\Examples\Misc;

use OpenApi\Annotations as OA;

/**
* @OA\OpenApi(
* security={{"bearerAuth": {}}},
* @OA\Tag(
* name="endpoints"
* )
* )
*
* @OA\Info(
* title="Testing annotations from bugreports",
* version="1.0.0",
* description="NOTE:
This sentence is on a new line",
* @OA\Contact(name="Swagger API Team")
* )
*
* @OA\Components(
* @OA\SecurityScheme(
* securityScheme="bearerAuth",
Expand All @@ -26,7 +30,6 @@
* ),
* @OA\Attachable
* )
*
* @OA\Server(
* url="{schema}://host.dev",
* description="OpenApi parameters",
Expand Down
6 changes: 6 additions & 0 deletions Examples/nesting/ActualModel.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
<?php declare(strict_types=1);

/**
* @license Apache 2.0
*/

namespace OpenApi\Examples\Nesting;

use OpenApi\Annotations as OA;

/**
* @OA\Schema
*/
Expand Down
6 changes: 6 additions & 0 deletions Examples/nesting/AlmostModel.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
<?php declare(strict_types=1);

/**
* @license Apache 2.0
*/

namespace OpenApi\Examples\Nesting;

use OpenApi\Annotations as OA;

/**
* @OA\Schema
*/
Expand Down
6 changes: 6 additions & 0 deletions Examples/nesting/ApiController.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
<?php declare(strict_types=1);

/**
* @license Apache 2.0
*/

namespace OpenApi\Examples\Nesting;

use OpenApi\Annotations as OA;

/**
* An entity controller class.
*
Expand Down
6 changes: 6 additions & 0 deletions Examples/nesting/BaseModel.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
<?php declare(strict_types=1);

/**
* @license Apache 2.0
*/

namespace OpenApi\Examples\Nesting;

use OpenApi\Annotations as OA;

/**
* @OA\Schema
*/
Expand Down
6 changes: 6 additions & 0 deletions Examples/nesting/IntermediateModel.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
<?php declare(strict_types=1);

/**
* @license Apache 2.0
*/

namespace OpenApi\Examples\Nesting;

use OpenApi\Annotations as OA;

/**
* No schema!
*/
Expand Down
6 changes: 6 additions & 0 deletions Examples/nesting/SoCloseModel.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
<?php declare(strict_types=1);

/**
* @license Apache 2.0
*/

namespace OpenApi\Examples\Nesting;

use OpenApi\Annotations as OA;

/**
* No schema!
*/
Expand Down
2 changes: 2 additions & 0 deletions Examples/petstore-3.0/Controllers/Pet.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

namespace OpenApi\Examples\Petstore30\Controllers;

use OpenApi\Annotations as OA;

/**
* Class Pet.
*
Expand Down
2 changes: 2 additions & 0 deletions Examples/petstore-3.0/Controllers/Store.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

namespace OpenApi\Examples\Petstore30\Controllers;

use OpenApi\Annotations as OA;

/**
* Class Store.
*
Expand Down
2 changes: 2 additions & 0 deletions Examples/petstore-3.0/Controllers/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

namespace OpenApi\Examples\Petstore30\Controllers;

use OpenApi\Annotations as OA;

/**
* Class User.
*
Expand Down
2 changes: 2 additions & 0 deletions Examples/petstore-3.0/Models/ApiResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

namespace OpenApi\Examples\Petstore30\Models;

use OpenApi\Annotations as OA;

/**
* Class ApiResponse.
*
Expand Down
2 changes: 2 additions & 0 deletions Examples/petstore-3.0/Petstore.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

namespace OpenApi\Examples\Petstore30;

use OpenApi\Annotations as OA;

/**
* @OA\Info(
* description="This is a sample Petstore server. You can find
Expand Down
2 changes: 2 additions & 0 deletions Examples/petstore-3.0/Security.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

namespace OpenApi\Examples\Petstore30;

use OpenApi\Annotations as OA;

/**
* @OA\SecurityScheme(
* type="oauth2",
Expand Down
2 changes: 2 additions & 0 deletions Examples/petstore.swagger.io/Controllers/PetController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace OpenApi\Examples\PetstoreSwaggerIo\Controllers;

use OpenApi\Annotations as OA;

final class PetController
{
/**
Expand Down
2 changes: 2 additions & 0 deletions Examples/petstore.swagger.io/Controllers/StoreController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace OpenApi\Examples\PetstoreSwaggerIo\Controllers;

use OpenApi\Annotations as OA;

abstract class StoreController
{
/**
Expand Down
2 changes: 2 additions & 0 deletions Examples/petstore.swagger.io/Controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace OpenApi\Examples\PetstoreSwaggerIo\Controllers;

use OpenApi\Annotations as OA;

class UserController
{
/**
Expand Down
2 changes: 2 additions & 0 deletions Examples/petstore.swagger.io/Models/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class Order

/**
* @var \DateTime
*
* @OA\Property
*/
public $shipDate;
Expand All @@ -47,6 +48,7 @@ class Order
* Order Status.
*
* @var string
*
* @OA\Property(enum={"placed", "approved", "delivered"})
*/
public $status;
Expand Down
4 changes: 4 additions & 0 deletions Examples/petstore.swagger.io/Models/Pet.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,21 @@ class Pet

/**
* @var Category
*
* @OA\Property
*/
public $category;

/**
* @var string[]
*
* @OA\Property(@OA\Xml(name="photoUrl", wrapped=true))
*/
public $photoUrls;

/**
* @var Tag[]
*
* @OA\Property(@OA\Xml(name="tag", wrapped=true))
*/
public $tags;
Expand All @@ -45,6 +48,7 @@ class Pet
* pet status in the store.
*
* @var string
*
* @OA\Property(enum={"available", "pending", "sold"})
*/
public $status;
Expand Down
4 changes: 4 additions & 0 deletions Examples/petstore.swagger.io/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,21 @@ class User

/**
* @var string
*
* @OA\Property
*/
public $email;

/**
* @var string
*
* @OA\Property
*/
public $password;

/**
* @var string
*
* @OA\Property
*/
public $phone;
Expand All @@ -59,6 +62,7 @@ class User
* User Status.
*
* @var int
*
* @OA\Property(format="int32")
*/
public $userStatus;
Expand Down
2 changes: 2 additions & 0 deletions Examples/petstore.swagger.io/OpenApiSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace OpenApi\Examples\PetstoreSwaggerIo;

use OpenApi\Annotations as OA;

/**
* @OA\OpenApi(
* @OA\Info(
Expand Down
2 changes: 2 additions & 0 deletions Examples/petstore.swagger.io/OpenApiTags.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace OpenApi\Examples\PetstoreSwaggerIo;

use OpenApi\Annotations as OA;

/**
* @OA\Tag(
* name="pet",
Expand Down
2 changes: 2 additions & 0 deletions Examples/petstore.swagger.io/PetstoreAuth.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace OpenApi\Examples\PetstoreSwaggerIo;

use OpenApi\Annotations as OA;

/**
* @OA\SecurityScheme(
* securityScheme="api_key",
Expand Down
2 changes: 2 additions & 0 deletions Examples/processors/schema-query-parameter/app/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ class Product
* The unique identifier of a product in our catalog.
*
* @var int
*
* @OA\Property(format="int64", example=1)
*/
public $id;

/**
* @var string
*
* @OA\Property(format="int64", example=1)
*/
public $name;
Expand Down
2 changes: 2 additions & 0 deletions Examples/swagger-spec/petstore-simple/OpenApiSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace OpenApi\Examples\SwaggerSpec\PetstoreSimple;

use OpenApi\Annotations as OA;

/**
* @OA\OpenApi(
* @OA\Server(
Expand Down
3 changes: 3 additions & 0 deletions Examples/swagger-spec/petstore-simple/SimplePet.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace OpenApi\Examples\SwaggerSpec\PetstoreSimple;

use OpenApi\Annotations as OA;

/**
* @OA\Schema(schema="NewPet", required={"name"})
*/
Expand All @@ -18,6 +20,7 @@ class SimplePet

/**
* @var string
*
* @OA\Property
*/
public $tag;
Expand Down
Loading