Skip to content

Commit b469f0c

Browse files
committed
Merge remote-tracking branch 'upstream/develop' into 4.6
2 parents bddbb3b + 3e88f85 commit b469f0c

File tree

8 files changed

+32
-55
lines changed

8 files changed

+32
-55
lines changed

.github/workflows/test-coding-standards.yml

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,5 @@ jobs:
5757
- name: Install dependencies
5858
run: composer update --ansi --no-interaction
5959

60-
- name: Run lint on `app/`, `admin/`, `public/`
61-
run: utils/vendor/bin/php-cs-fixer fix --verbose --ansi --dry-run --config=.php-cs-fixer.no-header.php --using-cache=no --diff
62-
63-
- name: Run lint on `system/`, `utils/`, and root PHP files
64-
run: utils/vendor/bin/php-cs-fixer fix --verbose --ansi --dry-run --using-cache=no --diff
65-
66-
- name: Run lint on `tests`
67-
run: utils/vendor/bin/php-cs-fixer fix --verbose --ansi --dry-run --config=.php-cs-fixer.tests.php --using-cache=no --diff
68-
69-
- name: Run lint on `user_guide_src/source/`
70-
run: utils/vendor/bin/php-cs-fixer fix --verbose --ansi --dry-run --config=.php-cs-fixer.user-guide.php --using-cache=no --diff
60+
- name: Run lint
61+
run: composer cs

.github/workflows/test-phpstan.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,4 @@ jobs:
8585
run: composer update --ansi --no-interaction
8686

8787
- name: Run static analysis
88-
run: vendor/bin/phpstan analyse
88+
run: composer phpstan:check

admin/pre-commit

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -24,39 +24,10 @@ if [ "$FILES" != "" ]; then
2424
echo "Running PHP CS Fixer..."
2525

2626
# Run on whole codebase to skip on unnecessary filtering
27-
# Run first on app, admin, public
28-
if [ -d /proc/cygdrive ]; then
29-
./utils/vendor/bin/php-cs-fixer fix --verbose --dry-run --diff --config=.php-cs-fixer.no-header.php
30-
else
31-
php ./utils/vendor/bin/php-cs-fixer fix --verbose --dry-run --diff --config=.php-cs-fixer.no-header.php
32-
fi
33-
34-
if [ $? != 0 ]; then
35-
echo "Files in app, admin, or public are not following the coding standards. Please fix them before commit."
36-
exit 1
37-
fi
38-
39-
# Next, run on system, tests, utils, and root PHP files
40-
if [ -d /proc/cygdrive ]; then
41-
./utils/vendor/bin/php-cs-fixer fix --verbose --dry-run --diff
42-
else
43-
php ./utils/vendor/bin/php-cs-fixer fix --verbose --dry-run --diff
44-
fi
45-
46-
if [ $? != 0 ]; then
47-
echo "Files in system, tests, utils, or root are not following the coding standards. Please fix them before commit."
48-
exit 1
49-
fi
50-
51-
# Next, run on user_guide_src/source PHP files
52-
if [ -d /proc/cygdrive ]; then
53-
./utils/vendor/bin/php-cs-fixer fix --verbose --dry-run --diff --config=.php-cs-fixer.user-guide.php
54-
else
55-
php ./utils/vendor/bin/php-cs-fixer fix --verbose --dry-run --diff --config=.php-cs-fixer.user-guide.php
56-
fi
27+
composer cs
5728

5829
if [ $? != 0 ]; then
59-
echo "Files in user_guide_src/source are not following the coding standards. Please fix them before commit."
30+
echo "There are PHP files which are not following the coding standards. Please fix them before commit."
6031
exit 1
6132
fi
6233
fi

composer.json

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"phpunit/phpcov": "^9.0.2",
2929
"phpunit/phpunit": "^10.5.16",
3030
"predis/predis": "^1.1 || ^2.0",
31-
"rector/rector": "1.2.1"
31+
"rector/rector": "1.2.2"
3232
},
3333
"replace": {
3434
"codeigniter4/framework": "self.version"
@@ -92,15 +92,15 @@
9292
],
9393
"analyze": [
9494
"Composer\\Config::disableProcessTimeout",
95-
"bash -c \"XDEBUG_MODE=off vendor/bin/phpstan analyse\"",
95+
"@phpstan:check",
9696
"vendor/bin/rector process --dry-run"
9797
],
9898
"cs": [
9999
"Composer\\Config::disableProcessTimeout",
100-
"utils/vendor/bin/php-cs-fixer fix --ansi --verbose --dry-run --diff --config=.php-cs-fixer.user-guide.php",
101-
"utils/vendor/bin/php-cs-fixer fix --ansi --verbose --dry-run --diff --config=.php-cs-fixer.no-header.php",
102-
"utils/vendor/bin/php-cs-fixer fix --ansi --verbose --dry-run --diff --config=.php-cs-fixer.tests.php",
103-
"utils/vendor/bin/php-cs-fixer fix --ansi --verbose --dry-run --diff"
100+
"utils/vendor/bin/php-cs-fixer check --ansi --verbose --diff --config=.php-cs-fixer.user-guide.php",
101+
"utils/vendor/bin/php-cs-fixer check --ansi --verbose --diff --config=.php-cs-fixer.no-header.php",
102+
"utils/vendor/bin/php-cs-fixer check --ansi --verbose --diff --config=.php-cs-fixer.tests.php",
103+
"utils/vendor/bin/php-cs-fixer check --ansi --verbose --diff"
104104
],
105105
"cs-fix": [
106106
"Composer\\Config::disableProcessTimeout",
@@ -110,6 +110,8 @@
110110
"utils/vendor/bin/php-cs-fixer fix --ansi --verbose --diff"
111111
],
112112
"metrics": "utils/vendor/bin/phpmetrics --config=phpmetrics.json",
113+
"phpstan:baseline": "vendor/bin/phpstan analyse --ansi --generate-baseline=phpstan-baseline.php",
114+
"phpstan:check": "vendor/bin/phpstan analyse --verbose --ansi",
113115
"sa": "@analyze",
114116
"style": "@cs-fix",
115117
"test": "phpunit"
@@ -119,6 +121,8 @@
119121
"cs": "Check the coding style",
120122
"cs-fix": "Fix the coding style",
121123
"metrics": "Run PhpMetrics",
124+
"phpstan:baseline": "Run PHPStan then dump all errors to baseline",
125+
"phpstan:check": "Run PHPStan with support for identifiers",
122126
"test": "Run unit tests"
123127
}
124128
}

system/Files/File.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ public function __construct(string $path, bool $checkFile = false)
5959
*
6060
* Implementations SHOULD return the value stored in the "size" key of
6161
* the file in the $_FILES array if available, as PHP calculates this based
62-
* on the actual size transmitted.
62+
* on the actual size transmitted. A RuntimeException will be thrown if the file
63+
* does not exist or an error occurs.
6364
*
6465
* @return false|int The file size in bytes, or false on failure
6566
*/

system/Throttle/Throttler.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,11 @@ public function check(string $key, int $capacity, int $seconds, int $cost = 1):
102102
// Number of seconds to get one token
103103
$refresh = 1 / $rate;
104104

105+
/** @var float|int|null $tokens */
106+
$tokens = $this->cache->get($tokenName);
107+
105108
// Check to see if the bucket has even been created yet.
106-
if (($tokens = $this->cache->get($tokenName)) === null) {
109+
if ($tokens === null) {
107110
// If it hasn't been created, then we'll set it to the maximum
108111
// capacity - 1, and save it to the cache.
109112
$tokens = $capacity - $cost;
@@ -124,7 +127,7 @@ public function check(string $key, int $capacity, int $seconds, int $cost = 1):
124127
// should be refilled, then checked against capacity
125128
// to be sure the bucket didn't overflow.
126129
$tokens += $rate * $elapsed;
127-
$tokens = $tokens > $capacity ? $capacity : $tokens;
130+
$tokens = min($tokens, $capacity);
128131

129132
// If $tokens >= 1, then we are safe to perform the action, but
130133
// we need to decrement the number of available tokens.

user_guide_src/source/database/query_builder.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,8 @@ Use the ``$db->newQuery()`` method to make a subquery the main table:
247247
Join
248248
====
249249

250+
.. _query-builder-join:
251+
250252
$builder->join()
251253
----------------
252254

@@ -270,7 +272,7 @@ RawSql
270272

271273
.. versionadded:: 4.2.0
272274

273-
Since v4.2.0, ``$builder->join()`` accepts a ``CodeIgniter\Database\RawSql`` instance, which expresses raw SQL strings.
275+
Since v4.2.0, ``$builder->join()`` accepts a ``CodeIgniter\Database\RawSql`` instance as the JOIN ON condition, which expresses raw SQL strings.
274276

275277
.. literalinclude:: query_builder/102.php
276278

@@ -1498,13 +1500,14 @@ Class Reference
14981500
.. php:method:: join($table, $cond[, $type = ''[, $escape = null]])
14991501
15001502
:param string $table: Table name to join
1501-
:param string $cond: The JOIN ON condition
1503+
:param string|RawSql $cond: The JOIN ON condition
15021504
:param string $type: The JOIN type
15031505
:param bool $escape: Whether to escape values and identifiers
15041506
:returns: ``BaseBuilder`` instance (method chaining)
15051507
:rtype: ``BaseBuilder``
15061508

1507-
Adds a ``JOIN`` clause to a query.
1509+
Adds a ``JOIN`` clause to a query. Since v4.2.0, ``RawSql`` can be used
1510+
as the JOIN ON condition. See also :ref:`query-builder-join`.
15081511

15091512
.. php:method:: where($key[, $value = null[, $escape = null]])
15101513

user_guide_src/source/libraries/files.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ Returns the size of the file in bytes:
5151
.. literalinclude:: files/004.php
5252
:lines: 2-
5353

54+
A ``RuntimeException`` will be thrown if the file does not exist or an error occurs.
55+
5456
getSizeByUnit()
5557
===============
5658

@@ -60,6 +62,8 @@ the results in kilobytes or megabytes, respectively:
6062
.. literalinclude:: files/005.php
6163
:lines: 2-
6264

65+
A ``RuntimeException`` will be thrown if the file does not exist or an error occurs.
66+
6367
getMimeType()
6468
=============
6569

0 commit comments

Comments
 (0)