PHPStan: Fix/phpstan styling#236
Merged
dantleech merged 9 commits intophp-tui:mainfrom May 4, 2026
Merged
Conversation
0e5ca61 to
55fd3ee
Compare
dantleech
reviewed
Apr 29, 2026
| private Display $display, | ||
| private ActivePage $activePage, | ||
| private array $pages, | ||
| private array $pages, |
Collaborator
There was a problem hiding this comment.
I assume that this wasn't CS fixer? I'd prefer not to have whitespace alignment...
dantleech
reviewed
Apr 29, 2026
| private readonly array $lines, | ||
| private readonly int $maxLineWidth, | ||
| private int $horizontalOffset = 0, | ||
| private readonly int $horizontalOffset = 0, |
Collaborator
There was a problem hiding this comment.
could simply make the class read only at this point
Collaborator
|
thanks, looks good. I'm confused about the whitepace parameter alignment though. |
Contributor
Author
|
would you consider using a custom Cs Fixer role for whitespace alignment in the costrustors? something like that // src/CsFixer/NoAlignedPropertiesFixer.php
<?php
namespace App\CsFixer;
use PhpCsFixer\AbstractFixer;
use PhpCsFixer\FixerDefinition\CodeSample;
use PhpCsFixer\FixerDefinition\FixerDefinition;
use PhpCsFixer\FixerDefinition\FixerDefinitionInterface;
use PhpCsFixer\Tokenizer\Tokens;
final class NoAlignedPropertiesFixer extends AbstractFixer
{
public function getName(): string
{
return 'App/no_aligned_properties';
}
public function getDefinition(): FixerDefinitionInterface
{
return new FixerDefinition(
'Removes whitespace alignment between type and variable name.',
[
new CodeSample("<?php\nfunction __construct(\n private Terminal \$terminal,\n private Display \$display,\n) {}\n"),
]
);
}
public function isCandidate(Tokens $tokens): bool
{
return true;
}
protected function applyFix(\SplFileInfo $file, Tokens $tokens): void
{
foreach ($tokens as $index => $token) {
if (!$token->isGivenKind(T_VARIABLE)) {
continue;
}
$prevIndex = $tokens->getPrevNonWhitespace($index);
if ($prevIndex === null) {
continue;
}
$prevToken = $tokens[$prevIndex];
if (!$prevToken->isGivenKind([T_STRING, T_ARRAY, T_CALLABLE, T_NULL, T_NS_SEPARATOR])) {
continue;
}
$whitespaceIndex = $prevIndex + 1;
if ($whitespaceIndex === $index) {
continue;
}
$whitespaceToken = $tokens[$whitespaceIndex];
if (!$whitespaceToken->isWhitespace()) {
continue;
}
$content = $whitespaceToken->getContent();
if (!str_contains($content, "\n") && strlen($content) > 1) {
$tokens[$whitespaceIndex] = new \PhpCsFixer\Tokenizer\Token([T_WHITESPACE, ' ']);
}
}
}
} |
Collaborator
off there were an existing fixer then why not, but i don't think it's worth adding a custom rule |
Collaborator
|
Probably 8.1 needs removing from the matrix? |
Contributor
Author
|
Hi @dantleech I just removed 8.1 from CI |
dantleech
approved these changes
May 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
The phpstan-baseline.neon file had accumulated 142 ignored errors across the codebase, this branch resolves every entry so that PHPStan runs cleanly with no exceptions,
going forward.
While in there, the branch also applies a one-shot Rector pass and a PHP-CS-Fixer pass to bring the touched files (and a handful of adjacent ones) up to the project's current coding standards.
What changed
BdfFont/BdfParser, Docgen, HalfBlockGrid, PhpTermBackend.
Test plan
composer rectorNote for the maintainer
Making php bumb, from 8.1 to 8.2 on
composer.json