Skip to content

Commit

Permalink
Improve 4.14.0 post
Browse files Browse the repository at this point in the history
Add Psalm.
  • Loading branch information
akrabat committed Jun 14, 2024
1 parent 0728dee commit 39a4567
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions _posts/2024-06-13-slim-4.14.0-release.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ $container = $this->app->getContainer();
$entries = $container->getKnownEntryNames();
```

[PHPStan](https://phpstan.org/) has no way of knowing that <tt>$container</tt> is an instance of <tt>DI\Container</tt> which has a <tt>getKnownEntryNames()</tt> method and so will complain.
[Psalm](https://psalm.dev) or [PHPStan](https://phpstan.org/) have no way of knowing that <tt>$container</tt> is an instance of <tt>DI\Container</tt> which has a <tt>getKnownEntryNames()</tt> method and so will complain.

To inform PHPStan that we created <tt>Slim\App</tt> with PHP-DI, we change: <tt>/** @var \Slim\App $app */</tt> to <tt>/** @var \Slim\App<DI\Container> $app */</tt> and now PHPStan knows that <tt>getKnownEntryNames()</tt> is a valid method call on <tt>$container</tt>.
To inform the static analyzer that we created <tt>Slim\App</tt> with PHP-DI, we change: <tt>/** @var \Slim\App $app */</tt> to <tt>/** @var \Slim\App<DI\Container> $app */</tt> and now PHPStan knows that <tt>getKnownEntryNames()</tt> is a valid method call on <tt>$container</tt>.


### Update your type hints
Expand Down

0 comments on commit 39a4567

Please sign in to comment.