Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to Psalm v5 #288

Open
wants to merge 16 commits into
base: 5.x
Choose a base branch
from
Open

Switch to Psalm v5 #288

wants to merge 16 commits into from

Conversation

danog
Copy link

@danog danog commented Dec 1, 2022

No description provided.

@schodemeiss
Copy link

This would very much tick this issue: #285

composer.json Outdated Show resolved Hide resolved
@michnovka
Copy link

michnovka commented Dec 4, 2022

@danog you should also fix https://github.com/psalm/psalm-plugin-symfony/actions/runs/3596019841/jobs/6062735638 , i.e. remove

use ReflectionClass;
use ReflectionException;

and escape them in code with leading \ in src/Handler/DoctrineRepositoryHandler.php

@danog
Copy link
Author

danog commented Dec 4, 2022

Or I could also just run cs-fix, but there's still some work to be done on the psalm side :)

@michnovka
Copy link

@danog thank you very much for taking time to work on this. Do you have any time estimate when you can finish? Thanks!

@danog danog changed the base branch from 4.x to 5.x December 17, 2022 17:22
@danog
Copy link
Author

danog commented Dec 17, 2022

I'm afraid the taint issues are caused by the same stubs issue caused by this plugin, that's causing issues upstream with user_defined classes.

@danog
Copy link
Author

danog commented Dec 17, 2022

In fact, analyzing this standalone code returns the taint issues as expected, but running psalm with the plugin enabled on the same file but without the class declarations doesn't:

<?php

class Response
{
    /**
     * @var array<int, string>
     */
    public static $statusTexts;

    /**
     * @throws \InvalidArgumentException When the HTTP status code is not valid
     * @psalm-taint-sink html $content
     */
    public function __construct(?string $content = '', int $status = 200, array $headers = []) {}
}

/**
 * HeaderBag is a container for HTTP headers.
 *
 * @author Fabien Potencier <fabien@symfony.com>
 */
class HeaderBag implements \IteratorAggregate, \Countable
{
    /**
     * Returns the headers as a string.
     *
     * @return string The headers
     *
     * @psalm-taint-source input
     */
    public function __toString() {}

    /**
     * @psalm-taint-source input
     * @psalm-mutation-free
     */
    public function get(string $key, string $default = null): ?string {}
}

/** @var HeaderBag */
$a = null;


new Response($a->get('test'));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants