Skip to content

Commit

Permalink
feat: stubs declaring strict types (#19)
Browse files Browse the repository at this point in the history
* feat: modify stubs to declare strict types

* ref: words sort in ascending order

* fix: add missing semicolon
  • Loading branch information
juantejer4 authored Jan 3, 2024
1 parent d0cd6ee commit a6bee7b
Show file tree
Hide file tree
Showing 44 changed files with 1,535 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"clsx",
"DBAL",
"Debugbar",
"Dispatchable",
"docblocks",
"EHLO",
"Encrypter",
Expand All @@ -39,6 +40,7 @@
"LIVEWIRE",
"macvim",
"magento",
"Mailables",
"mailgun",
"Mailpit",
"medtech",
Expand All @@ -52,14 +54,15 @@
"Npkj",
"Nuno",
"nunomaduro",
"roundrobin",
"PAPERTRAIL",
"Parens",
"passw",
"phpredis",
"Phpstan",
"phpstorm",
"phpunit",
"Queueable",
"roundrobin",
"sasl",
"Slevomat",
"sqlanywhere",
Expand Down
21 changes: 21 additions & 0 deletions stubs/cast.inbound.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);

namespace {{ namespace }};

use Illuminate\Database\Eloquent\Model;
use Illuminate\Contracts\Database\Eloquent\CastsInboundAttributes;

class {{ class }} implements CastsInboundAttributes
{
/**
* Prepare the given value for storage.
*
* @param array<string, mixed> $attributes
*/
public function set(Model $model, string $key, mixed $value, array $attributes): mixed
{
return $value;
}
}
31 changes: 31 additions & 0 deletions stubs/cast.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types=1);

namespace {{ namespace }};

use Illuminate\Database\Eloquent\Model;
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;

class {{ class }} implements CastsAttributes
{
/**
* Cast the given value.
*
* @param array<string, mixed> $attributes
*/
public function get(Model $model, string $key, mixed $value, array $attributes): mixed
{
return $value;
}

/**
* Prepare the given value for storage.
*
* @param array<string, mixed> $attributes
*/
public function set(Model $model, string $key, mixed $value, array $attributes): mixed
{
return $value;
}
}
32 changes: 32 additions & 0 deletions stubs/console.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

declare(strict_types=1);

namespace {{ namespace }};

use Illuminate\Console\Command;

class {{ class }} extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = '{{ command }}';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';

/**
* Execute the console command.
*/
public function handle()
{
//
}
}
51 changes: 51 additions & 0 deletions stubs/controller.api.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

declare(strict_types=1);

namespace {{ namespace }};

use {{ rootNamespace }}Http\Controllers\Controller;
use Illuminate\Http\Request;

class {{ class }} extends Controller
{
/**
* Display a listing of the resource.
*/
public function index()
{
//
}

/**
* Store a newly created resource in storage.
*/
public function store(Request $request)
{
//
}

/**
* Display the specified resource.
*/
public function show(string $id)
{
//
}

/**
* Update the specified resource in storage.
*/
public function update(Request $request, string $id)
{
//
}

/**
* Remove the specified resource from storage.
*/
public function destroy(string $id)
{
//
}
}
19 changes: 19 additions & 0 deletions stubs/controller.invokable.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

declare(strict_types=1);

namespace {{ namespace }};

use {{ rootNamespace }}Http\Controllers\Controller;
use Illuminate\Http\Request;

class {{ class }} extends Controller
{
/**
* Handle the incoming request.
*/
public function __invoke(Request $request)
{
//
}
}
52 changes: 52 additions & 0 deletions stubs/controller.model.api.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

declare(strict_types=1);

namespace {{ namespace }};

use {{ namespacedModel }};
use {{ rootNamespace }}Http\Controllers\Controller;
use {{ namespacedRequests }}

class {{ class }} extends Controller
{
/**
* Display a listing of the resource.
*/
public function index()
{
//
}

/**
* Store a newly created resource in storage.
*/
public function store({{ storeRequest }} $request)
{
//
}

/**
* Display the specified resource.
*/
public function show({{ model }} ${{ modelVariable }})
{
//
}

/**
* Update the specified resource in storage.
*/
public function update({{ updateRequest }} $request, {{ model }} ${{ modelVariable }})
{
//
}

/**
* Remove the specified resource from storage.
*/
public function destroy({{ model }} ${{ modelVariable }})
{
//
}
}
68 changes: 68 additions & 0 deletions stubs/controller.model.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php

declare(strict_types=1);

namespace {{ namespace }};

use {{ namespacedModel }};
use {{ rootNamespace }}Http\Controllers\Controller;
use {{ namespacedRequests }}

class {{ class }} extends Controller
{
/**
* Display a listing of the resource.
*/
public function index()
{
//
}

/**
* Show the form for creating a new resource.
*/
public function create()
{
//
}

/**
* Store a newly created resource in storage.
*/
public function store({{ storeRequest }} $request)
{
//
}

/**
* Display the specified resource.
*/
public function show({{ model }} ${{ modelVariable }})
{
//
}

/**
* Show the form for editing the specified resource.
*/
public function edit({{ model }} ${{ modelVariable }})
{
//
}

/**
* Update the specified resource in storage.
*/
public function update({{ updateRequest }} $request, {{ model }} ${{ modelVariable }})
{
//
}

/**
* Remove the specified resource from storage.
*/
public function destroy({{ model }} ${{ modelVariable }})
{
//
}
}
53 changes: 53 additions & 0 deletions stubs/controller.nested.api.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

declare(strict_types=1);

namespace {{ namespace }};

use {{ namespacedModel }};
use {{ rootNamespace }}Http\Controllers\Controller;
use {{ namespacedParentModel }};
use Illuminate\Http\Request;

class {{ class }} extends Controller
{
/**
* Display a listing of the resource.
*/
public function index({{ parentModel }} ${{ parentModelVariable }})
{
//
}

/**
* Store a newly created resource in storage.
*/
public function store(Request $request, {{ parentModel }} ${{ parentModelVariable }})
{
//
}

/**
* Display the specified resource.
*/
public function show({{ parentModel }} ${{ parentModelVariable }}, {{ model }} ${{ modelVariable }})
{
//
}

/**
* Update the specified resource in storage.
*/
public function update(Request $request, {{ parentModel }} ${{ parentModelVariable }}, {{ model }} ${{ modelVariable }})
{
//
}

/**
* Remove the specified resource from storage.
*/
public function destroy({{ parentModel }} ${{ parentModelVariable }}, {{ model }} ${{ modelVariable }})
{
//
}
}
Loading

0 comments on commit a6bee7b

Please sign in to comment.