Skip to content

Conversation

rodrigoprimo
Copy link
Collaborator

This PR moves the code related to checking color and formatting the help text to a new helper class. This way, it can be reused when the new DocCodeExamples script is introduced.

Tests were added for the new HelpTextFormatter::format() method.

This commit was originally added to #185, but after discussing it with @jrfnl, I'm opening a separate PR for it.

This commit moves the code related to checking color and formatting the help text to a new helper class. This way it can be reused when the new DocCodeExamples script is introduced. Tests were added for the new HelpTextFormatter::format() method.
*
* @return bool
*/
public static function isColorSupported()
Copy link
Member

@jrfnl jrfnl Jun 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this method belongs in the HelpTextFormatter class as this is also used to determine whether the non-help output of the CLI command(s) should be colorized or not...

I have a feeling this should be in a separate class, which maybe should also contain some "colorize" helper methods.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we discussed in a call, I will update this PR to remove isColorSupported() and then look into potentially creating a separate PR to add https://github.com/php-parallel-lint/PHP-Console-Color/ as a dependency and use it in this package.

Partially reverts the previous commit to keep isColorSupported() on the Config class as discussed during the PR review.
@rodrigoprimo rodrigoprimo force-pushed the refactor-feature-complete-config-class branch from 9b72325 to 96a0c87 Compare July 4, 2025 20:05
@jrfnl jrfnl changed the title Refactor FeatureComplete code for color support and formatting help text Refactor FeatureComplete code for formatting help text Jul 7, 2025
Copy link
Member

@jrfnl jrfnl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for setting this up @rodrigoprimo !

A couple of questions about the "design":

  1. Is the PHPCSDevTools\Scripts\FeatureComplete\Config::getHelp() method still necessary ?
  2. Any particular reason why the HelpTextFormatter is a static class and not an instantiatable one ?
  3. As the logic for the help display has now moved to the HelpTextFormatter, I wonder how much value the tests in the Tests\FeatureComplete\GetHelpTest now have and whether the @covers for that test is still correct/useful.
/**
* Format help text from a structured array of options.
*
* @param array<string, array<array<string, string>>> $helpTexts The help texts to format.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As the formatter is now in a separate class, I think the expected format for the $helpTexts array needs to be documented in more detail.

The class docblock might even be a better place than this function docblock.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment