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

SlevomatCodingStandard.TypeHints.PropertyTypeHint false positive when WeakMap<static, object{a: int}> (object shape). #1692

Open
LastDragon-ru opened this issue Aug 15, 2024 · 0 comments

Comments

@LastDragon-ru
Copy link

<?php declare(strict_types = 1);

namespace Bug;

use WeakMap;

class Bug {
    /**
     * @var WeakMap<static, object{a: int}> https://phpstan.org/writing-php-code/phpdoc-types#object-shapes
     */
    public WeakMap $objectMap;
    /**
     * @var WeakMap<static, array{a: int}>
     */
    public WeakMap $arrayMap;
}
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="./vendor-bin/phpcs/vendor/squizlabs/php_codesniffer/phpcs.xsd">
    <config name="installed_paths" value="../../slevomat/coding-standard"/>
    <rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHint"/>
</ruleset>

Actual:

--------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------------
 9 | ERROR | @var annotation of property \Bug\Bug::$objectMap does not specify type hint for its items.
--------------------------------------------------------------------------------------------------------

Expected:

no error
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

No branches or pull requests

1 participant