Skip to content
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

ReflectionFunctionAbstract::getTentativeReturnType called on reflection function #4386

Open
web-fu opened this issue Jan 14, 2025 · 5 comments

Comments

@web-fu
Copy link

web-fu commented Jan 14, 2025

From manual page: https://php.net/reflectionfunctionabstract.gettentativereturntype


In the manual page there is an example of the function ::getTentativeReturnType called upon a reflection method.
There is no example with a standard function
Has it sense applying this concept to standard function?

@Girgias
Copy link
Member

Girgias commented Jan 14, 2025

Sorry, I don't quite understand what your question is. Can you please clarify?

@web-fu
Copy link
Author

web-fu commented Jan 14, 2025

In the page there is this example of usage

<?php

$method = new ReflectionMethod(\ArrayAccess::class, 'offsetGet');
var_dump($method->getTentativeReturnType());

This function is defined in ReflectionFunctionAbstract, so it can be called also for "normal" function

<?php

$method = new ReflectionFunction('date');
var_dump($method->getTentativeReturnType());

It is the intended usage?
Are there cases that "normal" function can have tentative return type?

This part of documentation is pretty obscure

@Girgias
Copy link
Member

Girgias commented Jan 27, 2025

Ah, I don't think that normal functions can have a tentative return type, as this is only really an issue for methods of non-final classes. @kocsismate do you know why it was added to FunctionAbstract?

@kocsismate
Copy link
Member

do you know why it was added to FunctionAbstract?

I think it was just an oversight :/

@web-fu
Copy link
Author

web-fu commented Feb 4, 2025

do you know why it was added to FunctionAbstract?

I think it was just an oversight :/

Maybe it's "let's implement in there, just in case"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants