mirror of
https://github.com/danog/psalm-plugin-laravel.git
synced 2025-01-22 13:21:19 +01:00
Merge pull request #71 from psalm/response
feature: support for response helper
This commit is contained in:
commit
2e4cb7dacc
@ -24,3 +24,17 @@ function factory(string $modelClassName, $nameOrCount = null, $count = null)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 = [])
|
||||
{
|
||||
|
||||
}
|
||||
|
43
tests/acceptance/ResponseReturnType.feature
Normal file
43
tests/acceptance/ResponseReturnType.feature
Normal file
@ -0,0 +1,43 @@
|
||||
Feature: redirect
|
||||
The global redirect helper will return the correct type depending on args
|
||||
|
||||
Background:
|
||||
Given I have the following config
|
||||
"""
|
||||
<?xml version="1.0"?>
|
||||
<psalm totallyTyped="true">
|
||||
<projectFiles>
|
||||
<directory name="."/>
|
||||
<ignoreFiles> <directory name="../../vendor"/> </ignoreFiles>
|
||||
</projectFiles>
|
||||
<plugins>
|
||||
<pluginClass class="Psalm\LaravelPlugin\Plugin"/>
|
||||
</plugins>
|
||||
</psalm>
|
||||
"""
|
||||
|
||||
Scenario: response called with no arguments returns an instance of response factory
|
||||
Given I have the following code
|
||||
"""
|
||||
<?php
|
||||
class Foo {
|
||||
public function bar(): \Illuminate\Contracts\Routing\ResponseFactory {
|
||||
return response();
|
||||
}
|
||||
}
|
||||
"""
|
||||
When I run Psalm
|
||||
Then I see no errors
|
||||
|
||||
Scenario: response called with arguments returns an instance of response
|
||||
Given I have the following code
|
||||
"""
|
||||
<?php
|
||||
class Foo {
|
||||
public function bar(): \Illuminate\Http\Response {
|
||||
return response('ok');
|
||||
}
|
||||
}
|
||||
"""
|
||||
When I run Psalm
|
||||
Then I see no errors
|
Loading…
x
Reference in New Issue
Block a user