Skip to content

Commit

Permalink
Merge pull request #381 from alies-dev/more-stubs
Browse files Browse the repository at this point in the history
More stubs
  • Loading branch information
alies-dev authored Mar 17, 2024
2 parents f3107d9 + 5967ab7 commit 11c10b2
Show file tree
Hide file tree
Showing 7 changed files with 122 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,14 @@ protected function getCommonStubs(): array
glob(dirname(__DIR__) . '/stubs/Database/Eloquent/Concerns/*.stubphp'),
glob(dirname(__DIR__) . '/stubs/Database/Eloquent/Relations/*.stubphp'),
glob(dirname(__DIR__) . '/stubs/Database/Eloquent/*.stubphp'),
glob(dirname(__DIR__) . '/stubs/Database/Migrations/*.stubphp'),
glob(dirname(__DIR__) . '/stubs/Database/Query/*.stubphp'),
glob(dirname(__DIR__) . '/stubs/Database/*.stubphp'),
glob(dirname(__DIR__) . '/stubs/Foundation/*.stubphp'),
glob(dirname(__DIR__) . '/stubs/Http/*.stubphp'),
glob(dirname(__DIR__) . '/stubs/legacy-factories/*.stubphp'),
glob(dirname(__DIR__) . '/stubs/Pagination/*.stubphp'),
glob(dirname(__DIR__) . '/stubs/Notifications/**/*.stubphp'),
glob(dirname(__DIR__) . '/stubs/Routing/*.stubphp'),
glob(dirname(__DIR__) . '/stubs/Support/*.stubphp'),
glob(dirname(__DIR__) . '/stubs/Support/**/*.stubphp'),
Expand Down
16 changes: 16 additions & 0 deletions stubs/Database/Migrations/Migrator.stubphp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace Illuminate\Database\Migrations;

class Migrator
{
/**
* Execute the given callback using the given connection as the default connection.
*
* @template TCalbackReturn
* @param string $name
* @param callable(): TCalbackReturn $callback
* @return TCalbackReturn
*/
public function usingConnection($name, callable $callback) {}
}
11 changes: 10 additions & 1 deletion stubs/Foundation/Application.stubphp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,17 @@

namespace Illuminate\Foundation;

class Application
use Illuminate\Container\Container;
use Illuminate\Contracts\Foundation\Application as ApplicationContract;
use Illuminate\Contracts\Foundation\CachesConfiguration;
use Illuminate\Contracts\Foundation\CachesRoutes;
use Illuminate\Support\Traits\Macroable;
use Symfony\Component\HttpKernel\HttpKernelInterface;

class Application extends Container implements ApplicationContract, CachesConfiguration, CachesRoutes, HttpKernelInterface
{
use Macroable;

/**
* Get or check the current application environment.
* @param string|list<string> ...$environments
Expand Down
30 changes: 30 additions & 0 deletions stubs/Http/Request.stubphp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace Illuminate\Http;

use Symfony\Component\HttpFoundation\Request as SymfonyRequest;

class Request extends SymfonyRequest
{
/**
* Retrieve a header from the request.
*
* @template TDefault of string|array<string, string>|null
*
* @param string|null $key
* @param TDefault $default
* @return ($key is null ? array<string, array<int, string|null>> : string|TDefault)
*/
public function header($key = null, $default = null) {}

/**
* Get the route handling the request.
*
* @template TDefault
*
* @param string|null $param
* @param TDefault $default
* @psalm-return ($param is null ? \Illuminate\Routing\Route : TDefault|string|null)
*/
public function route($param = null, $default = null) {}
}
38 changes: 38 additions & 0 deletions stubs/Notifications/Messages/MailMessage.stubphp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

namespace Illuminate\Notifications\Messages;

class MailMessage
{
/**
* The "cc" information for the message.
* @var list<array{0: string, 1: string|null}> Where the first value is email, second — name (optional).
*/
public $cc = [];

/**
* The "bcc" information for the message.
* @var list<array{0: string, 1: string|null}> Where the first value is email, second — name (optional).
*/
public $bcc = [];

/**
* Set the cc address for the mail message.
* @param string|list<string>|array<string, string> $address
* @param string|null $name
* @return $this
*/
public function cc($address, $name = null)
{
}

/**
* Set the bcc address for the mail message.
* @param string|list<string>|array<string, string> $address
* @param string|null $name
* @return $this
*/
public function bcc($address, $name = null)
{
}
}
10 changes: 10 additions & 0 deletions tests/Type/tests/Database/Migrations/MigratorTest.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
--FILE--
<?php declare(strict_types=1);

function test(\Illuminate\Database\Migrations\Migrator $migrator): int {
return $migrator->usingConnection('default', function () {
return 1;
});
}
?>
--EXPECTF--
16 changes: 16 additions & 0 deletions tests/Type/tests/Http/RequestTest.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
--FILE--
<?php declare(strict_types=1);

function it_returns_all_headers(\Illuminate\Http\Request $request): array {
return $request->header();
};

function it_returns_one_header(\Illuminate\Http\Request $request): ?string {
return $request->header('Accept');
};

function it_returns_route(\Illuminate\Http\Request $request): \Illuminate\Routing\Route {
return $request->route();
};
?>
--EXPECTF--

0 comments on commit 11c10b2

Please sign in to comment.