Analyze constructor assignments to determine types of class variables more accurately #15

Closed
opened 1 year ago by hugo · 1 comments
hugo commented 1 year ago
Owner

Example case that currently isn't handled optimally ($this->deliveries doesn't get assigned the type ArrayCollection):

class Invoice
{
    /**
     * @var Delivery[]
     */
    private $deliveries;

    public function __construct(iterable $deliveries) {
        $this->deliveries = new ArrayCollection();

        foreach ($deliveries as $delivery) {
            $this->deliveries[] = $delivery;
        }
    }
}
Example case that currently isn't handled optimally ($this->deliveries doesn't get assigned the type ArrayCollection): ```php class Invoice { /** * @var Delivery[] */ private $deliveries; public function __construct(iterable $deliveries) { $this->deliveries = new ArrayCollection(); foreach ($deliveries as $delivery) { $this->deliveries[] = $delivery; } } } ```
hugo added this to the Ready for fieldtesting milestone 10 months ago
hugo commented 9 months ago
Poster
Owner

Implemented for currently edited buffers in 68c826243c .

Implemented for currently edited buffers in https://git.snorba.art/hugo/phpinspect.el/commit/68c826243c1c358a24e82df1fef148671b6c40fe .
hugo closed this issue 9 months ago
Sign in to join this conversation.
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: hugo/phpinspect.el#15
Loading…
There is no content yet.