Skip to content

Phan does not understand Closure::bind(). #5260

@SerheyDolgushev

Description

@SerheyDolgushev

Phan version: v6 dev
PHP version: 8.4
php-ast version: 1.1.3

Description:

<?php

class Item {
    private const DEFAULT_VALUE = 100;
}

$getDefaultValue = Closure::bind(
    static function () {
        return Item::DEFAULT_VALUE;
    },
    null,
    Item::class
);

var_dump($getDefaultValue());

Outputs

int(100)

But phan reports:

input:9: PhanAccessClassConstantPrivate Cannot access private class constant \Item::DEFAULT_VALUE defined at input:4

So seems like Closure::bind is not understood.

Demo link: https://phan.github.io/demo/?c=DwfgDgFmBQ0MYBsCGBnFACAkgFwKYFt0BvadM9MAJwEsA3JPdOAewDsVt0ARAUQDEAggFUAMgBUA%2BgDUBIoT3QBedAEYADGoDc0AL6wAJAHNc2LrgBmSAK4JsUpAiu4l6AMIJmKK5VwAuXwBG1KwAJgAUpOQcDNRw6OZWrHDY1GzoYQCUxJHk5D7Y3qxYePj%2BvIKikjJyPNq5OgA0OeisNghNuTgE-oioKNAZ2tD0lBIhVvhgYUYmZpY2dg5OmYNAA&php=84&phan=v6-dev&ast=1.1.3&plugins=310592423266

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementThis improves the quality of Phan's analysis of a codebase

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions