Skip to content

Commit

Permalink
Rector changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sileence committed May 6, 2024
1 parent 296b110 commit 1d2203c
Show file tree
Hide file tree
Showing 63 changed files with 168 additions and 148 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"require-dev": {
"phpunit/phpunit": "^11.0.1",
"orchestra/testbench": "^9.0",
"friendsofphp/php-cs-fixer": "^3.55"
"friendsofphp/php-cs-fixer": "^3.55",
"rector/rector": "^1.0"
},
"license": "MIT",
"authors": [
Expand Down
2 changes: 1 addition & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\TypeDeclaration\Rector\ClassMethod\AddVoidReturnTypeWhereNoReturnRector;

return RectorConfig::configure()
->withPaths([
__DIR__ . '/config',
__DIR__ . '/resources',
__DIR__ . '/src',
__DIR__ . '/tests',
])
// uncomment to reach your current PHP version
// ->withPhpSets()
->withRules([
AddVoidReturnTypeWhereNoReturnRector::class,
]);
2 changes: 1 addition & 1 deletion src/Console/DocumentationExporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function export(Run $run, string $baseDir, string $staticBaseUrl): void
$this->exportSearchJson($run);
}

private function exportAssets()
private function exportAssets(): void
{
$this->filesystem->deleteDirectory("{$this->baseDir}/assets");

Expand Down
2 changes: 1 addition & 1 deletion src/Drivers/BaseExampleBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public function setSlug(string $slug): ExampleBuilder
return $this;
}

public function setStatus(string $testStatus, string $status)
public function setStatus(string $testStatus, string $status): void
{
$this->testStatus = $testStatus;
$this->status = $status;
Expand Down
14 changes: 7 additions & 7 deletions src/Drivers/DatabaseExampleBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function __construct(DatabaseExampleGroupBuilder $exampleGroupBuilder)
$this->exampleGroupBuilder = $exampleGroupBuilder;
}

public function addRequest(RequestInfo $request)
public function addRequest(RequestInfo $request): void
{
$this->save();

Expand All @@ -55,7 +55,7 @@ public function addRequest(RequestInfo $request)
]));
}

public function setResponse(ResponseInfo $response, bool $followsRedirect, RouteInfo $routeInfo, array $session)
public function setResponse(ResponseInfo $response, bool $followsRedirect, RouteInfo $routeInfo, array $session): void
{
$this->save();

Expand All @@ -74,7 +74,7 @@ public function setResponse(ResponseInfo $response, bool $followsRedirect, Route
]);
}

public function setException(ExceptionInfo $exception)
public function setException(ExceptionInfo $exception): void
{
$this->example->exception->fill([
'class_name' => $exception->getClassName(),
Expand All @@ -87,7 +87,7 @@ public function setException(ExceptionInfo $exception)
])->save();
}

public function addQuery(QueryExecuted $queryExecuted)
public function addQuery(QueryExecuted $queryExecuted): void
{
$this->save();

Expand All @@ -100,7 +100,7 @@ public function addQuery(QueryExecuted $queryExecuted)
]);
}

public function addSnippet($key, string $code)
public function addSnippet($key, string $code): void
{
$this->save();

Expand All @@ -110,7 +110,7 @@ public function addSnippet($key, string $code)
]);
}

public function setSnippetResult($result)
public function setSnippetResult($result): void
{
$this->currentSnippet->update(['result' => $result]);

Expand All @@ -129,7 +129,7 @@ public function build(): ExampleContract
return $this->example;
}

