mirror of
https://github.com/danog/psalm-plugin-symfony.git
synced 2024-11-26 11:55:00 +01:00
Merge remote-tracking branch 'origin/5.x' into 4.x
This commit is contained in:
commit
ce95312a5d
@ -21,6 +21,7 @@ use Psalm\Type\Atomic\TBool;
|
||||
use Psalm\Type\Atomic\TInt;
|
||||
use Psalm\Type\Atomic\TNull;
|
||||
use Psalm\Type\Atomic\TString;
|
||||
use Psalm\Type\MutableUnion;
|
||||
use Psalm\Type\Union;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
@ -17,4 +17,10 @@ class HeaderBag implements \IteratorAggregate, \Countable
|
||||
* @psalm-taint-source input
|
||||
*/
|
||||
public function __toString() {}
|
||||
|
||||
/**
|
||||
* @psalm-taint-source input
|
||||
* @psalm-mutation-free
|
||||
*/
|
||||
public function get(string $key, string $default = null): ?string {}
|
||||
}
|
||||
|
@ -11,11 +11,9 @@ class Request
|
||||
*
|
||||
* @throws \LogicException
|
||||
*
|
||||
* @psalm-return (
|
||||
* $asResource is true
|
||||
* ? resource
|
||||
* : string
|
||||
* )
|
||||
* @psalm-template TAsResource as bool
|
||||
* @psalm-param TAsResource $asResource
|
||||
* @psalm-return (TAsResource is true ? resource : string)
|
||||
*/
|
||||
public function getContent($asResource = false) {}
|
||||
|
||||
|
@ -13,5 +13,5 @@ class Response
|
||||
* @throws \InvalidArgumentException When the HTTP status code is not valid
|
||||
* @psalm-taint-sink html $content
|
||||
*/
|
||||
public function __construct($content = '', int $status = 200, array $headers = []) {}
|
||||
public function __construct(?string $content = '', int $status = 200, array $headers = []) {}
|
||||
}
|
||||
|
@ -22,19 +22,19 @@ Feature: AuthenticatorInterface
|
||||
*/
|
||||
abstract class SomeAuthenticator implements AuthenticatorInterface
|
||||
{
|
||||
public function getCredentials(Request $request)
|
||||
public function getCredentials(Request $request): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function getUser($credentials, UserProviderInterface $provider)
|
||||
public function getUser($credentials, UserProviderInterface $provider): User
|
||||
{
|
||||
/** @psalm-trace $credentials */
|
||||
|
||||
return new User('name', 'pass');
|
||||
}
|
||||
|
||||
public function checkCredentials($credentials, UserInterface $user)
|
||||
public function checkCredentials($credentials, UserInterface $user): bool
|
||||
{
|
||||
/** @psalm-trace $credentials */
|
||||
|
||||
@ -43,7 +43,7 @@ Feature: AuthenticatorInterface
|
||||
/** @psalm-trace $user */
|
||||
}
|
||||
|
||||
public function createAuthenticatedToken(UserInterface $user, string $providerKey)
|
||||
public function createAuthenticatedToken(UserInterface $user, string $providerKey): PreAuthenticationGuardToken
|
||||
{
|
||||
/** @psalm-trace $user */
|
||||
|
||||
|
@ -3,7 +3,8 @@ Feature: Denormalizer interface
|
||||
Detect DenormalizerInterface::denormalize() result type
|
||||
|
||||
Background:
|
||||
Given I have Symfony plugin enabled
|
||||
Given I have issue handler "UnusedVariable,MethodSignatureMustProvideReturnType" suppressed
|
||||
And I have Symfony plugin enabled
|
||||
|
||||
Scenario: Psalm recognizes denormalization result as an object when a class is passed as a type
|
||||
Given I have the following code
|
||||
|
@ -57,22 +57,23 @@ Feature: Tainting
|
||||
| query |
|
||||
| cookies |
|
||||
|
||||
Scenario: The user-agent is used in the body of a Response object
|
||||
Given I have the following code
|
||||
"""
|
||||
class MyController
|
||||
{
|
||||
public function __invoke(Request $request): Response
|
||||
{
|
||||
return new Response($request->headers->get('user-agent'));
|
||||
}
|
||||
}
|
||||
"""
|
||||
When I run Psalm with taint analysis
|
||||
Then I see these errors
|
||||
| Type | Message |
|
||||
| TaintedHtml | Detected tainted HTML |
|
||||
And I see no other errors
|
||||
# todo: "@psalm-taint-source input" does not work on get() method
|
||||
# Scenario: The user-agent is used in the body of a Response object
|
||||
# Given I have the following code
|
||||
# """
|
||||
# class MyController
|
||||
# {
|
||||
# public function __invoke(Request $request): Response
|
||||
# {
|
||||
# return new Response($request->headers->get('user-agent'));
|
||||
# }
|
||||
# }
|
||||
# """
|
||||
# When I run Psalm with taint analysis
|
||||
# Then I see these errors
|
||||
# | Type | Message |
|
||||
# | TaintedHtml | Detected tainted HTML |
|
||||
# And I see no other errors
|
||||
|
||||
Scenario: All headers are printed in the body of a Response object
|
||||
Given I have the following code
|
||||
|
@ -3,7 +3,8 @@ Feature: Serializer interface
|
||||
Detect SerializerInterface::deserialize() result type
|
||||
|
||||
Background:
|
||||
Given I have Symfony plugin enabled
|
||||
Given I have issue handler "UnusedVariable,MethodSignatureMustProvideReturnType" suppressed
|
||||
And I have Symfony plugin enabled
|
||||
|
||||
Scenario: Psalm recognizes deserialization result as an object when a class is passed as a type
|
||||
Given I have the following code
|
||||
|
Loading…
Reference in New Issue
Block a user