Skip to content

Commit fea41d8

Browse files
committed
Merge remote-tracking branch 'upstream/develop' into 4.4
2 parents 7c76890 + d5b28fd commit fea41d8

File tree

5 files changed

+78
-38
lines changed

5 files changed

+78
-38
lines changed

system/HTTP/IncomingRequest.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ public function getDefaultLocale(): string
584584
*
585585
* @param array|string|null $index
586586
* @param int|null $filter Filter constant
587-
* @param mixed $flags
587+
* @param array|int|null $flags
588588
*
589589
* @return array|bool|float|int|stdClass|string|null
590590
*/
@@ -719,7 +719,7 @@ public function getRawInput()
719719
* @param int|null $filter Filter Constant
720720
* @param array|int|null $flags Option
721721
*
722-
* @return mixed
722+
* @return array|bool|float|int|object|string|null
723723
*/
724724
public function getRawInputVar($index = null, ?int $filter = null, $flags = null)
725725
{
@@ -771,9 +771,9 @@ public function getRawInputVar($index = null, ?int $filter = null, $flags = null
771771
*
772772
* @param array|string|null $index Index for item to fetch from $_GET.
773773
* @param int|null $filter A filter name to apply.
774-
* @param mixed|null $flags
774+
* @param array|int|null $flags
775775
*
776-
* @return mixed
776+
* @return array|bool|float|int|object|string|null
777777
*/
778778
public function getGet($index = null, $filter = null, $flags = null)
779779
{
@@ -785,9 +785,9 @@ public function getGet($index = null, $filter = null, $flags = null)
785785
*
786786
* @param array|string|null $index Index for item to fetch from $_POST.
787787
* @param int|null $filter A filter name to apply
788-
* @param mixed $flags
788+
* @param array|int|null $flags
789789
*
790-
* @return mixed
790+
* @return array|bool|float|int|object|string|null
791791
*/
792792
public function getPost($index = null, $filter = null, $flags = null)
793793
{
@@ -799,9 +799,9 @@ public function getPost($index = null, $filter = null, $flags = null)
799799
*
800800
* @param array|string|null $index Index for item to fetch from $_POST or $_GET
801801
* @param int|null $filter A filter name to apply
802-
* @param mixed $flags
802+
* @param array|int|null $flags
803803
*
804-
* @return mixed
804+
* @return array|bool|float|int|object|string|null
805805
*/
806806
public function getPostGet($index = null, $filter = null, $flags = null)
807807
{
@@ -821,9 +821,9 @@ public function getPostGet($index = null, $filter = null, $flags = null)
821821
*
822822
* @param array|string|null $index Index for item to be fetched from $_GET or $_POST
823823
* @param int|null $filter A filter name to apply
824-
* @param mixed $flags
824+
* @param array|int|null $flags
825825
*
826-
* @return mixed
826+
* @return array|bool|float|int|object|string|null
827827
*/
828828
public function getGetPost($index = null, $filter = null, $flags = null)
829829
{
@@ -843,9 +843,9 @@ public function getGetPost($index = null, $filter = null, $flags = null)
843843
*
844844
* @param array|string|null $index Index for item to be fetched from $_COOKIE
845845
* @param int|null $filter A filter name to be applied
846-
* @param mixed $flags
846+
* @param array|int|null $flags
847847
*
848-
* @return mixed
848+
* @return array|bool|float|int|object|string|null
849849
*/
850850
public function getCookie($index = null, $filter = null, $flags = null)
851851
{

system/HTTP/RequestTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ public function setGlobal(string $method, $value)
244244
* @param int|null $filter Filter constant
245245
* @param array|int|null $flags Options
246246
*
247-
* @return array|bool|string|null
247+
* @return array|bool|float|int|object|string|null
248248
*/
249249
public function fetchGlobal(string $method, $index = null, ?int $filter = null, $flags = null)
250250
{

user_guide_src/source/general/configuration.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ One of today's best practices for application setup is to use Environment Variab
6363

6464
Environment Variables should also be used for anything private such as passwords, API keys, or other sensitive data.
6565

66+
.. _dotenv-file:
67+
6668
Environment Variables and CodeIgniter
6769
=====================================
6870

user_guide_src/source/general/environments.rst

Lines changed: 53 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,44 @@ tools loaded that you don't in production environments, etc.
1111

1212
.. contents::
1313
:local:
14-
:depth: 2
14+
:depth: 3
15+
16+
************************
17+
The Defined Environments
18+
************************
19+
20+
By default, CodeIgniter has three environments defined.
21+
22+
- ``production`` for production
23+
- ``development`` for development
24+
- ``testing`` for PHPUnit testing
25+
26+
.. important:: The environment ``testing`` is reserved for PHPUnit testing. It
27+
has special conditions built into the framework at various places to assist
28+
with that. You can't use it for your development.
29+
30+
If you want another environment, e.g., for staging, you can add custom environments.
31+
See `Adding Environments`_.
32+
33+
*******************
34+
Setting Environment
35+
*******************
1536

1637
.. _environment-constant:
1738

1839
The ENVIRONMENT Constant
1940
========================
2041

21-
By default, CodeIgniter comes with the ``ENVIRONMENT`` constant set to use
22-
the value provided in ``$_SERVER['CI_ENVIRONMENT']``, otherwise defaulting to
23-
``production``. This can be set in several ways depending on your server setup.
24-
25-
.. note:: The environment ``testing`` is the special one for PHPUnit testing.
26-
It has special conditions built into the framework at various places to assist with that.
27-
You can't use it for your development.
42+
To set your environment, CodeIgniter comes with the ``ENVIRONMENT`` constant.
43+
If you set ``$_SERVER['CI_ENVIRONMENT']``, the value will be used,
44+
otherwise defaulting to ``production``.
2845

29-
.. note:: You can check the current environment by ``spark env`` command::
30-
31-
> php spark env
46+
This can be set in several ways depending on your server setup.
3247

3348
.env
3449
----
3550

36-
The simplest method to set the variable is in your :doc:`.env file </general/configuration>`.
51+
The simplest method to set the variable is in your :ref:`.env file <dotenv-file>`.
3752

3853
.. code-block:: ini
3954
@@ -88,8 +103,14 @@ In addition to affecting some basic framework behavior (see the next
88103
section), you may use this constant in your own development to
89104
differentiate between which environment you are running in.
90105

106+
*******************
107+
Adding Environments
108+
*******************
109+
110+
To add custom environments, you just need to add boot files for them.
111+
91112
Boot Files
92-
----------
113+
==========
93114

94115
CodeIgniter requires that a PHP script matching the environment's name is located
95116
under **APPPATH/Config/Boot**. These files can contain any customizations that
@@ -102,15 +123,32 @@ a fresh install:
102123
* production.php
103124
* testing.php
104125

126+
For example, if you want to add ``staging`` environment for staging, all you need
127+
to do is:
128+
129+
1. copy **APPPATH/Config/Boot/production.php** to **staging.php**.
130+
2. customize settings in **staging.php** if you want.
131+
132+
**********************************
133+
Confirming the Current Environment
134+
**********************************
135+
136+
To confirm the current environment, simply echo the constant ``ENVIRONMENT``.
137+
138+
You can also check the current environment by ``spark env`` command::
139+
140+
> php spark env
141+
142+
*************************************
105143
Effects on Default Framework Behavior
106-
=====================================
144+
*************************************
107145

108146
There are some places in the CodeIgniter system where the ``ENVIRONMENT``
109147
constant is used. This section describes how default framework behavior
110148
is affected.
111149

112150
Error Reporting
113-
---------------
151+
===============
114152

115153
Setting the ``ENVIRONMENT`` constant to a value of ``development`` will cause
116154
all PHP errors to be rendered to the browser when they occur.

user_guide_src/source/incoming/incomingrequest.rst

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ The methods provided by the parent classes that are available are:
321321
:param int $flags: Flags to apply. A list of flags can be found
322322
`here <https://www.php.net/manual/en/filter.filters.flags.php>`__.
323323
:returns: ``$_REQUEST`` if no parameters supplied, otherwise the REQUEST value if found, or null if not
324-
:rtype: mixed|null
324+
:rtype: array|bool|float|int|object|string|null
325325

326326
The first parameter will contain the name of the REQUEST item you are looking for:
327327

@@ -360,7 +360,7 @@ The methods provided by the parent classes that are available are:
360360
:param int $flags: Flags to apply. A list of flags can be found
361361
`here <https://www.php.net/manual/en/filter.filters.flags.php>`__.
362362
:returns: ``$_GET`` if no parameters supplied, otherwise the GET value if found, or null if not
363-
:rtype: mixed|null
363+
:rtype: array|bool|float|int|object|string|null
364364

365365
This method is identical to ``getVar()``, only it fetches GET data.
366366

@@ -372,7 +372,7 @@ The methods provided by the parent classes that are available are:
372372
:param int $flags: Flags to apply. A list of flags can be found
373373
`here <https://www.php.net/manual/en/filter.filters.flags.php>`__.
374374
:returns: ``$_POST`` if no parameters supplied, otherwise the POST value if found, or null if not
375-
:rtype: mixed|null
375+
:rtype: array|bool|float|int|object|string|null
376376

377377
This method is identical to ``getVar()``, only it fetches POST data.
378378

@@ -385,7 +385,7 @@ The methods provided by the parent classes that are available are:
385385
`here <https://www.php.net/manual/en/filter.filters.flags.php>`__.
386386
:returns: ``$_POST`` and ``$_GET`` combined if no parameters specified (prefer POST value on conflict),
387387
otherwise looks for POST value, if nothing found looks for GET value, if no value found returns null
388-
:rtype: mixed|null
388+
:rtype: array|bool|float|int|object|string|null
389389

390390
This method works pretty much the same way as ``getPost()`` and ``getGet()``, only combined.
391391
It will search through both POST and GET streams for data, looking first in POST, and
@@ -405,7 +405,7 @@ The methods provided by the parent classes that are available are:
405405
`here <https://www.php.net/manual/en/filter.filters.flags.php>`__.
406406
:returns: ``$_GET`` and ``$_POST`` combined if no parameters specified (prefer GET value on conflict),
407407
otherwise looks for GET value, if nothing found looks for POST value, if no value found returns null
408-
:rtype: mixed|null
408+
:rtype: array|bool|float|int|object|string|null
409409

410410
This method works pretty much the same way as ``getPost()`` and ``getGet()``, only combined.
411411
It will search through both GET and POST streams for data, looking first in GET, and
@@ -418,13 +418,13 @@ The methods provided by the parent classes that are available are:
418418

419419
.. php:method:: getCookie([$index = null[, $filter = null[, $flags = null]]])
420420
421-
:param mixed $index: COOKIE name
421+
:param array|string|null $index: COOKIE name
422422
:param int $filter: The type of filter to apply. A list of filters can be
423423
found `here <https://www.php.net/manual/en/filter.filters.php>`__.
424424
:param int $flags: Flags to apply. A list of flags can be found
425425
`here <https://www.php.net/manual/en/filter.filters.flags.php>`__.
426426
:returns: ``$_COOKIE`` if no parameters supplied, otherwise the COOKIE value if found or null if not
427-
:rtype: mixed
427+
:rtype: array|bool|float|int|object|string|null
428428

429429
This method is identical to ``getPost()`` and ``getGet()``, only it fetches cookie data:
430430

@@ -440,13 +440,13 @@ The methods provided by the parent classes that are available are:
440440

441441
.. php:method:: getServer([$index = null[, $filter = null[, $flags = null]]])
442442
443-
:param mixed $index: Value name
443+
:param array|string|null $index: Value name
444444
:param int $filter: The type of filter to apply. A list of filters can be
445445
found `here <https://www.php.net/manual/en/filter.filters.php>`__.
446446
:param int $flags: Flags to apply. A list of flags can be found
447447
`here <https://www.php.net/manual/en/filter.filters.flags.php>`__.
448448
:returns: ``$_SERVER`` item value if found, null if not
449-
:rtype: mixed
449+
:rtype: array|bool|float|int|object|string|null
450450

451451
This method is identical to the ``getPost()``, ``getGet()`` and ``getCookie()``
452452
methods, only it fetches getServer data (``$_SERVER``):
@@ -463,7 +463,7 @@ The methods provided by the parent classes that are available are:
463463
:param int $filter: The type of filter to apply. A list of filters can be
464464
found `here <https://www.php.net/manual/en/filter.filters.php>`__.
465465
:returns: The User Agent string, as found in the SERVER data, or null if not found.
466-
:rtype: mixed
466+
:rtype: CodeIgniter\\HTTP\\UserAgent
467467

468468
This method returns the User Agent string from the SERVER data:
469469

0 commit comments

Comments
 (0)