Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ indent_size = 4
trim_trailing_whitespace = true

[*.php]
ij_php_space_before_short_closure_left_parenthesis = true
ij_php_space_before_short_closure_left_parenthesis = false
ij_php_space_after_type_cast = true

[*.md]
trim_trailing_whitespace = false
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
"require-dev": {
"phpunit/phpunit": "^9.5",
"rector/rector": "^0.15.4",
"roave/infection-static-analysis-plugin": "^1.16",
"roave/infection-static-analysis-plugin": "^1.25",
"spatie/phpunit-watcher": "^1.23",
"vimeo/psalm": "^4.18"
"vimeo/psalm": "^4.30|^5.4"
},
"autoload": {
"psr-4": {
Expand Down
20 changes: 15 additions & 5 deletions src/ArrayHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,9 @@ public static function index(
if (!array_key_exists($value, $lastArray)) {
$lastArray[$value] = [];
}
/** @psalm-suppress MixedAssignment */
$lastArray = &$lastArray[$value];
/** @var array $lastArray */
}

if ($key === null) {
Expand Down Expand Up @@ -963,10 +965,10 @@ public static function htmlEncode(iterable $data, bool $valuesOnly = true, strin
$key = (string)$key;
}
if (!$valuesOnly && is_string($key)) {
$key = htmlspecialchars($key, ENT_QUOTES|ENT_SUBSTITUTE, $encoding, true);
$key = htmlspecialchars($key, ENT_QUOTES | ENT_SUBSTITUTE, $encoding, true);
}
if (is_string($value)) {
$d[$key] = htmlspecialchars($value, ENT_QUOTES|ENT_SUBSTITUTE, $encoding, true);
$d[$key] = htmlspecialchars($value, ENT_QUOTES | ENT_SUBSTITUTE, $encoding, true);
} elseif (is_array($value)) {
$d[$key] = self::htmlEncode($value, $valuesOnly, $encoding);
} else {
Expand Down Expand Up @@ -1223,13 +1225,19 @@ public static function filter(array $array, array $filters): array
if (!array_key_exists($key, $resultNode)) {
$resultNode[$key] = [];
}
/** @psalm-suppress MixedAssignment */
$resultNode = &$resultNode[$key];
/** @var array $resultNode */
}
/** @var mixed */
/** @var array */
$resultNode = $nodeValue;
}

/** @var array $result */
/**
* @psalm-suppress UnnecessaryVarAnnotation
*
* @var array $result
*/

foreach ($excludeFilters as $filter) {
$excludeNode = &$result;
Expand All @@ -1241,7 +1249,7 @@ public static function filter(array $array, array $filters): array
}

if ($i < $numNestedKeys) {
/** @var mixed */
/** @psalm-suppress MixedAssignment */
$excludeNode = &$excludeNode[$key];
} else {
unset($excludeNode[$key]);
Expand All @@ -1250,6 +1258,8 @@ public static function filter(array $array, array $filters): array
}
}

/** @var array $result */

return $result;
}

Expand Down
5 changes: 4 additions & 1 deletion src/ArraySorter.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ public static function multisort(

$_args = self::getArguments($array, $keys, $direction, $sortFlag);

/** @psalm-suppress UnsupportedReferenceUsage */
$_args[] = &$array;

/** @psalm-suppress MixedArgument */
array_multisort(...$_args);
}

Expand Down Expand Up @@ -110,7 +113,7 @@ private static function getKeys(array $array, array|Closure|string $key): array
* @param array<array-key, int> $direction Array of sorting directions.
* @param array<array-key, int> $sortFlags Array of sort flags.
*
* @return array{array, int, int} The arguments.
* @return array The arguments.
*/
private static function getArguments(array $array, array $keys, array $direction, array $sortFlags): array
{
Expand Down