mirror of
https://github.com/danog/psalm-plugin-symfony.git
synced 2024-11-26 20:04:58 +01:00
Add template for getRuntime method (#164)
This commit is contained in:
parent
e363384dfa
commit
9138d0bc80
10
.editorconfig
Normal file
10
.editorconfig
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
end_of_line = lf
|
||||||
|
insert_final_newline = true
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
[{*.php, *.json}]
|
||||||
|
indent_size = 4
|
@ -11,4 +11,15 @@ class Environment
|
|||||||
* @psalm-taint-specialize
|
* @psalm-taint-specialize
|
||||||
*/
|
*/
|
||||||
public function render($name, array $context = []): string {}
|
public function render($name, array $context = []): string {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @template T of object
|
||||||
|
*
|
||||||
|
* @param class-string<T> $class
|
||||||
|
*
|
||||||
|
* @return T
|
||||||
|
*
|
||||||
|
* @throws RuntimeError When the template cannot be found
|
||||||
|
*/
|
||||||
|
public function getRuntime($class) {}
|
||||||
}
|
}
|
||||||
|
37
tests/acceptance/acceptance/TwigEnvironment.feature
Normal file
37
tests/acceptance/acceptance/TwigEnvironment.feature
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
@symfony-common
|
||||||
|
Feature: Twig Environment
|
||||||
|
|
||||||
|
Background:
|
||||||
|
Given I have the following config
|
||||||
|
"""
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<psalm errorLevel="1">
|
||||||
|
<projectFiles>
|
||||||
|
<directory name="."/>
|
||||||
|
<ignoreFiles> <directory name="../../vendor"/> </ignoreFiles>
|
||||||
|
</projectFiles>
|
||||||
|
|
||||||
|
<plugins>
|
||||||
|
<pluginClass class="Psalm\SymfonyPsalmPlugin\Plugin"/>
|
||||||
|
</plugins>
|
||||||
|
</psalm>
|
||||||
|
"""
|
||||||
|
|
||||||
|
Scenario: getRuntime method return type is dynamic
|
||||||
|
Given I have the following code
|
||||||
|
"""
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Symfony\Component\Form\FormRenderer;
|
||||||
|
use Twig\Environment;
|
||||||
|
|
||||||
|
class Foo
|
||||||
|
{
|
||||||
|
public function foo(Environment $environment): FormRenderer
|
||||||
|
{
|
||||||
|
return $environment->getRuntime(FormRenderer::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
When I run Psalm
|
||||||
|
Then I see no errors
|
Loading…
Reference in New Issue
Block a user