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

Fix psalm issues #18

Merged
merged 1 commit into from
Mar 15, 2024
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
5 changes: 3 additions & 2 deletions src/Console/Helper/ConfiguredLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ public static function createFromConfig(?string $file, callable $configurator =
{
$loader = new StreamWrapperLoader();

if ($file) {
if ($file !== null) {
invariant($file !== '', 'File must not be empty.');
invariant(Filesystem\exists($file), 'File "%s" does not exist.', $file);
invariant(Filesystem\is_file($file), 'File "%s" is not a file.', $file);
invariant(Filesystem\is_readable($file), 'File "%s" is not readable.', $file);
Expand All @@ -34,6 +35,6 @@ public static function createFromConfig(?string $file, callable $configurator =
$loader = instance_of(WsdlLoader::class)->assert($included);
}

return $configurator ? $configurator($loader) : $loader;
return $configurator !== null ? $configurator($loader) : $loader;
}
}
2 changes: 1 addition & 1 deletion src/Xml/Configurator/FlattenWsdlImports.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ private function importWsdlImportElement(DOMElement $import): void
);

$result = $this->context->import($location);
if (!$result) {
if ($result === null || $result === '') {
remove($import);
return;
}
Expand Down
8 changes: 1 addition & 7 deletions src/Xml/Configurator/FlattenXsdImports.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,6 @@ private function importSchema(DOMElement $import): ?DOMElement
return null;
}

// Normally an import has an owner document, since it is coming from xpath on an existing document
// However, static analysis does not know about this.
if (!$import->ownerDocument) {
return null;
}

// Find the schema that wants to import the new schema:
$doc = Document::fromUnsafeDocument($import->ownerDocument);
$xpath = $doc->xpath(new WsdlPreset($doc));
Expand Down Expand Up @@ -158,7 +152,7 @@ private function loadSchema(string $location): ?DOMElement
$path = IncludePathBuilder::build($location, $this->currentLocation);
$result = $this->context->import($path);

if (!$result) {
if ($result === null || $result === '') {
return null;
}

Expand Down
5 changes: 4 additions & 1 deletion src/Xml/Validator/SchemaSyntaxValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ final class SchemaSyntaxValidator implements Validator
{
private string $xsd;

/**
* @param non-empty-string|null $xsd
*/
public function __construct(?string $xsd = null)
{
$this->xsd = $xsd ?: dirname(__DIR__, 3).'/xsd/XMLSchema.xsd';
$this->xsd = $xsd ?? dirname(__DIR__, 3).'/xsd/XMLSchema.xsd';
}

/**
Expand Down
5 changes: 4 additions & 1 deletion src/Xml/Validator/WsdlSyntaxValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ final class WsdlSyntaxValidator implements Validator
{
private string $xsd;

/**
* @param non-empty-string|null $xsd
*/
public function __construct(?string $xsd = null)
{
$this->xsd = $xsd ?: dirname(__DIR__, 3).'/xsd/wsdl.xsd';
$this->xsd = $xsd ?? dirname(__DIR__, 3).'/xsd/wsdl.xsd';
}

/**
Expand Down