Skip to content

Commit

Permalink
Merge branch '5.x' into 5.next
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed Aug 28, 2024
2 parents 910824d + 3cea64b commit e13084a
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 11 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"mikey179/vfsstream": "^1.6.10",
"mockery/mockery": "^1.6",
"paragonie/csp-builder": "^2.3 || ^3.0",
"phpstan/phpstan": "1.11.*",
"phpstan/phpstan": "1.12.0",
"phpstan/extension-installer": "^1.3",
"symplify/phpstan-rules": "^12.4",
"phpunit/phpunit": "^10.5.5 || ^11.1.3"
Expand Down
1 change: 1 addition & 0 deletions src/Database/Driver/Mysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ public function version(): string
if (str_contains($this->_version, 'MariaDB')) {
$this->serverType = static::SERVER_TYPE_MARIADB;
preg_match('/^(?:5\.5\.5-)?(\d+\.\d+\.\d+.*-MariaDB[^:]*)/', $this->_version, $matches);
/** @phpstan-ignore-next-line */
$this->_version = $matches[1];
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Database/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@
"require-dev": {
"cakephp/i18n": "^5.0",
"cakephp/log": "^5.0",
"phpstan/phpstan": "^1.10"
"phpstan/phpstan": "1.12.0"
}
}
2 changes: 1 addition & 1 deletion src/Datasource/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@
"cakephp/cache": "^5.0",
"cakephp/collection": "^5.0",
"cakephp/utility": "^5.0",
"phpstan/phpstan": "^1.10"
"phpstan/phpstan": "1.12.0"
}
}
3 changes: 3 additions & 0 deletions src/Http/Client/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,11 @@ protected function _parseHeaders(array $headers): void
foreach ($headers as $value) {
if (str_starts_with($value, 'HTTP/')) {
preg_match('/HTTP\/([\d.]+) ([0-9]+)(.*)/i', $value, $matches);
/** @phpstan-ignore-next-line */
$this->protocol = $matches[1];
/** @phpstan-ignore-next-line */
$this->code = (int)$matches[2];
/** @phpstan-ignore-next-line */
$this->reasonPhrase = trim($matches[3]);
continue;
}
Expand Down
8 changes: 8 additions & 0 deletions src/Http/HeaderUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ protected static function parseLinkItem(string $value): array
{
preg_match('/<(.*)>[; ]?[; ]?(.*)?/i', $value, $matches);

if ($matches === []) {
return [];
}

$url = $matches[1];
$parsedParams = ['link' => $url];

Expand All @@ -48,8 +52,11 @@ protected static function parseLinkItem(string $value): array
// See https://www.rfc-editor.org/rfc/rfc8187#section-3.2.3
preg_match("/(.*)'(.*)'(.*)/i", $trimedValue, $matches);
$trimedValue = [
/** @phpstan-ignore-next-line */
'language' => $matches[2],
/** @phpstan-ignore-next-line */
'encoding' => $matches[1],
/** @phpstan-ignore-next-line */
'value' => urldecode($matches[3]),
];
}
Expand Down Expand Up @@ -117,6 +124,7 @@ public static function parseWwwAuthenticate(string $value): array

$return = [];
foreach ($matches as $match) {
/** @phpstan-ignore-next-line */
$return[$match[1]] = $match[3] ?? $match[2];
}

Expand Down
2 changes: 1 addition & 1 deletion src/Http/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,6 @@
"cakephp/orm": "^5.0",
"cakephp/i18n": "^5.0",
"paragonie/csp-builder": "^2.3",
"phpstan/phpstan": "^1.10"
"phpstan/phpstan": "1.12.0"
}
}
2 changes: 1 addition & 1 deletion src/ORM/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@
"require-dev": {
"cakephp/cache": "^5.0",
"cakephp/i18n": "^5.0",
"phpstan/phpstan": "^1.10"
"phpstan/phpstan": "1.12.0"
}
}
2 changes: 1 addition & 1 deletion src/Validation/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@
},
"require-dev": {
"cakephp/i18n": "^5.0",
"phpstan/phpstan": "^1.10"
"phpstan/phpstan": "1.12.0"
}
}
13 changes: 8 additions & 5 deletions src/View/Helper/FormHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -1352,12 +1352,15 @@ protected function enumOptions(string $enumClass): array
{
assert(is_subclass_of($enumClass, BackedEnum::class));

$hasLabel = is_a($enumClass, EnumLabelInterface::class, true) || method_exists($enumClass, 'label');
$values = [];
/** @var \BackedEnum $case */
foreach ($enumClass::cases() as $case) {
$hasLabel = $case instanceof EnumLabelInterface || method_exists($case, 'label');
$values[$case->value] = $hasLabel ? $case->label()
: Inflector::humanize(Inflector::underscore($case->name));
foreach ($enumClass::cases() as $enumClass) {
/**
* @psalm-suppress UndefinedInterfaceMethod
* @phpstan-ignore-next-line
*/
$values[$enumClass->value] = $hasLabel ? $enumClass->label()
: Inflector::humanize(Inflector::underscore($enumClass->name));
}

return $values;
Expand Down

0 comments on commit e13084a

Please sign in to comment.