Skip to content

Commit 8c594b2

Browse files
committed
Merge remote-tracking branch 'origin/2.1.x' into 2.2.x
2 parents 5fb9ee6 + 584420d commit 8c594b2

File tree

7 files changed

+54
-11
lines changed

7 files changed

+54
-11
lines changed

.github/workflows/e2e-tests.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,9 @@ jobs:
380380
- script: |
381381
cd e2e/bug-11819
382382
../../bin/phpstan
383+
- script: |
384+
cd e2e/bug-14305
385+
../../bin/phpstan
383386
- script: |
384387
cd e2e/composer-and-phpstan-version-config
385388
composer install --ignore-platform-reqs

.github/workflows/merge-maintained-branch.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,13 @@ jobs:
2020

2121
- name: "Checkout"
2222
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
23-
- name: "Merge branch"
24-
uses: everlytic/branch-merge@c4a244dc23143f824ae6c022a10732566cb8e973 # 1.1.5
2523
with:
26-
github_token: "${{ secrets.PHPSTAN_BOT_TOKEN }}"
27-
source_ref: ${{ github.ref }}
28-
target_branch: '2.2.x'
29-
commit_message_template: 'Merge branch {source_ref} into {target_branch}'
24+
fetch-depth: 0
25+
ref: '2.2.x'
26+
token: "${{ secrets.PHPSTAN_BOT_TOKEN }}"
27+
- name: "Merge branch"
28+
run: |
29+
git config user.name "phpstan-bot"
30+
git config user.email "bot@phpstan.org"
31+
git merge --strategy=ort origin/${{ github.ref_name }} -m "Merge branch ${{ github.ref_name }} into 2.2.x"
32+
git push

bin/phpstan

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,14 @@ use Symfony\Component\Console\Helper\ProgressBar;
2626

2727
$devOrPharLoader = require_once __DIR__ . '/../vendor/autoload.php';
2828
require_once __DIR__ . '/../preload.php';
29-
$composerJsonPath = ComposerHelper::getComposerJsonPath(getcwd());
30-
$composer = ComposerHelper::getComposerConfig(getcwd());
29+
$cwd = getcwd();
30+
$composerJsonPath = ComposerHelper::getComposerJsonPath($cwd);
31+
$composer = ComposerHelper::getComposerConfig($cwd);
3132

3233
if ($composer !== null) {
33-
$vendorDirectory = ComposerHelper::getVendorDirFromComposerConfig(getcwd(), $composer);
34+
$vendorDirectory = ComposerHelper::getVendorDirFromComposerConfig($cwd, $composer);
3435
} else {
35-
$vendorDirectory = getcwd() . '/vendor';
36+
$vendorDirectory = $cwd . '/vendor';
3637
}
3738
$devOrPharLoader->unregister();
3839

e2e/bug-14305/phpstan.neon

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
parameters:
2+
level: 5
3+
paths:
4+
- test.php

e2e/bug-14305/test.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
namespace Bug14305;
4+
5+
define('BUG14305_XDOC_GMETA_EMTY', 0);
6+
define('BUG14305_XDOC_GMETA_NUPATH', 7);
7+
define('BUG14305_XDOC_GMETAS', [
8+
'empty' => 0,
9+
'nupath' => 7,
10+
]);
11+
12+
$row = ['id' => 0];
13+
14+
foreach ([BUG14305_XDOC_GMETA_EMTY, BUG14305_XDOC_GMETA_NUPATH] as $meta)
15+
$row[array_search($meta, BUG14305_XDOC_GMETAS)] = '';

phpstan-baseline.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,7 @@ parameters:
966966
-
967967
rawMessage: PHPDoc tag @var with type float|int is not subtype of native type int.
968968
identifier: varTag.nativeType
969-
count: 2
969+
count: 3
970970
path: src/Type/Constant/ConstantArrayTypeBuilder.php
971971

972972
-

src/Type/Constant/ConstantArrayTypeBuilder.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,23 @@ public function setOffsetValueType(?Type $offsetType, Type $valueType, bool $opt
291291
$this->keyTypes[] = $scalarType;
292292
$this->valueTypes[] = $valueType;
293293
$this->optionalKeys[] = count($this->keyTypes) - 1;
294+
295+
if (!($scalarType instanceof ConstantIntegerType)) {
296+
continue;
297+
}
298+
299+
$max = max($this->nextAutoIndexes);
300+
$offsetValue = $scalarType->getValue();
301+
if ($offsetValue < $max) {
302+
continue;
303+
}
304+
305+
/** @var int|float $newAutoIndex */
306+
$newAutoIndex = $offsetValue + 1;
307+
if (is_float($newAutoIndex)) {
308+
$newAutoIndex = $max;
309+
}
310+
$this->nextAutoIndexes[] = $newAutoIndex;
294311
}
295312

296313
$this->isList = TrinaryLogic::createNo();

0 commit comments

Comments
 (0)