Skip to content

Commit 0d998c1

Browse files
committed
Merge branch '6.x'
2 parents e66308f + d0b040a commit 0d998c1

15 files changed

Lines changed: 36 additions & 46 deletions

File tree

.github/workflows/bcc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
composer update --no-install
3131
3232
- name: Cache composer cache
33-
uses: actions/cache@v4
33+
uses: actions/cache@v5
3434
with:
3535
path: |
3636
${{ steps.composer-cache.outputs.files_cache }}

.github/workflows/build-docker.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ jobs:
6868
composer update --no-install
6969
7070
- name: Cache composer cache
71-
uses: actions/cache@v4
71+
uses: actions/cache@v5
7272
with:
7373
path: |
7474
${{ steps.composer-cache.outputs.files_cache }}

.github/workflows/build-phar.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060
composer update --no-install
6161
6262
- name: Cache composer cache
63-
uses: actions/cache@v4
63+
uses: actions/cache@v5
6464
with:
6565
path: |
6666
${{ steps.composer-cache.outputs.files_cache }}

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
COMPOSER_ROOT_VERSION: dev-master
4040

4141
- name: Cache composer cache
42-
uses: actions/cache@v4
42+
uses: actions/cache@v5
4343
with:
4444
path: |
4545
${{ steps.composer-cache.outputs.files_cache }}
@@ -83,7 +83,7 @@ jobs:
8383
COMPOSER_ROOT_VERSION: dev-master
8484

8585
- name: Cache composer cache
86-
uses: actions/cache@v4
86+
uses: actions/cache@v5
8787
with:
8888
path: |
8989
${{ steps.composer-cache.outputs.files_cache }}
@@ -172,7 +172,7 @@ jobs:
172172
COMPOSER_ROOT_VERSION: dev-master
173173

174174
- name: Cache composer cache
175-
uses: actions/cache@v4
175+
uses: actions/cache@v5
176176
with:
177177
path: |
178178
${{ steps.composer-cache.outputs.files_cache }}

.github/workflows/windows-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ jobs:
8585
COMPOSER_ROOT_VERSION: dev-master
8686

8787
- name: Cache composer cache
88-
uses: actions/cache@v4
88+
uses: actions/cache@v5
8989
with:
9090
path: |
9191
${{ steps.composer-cache.outputs.files_cache }}

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@
4141
"nikic/php-parser": "^5.0.0",
4242
"sebastian/diff": "^4.0 || ^5.0 || ^6.0 || ^7.0",
4343
"spatie/array-to-xml": "^2.17.0 || ^3.0",
44-
"symfony/console": "^6.0 || ^7.0",
45-
"symfony/filesystem": "~6.3.12 || ~6.4.3 || ^7.0.3",
44+
"symfony/console": "^6.0 || ^7.0 || ^8.0",
45+
"symfony/filesystem": "~6.3.12 || ~6.4.3 || ^7.0.3 || ^8.0",
4646
"symfony/polyfill-php84": "^1.31.0"
4747
},
4848
"provide": {
@@ -64,7 +64,7 @@
6464
"psalm/plugin-phpunit": "^0.19",
6565
"slevomat/coding-standard": "^8.4",
6666
"squizlabs/php_codesniffer": "^3.6",
67-
"symfony/process": "^6.0 || ^7.0"
67+
"symfony/process": "^6.0 || ^7.0 || ^8.0"
6868
},
6969
"suggest": {
7070
"ext-igbinary": "^2.0.5 is required, used to serialize caching data",

docs/running_psalm/issues/TaintedSSRF.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ $ch = curl_init();
1717
curl_setopt($ch, CURLOPT_URL, $_GET['url']);
1818

1919
curl_exec($ch);
20-
21-
curl_close($ch);
2220
```
2321

2422
## Mitigations

src/Psalm/Internal/Analyzer/AttributesAnalyzer.php

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Psalm\Internal\Analyzer;
66

7+
use Attribute as GlobalAttribute;
78
use Generator;
89
use PhpParser\Node\Arg;
910
use PhpParser\Node\Attribute;
@@ -47,16 +48,6 @@ final class AttributesAnalyzer
4748
40 => 'promoted property',
4849
];
4950

50-
// Copied from Attribute class since that class might not exist at runtime
51-
public const TARGET_CLASS = 1;
52-
public const TARGET_FUNCTION = 2;
53-
public const TARGET_METHOD = 4;
54-
public const TARGET_PROPERTY = 8;
55-
public const TARGET_CLASS_CONSTANT = 16;
56-
public const TARGET_PARAMETER = 32;
57-
public const TARGET_ALL = 63;
58-
public const IS_REPEATABLE = 64;
59-
6051
/**
6152
* @param array<array-key, AttributeGroup> $attribute_groups
6253
* @param key-of<self::TARGET_DESCRIPTIONS> $target
@@ -104,7 +95,7 @@ public static function analyze(
10495
$storage instanceof ClassLikeStorage ? $storage : null,
10596
);
10697

107-
if (($attribute_class_flags & self::IS_REPEATABLE) === 0) {
98+
if (($attribute_class_flags & GlobalAttribute::IS_REPEATABLE) === 0) {
10899
// Not IS_REPEATABLE
109100
if (isset($appearing_non_repeatable_attributes[$fq_attribute_name])) {
110101
IssueBuffer::maybeAdd(
@@ -252,17 +243,17 @@ private static function getAttributeClassFlags(
252243
if (strtolower($fq_attribute_name) === "attribute") {
253244
// We override this here because we still want to analyze attributes
254245
// for PHP 7.4 when the Attribute class doesn't yet exist.
255-
return self::TARGET_CLASS;
246+
return GlobalAttribute::TARGET_CLASS;
256247
}
257248

258249
if ($attribute_class_storage === null) {
259-
return self::TARGET_ALL; // Defaults to TARGET_ALL
250+
return GlobalAttribute::TARGET_ALL; // Defaults to TARGET_ALL
260251
}
261252

262253
foreach ($attribute_class_storage->attributes as $attribute_attribute) {
263254
if ($attribute_attribute->fq_class_name === 'Attribute') {
264255
if (!$attribute_attribute->args) {
265-
return self::TARGET_ALL; // Defaults to TARGET_ALL
256+
return GlobalAttribute::TARGET_ALL; // Defaults to TARGET_ALL
266257
}
267258

268259
$first_arg = $attribute_attribute->args[array_key_first($attribute_attribute->args)];
@@ -280,7 +271,7 @@ private static function getAttributeClassFlags(
280271
}
281272

282273
if (!$first_arg_type->isSingleIntLiteral()) {
283-
return self::TARGET_ALL; // Fall back to default if it's invalid
274+
return GlobalAttribute::TARGET_ALL; // Fall back to default if it's invalid
284275
}
285276

286277
return $first_arg_type->getSingleIntLiteral()->value;
@@ -295,7 +286,7 @@ private static function getAttributeClassFlags(
295286
$suppressed_issues,
296287
);
297288

298-
return self::TARGET_ALL; // Fall back to default if it's invalid
289+
return GlobalAttribute::TARGET_ALL; // Fall back to default if it's invalid
299290
}
300291

301292
/**
@@ -330,22 +321,22 @@ public static function analyzeGetAttributes(
330321

331322
switch ($method_id) {
332323
case "ReflectionClass::getattributes":
333-
$target = self::TARGET_CLASS;
324+
$target = GlobalAttribute::TARGET_CLASS;
334325
break;
335326
case "ReflectionFunction::getattributes":
336-
$target = self::TARGET_FUNCTION;
327+
$target = GlobalAttribute::TARGET_FUNCTION;
337328
break;
338329
case "ReflectionMethod::getattributes":
339-
$target = self::TARGET_METHOD;
330+
$target = GlobalAttribute::TARGET_METHOD;
340331
break;
341332
case "ReflectionProperty::getattributes":
342-
$target = self::TARGET_PROPERTY;
333+
$target = GlobalAttribute::TARGET_PROPERTY;
343334
break;
344335
case "ReflectionClassConstant::getattributes":
345-
$target = self::TARGET_CLASS_CONSTANT;
336+
$target = GlobalAttribute::TARGET_CLASS_CONSTANT;
346337
break;
347338
case "ReflectionParameter::getattributes":
348-
$target = self::TARGET_PARAMETER;
339+
$target = GlobalAttribute::TARGET_PARAMETER;
349340
break;
350341
default:
351342
return;

src/Psalm/Internal/Analyzer/ClassAnalyzer.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Psalm\Internal\Analyzer;
66

7+
use Attribute;
78
use Exception;
89
use InvalidArgumentException;
910
use LogicException;
@@ -426,7 +427,7 @@ public function analyze(
426427
$class_context,
427428
$storage,
428429
$class->attrGroups,
429-
AttributesAnalyzer::TARGET_CLASS,
430+
Attribute::TARGET_CLASS,
430431
$storage->suppressed_issues + $this->getSuppressedIssues(),
431432
);
432433

@@ -1567,7 +1568,7 @@ private function analyzeProperty(
15671568
$context,
15681569
$property_storage,
15691570
$stmt->attrGroups,
1570-
AttributesAnalyzer::TARGET_PROPERTY,
1571+
Attribute::TARGET_PROPERTY,
15711572
$property_storage->suppressed_issues + $this->getSuppressedIssues(),
15721573
);
15731574

src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Psalm\Internal\Analyzer;
66

7+
use Attribute;
78
use Override;
89
use PhpParser;
910
use PhpParser\Node\Expr\ArrowFunction;
@@ -914,7 +915,7 @@ public function analyze(
914915
$context,
915916
$storage,
916917
$this->function->attrGroups,
917-
$storage instanceof MethodStorage ? AttributesAnalyzer::TARGET_METHOD : AttributesAnalyzer::TARGET_FUNCTION,
918+
$storage instanceof MethodStorage ? Attribute::TARGET_METHOD : Attribute::TARGET_FUNCTION,
918919
$storage->suppressed_issues + $this->getSuppressedIssues(),
919920
);
920921

@@ -1362,8 +1363,8 @@ private function processParams(
13621363
$context,
13631364
$function_param,
13641365
$param_stmts[$offset]->attrGroups,
1365-
AttributesAnalyzer::TARGET_PARAMETER
1366-
| ($function_param->promoted_property ? AttributesAnalyzer::TARGET_PROPERTY : 0),
1366+
Attribute::TARGET_PARAMETER
1367+
| ($function_param->promoted_property ? Attribute::TARGET_PROPERTY : 0),
13671368
$storage->suppressed_issues + $this->getSuppressedIssues(),
13681369
);
13691370
}

0 commit comments

Comments
 (0)