Skip to content

Commit d4da78c

Browse files
committed
Merge remote-tracking branch 'upstream/develop' into 4.8
2 parents 6a20a77 + 71f6dcc commit d4da78c

38 files changed

Lines changed: 407 additions & 155 deletions

‎.github/workflows/deploy-apidocs.yml‎

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,33 @@ jobs:
4747
uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # 2.40.0
4848
with:
4949
php-version: '8.3'
50-
tools: phive
5150
coverage: none
5251

53-
- name: Download latest phpDocumentor
52+
- name: Download phpDocumentor
5453
working-directory: source
55-
run: phive --no-progress install --trust-gpg-keys 6DA3ACC4991FFAE5 phpDocumentor
54+
env:
55+
GITHUB_TOKEN: ${{ github.token }}
56+
run: |
57+
curl_retry() {
58+
curl --fail --silent --show-error --location --retry 5 --retry-all-errors --retry-delay 5 "$@"
59+
}
60+
61+
asset=$(curl_retry \
62+
--header "Authorization: Bearer ${GITHUB_TOKEN}" \
63+
https://api.github.com/repos/phpDocumentor/phpDocumentor/releases/latest \
64+
| jq --compact-output '.assets[] | select(.name == "phpDocumentor.phar")')
65+
66+
url=$(jq --raw-output '.browser_download_url' <<< "${asset}")
67+
sha256=$(jq --raw-output '.digest | sub("^sha256:"; "")' <<< "${asset}")
68+
69+
if [ -z "${url}" ] || ! [[ "${sha256}" =~ ^[0-9a-f]{64}$ ]]; then
70+
echo "Could not resolve the phpDocumentor phar and its SHA-256 digest."
71+
exit 1
72+
fi
73+
74+
mkdir --parents tools
75+
curl_retry --output tools/phpDocumentor "${url}"
76+
echo "${sha256} tools/phpDocumentor" | sha256sum --check --strict
5677
5778
- name: Prepare API repo
5879
working-directory: api

‎.github/workflows/test-psalm.yml‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ on:
1212
- 'tests/**'
1313
- 'spark'
1414
- 'composer.json'
15-
- 'psalm*'
15+
- 'utils/composer.json'
16+
- 'psalm.xml'
17+
- 'psalm-baseline.xml'
18+
- 'psalm-autoload.php'
19+
- '.github/actions/composer-update/**'
1620
- '.github/workflows/test-psalm.yml'
1721
push:
1822
branches:
@@ -25,7 +29,11 @@ on:
2529
- 'tests/**'
2630
- 'spark'
2731
- 'composer.json'
28-
- 'psalm*'
32+
- 'utils/composer.json'
33+
- 'psalm.xml'
34+
- 'psalm-baseline.xml'
35+
- 'psalm-autoload.php'
36+
- '.github/actions/composer-update/**'
2937
- '.github/workflows/test-psalm.yml'
3038

3139
permissions:

‎admin/framework/composer.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"codeigniter/coding-standard": "^1.7",
2121
"fakerphp/faker": "^1.24",
2222
"friendsofphp/php-cs-fixer": "^3.47.1",
23-
"kint-php/kint": "^6.1",
23+
"kint-php/kint": "^6.1.1",
2424
"mikey179/vfsstream": "^1.6.12",
2525
"nexusphp/cs-config": "^3.6",
2626
"phpunit/phpunit": "^10.5.16 || ^11.2",

