diff --git a/tests/acceptance/acceptance/ContainerService.feature b/tests/acceptance/acceptance/ContainerService.feature index eca7710..03e58f5 100644 --- a/tests/acceptance/acceptance/ContainerService.feature +++ b/tests/acceptance/acceptance/ContainerService.feature @@ -4,23 +4,26 @@ Feature: Container service Background: Given I have Symfony plugin enabled - - Scenario: Asserting psalm recognizes return type of service got via 'ContainerInterface::get()' - Given I have the following code + And I have the following code preamble """ container->get(SomeService::class)->do(); + $container->get(SomeService::class)->do(); } } """ @@ -30,19 +33,11 @@ Feature: Container service Scenario: Asserting psalm recognizes return type of service got via 'ContainerInterface::get()'. Given I have the following code """ - container->get(SomeService::class)->nosuchmethod(); + $container->get(SomeService::class)->nosuchmethod(); } } """ @@ -55,18 +50,16 @@ Feature: Container service Scenario: Container get(self::class) should not crash Given I have the following code """ - container->get(self::class)->index(); + $container->get(self::class)->index(); } } """ When I run Psalm Then I see these errors - | Type | Message | - | MissingReturnType | Method SomeController::index does not have a return type, expecting void | + | Type | Message | + | MixedMethodCall | Cannot determine the type of the object on the left hand side of this expression | + And I see no other errors diff --git a/tests/acceptance/acceptance/ContainerXml.feature b/tests/acceptance/acceptance/ContainerXml.feature index 8c4f8ab..6cb8b9c 100644 --- a/tests/acceptance/acceptance/ContainerXml.feature +++ b/tests/acceptance/acceptance/ContainerXml.feature @@ -7,19 +7,21 @@ Feature: Container XML config """ ../../tests/acceptance/container.xml """ + And I have the following code preamble + """ + container->get('service_container')->has('lorem'); + return $container->get('service_container')->has('lorem'); } } """ @@ -29,15 +31,11 @@ Feature: Container XML config Scenario: Psalm emits when service ID not found in container' Given I have the following code """ - container->get('not_a_service')->has('lorem'); + $container->get('not_a_service')->has('lorem'); } } """ @@ -49,18 +47,12 @@ Feature: Container XML config Scenario: Using service both via alias and class const Given I have the following code """ - container->get('http_kernel'); - $this->container->get(HttpKernelInterface::class); + $container->get('http_kernel'); + $container->get(HttpKernelInterface::class); } } """ @@ -70,15 +62,11 @@ Feature: Container XML config Scenario: Using private service Given I have the following code """ - container->get('private_service'); + $container->get('private_service'); } } """ diff --git a/tests/acceptance/acceptance/HeaderBag.feature b/tests/acceptance/acceptance/HeaderBag.feature index 157278c..ae1a753 100644 --- a/tests/acceptance/acceptance/HeaderBag.feature +++ b/tests/acceptance/acceptance/HeaderBag.feature @@ -2,7 +2,7 @@ Feature: Header get Background: - Given I have issue handler "UnusedFunctionCall" suppressed + Given I have issue handler "UnusedVariable" suppressed And I have Symfony plugin enabled And I have the following code preamble """ @@ -11,24 +11,23 @@ Feature: Header get use Symfony\Component\HttpFoundation\Request; """ - Scenario: HeaderBag get method return type should return `?string` (unless third argument is provided for < Sf4.4) + Scenario: HeaderBag get method return type should return `?string` Given I have the following code """ class App { public function index(Request $request): void { - $string = $request->headers->get('nullable_string'); - if (!$string) { - return; - } - - trim($string); + /** @psalm-trace $nullableString */ + $nullableString = $request->headers->get('nullable_string'); } } """ When I run Psalm - Then I see no errors + Then I see these errors + | Type | Message | + | Trace | $nullableString: null\|string | + And I see no other errors Scenario: HeaderBag get method return type should return `string` if default value is provided with string Given I have the following code @@ -37,11 +36,13 @@ Feature: Header get { public function index(Request $request): void { + /** @psalm-trace $string */ $string = $request->headers->get('string', 'string'); - - trim($string); } } """ When I run Psalm - Then I see no errors + Then I see these errors + | Type | Message | + | Trace | $string: string | + And I see no other errors diff --git a/tests/acceptance/acceptance/NamingConventions.feature b/tests/acceptance/acceptance/NamingConventions.feature index a376170..928149f 100644 --- a/tests/acceptance/acceptance/NamingConventions.feature +++ b/tests/acceptance/acceptance/NamingConventions.feature @@ -7,19 +7,22 @@ Feature: Naming conventions """ ../../tests/acceptance/container.xml """ + And I have the following code preamble + """ + container->get('service_container')->has('lorem'); + return $container->get('service_container')->has('lorem'); } } """ @@ -29,15 +32,11 @@ Feature: Naming conventions Scenario: Detects service naming convention violation Given I have the following code """ - container->get('wronglyNamedService'); + $container->get('wronglyNamedService'); } } """ @@ -50,17 +49,11 @@ Feature: Naming conventions Scenario: No service naming convention violation when using FQCNs Given I have the following code """ - container->get(HttpKernelInterface::class); + $container->get(HttpKernelInterface::class); } } """ @@ -70,15 +63,11 @@ Feature: Naming conventions Scenario: No naming convention violation for parameter Given I have the following code """ - container->getParameter('kernel.cache_dir'); + $container->getParameter('kernel.cache_dir'); } } """ @@ -88,15 +77,11 @@ Feature: Naming conventions Scenario: Detects parameter naming convention violation Given I have the following code """ - container->getParameter('wronglyNamedParameter'); + $container->getParameter('wronglyNamedParameter'); } } """ @@ -109,15 +94,11 @@ Feature: Naming conventions Scenario: No parameter naming convention violation when using environment variables Given I have the following code """ - container->getParameter('env(SOME_ENV_VAR)'); + $container->getParameter('env(SOME_ENV_VAR)'); } } """