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

Don't allow negativ str_repeats #37

Merged
merged 1 commit into from
Aug 3, 2023

Conversation

mpociot
Copy link
Contributor

@mpociot mpociot commented Aug 3, 2023

As soon as you manually add a newLine output in combination with Prompts, the command throws an exception.

For example, this example command currently breaks with Prompts.

<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use function Laravel\Prompts\note;

class TestCommand extends Command
{
    protected $signature = 'app:test-command';

    public function handle()
    {
        note("1");
        note("2");
        $this->output->newLine();
        note("3");
    }
}

In this case, the calculated value for str_repeat becomes negative, which is not allowed as per the PHP docs.

This PR fixes this by only using the values 0 or greater.

@jessarcher jessarcher merged commit bb48119 into laravel:main Aug 3, 2023
4 checks passed
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

Successfully merging this pull request may close these issues.

2 participants