‎composer.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
"psr/log": "^3.0"
1818
},
1919
"require-dev": {
20-
"boundwize/structarmed": "^0.21",
20+
"boundwize/structarmed": "^0.22",
2121
"codeigniter/phpstan-codeigniter": "^2.4",
2222
"fakerphp/faker": "^1.24",
23-
"kint-php/kint": "^6.1",
23+
"kint-php/kint": "^6.1.1",
2424
"mikey179/vfsstream": "^1.6.12",
2525
"nexusphp/tachycardia": "^2.0",
2626
"phpstan/extension-installer": "^1.4",

‎docs/changelogs/v4.7.7.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ Release Date: Unreleased
3434
- **Database:** Fixed a bug where `SQLite3\Connection::_foreignKeyData()` did not escape table identifiers in `PRAGMA foreign_key_list`, causing syntax errors on table names containing hyphens or schemas.
3535
- **Database:** Fixed a bug where `SQLite3\Table::dropIndexes()` used single-quoted string literals instead of escaped identifiers in `DROP INDEX IF EXISTS`, causing syntax errors on index names containing quotes or special characters.
3636
- **Debug Toolbar:** Fixed a bug where `History::setFiles()` emitted a PHP warning when attempting to delete a debugbar history file that had already been removed.
37+
- **Helpers:** Fixed a bug in `ellipsize()` where `$position` was clamped after slicing the beginning of the string and where float `1.0` was not treated identically to integer `1`.
3738
- **Helpers:** Fixed a bug where `excerpt()` threw a `TypeError` when `$phrase` was not found in `$text` or when `$phrase` was `null` and `$radius` was an odd integer. When `$phrase` is not found, `excerpt()` now falls back to extracting an excerpt from the beginning of `$text`.
39+
- **Helpers:** Fixed a bug where `format_number()` with `$precision = 0` appended a trailing comma in locales using a comma as the decimal separator.
40+
- **Helpers:** Fixed a bug where `parse_subdomain()` incorrectly treated hostnames with ports (such as IP addresses and two-part TLD domains) as having unexpected subdomains.
41+
- **Helpers:** Fixed a bug in `plural()` where the regex for `matrix`, `vertex`, and `index` lacked non-capturing grouping and an end-of-string anchor for the `ix` alternative, causing incorrect pluralization of words like `complex`, `sex`, and strings containing `matrix` before the end. Expanded `plural()` and `singular()` to support additional words ending in `ix` or `ex` (`apex`, `appendix`, `codex`, `cortex`, `latex`, `murex`, `vortex`).
3842
- **Helpers:** Fixed bugs in `ArrayHelper::dotKeyExists()` where `'0'` path segments caused early loop termination, non-array intermediate values threw a `TypeError`, and paths with segments after a wildcard failed when the wildcard matched multiple elements.
3943
- **Helpers:** Fixed escaping of attribute values in HTML media helpers to prevent malformed HTML and attribute injection.
4044
- **HTTP:** Fixed a bug where query-string based routing truncated additional query parameters in `SiteURIFactory::parseRequestURI()` due to incorrect array index access.
@@ -48,6 +52,7 @@ Release Date: Unreleased
4852
- **Session:** Fixed a bug where `BaseHandler::destroyCookie()` did not send the `SameSite` attribute in the `Set-Cookie` header, which could prevent browsers from properly clearing the session cookie.
4953
- **Session:** Fixed a bug where `MemcachedHandler` did not reset lock state in `close()` or release an existing lock for a different session ID in `lockSession()`, causing subsequent reads and session ID regeneration on the same handler instance to fail.
5054
- **Session:** Fixed a bug where `Session::start()` did not remove an invalid session cookie from `Request`'s cached cookie global if cookies had already been read from `Request`.
55+
- **Validation:** Fixed a bug where `valid_cc_number` rejected valid Discover cards starting with `646` due to a typo in the prefixes list (`656` instead of `646`).
5156
- **Worker Mode:** Fixed a bug where every request that ended with an uncaught exception, including a `404 Page Not Found` without a 404 override, called `exit()` in the exception handler. This ended the worker script, so FrankenPHP booted a new one, and the worker loop skipped its cleanup after the request. The exception handler now returns to the worker loop.
5257

5358
See the repo's [CHANGELOG.md](https://github.com/codeigniter4/CodeIgniter4/blob/develop/CHANGELOG.md) for a complete list of bugs fixed.

‎system/Helpers/inflector_helper.php‎

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ function singular(string $string): string
3131

3232
// Arranged in order.
3333
$singularRules = [
34-
'/(matr)ices$/' => '\1ix',
35-
'/(vert|ind)ices$/' => '\1ex',
34+
'/(matr|append)ices$/' => '\1ix',
35+
'/(vert|ind|vort|cort|cod|lat|mur|ap)ices$/' => '\1ex',
3636
'/^(ox)en/' => '\1',
3737
'/(alias)es$/' => '\1',
3838
'/([octop|vir])i$/' => '\1us',
@@ -89,26 +89,27 @@ function plural(string $string): string
8989
}
9090

9191
$pluralRules = [
92-
'/(quiz)$/' => '\1zes', // quizzes
93-
'/^(ox)$/' => '\1\2en', // ox
94-
'/([m|l])ouse$/' => '\1ice', // mouse, louse
95-
'/(matr|vert|ind)ix|ex$/' => '\1ices', // matrix, vertex, index
96-
'/(x|ch|ss|sh)$/' => '\1es', // search, switch, fix, box, process, address
97-
'/([^aeiouy]|qu)y$/' => '\1ies', // query, ability, agency
98-
'/(hive)$/' => '\1s', // archive, hive
99-
'/(?:([^f])fe|([lr])f)$/' => '\1\2ves', // half, safe, wife
100-
'/sis$/' => 'ses', // basis, diagnosis
101-
'/([ti])um$/' => '\1a', // datum, medium
102-
'/(p)erson$/' => '\1eople', // person, salesperson
103-
'/(m)an$/' => '\1en', // man, woman, spokesman
104-
'/(c)hild$/' => '\1hildren', // child
105-
'/(buffal|tomat)o$/' => '\1\2oes', // buffalo, tomato
106-
'/(bu|campu)s$/' => '\1\2ses', // bus, campus
107-
'/(alias|status|virus)$/' => '\1es', // alias
108-
'/(octop)us$/' => '\1i', // octopus
109-
'/(ax|cris|test)is$/' => '\1es', // axis, crisis
110-
'/s$/' => 's', // no change (compatibility)
111-
'/$/' => 's',
92+
'/(quiz)$/' => '\1zes', // quizzes
93+
'/^(ox)$/' => '\1\2en', // ox
94+
'/([m|l])ouse$/' => '\1ice', // mouse, louse
95+
'/(matr|append)ix$/' => '\1ices', // matrix, appendix
96+
'/(vert|ind|vort|cort|cod|lat|mur|ap)ex$/' => '\1ices', // vertex, index, vortex, cortex, codex, latex, murex, apex
97+
'/(x|ch|ss|sh)$/' => '\1es', // search, switch, fix, box, process, address
98+
'/([^aeiouy]|qu)y$/' => '\1ies', // query, ability, agency
99+
'/(hive)$/' => '\1s', // archive, hive
100+
'/(?:([^f])fe|([lr])f)$/' => '\1\2ves', // half, safe, wife
101+
'/sis$/' => 'ses', // basis, diagnosis
102+
'/([ti])um$/' => '\1a', // datum, medium
103+
'/(p)erson$/' => '\1eople', // person, salesperson
104+
'/(m)an$/' => '\1en', // man, woman, spokesman
105+
'/(c)hild$/' => '\1hildren', // child
106+
'/(buffal|tomat)o$/' => '\1\2oes', // buffalo, tomato
107+
'/(bu|campu)s$/' => '\1\2ses', // bus, campus
108+
'/(alias|status|virus)$/' => '\1es', // alias
109+
'/(octop)us$/' => '\1i', // octopus
110+
'/(ax|cris|test)is$/' => '\1es', // axis, crisis
111+
'/s$/' => 's', // no change (compatibility)
112+
'/$/' => 's',
112113
];
113114

114115
foreach ($pluralRules as $rule => $replacement) {

‎system/Helpers/number_helper.php‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,14 +151,13 @@ function format_number(float $num, int $precision = 1, ?string $locale = null, a
151151
} else {
152152
// In order to specify a precision, we'll have to modify
153153
// the pattern used by NumberFormatter.
154-
$pattern = '#,##0.' . str_repeat('#', $precision);
154+
$pattern = $precision === 0 ? '#,##0' : '#,##0.' . str_repeat('#', $precision);
155155

156156
$formatter->setPattern($pattern);
157157
$output = $formatter->format($num);
158158
}
159159

160-
// This might lead a trailing period if $precision == 0
161-
$output = trim($output, '. ');
160+
$output = trim($output);
162161

163162
if (intl_is_failure($formatter->getErrorCode())) {
164163
throw new BadFunctionCallException($formatter->getErrorMessage());

‎system/Helpers/text_helper.php‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -437,14 +437,10 @@ function ellipsize(string $str, int $maxLength, $position = 1, string $ellipsis
437437
return $str;
438438
}
439439

440-
$beg = mb_substr($str, 0, (int) floor($maxLength * $position));
441-
$position = ($position > 1) ? 1 : $position;
442-
443-
if ($position === 1) {
444-
$end = mb_substr($str, 0, -($maxLength - mb_strlen($beg)));
445-
} else {
446-
$end = mb_substr($str, -($maxLength - mb_strlen($beg)));
447-
}
440+
$position = max(0.0, min(1.0, $position * 1.0));
441+
$beg = mb_substr($str, 0, (int) floor($maxLength * $position));
442+
$remaining = $maxLength - mb_strlen($beg);
443+
$end = $remaining > 0 ? mb_substr($str, -$remaining) : '';
448444

449445
return $beg . $ellipsis . $end;
450446
}

‎system/Helpers/url_helper.php‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,17 @@ function parse_subdomain(?string $host = null): string
548548
{
549549
$host ??= service('request')->getUri()->getHost();
550550

551+
// Handle IPv6 enclosed in brackets, with or without port: e.g. [::1] or [::1]:8080
552+
if (str_starts_with($host, '[')) {
553+
return '';
554+
}
555+
556+
// If host has a port (e.g. host:8080 or 192.168.1.1:8080), strip the port.
557+
// IPv6 addresses without brackets have multiple colons and are handled by FILTER_VALIDATE_IP.
558+
if (substr_count($host, ':') === 1) {
559+
$host = explode(':', $host, 2)[0];
560+
}
561+
551562
// Handle localhost and IP addresses - they don't have subdomains
552563
if ($host === 'localhost' || filter_var($host, FILTER_VALIDATE_IP)) {
553564
return '';

‎system/ThirdParty/Kint/CallFinder.php‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ public static function getFunctionCalls(string $source, int $line, $function): a
208208
$function_calls = [];
209209

210210
// Performance optimization preventing backwards loops
211-
/** @psalm-var array<PhpToken|null> */
211+
/** @psalm-var array<null|PhpToken> */
212212
$prev_tokens = [null, null, null];
213213

214214
if (\is_array($function)) {
@@ -522,11 +522,11 @@ public static function getFunctionCalls(string $source, int $line, $function): a
522522
'literal' => $literal,
523523
'new_without_parens' => $new_without_parens,
524524
];
525-
}
526525

527-
// Skip first-class callables
528-
if (KINT_PHP81 && 1 === \count($formatted_parameters) && '...' === \reset($formatted_parameters)['path']) {
529-
continue;
526+
// Skip callable assignment
527+
if ('...' === $path || '?' === $path) {
528+
continue 2;
529+
}
530530
}
531531

532532
// Get the modifiers

0 commit comments

Comments
 (0)