Skip to content

False positive "Unused private elements" #363

Open
@liepumartins

Description

@liepumartins
Q A
Bug report? yes
Feature request? no
Library version 1.13.0

Following example, methods are just to mimic the behaviour.

<?php

class Date
{
    private $datetime;

    public static function getAvailable(): DateTime
    {
        $specific = self::getSpecific();
        if ($specific) {
            return $specific->dateTime();
        }
        return new DateTime();
    }

    private static function getSpecific(): ?Date
    {
        return new Date();
    }

    private function dateTime(): DateTime
    {
        return DateTime::createFromFormat('Y-m-d H:i:s', $this->datetime);
    }
}

Insights reports incorrectly, that dateTime() is unused:

[Code] Unused private elements:
  Date.php:21: Class Date contains unused private method dateTime().

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingenhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions