Skip to content

Commit

Permalink
Merge pull request #1 from ardin0546/feature/update-styles
Browse files Browse the repository at this point in the history
Feature/update styles
  • Loading branch information
ardin0546 authored Oct 24, 2024
2 parents deb5c7d + 1e0060a commit 75352f5
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 106 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,18 @@ Laravel 7+ stub files more consistent with PSR-12 / PHP 7+

- Version 1.x is aimed at Laravel 7 and PHP 7
- Version 2.x is aimed at Laravel 8+ and PHP 8

# Usage

To install the stubs, run the following command:
```bash
php artisan coddin-stubs:install
```
> **Note:** This will not overwrite existing stub files
To update the stubs, run the following command:

```bash
php artisan coddin-stubs:update
```
> **Note:** This will overwrite existing stub files. Custom stubs will not be overwritten.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
}
],
"require": {
"php": "^7.3|^8.0"
"php": "^8.2"
},
"autoload": {
"psr-4": {
Expand Down
1 change: 1 addition & 0 deletions src/CoddinStubsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ private function registerCommands()
if ($this->app->runningInConsole()) {
$this->commands([
Console\InstallCommand::class,
Console\UpdateCommand::class,
]);
}
}
Expand Down
23 changes: 23 additions & 0 deletions src/Console/UpdateCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

namespace Coddin\Stubs\Console;

use Illuminate\Console\Command;

final class UpdateCommand extends Command
{
protected $signature = 'coddin-stubs:update';

protected $description = 'Updates and overwrites the stubs modified for PSR-12';

public function handle(): void
{
$this->comment('Publishing Coddin Stubs Provider...');
$this->callSilent('vendor:publish', [
'--tag' => 'stubs',
'--force' => true,
]);
}
}
14 changes: 5 additions & 9 deletions stubs/console.stub
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,12 @@ use Illuminate\Console\Command;

final class {{ class }} extends Command
{
public function handle(): void
{
// Add your command logic
}
protected $signature = '{{ command }}';

protected function configure(): void
{
$this->setName('command:name');
$this->setDescription('Command description');
protected $description = 'Command description';

parent::configure();
public function handle(): int
{
return self::SUCCESS;
}
}
40 changes: 5 additions & 35 deletions stubs/observer.stub
Original file line number Diff line number Diff line change
Expand Up @@ -8,57 +8,27 @@ use {{ namespacedModel }};

final class {{ class }}
{
/**
* Handle the {{ model }} "created" event.
*
* @param \{{ namespacedModel }} ${{ modelVariable }}
* @return void
*/
public function created({{ model }} ${{ modelVariable }})
public function created({{ model }} ${{ modelVariable }}): void
{
//
}

/**
* Handle the {{ model }} "updated" event.
*
* @param \{{ namespacedModel }} ${{ modelVariable }}
* @return void
*/
public function updated({{ model }} ${{ modelVariable }})
public function updated({{ model }} ${{ modelVariable }}): void
{
//
}

/**
* Handle the {{ model }} "deleted" event.
*
* @param \{{ namespacedModel }} ${{ modelVariable }}
* @return void
*/
public function deleted({{ model }} ${{ modelVariable }})
public function deleted({{ model }} ${{ modelVariable }}): void
{
//
}

/**
* Handle the {{ model }} "restored" event.
*
* @param \{{ namespacedModel }} ${{ modelVariable }}
* @return void
*/
public function restored({{ model }} ${{ modelVariable }})
public function restored({{ model }} ${{ modelVariable }}): void
{
//
}

/**
* Handle the {{ model }} "force deleted" event.
*
* @param \{{ namespacedModel }} ${{ modelVariable }}
* @return void
*/
public function forceDeleted({{ model }} ${{ modelVariable }})
public function forceDeleted({{ model }} ${{ modelVariable }}): void
{
//
}
Expand Down
75 changes: 14 additions & 61 deletions stubs/policy.stub
Original file line number Diff line number Diff line change
Expand Up @@ -12,85 +12,38 @@ final class {{ class }}
{
use HandlesAuthorization;

/**
* Determine whether the user can view any models.
*
* @param \{{ namespacedUserModel }} $user
* @return mixed
*/
public function viewAny({{ user }} $user)
public function viewAny({{ user }} $user): bool
{
//
return false;
}

/**
* Determine whether the user can view the model.
*
* @param \{{ namespacedUserModel }} $user
* @param \{{ namespacedModel }} ${{ modelVariable }}
* @return mixed
*/
public function view({{ user }} $user, {{ model }} ${{ modelVariable }})
public function view({{ user }} $user, {{ model }} ${{ modelVariable }}): bool
{
//
return false;
}

/**
* Determine whether the user can create models.
*
* @param \{{ namespacedUserModel }} $user
* @return mixed
*/
public function create({{ user }} $user)
public function create({{ user }} $user): bool
{
//
return false;
}

/**
* Determine whether the user can update the model.
*
* @param \{{ namespacedUserModel }} $user
* @param \{{ namespacedModel }} ${{ modelVariable }}
* @return mixed
*/
public function update({{ user }} $user, {{ model }} ${{ modelVariable }})
public function update({{ user }} $user, {{ model }} ${{ modelVariable }}): bool
{
//
return false;
}

/**
* Determine whether the user can delete the model.
*
* @param \{{ namespacedUserModel }} $user
* @param \{{ namespacedModel }} ${{ modelVariable }}
* @return mixed
*/
public function delete({{ user }} $user, {{ model }} ${{ modelVariable }})
public function delete({{ user }} $user, {{ model }} ${{ modelVariable }}): bool
{
//
return false;
}

/**
* Determine whether the user can restore the model.
*
* @param \{{ namespacedUserModel }} $user
* @param \{{ namespacedModel }} ${{ modelVariable }}
* @return mixed
*/
public function restore({{ user }} $user, {{ model }} ${{ modelVariable }})
public function restore({{ user }} $user, {{ model }} ${{ modelVariable }}): bool
{
//
return false;
}

/**
* Determine whether the user can permanently delete the model.
*
* @param \{{ namespacedUserModel }} $user
* @param \{{ namespacedModel }} ${{ modelVariable }}
* @return mixed
*/
public function forceDelete({{ user }} $user, {{ model }} ${{ modelVariable }})
public function forceDelete({{ user }} $user, {{ model }} ${{ modelVariable }}): bool
{
//
return false;
}
}

0 comments on commit 75352f5

Please sign in to comment.