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

newLine() does not exist in console app #1074

Open
lifewcody opened this issue Feb 10, 2024 · 3 comments
Open

newLine() does not exist in console app #1074

lifewcody opened this issue Feb 10, 2024 · 3 comments
Assignees
Labels
Milestone

Comments

@lifewcody
Copy link

Description

protected function alert(string $string): void

in HelpersTrait.php calls the following:

$this->newLine();

Which calls $this->output->newLine($count);

Which returns:

[Error]
Call to undefined method Symfony\Component\Console\Output\ConsoleOutput::newLine()
in vendor/spiral/framework/src/Console/src/Traits/HelpersTrait.php:197

How To Reproduce

In the console application, set to production/prod and call $this->alert(),

Additional Info

Q A
Framework Version 3.11
PHP version 8.3.1
Operating system Linux
@msmakouz
Copy link
Member

@lifewcody Hi, I installed a clean installation of spiral/app (in the installer I selected the console application) and added the call to the example console command:

namespace App\Endpoint\Console;

use Spiral\Console\Attribute\AsCommand;
use Spiral\Console\Command;

#[AsCommand(name: 'do-nothing', description: 'The command does nothing.')]
final class DoNothing extends Command
{
    public function perform(): int
    {
        $this->alert('test');  // <----

        return self::SUCCESS;
    }
}

And it worked correctly for me. Screenshot:

22

In the base class, in the execute method on the 87 line, the prepareOutput method is called, which for $this->output creates a SymfonyStyle object that has the desired method:
https://github.com/spiral/framework/blob/3.11.1/src/Console/src/Command.php#L87

Did you make any changes in your console command that might break this? Can you provide an example code for the console command that causes the error?

@lifewcody
Copy link
Author

I should have been more specific; It's only when calling confirmToProceed()

But then I'm not sure why alert works but not in confirmToProceed()

if (!$confirmation->confirmToProceed()) {
            return self::FAILURE;
        }

@butschster butschster added this to the 3.12 milestone Feb 19, 2024
@butschster
Copy link
Member

Hi @lifewcody, thank you for the bug report! Yes, I was able to reproduce the problem. We will fix it soon.

butschster added a commit that referenced this issue Feb 20, 2024
This was referenced Feb 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: In Progress
Development

No branches or pull requests

3 participants