Skip to content

[Console] Inherit phpdoc from OutputFormatterInterface #22342

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

Merged
merged 1 commit into from
Apr 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 6 additions & 27 deletions src/Symfony/Component/Console/Formatter/OutputFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,56 +79,39 @@ public function __construct($decorated = false, array $styles = array())
}

/**
* Sets the decorated flag.
*
* @param bool $decorated Whether to decorate the messages or not
* {@inheritdoc}
*/
public function setDecorated($decorated)
{
$this->decorated = (bool) $decorated;
}

/**
* Gets the decorated flag.
*
* @return bool true if the output will decorate messages, false otherwise
* {@inheritdoc}
*/
public function isDecorated()
{
return $this->decorated;
}

/**
* Sets a new style.
*
* @param string $name The style name
* @param OutputFormatterStyleInterface $style The style instance
* {@inheritdoc}
*/
public function setStyle($name, OutputFormatterStyleInterface $style)
{
$this->styles[strtolower($name)] = $style;
}

/**
* Checks if output formatter has style with specified name.
*
* @param string $name
*
* @return bool
* {@inheritdoc}
*/
public function hasStyle($name)
{
return isset($this->styles[strtolower($name)]);
}

/**
* Gets style options from style with specified name.
*
* @param string $name
*
* @return OutputFormatterStyleInterface
*
* @throws \InvalidArgumentException When style isn't defined
Copy link
Contributor Author

Choose a reason for hiding this comment

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

let me know if this need to be added to the interface (see also #22231).

Copy link
Member

@chalasr chalasr Apr 7, 2017

Choose a reason for hiding this comment

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

I would say it should be. unrelated but this should use the console domain exception instead

Copy link
Contributor Author

Choose a reason for hiding this comment

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

personally i never add logic ones to the interface.. only concrete runtime scenarios that all implementations must adhere to (SomethingIsWrongException). But this is a thin line in PHP so i dont mind, hence i asked :)

Copy link
Member

Choose a reason for hiding this comment

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

let's see what others think then :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

to clarify.. i always follow; logic=programmers fault, runtime=program fault

Copy link
Contributor Author

Choose a reason for hiding this comment

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

given the actual implementation is a program fault.. i think im gonna add it. I would have used StyleNotFoundException extends \RuntimeException. But that's semantics.. who cares :P

* {@inheritdoc}
*/
public function getStyle($name)
{
Expand All @@ -140,11 +123,7 @@ public function getStyle($name)
}

/**
* Formats a message according to the given styles.
*
* @param string $message The message to style
*
* @return string The styled message
* {@inheritdoc}
*/
public function format($message)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ public function hasStyle($name);
* @param string $name
*
* @return OutputFormatterStyleInterface
*
* @throws \InvalidArgumentException When style isn't defined
*/
public function getStyle($name);

Expand Down