Merge pull request #71 from psalm/response

feature: support for response helper
This commit is contained in:
feek 2020-05-24 00:43:58 -07:00 committed by GitHub
commit 2e4cb7dacc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 57 additions and 0 deletions

View File

@ -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 = [])
{
}

View 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