Skip to content

Commit

Permalink
PHPStan (found a bug)
Browse files Browse the repository at this point in the history
  • Loading branch information
Luc45 committed Mar 13, 2024
1 parent 48b9510 commit e687380
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public function categorize_extensions( array $plugins, array $themes ): array {
}
}

if ( ! isset( $ext->handler ) ) {
if ( empty( $ext->handler ) ) {
if ( is_numeric( $extension_id ) ) {
// Woo.com product ID.
$ext->handler = QITHandler::class;
Expand Down
1 change: 1 addition & 0 deletions src/src/Environment/ExtensionDownload/ExtensionZip.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class ExtensionZip {
/** @var Docker */
private $docker;

/** @var array<string, string> Keys are paths, values are checksum hashes. We use this to make sure we don't validate the same file on this request. */
private $already_validated = [];

public function __construct( OutputInterface $output, Docker $docker ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function maybe_download_extensions( array $extensions, string $cache_dir
$this->find_type_in_dir( $e );
} elseif ( is_file( $e->extension_identifier ) ) {
// Must be a ".zip" file.
if ( ! substr( $e->extension_identifier, - 4 ) === '.zip' ) {
if ( substr( $e->extension_identifier, - 4 ) !== '.zip' ) {
throw new \RuntimeException( sprintf( 'When passing a local path, it must be either a directory or a zip file. Found: %s', $e->extension_identifier ) );
}
$this->find_type_in_zip( $e );
Expand All @@ -38,7 +38,7 @@ public function maybe_download_extensions( array $extensions, string $cache_dir
}

// Basic validation, but should never happen.
if ( empty( $e->type ) ) {
if ( empty( $e->type ) ) { // @phpstan-ignore-line
throw new \RuntimeException( 'Could not determine the type of the extension.' );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function maybe_download_extensions( array $extensions, string $cache_dir
}
}

if ( ! isset( $e->download_url ) ) {
if ( empty( $e->download_url ) ) {
throw new \RuntimeException( 'No download URL found for ' . $e->extension_identifier );
}

Expand Down

0 comments on commit e687380

Please sign in to comment.