Skip to content

[SOLID] Rector\SOLID\Rector\ClassConst\PrivatizeLocalClassConstantRector: false positive (turns constant to private that is publicly used) #1634

@gnutix

Description

@gnutix

Adding the solid level gives me some false positive on constants :

1) src/SomeNamespace/ContentCacheManager.php

    ---------- begin diff ----------
--- Original
+++ New
@@ -23,7 +23,7 @@
     /**
      * @var string
      */
-    public const CMS_CACHE_PATH = 'cms';
+    private const CMS_CACHE_PATH = 'cms';

     /**
      * @var string
    ----------- end diff -----------

Applied rectors:

 * Rector\SOLID\Rector\ClassConst\PrivatizeLocalClassConstantRector
 * Rector\CodingStyle\Rector\Namespace_\ImportFullyQualifiedNamesRector

Even though it is used in others classes, for example :

use SomeNamespace\ContentCacheManager;

final class LanguageFinder
{
    /**
     * @var string
     */
    public const CACHE_TAG_LANGS = ContentCacheManager::CMS_CACHE_PATH . '_langs';

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions