Skip to content

Commit 7bdecb5

Browse files
committed
Merge remote-tracking branch 'upstream/develop' into 4.3
2 parents 59614de + 57385ea commit 7bdecb5

File tree

11 files changed

+82
-22
lines changed

11 files changed

+82
-22
lines changed

composer.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,11 @@
7171
"CodeIgniter\\ComposerScripts::postUpdate",
7272
"bash -c \"if [ -f admin/setup.sh ]; then bash admin/setup.sh; fi\""
7373
],
74-
"analyze": "phpstan analyse",
74+
"analyze": [
75+
"phpstan analyze",
76+
"rector process --dry-run"
77+
],
78+
"sa": "@analyze",
7579
"test": "phpunit",
7680
"cs": [
7781
"php-cs-fixer fix --ansi --verbose --dry-run --diff --config=.php-cs-fixer.user-guide.php",
@@ -82,7 +86,8 @@
8286
"php-cs-fixer fix --ansi --verbose --diff --config=.php-cs-fixer.user-guide.php",
8387
"php-cs-fixer fix --ansi --verbose --diff --config=.php-cs-fixer.no-header.php",
8488
"php-cs-fixer fix --ansi --verbose --diff"
85-
]
89+
],
90+
"style": "@cs-fix"
8691
},
8792
"scripts-descriptions": {
8893
"analyze": "Run static analysis",

contributing/pull_request.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,6 @@ The best way to contribute is to fork the CodeIgniter4 repository, and "clone" t
252252
- Commit messages are expected to be descriptive of why and what you changed specifically. Commit messages like "Fixes #1234" would be asked by the reviewer to be revised. [Atomic commit](https://en.wikipedia.org/wiki/Atomic_commit#Atomic_commit_convention) is recommended. See [Contribution Workflow](./workflow.md#commit-messages) for details.
253253
9. If you have touched PHP code, run static analysis.
254254
- `> composer analyze`
255-
- `> vendor/bin/rector process`
256255
10. Run unit tests on the specific file you modified. If there are no existing tests yet, please create one.
257256
- `> vendor/bin/phpunit tests/system/path/to/file/you/modified`
258257
- Make sure the tests pass to have a higher chance of merging.

contributing/workflow.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Clone your repository, leaving a local folder for you to work with:
6666
> git clone ORIGIN_URL
6767
```
6868

69-
## Syncing your repository
69+
## Syncing Your Repository
7070

7171
Within your local repository, Git will have created an alias,
7272
**origin**, for the GitHub repository it is bound to. You want to create
@@ -179,7 +179,11 @@ For instance, to commit your work from a debugging session:
179179

180180
Just make sure that your commits in a feature branch are all related.
181181

182-
### When you work on two features
182+
### Changing a Commit Message
183+
184+
See <https://docs.github.com/en/pull-requests/committing-changes-to-your-project/creating-and-editing-commits/changing-a-commit-message>.
185+
186+
### When You Work on Two Features
183187

184188
If you are working on two features at a time, then you will want to
185189
switch between them to keep the contributions separate. For instance:
@@ -314,7 +318,7 @@ And finally push your local branch to your GitHub repository:
314318
> git push --force-with-lease origin fix/problem123
315319
```
316320

317-
## If you sent to the wrong branch
321+
## If You Sent to the Wrong Branch
318322

319323
If you have sent a PR to the wrong branch, you need to create a new PR branch.
320324

system/Entity/Entity.php

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
use CodeIgniter\Entity\Cast\URICast;
2727
use CodeIgniter\Entity\Exceptions\CastException;
2828
use CodeIgniter\I18n\Time;
29+
use DateTime;
2930
use Exception;
3031
use JsonSerializable;
3132
use ReturnTypeWillChange;
@@ -149,7 +150,7 @@ public function fill(?array $data = null)
149150
*
150151
* @param bool $onlyChanged If true, only return values that have changed since object creation
151152
* @param bool $cast If true, properties will be cast.
152-
* @param bool $recursive If true, inner entities will be casted as array as well.
153+
* @param bool $recursive If true, inner entities will be cast as array as well.
153154
*/
154155
public function toArray(bool $onlyChanged = false, bool $cast = true, bool $recursive = false): array
155156
{
@@ -191,7 +192,7 @@ public function toArray(bool $onlyChanged = false, bool $cast = true, bool $recu
191192
* Returns the raw values of the current attributes.
192193
*
193194
* @param bool $onlyChanged If true, only return values that have changed since object creation
194-
* @param bool $recursive If true, inner entities will be casted as array as well.
195+
* @param bool $recursive If true, inner entities will be cast as array as well.
195196
*/
196197
public function toRawArray(bool $onlyChanged = false, bool $recursive = false): array
197198
{
@@ -249,7 +250,7 @@ public function syncOriginal()
249250
* was created. Or, without a parameter, checks if any
250251
* properties have changed.
251252
*
252-
* @param string $key
253+
* @param string|null $key class property
253254
*/
254255
public function hasChanged(?string $key = null): bool
255256
{
@@ -310,11 +311,11 @@ protected function mapProperty(string $key)
310311
* Converts the given string|timestamp|DateTime|Time instance
311312
* into the "CodeIgniter\I18n\Time" object.
312313
*
313-
* @param mixed $value
314+
* @param DateTime|float|int|string|Time $value
314315
*
315316
* @throws Exception
316317
*
317-
* @return mixed|Time
318+
* @return Time
318319
*/
319320
protected function mutateDate($value)
320321
{
@@ -326,13 +327,13 @@ protected function mutateDate($value)
326327
* Add ? at the beginning of $type (i.e. ?string) to get NULL
327328
* instead of casting $value if $value === null
328329
*
329-
* @param mixed $value Attribute value
330-
* @param string $attribute Attribute name
331-
* @param string $method Allowed to "get" and "set"
330+
* @param bool|float|int|string|null $value Attribute value
331+
* @param string $attribute Attribute name
332+
* @param string $method Allowed to "get" and "set"
332333
*
333334
* @throws CastException
334335
*
335-
* @return mixed
336+
* @return array|bool|float|int|object|string|null
336337
*/
337338
protected function castAs($value, string $attribute, string $method = 'get')
338339
{
@@ -426,7 +427,7 @@ public function cast(?bool $cast = null)
426427
* $this->my_property = $p;
427428
* $this->setMyProperty() = $p;
428429
*
429-
* @param mixed|null $value
430+
* @param array|bool|float|int|object|string|null $value
430431
*
431432
* @throws Exception
432433
*
@@ -472,8 +473,9 @@ public function __set(string $key, $value = null)
472473
* $p = $this->getMyProperty()
473474
*
474475
* @throws Exception
476+
* @params string $key class property
475477
*
476-
* @return mixed
478+
* @return array|bool|float|int|object|string|null
477479
*/
478480
public function __get(string $key)
479481
{

system/Validation/FileRules.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace CodeIgniter\Validation;
1313

14+
use CodeIgniter\HTTP\CLIRequest;
1415
use CodeIgniter\HTTP\IncomingRequest;
1516
use CodeIgniter\HTTP\Request;
1617
use CodeIgniter\HTTP\RequestInterface;
@@ -39,7 +40,7 @@ public function __construct(?RequestInterface $request = null)
3940
$request = Services::request();
4041
}
4142

42-
assert($request instanceof IncomingRequest);
43+
assert($request instanceof IncomingRequest || $request instanceof CLIRequest);
4344

4445
$this->request = $request;
4546
}

tests/system/I18n/TimeDifferenceTest.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,23 @@
1919
*/
2020
final class TimeDifferenceTest extends CIUnitTestCase
2121
{
22+
private string $currentLocale;
23+
2224
protected function setUp(): void
2325
{
2426
parent::setUp();
2527

2628
helper('date');
27-
Locale::setDefault('America/Chicago');
29+
30+
$this->currentLocale = Locale::getDefault();
31+
Locale::setDefault('en-US');
32+
}
33+
34+
protected function tearDown(): void
35+
{
36+
parent::tearDown();
37+
38+
Locale::setDefault($this->currentLocale);
2839
}
2940

3041
public function testDifferenceBasics()

tests/system/I18n/TimeTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,25 @@
2525
*/
2626
final class TimeTest extends CIUnitTestCase
2727
{
28+
private string $currentLocale;
29+
2830
protected function setUp(): void
2931
{
3032
parent::setUp();
3133

3234
helper('date');
35+
36+
$this->currentLocale = Locale::getDefault();
3337
Locale::setDefault('en_US');
3438
}
3539

40+
protected function tearDown(): void
41+
{
42+
parent::tearDown();
43+
44+
Locale::setDefault($this->currentLocale);
45+
}
46+
3647
public function testNewTimeNow()
3748
{
3849
$formatter = new IntlDateFormatter(

user_guide_src/source/database/metadata.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ database:
103103
- name - column name
104104
- type - the type of the column
105105
- max_length - maximum length of the column
106-
- primary_key - integer ``1`` if the column is a primary key (all integer ``1``, even if there are multiple primary keys), otherwise integer ``0``
107-
- nullable - boolean ``true`` if the column is nullable, otherwise boolean ``false``
106+
- primary_key - integer ``1`` if the column is a primary key (all integer ``1``, even if there are multiple primary keys), otherwise integer ``0`` (This field is currently only available for MySQL and SQLite3)
107+
- nullable - boolean ``true`` if the column is nullable, otherwise boolean ``false`` (This field is currently not available in SQL Server)
108108
- default - the default value
109109

110110
List the Indexes in a Table

user_guide_src/source/incoming/routing.rst

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,23 @@ You can supply multiple verbs that a route should match by passing them in as an
4747

4848
.. literalinclude:: routing/004.php
4949

50+
Controller's Namespace
51+
======================
52+
53+
If a controller name is stated without beginning with ``\``, the :ref:`routing-default-namespace` will be prepended:
54+
55+
.. literalinclude:: routing/063.php
56+
57+
If you put ``\`` at the beginning, it is treated as a fully qualified class name:
58+
59+
.. literalinclude:: routing/064.php
60+
61+
You can also specify the namespace with the ``namespace`` option:
62+
63+
.. literalinclude:: routing/038.php
64+
65+
See :ref:`assigning-namespace` for details.
66+
5067
Placeholders
5168
============
5269

@@ -397,7 +414,7 @@ You specify an array for the filter value:
397414
Assigning Namespace
398415
-------------------
399416

400-
While a default namespace will be prepended to the generated controllers (see below), you can also specify
417+
While a :ref:`routing-default-namespace` will be prepended to the generated controllers, you can also specify
401418
a different namespace to be used in any options array, with the ``namespace`` option. The value should be the
402419
namespace you want modified:
403420

@@ -483,6 +500,8 @@ Routes Configuration Options
483500
The RoutesCollection class provides several options that affect all routes, and can be modified to meet your
484501
application's needs. These options are available at the top of **app/Config/Routes.php**.
485502

503+
.. _routing-default-namespace:
504+
486505
Default Namespace
487506
=================
488507

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?php
2+
3+
// Routes to \App\Controllers\Api\Users::update()
4+
$routes->post('api/users', 'Api\Users::update');
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?php
2+
3+
// Routes to \Acme\Blog\Controllers\Home::list()
4+
$routes->get('blog', '\Acme\Blog\Controllers\Home::list');

0 commit comments

Comments
 (0)