Skip to content

Commit

Permalink
Add rector and apply
Browse files Browse the repository at this point in the history
  • Loading branch information
DerManoMann committed Nov 10, 2024
1 parent 4f77304 commit 924a3b1
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 25 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"prefer-stable": true,
"scripts": {
"cs": "php-cs-fixer fix --allow-risky=yes",
"rector": "rector process src test",
"rector": "rector process src tests",
"lint": [
"@cs --dry-run",
"@rector --dry-run"
Expand Down
2 changes: 1 addition & 1 deletion rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
TypedPropertyFromStrictConstructorRector::class
])
->withPreparedSets(true, true)
->withPhpVersion(PhpVersion::PHP_74);
->withPhpVersion(PhpVersion::PHP_81);
8 changes: 2 additions & 6 deletions tests/Concerns/Fixtures.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,11 @@ trait Fixtures
public function getFixtureFinder(): Finder
{
$controllersDir = __DIR__ . '/../Fixtures/Controllers';
$finder = (new Finder())

return (new Finder())
->files()
->followLinks()
->name('*.php')
->in($controllersDir);
if (\PHP_VERSION_ID < 80100) {
$finder->notName('AttributeController.php');
}

return $finder;
}
}
22 changes: 10 additions & 12 deletions tests/Fixtures/Controllers/AttributeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,16 @@
use Radebatz\OpenApi\Routing\Tests\Fixtures\Middleware\BarMiddleware;
use Radebatz\OpenApi\Routing\Tests\Fixtures\Middleware\FooMiddleware;

if (\PHP_VERSION_ID >= 80100) {
#[OAX\Controller(prefix: '/attributes')]
#[OAT\Response(response: 403, description: 'Not allowed')]
#[OAX\Middleware([FooMiddleware::class])]
class AttributeController
#[OAX\Controller(prefix: '/attributes')]
#[OAT\Response(response: 403, description: 'Not allowed')]
#[OAX\Middleware([FooMiddleware::class])]
class AttributeController
{
#[OAT\Get(path: '/prefixed', x: ['name' => 'attributes'])]
#[OAT\Response(response: 200, description: 'All good')]
#[OAX\Middleware([BarMiddleware::class])]
public function prefixed()
{
#[OAT\Get(path: '/prefixed', x: ['name' => 'attributes'])]
#[OAT\Response(response: 200, description: 'All good')]
#[OAX\Middleware([BarMiddleware::class])]
public function prefixed()
{
return FakeResponse::create('Get fooya');
}
return FakeResponse::create('Get fooya');
}
}
2 changes: 1 addition & 1 deletion tests/Laravel/CachingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function testReload(?CacheInterface $cache, $reload, $openapisCached)
$router = $app['router'];
$this->assertNotNull($router->getRoutes()->getByName('getya'));

$this->assertEquals($openapisCached, $cache ? $cache->has(OpenApiRouter::CACHE_KEY_OPENAPI) : false);
$this->assertEquals($openapisCached, $cache && $cache->has(OpenApiRouter::CACHE_KEY_OPENAPI));
}

protected function getApp(): Application
Expand Down
2 changes: 1 addition & 1 deletion tests/Laravel/CallsApplicationTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ trait CallsApplicationTrait
{
use Fixtures;

protected $app = null;
protected $app;

protected function setUp(): void
{
Expand Down
2 changes: 2 additions & 0 deletions tests/Lumen/LumenTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

class LumenTest extends LumenTestCase
{
public $response;

use CallsApplicationTrait;

/** @test */
Expand Down
1 change: 1 addition & 0 deletions tests/Lumen/ParametersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

class ParametersTest extends LumenTestCase
{
public $response;
use CallsApplicationTrait;

/** @test */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php declare(strict_types=1);

namespace Radebatz\OpenApi\Routing\Tests\Slim4;
namespace Radebatz\OpenApi\Routing\Tests\Slim;

use Nyholm\Psr7\Factory\Psr17Factory;
use Psr\Http\Message\ResponseInterface;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php declare(strict_types=1);

namespace Radebatz\OpenApi\Routing\Tests\Slim4;
namespace Radebatz\OpenApi\Routing\Tests\Slim;

use PHPUnit\Framework\TestCase;

Expand Down
2 changes: 1 addition & 1 deletion tests/Slim4/SlimTest.php → tests/Slim/SlimTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php declare(strict_types=1);

namespace Radebatz\OpenApi\Routing\Tests\Slim4;
namespace Radebatz\OpenApi\Routing\Tests\Slim;

use PHPUnit\Framework\TestCase;

Expand Down

0 comments on commit 924a3b1

Please sign in to comment.