Remove this unused "$ptpformcollection" private field

Template for a good false-positive report, formatted with Markdown:

  • versions used (Cloud)
  • minimal code sample to reproduce (with analysis parameter, and potential instructions to compile).
class PriorAuthorizationViewModel
{
    /**
     * @var PriorAuthorization
     */
    private $authorization;
    /**
     * @var PriorAuthorizationFormPresenter
     */
    private $formPresenter;
    /**
     * @var FormCollection
     */
    private $staysFormCollection;
    /**
     * @var FormCollection
     */
    private $servicesFormCollection;
    /**
     * @var FormCollection
     */
    private $diagnosesFormCollection;
    /**
     * @var FormCollection
     */
    private $ptpFormCollection;
    /**
     * @return FormCollection
     */
    public function getPeerToPeerFormCollection(): FormCollection
    {
        if ($this->ptpFormCollection === null) {
            $peerToPeers = $this->authorization->peerToPeerComments;
            $countPeerToPeers = count($peerToPeers);
            while ($countPeerToPeers < PriorAuthorization::MAX_PEER_TO_PEER_ROWS) {
                $peerToPeers[] = new PriorAuthorizationPeerToPeer();
                $countPeerToPeers ++;
            }
            $this->ptpFormCollection = new FormCollection(
                new FormInitializer(),
                new PeerToPeerFormCollectionValidator($this->authorization),
                PriorAuthorizationPeerToPeer::class,
                $peerToPeers
            );
        }
        return $this->ptpFormCollection;
    }
}

Sonar error looks like he can’t right define the property register.

https://sonarcloud.io/project/issues?id=virtualhealth_virtual-health&issues=AW_JXiFJAswFs5HOhgl9&open=AW_JXiFJAswFs5HOhgl9&pullRequest=16191

Sorry, I don’t understand your problem.

First, it seems that your link to SonarCloud refers to a private project, so I cannot see the issue you refer to.

Secondly, I cannot reproduce the problem with the file you sent. I tried to analyze your file (just adding <?php at the beginning) and I got 4 issues for unused private fields but none of them on $ptpFormCollection.

Sorry for misunderstanding. I left all private properties that are in use below the code.
But it seems the reason of error was in Git. Because when I learn Sonar to do not see the error I could not merge this pull request.
We created the new one and Sonar did not shout about this error anymore.

Thank’s for your help!