Skip to content

Is there a single rule for Use of undefined constant in array keys #7015

Answered by samsonasik
leevigraham asked this question in Q&A
Discussion options

You must be logged in to vote

You may can create custom rector rule for it:

<?php

declare(strict_types=1);

namespace Utils\Rector\ConstFetch;

use PhpParser\Node;
use Rector\Core\Rector\AbstractRector;
use PHPStan\Reflection\ReflectionProvider;
use Rector\NodeTypeResolver\Node\AttributeKey;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;

final class QuoteConstFetchRector extends AbstractRector
{
    public function __construct(
        private readonly ReflectionProvider $reflectionProvider
    ) {
    }

    public function getRuleDefinition(): RuleDefinition
    {
        return new RuleDefinition('Quote constant not exists', [
            n…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by samsonasik
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants