Skip to content

Commit 52553fb

Browse files
committed
Fix PHPStan errors
1 parent c925914 commit 52553fb

File tree

2 files changed

+13
-27
lines changed

2 files changed

+13
-27
lines changed

src/StaticPHP/Util/FileSystem.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -370,17 +370,6 @@ public static function resetDir(string $dir_name): void
370370
self::createDir($dir_name);
371371
}
372372

373-
/**
374-
* Add source extraction hook
375-
*
376-
* @param string $name Source name
377-
* @param callable $callback Callback function
378-
*/
379-
public static function addSourceExtractHook(string $name, callable $callback): void
380-
{
381-
self::$_extract_hook[$name][] = $callback;
382-
}
383-
384373
/**
385374
* Check if path is relative
386375
*

src/StaticPHP/Util/SPCConfigUtil.php

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
use StaticPHP\Config\PackageConfig;
88
use StaticPHP\Exception\WrongUsageException;
9+
use StaticPHP\Package\LibraryPackage;
10+
use StaticPHP\Package\PhpExtensionPackage;
911
use StaticPHP\Runtime\SystemTarget;
1012

1113
class SPCConfigUtil
@@ -99,42 +101,37 @@ public function config(array $packages = [], bool $include_suggests = false): ar
99101
* [Helper function]
100102
* Get configuration for a specific extension(s) dependencies.
101103
*
102-
* @param Extension|Extension[] $extension Extension instance or list
103-
* @param bool $include_suggest_ext Whether to include suggested extensions
104-
* @param bool $include_suggest_lib Whether to include suggested libraries
104+
* @param array|PhpExtensionPackage $extension_packages Extension instance or list
105105
* @return array{
106106
* cflags: string,
107107
* ldflags: string,
108108
* libs: string
109109
* }
110110
*/
111-
public function getExtensionConfig(array|Extension $extension, bool $include_suggest_ext = false, bool $include_suggest_lib = false): array
111+
public function getExtensionConfig(array|PhpExtensionPackage $extension_packages, bool $include_suggests = false): array
112112
{
113-
if (!is_array($extension)) {
114-
$extension = [$extension];
113+
if (!is_array($extension_packages)) {
114+
$extension_packages = [$extension_packages];
115115
}
116-
$libs = array_map(fn ($y) => $y->getName(), array_merge(...array_map(fn ($x) => $x->getLibraryDependencies(true), $extension)));
117116
return $this->config(
118-
extensions: array_map(fn ($x) => $x->getName(), $extension),
119-
libraries: $libs,
120-
include_suggest_ext: $include_suggest_ext ?: $this->builder?->getOption('with-suggested-exts') ?? false,
121-
include_suggest_lib: $include_suggest_lib ?: $this->builder?->getOption('with-suggested-libs') ?? false,
117+
packages: array_map(fn ($y) => $y->getName(), $extension_packages),
118+
include_suggests: $include_suggests,
122119
);
123120
}
124121

125122
/**
126123
* [Helper function]
127124
* Get configuration for a specific library(s) dependencies.
128125
*
129-
* @param LibraryBase|LibraryBase[] $lib Library instance or list
130-
* @param bool $include_suggest_lib Whether to include suggested libraries
126+
* @param array|LibraryPackage $lib Library instance or list
127+
* @param bool $include_suggests Whether to include suggested libraries
131128
* @return array{
132129
* cflags: string,
133130
* ldflags: string,
134131
* libs: string
135132
* }
136133
*/
137-
public function getLibraryConfig(array|LibraryBase $lib, bool $include_suggest_lib = false): array
134+
public function getLibraryConfig(array|LibraryPackage $lib, bool $include_suggests = false): array
138135
{
139136
if (!is_array($lib)) {
140137
$lib = [$lib];
@@ -144,8 +141,8 @@ public function getLibraryConfig(array|LibraryBase $lib, bool $include_suggest_l
144141
$save_libs_only_deps = $this->libs_only_deps;
145142
$this->libs_only_deps = true;
146143
$ret = $this->config(
147-
libraries: array_map(fn ($x) => $x->getName(), $lib),
148-
include_suggest_lib: $include_suggest_lib ?: $this->builder?->getOption('with-suggested-libs') ?? false,
144+
packages: array_map(fn ($y) => $y->getName(), $lib),
145+
include_suggests: $include_suggests,
149146
);
150147
$this->no_php = $save_no_php;
151148
$this->libs_only_deps = $save_libs_only_deps;

0 commit comments

Comments
 (0)