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

Simplify usage of FileParserFactory #408

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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: 5 additions & 3 deletions src/Analyzer/FileParserFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@

class FileParserFactory
{
public static function createFileParser(TargetPhpVersion $targetPhpVersion, bool $parseCustomAnnotations = true): FileParser
{
public static function createFileParser(
TargetPhpVersion $targetPhpVersion = null,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
TargetPhpVersion $targetPhpVersion = null,
?TargetPhpVersion $targetPhpVersion = null,

I assume this should be explicitly marked as a nullable type instead of depending on implicit PHP behaviour.

bool $parseCustomAnnotations = true
): FileParser {
return new FileParser(
new NodeTraverser(),
new FileVisitor(new ClassDescriptionBuilder()),
new NameResolver(null, ['parseCustomAnnotations' => $parseCustomAnnotations]),
$targetPhpVersion
$targetPhpVersion ?? TargetPhpVersion::create()
);
}
}
2 changes: 1 addition & 1 deletion src/CLI/TargetPhpVersion.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ private function __construct(?string $version)
$this->version = $version;
}

public static function create(?string $version): self
public static function create(string $version = null): self
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
public static function create(string $version = null): self
public static function create(?string $version = null): self

as above

{
if (null === $version) {
return new self(phpversion());
Expand Down