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

use ContainerAwareTrait must supress PropertyNotSetInConstructor #141

Open
Punk-UnDeaD opened this issue Feb 10, 2021 · 1 comment
Open
Labels
feature New feature or request

Comments

@Punk-UnDeaD
Copy link
Contributor

hello
we need something like this

<?php

declare(strict_types=1);

namespace App\Psalm;

use PhpParser\Node\Stmt\ClassLike;
use Psalm\Codebase;
use Psalm\FileSource;
use Psalm\Plugin\Hook\AfterClassLikeVisitInterface;
use Psalm\Storage\ClassLikeStorage;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;

class ContainerAwareTraitHandler implements AfterClassLikeVisitInterface
{
    public static function afterClassLikeVisit(
        ClassLike $stmt,
        ClassLikeStorage $storage,
        FileSource $statements_source,
        Codebase $codebase,
        array &$file_replacements = []
    ) {
        if (ContainerAwareTrait::class === $storage->name) {
            $storage->initialized_properties['container'] = true;
        }
    }
}

@seferov
Copy link
Member

seferov commented Feb 11, 2021

hi @Punk-UnDeaD,

Thank you for the issue. The code seems valid. Can you please create a PR for it?

@seferov seferov added the feature New feature or request label Feb 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants