Skip to content

Commit 1e5a826

Browse files
committed
Improve PHP 8.4+ support by avoiding implicitly nullable types
1 parent c3e5276 commit 1e5a826

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
],
1313
"require": {
1414
"php": ">=5.3.6",
15-
"knplabs/packagist-api": "^1.0",
15+
"knplabs/packagist-api": "^1.5",
1616
"symfony/console": "^6.0 || ^5.0 || ^4.0 || ^3.0 || ^2.5",
1717
"symfony/finder": "^6.0 || ^5.0 || ^4.0 || ^3.0 || ^2.5",
1818
"symfony/process": "^6.0 || ^5.0 || ^4.0 || ^3.0 || ^2.5"

src/Command/Build.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class Build extends Command
1313
/** @var Packager */
1414
private $packager;
1515

16-
public function __construct(Packager $packager = null)
16+
public function __construct($packager = null)
1717
{
1818
parent::__construct();
1919

src/Command/Install.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class Install extends Command
1818
/** @var bool */
1919
private $isWindows;
2020

21-
public function __construct(Packager $packager = null, $isWindows = null)
21+
public function __construct($packager = null, $isWindows = null)
2222
{
2323
if ($packager === null) {
2424
$packager = new Packager();

src/Command/Search.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class Search extends Command
2727
/** @var bool */
2828
private $isWindows;
2929

30-
public function __construct(Packager $packager = null, Client $packagist = null, $isWindows = null)
30+
public function __construct($packager = null, $packagist = null, $isWindows = null)
3131
{
3232
if ($packager === null) {
3333
$packager = new Packager();
@@ -77,13 +77,24 @@ protected function select(InputInterface $input, OutputInterface $output, $label
7777
}
7878

7979
$question = new ChoiceQuestion($label, $select);
80-
$index = array_search($helper->ask($input, $output, $question), $select);
80+
$selected = $helper->ask($input, $output, $question);
81+
$index = array_search($selected, $select, true);
82+
83+
// Check if the index is valid (not false)
84+
if ($index === false) {
85+
return null;
86+
}
8187

8288
if ($index === 0) {
8389
return null;
8490
}
8591

8692
$indices = array_keys($choices);
93+
// Verify index is in range before accessing
94+
if (!isset($indices[$index - 1])) {
95+
return null;
96+
}
97+
8798
return $indices[$index - 1];
8899
}
89100

0 commit comments

Comments
 (0)