Skip to content

Commit

Permalink
cs-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
danog committed Jan 18, 2025
1 parent e9e270f commit 0d0aedc
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 21 deletions.
26 changes: 16 additions & 10 deletions bin/gen_base_callmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

$callmap = [];

function namedTypeName(ReflectionNamedType $refl): string
{
return $refl->getName();
}

/**
* @var ?ReflectionType $reflection_type
*/
Expand All @@ -16,14 +21,8 @@ function typeToString($reflection_type, string $defaultType): string
if ($reflection_type instanceof ReflectionNamedType) {
$type = $reflection_type->getName();
} elseif ($reflection_type instanceof ReflectionUnionType) {
$type = implode(
'|',
array_map(
static function (ReflectionNamedType $reflection): string { return $reflection->getName(); },
$reflection_type->getTypes()
)
);
} else if ($reflection_type instanceof ReflectionType) {
$type = implode('|', array_map('namedTypeName', $reflection_type->getTypes()));
} elseif ($reflection_type instanceof ReflectionType) {
$type = $reflection_type->__toString();
} else {
throw new LogicException('Unexpected reflection class ' . get_class($reflection_type) . ' found.');
Expand Down Expand Up @@ -81,8 +80,15 @@ function paramsToEntries(ReflectionFunctionAbstract $reflectionFunction, string
foreach (get_defined_functions() as $sub) {
foreach ($sub as $name) {
$name = strtolower($name);
if ($name === 'paramstoentries') continue;
if ($name === 'typetostring') continue;
if ($name === 'paramstoentries') {
continue;
}
if ($name === 'typetostring') {
continue;
}
if ($name === 'namedtypename') {
continue;
}
$func = new ReflectionFunction($name);

$args = paramsToEntries($func, 'mixed');
Expand Down
2 changes: 1 addition & 1 deletion bin/gen_callmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@
}
$data = normalizeCallMap($data);
writeCallMap("dictionaries/override/CallMap_{$version}.php", $data);
}
}
2 changes: 1 addition & 1 deletion dictionaries/CallMap_80.php
Original file line number Diff line number Diff line change
Expand Up @@ -35997,8 +35997,8 @@
0 => 'bool',
'image' => 'GdImage',
'x1' => 'int',
'x2' => 'int',
'y1' => 'int',
'x2' => 'int',
'y2' => 'int',
),
'imagesetinterpolation' =>
Expand Down
2 changes: 1 addition & 1 deletion dictionaries/CallMap_81.php
Original file line number Diff line number Diff line change
Expand Up @@ -34967,8 +34967,8 @@
0 => 'bool',
'image' => 'GdImage',
'x1' => 'int',
'x2' => 'int',
'y1' => 'int',
'x2' => 'int',
'y2' => 'int',
),
'imagesetinterpolation' =>
Expand Down
2 changes: 1 addition & 1 deletion dictionaries/CallMap_82.php
Original file line number Diff line number Diff line change
Expand Up @@ -35040,8 +35040,8 @@
0 => 'bool',
'image' => 'GdImage',
'x1' => 'int',
'x2' => 'int',
'y1' => 'int',
'x2' => 'int',
'y2' => 'int',
),
'imagesetinterpolation' =>
Expand Down
2 changes: 1 addition & 1 deletion dictionaries/CallMap_83.php
Original file line number Diff line number Diff line change
Expand Up @@ -35652,8 +35652,8 @@
0 => 'bool',
'image' => 'GdImage',
'x1' => 'int',
'x2' => 'int',
'y1' => 'int',
'x2' => 'int',
'y2' => 'int',
),
'imagesetinterpolation' =>
Expand Down
2 changes: 1 addition & 1 deletion dictionaries/CallMap_84.php
Original file line number Diff line number Diff line change
Expand Up @@ -39223,8 +39223,8 @@
0 => 'bool',
'image' => 'GdImage',
'x1' => 'int',
'x2' => 'int',
'y1' => 'int',
'x2' => 'int',
'y2' => 'int',
),
'imagesetinterpolation' =>
Expand Down
7 changes: 4 additions & 3 deletions src/Psalm/Internal/Analyzer/Statements/DeclareAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Psalm\Internal\Analyzer\Statements;

use PhpParser;
use PhpParser\Node\DeclareItem;
use Psalm\CodeLocation;
use Psalm\Context;
use Psalm\Internal\Analyzer\StatementsAnalyzer;
Expand Down Expand Up @@ -56,7 +57,7 @@ public static function analyze(

private static function analyzeStrictTypesDeclaration(
StatementsAnalyzer $statements_analyzer,
PhpParser\Node\Stmt\DeclareDeclare $declaration,
DeclareItem $declaration,
Context $context,
): void {
if (!$declaration->value instanceof PhpParser\Node\Scalar\LNumber
Expand All @@ -80,7 +81,7 @@ private static function analyzeStrictTypesDeclaration(

private static function analyzeTicksDeclaration(
StatementsAnalyzer $statements_analyzer,
PhpParser\Node\Stmt\DeclareDeclare $declaration,
DeclareItem $declaration,
): void {
if (!$declaration->value instanceof PhpParser\Node\Scalar\LNumber) {
IssueBuffer::maybeAdd(
Expand All @@ -95,7 +96,7 @@ private static function analyzeTicksDeclaration(

private static function analyzeEncodingDeclaration(
StatementsAnalyzer $statements_analyzer,
PhpParser\Node\Stmt\DeclareDeclare $declaration,
DeclareItem $declaration,
): void {
if (!$declaration->value instanceof PhpParser\Node\Scalar\String_) {
IssueBuffer::maybeAdd(
Expand Down
4 changes: 2 additions & 2 deletions src/Psalm/Internal/Codebase/InternalCallMapHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,12 @@
use function assert;
use function count;
use function dirname;
use function file_exists;
use function max;
use function str_ends_with;
use function str_starts_with;
use function strlen;
use function strtolower;
use function substr;
use function version_compare;

/**
* @internal
Expand Down Expand Up @@ -345,6 +344,7 @@ public static function getCallablesFromCallMap(string $function_id): ?array
* @return non-empty-array<string, array<int|string, string>>
* @psalm-assert !null self::$taint_sink_map
* @psalm-assert !null self::$call_map
* @psalm-suppress UnresolvableInclude
*/
public static function getCallMap(): array
{
Expand Down
2 changes: 2 additions & 0 deletions src/Psalm/Internal/Codebase/Reflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
use function implode;
use function strtolower;

use const PHP_VERSION_ID;

/**
* @internal
*
Expand Down

0 comments on commit 0d0aedc

Please sign in to comment.