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

Bug: The CLI::color cannot create multicolored strings if ordering of strings is reversed #3173

Closed
paulbalandan opened this issue Jun 26, 2020 · 0 comments
Labels
bug Verified issues on the current code behavior or pull requests that will fix them

Comments

@paulbalandan
Copy link
Member

Describe the bug
The documentation says that you can create multicolored strings by embedding a CLI::color within a CLI::color. However, when you changes the position of the embedded CLI::color, some of the text becomes uncolored.

CodeIgniter 4 version
dev-develop, possibly all releases too

Affected module(s)
CLI library

Expected behavior, and steps to reproduce if appropriate

  1. Create a simple PHP script
require __DIR__ . '/vendor/autoload.php';

define('ENVIRONMENT', 'development');  // This is needed for the new function `hasColorSupport`

use CodeIgniter\CLI\CLI;

echo CLI::color('yellow ' . CLI::color('green', 'green'), 'yellow');
  1. This script will give the expected output:
    image

  2. Reversing however the position will give a different output:

require __DIR__ . '/vendor/autoload.php';

define('ENVIRONMENT', 'development');  // This is needed for the new function `hasColorSupport`

use CodeIgniter\CLI\CLI;

echo CLI::color(CLI::color('green', 'green') . ' yellow', 'yellow');
  1. This will give instead:
    image

  2. Testing when the embedded CLI::color is in the middle of two strings:

require __DIR__ . '/vendor/autoload.php';

define('ENVIRONMENT', 'development');  // This is needed for the new function `hasColorSupport`

use CodeIgniter\CLI\CLI;

echo CLI::color('yellow ' . CLI::color('green', 'green') . ' yellow', 'yellow');

will give:
image

  1. It is expected that all scripts will give multi colored strings.

Context

  • OS: Win10 2004
  • Web server: CLI
  • PHP version: PHP 7.4.5
@paulbalandan paulbalandan added the bug Verified issues on the current code behavior or pull requests that will fix them label Jun 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified issues on the current code behavior or pull requests that will fix them
Projects
None yet
Development

No branches or pull requests

1 participant