private function save()
private function save(): void
{
if ($this->example != null) {
return;
Expand Down
4 changes: 2 additions & 2 deletions src/Enlighten.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ class Enlighten
{
private static $isDocumenting = false;

public static function document()
public static function document(): void
{
static::$isDocumenting = true;
}

public static function stopDocumenting()
public static function stopDocumenting(): void
{
static::$isDocumenting = true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/ExampleCreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function getCurrentExample(): ?ExampleBuilder
return $this->currentExampleBuilder;
}

public function makeExample(string $className, string $methodName, array $providedData = null, $dataName = null)
public function makeExample(string $className, string $methodName, array $providedData = null, $dataName = null): void
{
$this->currentExampleBuilder = null;
$this->currentException = null;
Expand Down
4 changes: 2 additions & 2 deletions src/HttpExamples/HttpExampleCreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public static function followingRedirect(Closure $callback)
return $response;
}

public function createHttpExample(Request $request)
public function createHttpExample(Request $request): void
{
$testExample = $this->exampleCreator->getCurrentExample();

Expand All @@ -78,7 +78,7 @@ public function createHttpExample(Request $request)
);
}

public function saveHttpResponseData(Request $request, Response $response)
public function saveHttpResponseData(Request $request, Response $response): void
{
$testExample = $this->exampleCreator->getCurrentExample();

Expand Down
2 changes: 1 addition & 1 deletion src/Providers/EnlightenServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class EnlightenServiceProvider extends ServiceProvider
{
use RegistersConsoleConfiguration, RegistersViewComponents, RegistersDatabaseConnection;

public function boot()
public function boot(): void
{
if ($this->app->environment('production') && ! $this->app->runningInConsole()) {
return;
Expand Down
8 changes: 4 additions & 4 deletions src/Tests/ExceptionRecorder.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,19 @@ public function __construct(ExceptionHandler $originalHandler)
$this->originalHandler = $originalHandler;
}

public function forwardToORiginal()
public function forwardToORiginal(): void
{
$this->forwardToOriginalHandler = true;
$this->except = [];
}

public function forceThrow(array $except = [])
public function forceThrow(array $except = []): void
{
$this->forwardToOriginalHandler = false;
$this->except = $except;
}

public function report(Throwable $e)
public function report(Throwable $e): void
{
app(ExampleCreator::class)->captureException($e);

Expand Down Expand Up @@ -80,7 +80,7 @@ public function render($request, Throwable $e)
throw $e;
}

public function renderForConsole($output, Throwable $e)
public function renderForConsole($output, Throwable $e): void
{
if ($this->forwardToOriginalHandler) {
$this->originalHandler->renderForConsole($output, $e);
Expand Down
2 changes: 1 addition & 1 deletion src/Utils/Annotations.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Annotations
{
protected $casts = [];

public function addCast(string $key, Closure $callback)
public function addCast(string $key, Closure $callback): void
{
$this->casts[$key] = $callback;
}
Expand Down
12 changes: 6 additions & 6 deletions tests/Console/DocumentationExporterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ protected function setUp(): void
}

#[Test]
function exports_run_as_static_files()
function exports_run_as_static_files(): void
{
$run = $this->createRun('main', 'abcde', true);
$group1 = $this->createExampleGroup($run, 'Tests\Feature\ListUsersTest', 'List Users');
Expand Down Expand Up @@ -103,7 +103,7 @@ function exports_run_as_static_files()
}

#[Test]
function replaces_the_original_urls_with_relative_urls()
function replaces_the_original_urls_with_relative_urls(): void
{
$run = $this->createRun('main', 'abcde', true);

Expand Down Expand Up @@ -131,7 +131,7 @@ function replaces_the_original_urls_with_relative_urls()
}

#[Test]
function replaces_the_original_urls_with_absolute_urls()
function replaces_the_original_urls_with_absolute_urls(): void
{
$run = $this->createRun('main', 'abcde', true);

Expand Down Expand Up @@ -159,7 +159,7 @@ function replaces_the_original_urls_with_absolute_urls()
}

#[Test]
function replaces_the_search_file_path_with_the_export_base_path()
function replaces_the_search_file_path_with_the_export_base_path(): void
{
$run = $this->createRun('main', 'abcde', true);

Expand All @@ -176,7 +176,7 @@ function replaces_the_search_file_path_with_the_export_base_path()
', 'index.html');
}

private function resetDirectory(Filesystem $filesystem, $dir)
private function resetDirectory(Filesystem $filesystem, $dir): void
{
if (! $filesystem->isDirectory($dir)) {
return;
Expand All @@ -185,7 +185,7 @@ private function resetDirectory(Filesystem $filesystem, $dir)
$filesystem->deleteDirectory($dir);
}

private function assertDocumentHasContent(string $expectedContent, $filename)
private function assertDocumentHasContent(string $expectedContent, $filename): void
{
$this->assertFileExists("{$this->baseDir}/{$filename}");
$this->assertSame($expectedContent, file_get_contents("{$this->baseDir}/$filename"));
Expand Down
6 changes: 3 additions & 3 deletions tests/Console/ExportDocumentationCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ protected function setUp(): void
}

#[Test]
function exports_a_run_with_a_relative_url()
function exports_a_run_with_a_relative_url(): void
{
$this->createRun('main', 'abcde', true);
$this->createRun('develop', 'fghij', false);
Expand All @@ -51,7 +51,7 @@ function exports_a_run_with_a_relative_url()
}

#[Test]
function exports_a_run_with_an_absolute_url()
function exports_a_run_with_an_absolute_url(): void
{
$this->createRun('main', 'abcde', true);
$this->createRun('develop', 'fghij', false);
Expand All @@ -78,7 +78,7 @@ function exports_a_run_with_an_absolute_url()
}

#[Test]
function asks_the_user_to_run_the_tests_before_trying_to_export_the_documentation()
function asks_the_user_to_run_the_tests_before_trying_to_export_the_documentation(): void
{
$this->artisan('enlighten:export')
->expectsOutput('There are no runs available. Please setup `Enlighten` and run the tests first.');
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/App/Providers/RouteServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class RouteServiceProvider extends ServiceProvider
*
* @return void
*/
public function boot()
public function boot(): void
{
Route::middleware('web')
->group(__DIR__ . '/../../routes/web.php');
Expand Down
Loading

0 comments on commit 1d2203c

Please sign in to comment.