Skip to content
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

Upgrade phpstan #194

Merged
merged 4 commits into from
Dec 3, 2022
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
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@
"require-dev": {
"doctrine/coding-standard": "^8.0",
"gajus/dindent": "^2.0.2",
"phpstan/phpstan": "^0.12",
"phpstan/phpstan-deprecation-rules": "^0.12",
"phpstan/phpstan-phpunit": "^0.12",
"phpstan/phpstan-strict-rules": "^0.12",
"phpstan/phpstan": "^1.9",
"phpstan/phpstan-deprecation-rules": "^1.0",
"phpstan/phpstan-phpunit": "^1.2",
"phpstan/phpstan-strict-rules": "^1.4",
"phpunit/phpunit": "^7.5 || ^8.0 || ^9.0",
"symfony/css-selector": "4.4 || ^5.2 || ^6.0",
"symfony/dom-crawler": "4.4 || ^5.2 || ^6.0"
Expand Down
13 changes: 0 additions & 13 deletions lib/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use Doctrine\RST\Meta\CachedMetasLoader;
use Doctrine\RST\Meta\Metas;
use InvalidArgumentException;
use LogicException;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Finder\Finder;

Expand Down Expand Up @@ -47,9 +46,6 @@ final class Builder
/** @var Documents */
private $documents;

/** @var ParseQueue|null */
private $parseQueue;

/** @var Copier */
private $copier;

Expand Down Expand Up @@ -132,15 +128,6 @@ public function getMetas(): Metas
return $this->metas;
}

public function getParseQueue(): ParseQueue
{
if ($this->parseQueue === null) {
throw new LogicException('The ParseQueue is not set until after the build is complete');
}

return $this->parseQueue;
}

Comment on lines -135 to -143
Copy link
Member

Choose a reason for hiding this comment

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

Removing a public method from a patch version? What's the connection to PHPStan?

Copy link
Member Author

@greg0ire greg0ire Dec 1, 2022

Choose a reason for hiding this comment

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

parseQueue is never ever written to, the class is final and that property private, and that method is unused. It should have been removed in 655bd01

public function build(
string $directory,
string $targetDirectory = 'output'
Expand Down
1 change: 0 additions & 1 deletion lib/Parser/TableParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ public function parseTableSeparatorLine(string $line): ?TableSeparatorLineConfig
$parts = [];
$currentPartStart = null;

$i = 0;
for ($i = 0; $i < strlen($line); $i++) {
// we found the "line char": "-" or "="
if ($line[$i] === $chars[0]) {
Expand Down
4 changes: 2 additions & 2 deletions lib/Span/SpanProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ function (array $match): string {
private function replaceTitleLetters(string $span): string
{
foreach ($this->environment->getTitleLetters() as $level => $letter) {
$span = (string) preg_replace_callback('/\#\\' . $letter . '/mUsi', function (array $match) use ($level): int {
return $this->environment->getNumber($level);
$span = (string) preg_replace_callback('/\#\\' . $letter . '/mUsi', function (array $match) use ($level): string {
return (string) $this->environment->getNumber($level);
}, $span);
}

Expand Down
2 changes: 2 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ parameters:
paths:
- lib
- tests
polluteScopeWithLoopInitialAssignments: true
reportMaybesInPropertyPhpDocTypes: false

ignoreErrors:
- '#Variable method call on Doctrine\\RST\\Nodes\\DocumentNode\.#'