Skip to content

[TASK] Add native type declarations to OutputFormat #875

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
Feb 3, 2025
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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Please also have a look at our
### Changed

- Use more native type declarations and strict mode
(#641, #772, #774, #778, #804, #841, #873)
(#641, #772, #774, #778, #804, #841, #873, #875)
- Add visibility to all class/interface constants (#469)

### Deprecated
Expand Down
16 changes: 4 additions & 12 deletions src/OutputFormat.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,9 @@ class OutputFormat
public function __construct() {}

/**
* @param string $sName
*
* @return string|null
* @return string|int|bool|null
Copy link
Collaborator

Choose a reason for hiding this comment

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

Possibly even array, but we'll see (and that's beyond the scope of this)...

*/
public function get($sName)
public function get(string $sName)
{
$aVarPrefixes = ['a', 's', 'm', 'b', 'f', 'o', 'c', 'i'];
foreach ($aVarPrefixes as $sPrefix) {
Expand Down Expand Up @@ -258,10 +256,7 @@ public function indentWithSpaces(int $numberOfSpaces = 2): self
return $this->setIndentation(\str_repeat(' ', $numberOfSpaces));
}

/**
* @return OutputFormat
*/
public function nextLevel()
public function nextLevel(): self
Copy link
Collaborator

Choose a reason for hiding this comment

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

IIUC, we are only PHPDoccing @return $this fluent interface when the method returns itself, as opposed to when it returns some relative of the same genus or class.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, correct.

{
if ($this->oNextLevelFormat === null) {
$this->oNextLevelFormat = clone $this;
Expand All @@ -276,10 +271,7 @@ public function beLenient(): void
$this->bIgnoreExceptions = true;
}

/**
* @return OutputFormatter
*/
public function getFormatter()
public function getFormatter(): OutputFormatter
{
if ($this->oFormatter === null) {
$this->oFormatter = new OutputFormatter($this);
Expand Down