Skip to content

Commit

Permalink
Merge pull request #369 from alies-dev/update-stubs
Browse files Browse the repository at this point in the history
Update stubs: add `Route`, `once()`, update `Model` properties
  • Loading branch information
alies-dev authored Mar 13, 2024
2 parents cde7800 + f66e4d3 commit e509f8a
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 1 deletion.
1 change: 0 additions & 1 deletion psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
errorBaseline="psalm-baseline.xml"
findUnusedBaselineEntry="false"
findUnusedCode="true"
phpVersion="8.0"
>
<projectFiles>
<directory name="src" />
Expand Down
2 changes: 2 additions & 0 deletions src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ protected function getCommonStubs(): array
glob(dirname(__DIR__) . '/stubs/Http/*.stubphp'),
glob(dirname(__DIR__) . '/stubs/legacy-factories/*.stubphp'),
glob(dirname(__DIR__) . '/stubs/Pagination/*.stubphp'),
glob(dirname(__DIR__) . '/stubs/Routing/*.stubphp'),
glob(dirname(__DIR__) . '/stubs/Support/*.stubphp'),
glob(dirname(__DIR__) . '/stubs/Support/**/*.stubphp'),
);
}

Expand Down
Empty file added stubs/10/.gitignore
Empty file.
16 changes: 16 additions & 0 deletions stubs/11/helpers.stubphp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

/**
* Stubs for {@see https://github.com/laravel/framework/blob/master/src/Illuminate/Support/helpers.php}
*/

/**
* Ensures a callable is only called once, and returns the result on subsequent calls.
*
* @template TReturnType
*
* @param callable(): TReturnType $callback
* @return TReturnType
* @psalm-pure
*/
function once(callable $callback) {}
2 changes: 2 additions & 0 deletions stubs/Collections/helpers.stubphp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ function data_fill(&$target, $key, $value) {}
*/
function data_set(&$target, $key, $value, $overwrite = true) {}

// data_set: nothing to stub

/**
* Get the first element of an array. Useful for method chaining.
*
Expand Down
20 changes: 20 additions & 0 deletions stubs/Database/Eloquent/Model.stubphp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,26 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
Concerns\GuardsAttributes,
ForwardsCalls;

/**
* @var array<string, string>
*/
protected $casts = [];

/**
* @var list<string>
*/
protected $hidden = [];

/**
* @var list<string>
*/
protected $visible = [];

/**
* @var list<string>
*/
protected $appends = [];

/**
* @param array|mixed $columns
* @return \Illuminate\Database\Eloquent\Collection<int, static>
Expand Down
14 changes: 14 additions & 0 deletions stubs/Routing/Route.stubphp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace Illuminate\Routing;

class Route
{
/**
* Get or set the middlewares attached to the route.
*
* @param string[]|string|null $middleware
* @return ($middleware is null ? string[] : $this)
*/
public function middleware($middleware = null) {}
}
File renamed without changes.
2 changes: 2 additions & 0 deletions stubs/Support/helpers.stubphp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ function class_uses_recursive($class) {}
*/
function filled($value) {}

// literal: @todo add stub

/**
* Get an item from an object using "dot" notation.
*
Expand Down

0 comments on commit e509f8a

Please sign in to comment.