-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[Console] Wrong documentation about section() #9927
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
Comments
I've just tested this same code in a 4.1 app (the Symfony Demo in fact) and it worked for me. Do you see an exception when using this code in your app? |
@javiereguiluz , no, I don't see any exception: the code works perfectly. The problem is that the IDE (PHPStorm) signals errors in the type hinting and the static analysis, too. It works because the consoole object implements both interfaces, but the type hinting is on the So, the method is concretely available, but the IDE (nor the static analysis tools) cannot find it as we type hint on the |
This could indeed lead to problems when writing tests for your commands where you will probably not pass a |
@xabbuh , I've not written tests at the moment: I don't know if it will cause problems... Anyway, I think that no: I will not mock |
Yea, you need an @xabbuh The output used for command testing is a |
Thanks @chalasr for your comments. I'm closing this issue accordingly. Thanks! |
@chalasr , yes, you are right, I know this: this is sufficient for the static analysis. Unfortunately, this forces me to not set a method parameter type hinting, and this causes SymfonyInsight to complain about this as it suggests to add the type hint. Now, I could also simply hide the issue on SymfonyInsights side, but this is a kind of blindness and not a real fix. @javiereguiluz , please, reopen the issue as it is not solved. |
The documentation about Console Sections is wrong.
The documentation uses this example:
The problem is that the
interface
OutputInterface
doesn't have anysection()
method.The
section()
method, instead, is inConsoleOutputInterface
.I don't know why it is a DocComment and not a real method, but anyway, the examples of the documentation are wrong, as the interface to use is
ConsoleOutputInterface
and notOutputInterface
.The problem is that type hinting the
execute()
method with the interfaceConsoleOutputInterface
is not allowed by PHP.I don't know where this should be discussed, but is something that should be addressed as to use the
section()
method someone has to dig in the code to understand where this method is.This is the PR that updated the documentation: #9462
The same "errors" are also in the blog post that announced the new feature: https://symfony.com/blog/new-in-symfony-4-1-advanced-console-output
The text was updated successfully, but these errors were encountered: