Skip to content

Commit 17d5917

Browse files
committed
Fix IDE warnings
1 parent e5886d1 commit 17d5917

File tree

13 files changed

+29
-15
lines changed

13 files changed

+29
-15
lines changed

src/Base/Abstracts/Package.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class Package extends CompletePackage
4545
public function getSimpleName()
4646
{
4747
$full_name = $this->getName();
48-
48+
$m = null;
4949
if (!preg_match(',(.+)/(.+),', $full_name, $m)) {
5050
return $full_name;
5151
}
@@ -56,7 +56,7 @@ public function getSimpleName()
5656
public function getVendorName()
5757
{
5858
$full_name = $this->getName();
59-
59+
$m = null;
6060
if (!preg_match(',(.+)/(.+),', $full_name, $m)) {
6161
return;
6262
}

src/Engine/PHP.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ private function getFromConstants()
270270

271271
$cmd = $this->phpCliEscaped . ' -r ' . '"' . str_replace("\n", '', $script) . '"';
272272

273+
$info = null;
273274
exec($cmd, $info);
274275
if (count($info) !== 7) {
275276
throw new Exception('Could not determine info from the PHP binary');
@@ -286,6 +287,7 @@ private function getFromConstants()
286287
private function getFromPhpInfo()
287288
{
288289
$cmd = $this->phpCliEscaped . ' -i';
290+
$info = null;
289291
exec($cmd, $info);
290292

291293
if (!is_array($info)) {

src/Package/Convey/Command/Git.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ public function getType()
6161

6262
protected function prepare()
6363
{
64+
$matches = null;
6465
if (Type::determineGit($this->path, $matches) < 1) {
6566
throw new Exception('Not valid git URI');
6667
}

src/Package/Convey/Command/Pickle.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ protected function fetchPackageJson()
7070
{
7171
$extensionJson = @file_get_contents('http://localhost:8080/json/' . $this->name . '.json');
7272
if (!$extensionJson) {
73+
/** @var array $http_response_header */
7374
$status = $http_response_header[0] ?? '';
7475
if (strpos($status, '404') !== false) {
7576
throw new Exception("cannot find {$this->name}");
@@ -85,6 +86,7 @@ protected function fetchPackageJson()
8586

8687
protected function prepare()
8788
{
89+
$matches = null;
8890
if (Type::determinePickle($this->path, $matches) < 1) {
8991
throw new Exception('Not a pickle git URI');
9092
}
@@ -105,7 +107,7 @@ protected function prepare()
105107
$versionConstraints = $versionParser->parseConstraints($matches['version']);
106108

107109
/* versions are sorted decreasing */
108-
foreach ($extension['packages'][$this->name] as $version => $release) {
110+
foreach (array_keys($extension['packages'][$this->name]) as $version) {
109111
$constraint = new VersionConstraint('=', $versionParser->normalize($version));
110112
if ($versionConstraints->matches($constraint)) {
111113
$versionToUse = $version;

src/Package/Convey/Command/Type.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ public static function determine($path, $remote)
120120
if (substr($path, -4) == '.tgz' || substr($path, -7) == '.tar.gz') {
121121
return self::TGZ;
122122
}
123+
$matches = null;
123124
if ($remote && self::determinePecl($path, $matches) > 0) {
124125
return self::PECL;
125126
}

src/Package/PHP/Command/Build/Windows.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public function getInfo()
134134
$info = [];
135135
$info = array_merge($info, $this->getInfoFromPhpizeLog());
136136
$info = array_merge($info, $this->getInfoFromConfigureLog());
137-
137+
$m = null;
138138
if (!preg_match(',(.+)/(.+),', $info['name'], $m)) {
139139
$info['vendor'] = null;
140140
} else {
@@ -178,6 +178,7 @@ protected function getInfoFromPhpizeLog()
178178
];
179179

180180
$tmp = $this->getLog('phpize');
181+
$m = null;
181182
if (!preg_match(",Rebuilding configure.js[\n\r\\d:]+\\s+(.+)[\n\r]+,", $tmp, $m)) {
182183
throw new Exception("Couldn't determine PHP development SDK path");
183184
}
@@ -211,13 +212,15 @@ protected function getInfoFromConfigureLog()
211212
'arch' => null,
212213
'version' => null,
213214
'name' => null,
215+
'is_release' => null,
214216
];
215217

216218
$tmp = $this->getLog('configure');
217-
219+
$m = null;
218220
if (!preg_match(',Build type\\s+\\|\\s+([a-zA-Z]+),', $tmp, $m)) {
219221
throw new Exception("Couldn't determine the build thread safety");
220222
}
223+
$info['is_release'] = $m[1] === 'Release';
221224

222225
if (!preg_match(',Thread Safety\\s+\\|\\s+([a-zA-Z]+),', $tmp, $m)) {
223226
throw new Exception("Couldn't determine the build thread safety");

src/Package/PHP/Command/Install/Windows/Binary.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,9 @@ private function download($url)
251251
},
252252
]
253253
);
254-
$output->writeln("downloading {$url} ");
254+
if ($this->output) {
255+
$this->output->writeln("downloading {$url} ");
256+
}
255257
$fileContents = file_get_contents($url, false, $ctx);
256258
$progress->finish();
257259
if (!$fileContents) {
@@ -325,7 +327,7 @@ private function getInfoFromPecl()
325327
if ($headerPkg === null) {
326328
throw new Exception('Cannot find extension <' . $this->extName . '>');
327329
}
328-
330+
$m = null;
329331
if (!preg_match('|=(.*)\\.[a-z0-9]{2,3}$|', $headerPkg, $m)) {
330332
throw new Exception('Invalid response from pecl.php.net');
331333
}

src/Package/PHP/Command/Release.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
use Phar;
4242
use PharData;
4343
use Pickle\Base\Interfaces;
44-
use Pickle\Package;
4544
use Pickle\Package\PHP\Util\PackageJson;
4645
use Pickle\Package\Util\Header;
4746

src/Package/PHP/Command/Release/Windows/Binary.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@
3636

3737
namespace Pickle\Package\PHP\Command\Release\Windows;
3838

39+
use Closure;
3940
use Exception;
4041
use Pickle\Base\Archive;
4142
use Pickle\Base\Interfaces;
42-
use Pickle\Package;
4343
use Pickle\Package\PHP\Util\PackageJson;
4444
use Pickle\Package\Util\Header;
4545

@@ -51,7 +51,7 @@ class Binary implements Interfaces\Package\Release
5151
protected $pkg;
5252

5353
/**
54-
* @var \Closure
54+
* @var Closure
5555
*/
5656
protected $cb;
5757

@@ -69,7 +69,7 @@ class Binary implements Interfaces\Package\Release
6969
* Constructor.
7070
*
7171
* @param string $path
72-
* @param \Closure $cb
72+
* @param Closure $cb
7373
* @param bool $noConvert
7474
*/
7575
public function __construct($path, $cb = null, $noConvert = false)
@@ -99,6 +99,7 @@ public function create(array $args = [])
9999
$tmp_dir = $build->getTempDir();
100100

101101
$tmp = $build->getLog('configure');
102+
$m = null;
102103
if (preg_match(',Build dir:\\s+([\\:\\-\\.0-9a-zA-Z\\\\_]+),', $tmp, $m)) {
103104
if (preg_match(',^[a-z]\\:\\\\,i', $m[1]) && is_dir($m[1])) {
104105
/* Parsed the fully qualified path */
@@ -109,7 +110,7 @@ public function create(array $args = [])
109110
}
110111
} else {
111112
$build_dir = $info['arch'] == 'x86' ? $tmp_dir : $tmp_dir . DIRECTORY_SEPARATOR . 'x64';
112-
$build_dir .= DIRECTORY_SEPARATOR . ($is_release ? 'Release' : 'Debug');
113+
$build_dir .= DIRECTORY_SEPARATOR . (($info['is_release'] ?? true) ? 'Release' : 'Debug');
113114
$build_dir .= ($info['thread_safe'] ? '_TS' : '');
114115
}
115116

@@ -191,6 +192,7 @@ public function getMultiExtensionNames()
191192
multiple DLLs be built. */
192193
$config_w32_path = $this->build->getPackage()->getSourceDir() . DIRECTORY_SEPARATOR . 'config.w32';
193194
$config_w32 = file_get_contents($config_w32_path);
195+
$m = null;
194196
if (preg_match_all("/EXTENSION\\s*\\(\\s*('|\")([a-z0-9_]+)('|\")\\s*,/Sm", $config_w32, $m, PREG_SET_ORDER)) {
195197
foreach ($m as $r) {
196198
if (!in_array($r[2], $ext_names)) {

src/Package/PHP/Convey/Command/Pecl.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function getType()
6363
protected function prepare()
6464
{
6565
$engine = Engine::factory();
66-
66+
$matches = null;
6767
if (Type::determinePecl($this->path, $matches) < 1) {
6868
throw new Exception('Not valid PECL URI');
6969
}

0 commit comments

Comments
 (0)