Skip to content

Add stub/document ReflectionFunctionAbstract::getClosureCalledClass() #4043

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Nov 13, 2024

Conversation

Girgias
Copy link
Member

@Girgias Girgias commented Nov 11, 2024

No description provided.

@Girgias Girgias mentioned this pull request Nov 11, 2024
@Girgias Girgias force-pushed the reflections-8.4-new branch from e1213d8 to 0d99784 Compare November 11, 2024 16:43
@Girgias Girgias added the help wanted Extra attention is needed label Nov 11, 2024
@cmb69
Copy link
Member

cmb69 commented Nov 11, 2024

Thank you! Maybe switch to draft for now?

@TimWolla
Copy link
Member

Create stub for ReflectionClassConstant::isDeprecated

This is already done in #3895.

@Girgias Girgias force-pushed the reflections-8.4-new branch from 0d99784 to c1e7ac4 Compare November 12, 2024 14:28
@Girgias Girgias force-pushed the reflections-8.4-new branch from c1e7ac4 to bc1fa9a Compare November 12, 2024 15:32
@Girgias Girgias marked this pull request as draft November 12, 2024 15:32
@Girgias Girgias changed the title Add stubs for various Reflection methods Add stub/document ReflectionFunctionAbstract::getClosureCalledClass() Nov 12, 2024
@Girgias
Copy link
Member Author

Girgias commented Nov 12, 2024

@arnaud-lb do you know how ReflectionFunctionAbstract::getClosureCalledClass() works or what it does?

@arnaud-lb
Copy link
Member

@Girgias it's related to https://www.php.net/manual/en/language.oop5.late-static-bindings.php#language.oop5.late-static-bindings.usage, and returns the same class that static:: (and $this::) refers to inside the closure.

@Girgias Girgias marked this pull request as ready for review November 12, 2024 19:48
@Girgias Girgias requested a review from arnaud-lb November 12, 2024 19:48
@Girgias
Copy link
Member Author

Girgias commented Nov 12, 2024

Not sure the example is good, but I kinda struggle with this concept myself

Comment on lines +36 to +38
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('reflectionfunctionabstract.getclosurecalledclass')/db:refsect1[@role='examples']/.)">
<xi:fallback/>
</xi:include>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh this is funky. This would also have been an option for the curl multi docs.

@TimWolla
Copy link
Member

TimWolla commented Nov 12, 2024

Not sure the example is good, but I kinda struggle with this concept myself

The example is much too long. Use this:

<?php

class A {
    public function getClosure() {
        var_dump(self::class, static::class);
        return function () {
            
        };
    }
}

class B extends A {
    
}

$b = new B();
$c = $b->getClosure();
$r = new ReflectionFunction($c);
var_dump($r->getClosureThis() === $b);
var_dump($r->getClosureScopeClass()); // self::class
var_dump($r->getClosureCalledClass()); // static::class

https://3v4l.org/JOphS

Copy link
Member

@arnaud-lb arnaud-lb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@Girgias Girgias merged commit 348789a into php:master Nov 13, 2024
2 checks passed
@Girgias Girgias deleted the reflections-8.4-new branch November 13, 2024 16:58
@TimWolla
Copy link
Member

For the record: LGTM.

@Girgias Girgias added this to the PHP 8.4 milestone Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants