61 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
1
vote
1
answer
139
views
Psalm does not detect SQL Injection
I'm trying to use Psalm to detect SQL Injections. I have the following code :
$pdo = new PDO("mysql:host=db;dbname=tp;port=3306", "user", "password");;
// VULNERABLE ...
0
votes
1
answer
733
views
Psalm error when extending a class with template
I have a PHP 8.1 application with Symfony 5.4 and Doctrine 2.17. We use psalm 5.18. With Doctrine ODM bundle (v4.7) there is a ServiceDocumentRepository class:
<?php
declare(strict_types=1);
...
0
votes
1
answer
210
views
How do I document child classes that return more specific types than parent?
I am trying to figure out how to properly document some code, mostly so that tools like PHPStan and Psalm don't complain.
Simplified, I have an abstract class that defines methods for setting and ...
1
vote
0
answers
283
views
Psalm laravel UndefinedMagicMethod
Psalm speaks of mistakes...
UndefinedMagicMethod Magic method App\Models\User::wherenull() does not exist
UndefinedMagicMethod Magic method App\Models\User::create()
UndefinedMagicMethod Magic ...
0
votes
0
answers
137
views
PHP: ArrayObject method signature not compatible with ArrayAccess interface
When I extend an ArrayObject and use vimeo/psalm static analyzer to check my code, I get the following error:
ERROR: ParamNameMismatch
at /var/www/file.php:13:37
Argument 1 of ...
0
votes
1
answer
207
views
Psalm types inferring for abstract classes and its implementations
Is something wrong with templates in this example: https://psalm.dev/r/113297eeaf?
Why Psalm doesn't agree that Pet<Cat|Dog> and Cat|Dog are the same types here?
Can this be solved somehow (...
1
vote
2
answers
516
views
Psalm: Unable to determine the type that $x is being assigned to
I have the following code and want to get it through Psalm static checks:
if (
empty($sessions[$token]->product)
|| !is_object($sessions[$token]->product)
) {
continue;
}
if (
...
Alex's user avatar
- 35.8k
0
votes
1
answer
952
views
PossiblyUnusedMethod: Cannot find any calls to method in Repository
I'm working on a Symfony project and I'm starting using Psalm. Almost everything is fine, as I keep getting an error that I don't understand:
ERROR: PossiblyUnusedMethod - src/Repository/...
1
vote
1
answer
677
views
Generics on Interfaces
I have an interface that implements a method which takes an array of format X and returns an array with the same format X. I tried using generics to express this, but apparently I can't do so because ...
1
vote
2
answers
563
views
How to solve a problem with a DocblockTypeContradiction in Psalm
I have the simplified code example from my library, to which psalm, for reasons I don't understand, outputs warnings.
class Example {
public const C_1 = 'val1';
public const C_2 = 'val2';
...
1
vote
2
answers
243
views
Psalm stdClass with properties definition anotation error
What is the correct returning object definition in psalm?
/**
* @psalm-return \stdClass{foo?: string}
*/
function returnObject(): \stdClass {
$item2 = new \stdClass();
$item2->foo = "asd&...
3
votes
1
answer
1k
views
How to tell PHP static code analysers to read the generic type hint from a callable, instead of expecting the class name as a string?
I'm trying to remove some code duplication that has proven to be prone to human errors.
I created a working sample code at https://3v4l.org/QFA6m#v8.2.7 and a demo of PHPStan failing where expected, ...
0
votes
1
answer
795
views
Does PhpStan and Psalm measures cyclomatic complexity?
I've read the documentation from PhpStan and Psalm, and i couldn't find the rules where it checks the Cyclomatic Complexity like Phpmd does here
Also, is it possible to cusomise rules within levels ...
3
votes
0
answers
248
views
Is there an error baseline feature for Typescript
The PHP linter "Psalm" has a feature called baseline. It can be used to "ignore" errors that are tracked by a baseline file but prevent new errors from accumulating. This is useful ...
2
votes
0
answers
206
views
PHP Psalm covariance on method parameter
I have a case in PHP psalm that can be represented by this snippet:
https://psalm.dev/r/c31997fed4
The handleNode() method does not care about the type of node used, it should only care about that it ...