-
Notifications
You must be signed in to change notification settings - Fork 4
Php diff 60 #61
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
Php diff 60 #61
Conversation
@@ -49,7 +49,7 @@ public function render(): string | |||
if (!isset($this->options['cliColor'])) { | |||
return $this->output(); | |||
} | |||
if (isset($this->options['cliColor']) && $this->options['cliColor'] == 'simple') { | |||
if (isset($this->options['cliColor']) && $this->options['cliColor'] === true) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think if ($this->options['cliColor']) {
is sufficient.
The variable should be set already by MainRendererAbstract and acting on any truthy value is ok.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed that
@@ -63,7 +63,7 @@ public function render(): string | |||
*/ | |||
private function colorizeString($string, $color = ''): string | |||
{ | |||
if (isset($this->options['cliColor']) && $this->options['cliColor'] == 'simple') { | |||
if (isset($this->options['cliColor']) && $this->options['cliColor'] === true) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think if ($this->options['cliColor']) {
is sufficient.
The variable should be set already by MainRendererAbstract and acting on any truthy value is ok.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've made some inline comments.
@@ -49,10 +49,7 @@ public function render(): string | |||
if (!isset($this->options['cliColor'])) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$this->options['cliColor']
should be set by MainRendererAbstract.
Therefor this line will always evaluate to true.
Please also check remaining code which uses this variable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not always true. I check that via the example/cli.php script.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's why I'm saying 'should' while it's not. 😉
When extending MainRendererAbstract
, the options for a sub renderer are supposed to be a merge of:
MainRendererAbstract::$mainOptions
(Default renderer options)SubRenderer::$subOptions
(Default child renderer options)- The array parameter of
SubRenderer::__construct()
(custom options).
SubRenderer::__construct()
should look something like:
public function __construct(array $options = [])
{
parent::__construct();
$this->setOptions($this->subOptions); // Override/Add options MainRenderer with defaults of SubRenderer.
$this->setOptions($options); // Override/Add options MainRenderer with customs.
}
Method setOptions
, inherited from MainRendererAbstract
, will take care of the merges.
Currently UnifiedCli::__construct()
is different:
public function __construct(array $options = [])
{
parent::__construct($options);
$this->colors = new CliColors();
$this->options = $options;
}
You can look at InlineCli.php
as an example on how to apply options.
Also it's described at https://github.com/JBlond/php-diff/wiki/b)-Parameters-and-Options#parameters-1
and https://github.com/JBlond/php-diff/wiki/b)-Parameters-and-Options#text-unified-cli-renderer
Please also check remaining code which uses |
I did.
Yes
Nope, in doubt the colorizeString function returns the string as is. |
I'm not sure what 'In doubt' means. Currently:
Expected:
Having |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's all ok now.
Maybe we should user ask/warn vendeeglobe there's a PR merge comming up and ask for his feedback.
@vendeeglobe please give feedback to this PR. |
Looks good to me. I'll pull and test it after it's merged into master. |
No description provided.