psalm-plugin-laravel/stubs/helpers.stubphp

139 lines
3.2 KiB
Plaintext
Raw Permalink Normal View History

2020-04-29 00:25:24 +02:00
<?php
2020-05-24 09:34:43 +02:00
/**
* Return a new response from the application.
*
* @param \Illuminate\View\View|string|array|null $content
* @param int $status
* @param array $headers
* @return \Illuminate\Http\Response|\Illuminate\Contracts\Routing\ResponseFactory
* @psalm-return (func_num_args() is 0 ? \Illuminate\Contracts\Routing\ResponseFactory : \Illuminate\Http\Response)
*/
function response($content = '', $status = 200, array $headers = [])
{
}
2020-07-21 05:56:35 +02:00
/**
* Throw an HttpException with the given data if the given condition is true.
*
* @param bool $boolean
* @psalm-assert falsy $boolean
* @psalm-return ($boolean is false ? never-return : void )
2020-07-21 05:56:35 +02:00
* @param int $code
* @param string $message
* @param array $headers
* @return void
*
* @throws \Symfony\Component\HttpKernel\Exception\HttpException
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
*/
function abort_if($boolean, $code, $message = '', array $headers = [])
{
}
/**
* @see https://github.com/vimeo/psalm/issues/4816 for why this hack exists
*/
class NullObject {
/**
* @return null
*/
public function __call(string $_name, array $args) {
return null;
}
/**
* @return null
*/
public function __get(string $s) {
return null;
}
public function __set(string $_name, string $_value) : void {
}
}
2021-07-05 11:35:03 +02:00
/**
* Get the first element of an array. Useful for method chaining.
*
* @template TValue
* @template TParam of TValue[]
* @param TParam $array
* @return (TParam is non-empty-array ? TValue : false)
*/
function head($array)
{
return reset($array);
}
/**
* Get the last element from an array.
*
* @template TValue
* @template TParam of TValue[]
* @param TParam $array
* @return (TParam is non-empty-array ? TValue : false)
*/
function last($array)
{
}
/**
* Provide access to optional objects.
*
* @template TValue
* @template TResult
* @template TCallback of null|callable(TValue): TResult
* @psalm-param TValue $value
* @psalm-return (
TValue is null
? NullObject
: ( TCallback is null ? TValue : TResult )
)
*/
function optional($value = null, callable $callback = null)
{
}
/**
* Log a debug message to the logs.
*
* @param string|null $message
* @param array $context
* @return \Illuminate\Log\LogManager|null
* @psalm-return (func_num_args() is 0 ? \Illuminate\Log\LogManager : void)
*/
function logger($message = null, array $context = [])
{
if (is_null($message)) {
return app('log');
}
return app('log')->debug($message, $context);
}
/**
* Get / set the specified configuration value.
*
* If an array is passed as the key, we will assume you want to set an array of values.
*
* @param array<string, mixed>|string|null $key
* @param mixed $default
* @return ($key is null ? \Illuminate\Config\Repository : ($key is array ? null : mixed))
*/
function config($key = null, $default = null) {}
2022-11-01 20:57:40 +01:00
/**
* Get an instance of the current request or an input item from the request.
*
* @param string[]|string|null $key
* @param mixed $default
* @return ($key is null ? \Illuminate\Http\Request : ($key is array ? string[] : mixed))
*/
function request($key = null, $default = null) {}