Skip to content

Commit

Permalink
Merge pull request #1 from Hi-Folks/feat/rector-php
Browse files Browse the repository at this point in the history
Adding Rector PHP
  • Loading branch information
roberto-butti authored Apr 7, 2024
2 parents df64db9 + 391b99a commit ae63a1c
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 16 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 0.0.2 - WIP
- Adding Rector PHP https://github.com/rectorphp/rector
- Updating Readme for real-time updates

## 0.0.1 - 2024-04-06

Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"require-dev": {
"laravel/pint": "^1.13",
"orchestra/testbench": "^9.0",
"pestphp/pest": "^2.34"
"pestphp/pest": "^2.34",
"rector/rector": "^1.0"
},
"autoload": {
"psr-4": {
Expand Down
25 changes: 25 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

declare(strict_types=1);

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

return RectorConfig::configure()
->withPaths([
__DIR__.'/config',
__DIR__.'/src',
])
->withPhpSets(
php83: true
)
->withRules([
AddVoidReturnTypeWhereNoReturnRector::class,
])
->withPreparedSets(
deadCode: true,
codeQuality: true,
earlyReturn: true,
typeDeclarations: true,
codingStyle: true
);
8 changes: 3 additions & 5 deletions src/FusionServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class FusionServiceProvider extends ServiceProvider
/**
* Bootstrap the application services.
*/
public function boot()
public function boot(): void
{
/*
* Optional methods to load your package assets
Expand Down Expand Up @@ -47,14 +47,12 @@ public function boot()
/**
* Register the application services.
*/
public function register()
public function register(): void
{
// Automatically apply the package configuration
$this->mergeConfigFrom(__DIR__.'/../config/config.php', 'fusion');

// Register the main class to use with the facade
$this->app->singleton('fusion', function () {
return new Fusion;
});
$this->app->singleton('fusion', static fn (): \HiFolks\Fusion\Fusion => new Fusion);
}
}
9 changes: 6 additions & 3 deletions src/Models/FusionBaseModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function getResourceFolder(): string
$folderName = str_replace(
'App\\Models\\',
'',
get_called_class()
static::class
);
$folderName = Str::snake($folderName);

Expand All @@ -39,14 +39,17 @@ public function frontmatterFields(): array
];
}

public function getRows()
public function getRows(): array
{
return $this->getFrontmatterRows(
$this->frontmatterFields()
);
}

public function getFrontmatterRows($columns = [])
/**
* @return non-empty-array[]
*/
public function getFrontmatterRows($columns = []): array
{

$environment = (new Environment())
Expand Down
2 changes: 1 addition & 1 deletion src/Traits/FusionModelTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ trait FusionModelTrait
{
use Sushi;

public function getRows()
public function getRows(): array
{
return parent::getRows();
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Feature/ExampleTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php

test('example', function () {
test('example', function (): void {
expect(true)->toBeTrue();
});
6 changes: 2 additions & 4 deletions tests/Pest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
|
*/

expect()->extend('toBeOne', function () {
return $this->toBe(1);
});
expect()->extend('toBeOne', fn () => $this->toBe(1));

/*
|--------------------------------------------------------------------------
Expand All @@ -39,7 +37,7 @@
|
*/

function something()
function something(): void
{
// ..
}
2 changes: 1 addition & 1 deletion tests/Unit/ExampleTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php

test('example', function () {
test('example', function (): void {
expect(true)->toBeTrue();
});

0 comments on commit ae63a1c

Please sign in to comment.