Skip to content

ReadOnlyPropertyRector not detecting when property passed by reference #8696

@nikolicaleksa

Description

@nikolicaleksa

Bug Report

Subject Details
Rector version last dev-main

Minimal PHP Code Causing Issue

See https://getrector.com/demo/5c08c3f0-8d7f-4b44-93e7-732a963c4df8

<?php

declare(strict_types=1);

namespace Rector\Tests\Php81\Rector\Property\ReadOnlyPropertyRector\Fixture;

use PDO;

class A
{
    public function __construct(
        private int $id
    ) {
    }

    public function prepare(): void
    {
        $dsn = 'mysql:dbname=testdb;host=127.0.0.1';
        $user = 'dbuser';
        $password = 'dbpass';

        $dbh = new PDO($dsn, $user, $password);
        $sth = $dbh->prepare('SELECT * FROM users WHERE id = :id');
        $sth->bindParam('id', $this->id, PDO::PARAM_INT);
        $sth->execute();
    }
}

Expected Behaviour

Property should not be changed as it's passed by reference in the bindParam method call

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