diff --git a/system/HTTP/CURLRequest.php b/system/HTTP/CURLRequest.php index 8b30f127863b..9b12d0c1c699 100644 --- a/system/HTTP/CURLRequest.php +++ b/system/HTTP/CURLRequest.php @@ -313,7 +313,7 @@ public function setJSON($data) protected function parseOptions(array $options) { if (array_key_exists('baseURI', $options)) { - $this->baseURI = $this->baseURI->setURI($options['baseURI']); + $this->baseURI = (new URI($options['baseURI']))->useRawQueryString(); unset($options['baseURI']); } diff --git a/system/HTTP/Message.php b/system/HTTP/Message.php index 525bf1b49eec..bb319bf82bc1 100644 --- a/system/HTTP/Message.php +++ b/system/HTTP/Message.php @@ -60,39 +60,6 @@ public function getBody() return $this->body; } - /** - * Returns an array containing all headers. - * - * @return array An array of the request headers - * - * @deprecated 4.0.5 Use Message::headers() to make room for PSR-7 - * - * @TODO Incompatible return value with PSR-7 - * - * @codeCoverageIgnore - */ - public function getHeaders(): array - { - return $this->headers(); - } - - /** - * Returns a single header object. If multiple headers with the same - * name exist, then will return an array of header objects. - * - * @return array|Header|null - * - * @deprecated 4.0.5 Use Message::header() to make room for PSR-7 - * - * @TODO Incompatible return value with PSR-7 - * - * @codeCoverageIgnore - */ - public function getHeader(string $name) - { - return $this->header($name); - } - /** * Determines whether a header exists. */ diff --git a/system/HTTP/RequestTrait.php b/system/HTTP/RequestTrait.php index da0250555b7c..ecc2aff04bab 100644 --- a/system/HTTP/RequestTrait.php +++ b/system/HTTP/RequestTrait.php @@ -36,12 +36,8 @@ trait RequestTrait /** * IP address of the current user. - * - * @var string - * - * @deprecated 4.0.5 Will become private in a future release */ - protected $ipAddress = ''; + private string $ipAddress = ''; /** * Stores values we've retrieved from PHP globals. @@ -78,11 +74,11 @@ public function getIPAddress(): string ); } - $this->ipAddress = $this->getServer('REMOTE_ADDR'); + $this->ipAddress = $this->getServer('REMOTE_ADDR') ?? '0.0.0.0'; - // If this is a CLI request, $this->ipAddress is null. - if ($this->ipAddress === null) { - return $this->ipAddress = '0.0.0.0'; + // If this is a CLI request, $this->ipAddress is '0.0.0.0'. + if ($this->ipAddress === '0.0.0.0') { + return $this->ipAddress; } // @TODO Extract all this IP address logic to another class. @@ -206,23 +202,6 @@ public function getServer($index = null, $filter = null, $flags = null) return $this->fetchGlobal('server', $index, $filter, $flags); } - /** - * Fetch an item from the $_ENV array. - * - * @param array|string|null $index Index for item to be fetched from $_ENV - * @param int|null $filter A filter name to be applied - * @param array|int|null $flags - * - * @return mixed - * - * @deprecated 4.4.4 This method does not work from the beginning. Use `env()`. - */ - public function getEnv($index = null, $filter = null, $flags = null) - { - // @phpstan-ignore-next-line - return $this->fetchGlobal('env', $index, $filter, $flags); - } - /** * Allows manually setting the value of PHP global, like $_GET, $_POST, etc. * diff --git a/system/HTTP/SiteURI.php b/system/HTTP/SiteURI.php index dbc241b3c2d7..dc4224455fc6 100644 --- a/system/HTTP/SiteURI.php +++ b/system/HTTP/SiteURI.php @@ -13,7 +13,6 @@ namespace CodeIgniter\HTTP; -use CodeIgniter\Exceptions\BadMethodCallException; use CodeIgniter\Exceptions\ConfigException; use CodeIgniter\HTTP\Exceptions\HTTPException; use Config\App; @@ -53,26 +52,10 @@ class SiteURI extends URI * 1 => 'public', * 2 => 'index.php', * ]; - */ - private array $baseSegments; - - /** - * List of URI segments after indexPage. - * - * The word "URI Segments" originally means only the URI path part relative - * to the baseURL. - * - * If the URI is "http://localhost:8888/ci431/public/index.php/test?a=b", - * and the baseURL is "http://localhost:8888/ci431/public/", then: - * $segments = [ - * 0 => 'test', - * ]; * - * @var array - * - * @deprecated 4.4.0 This property will be private. + * @var list */ - protected $segments; + private array $baseSegments; /** * URI path relative to baseURL. @@ -149,9 +132,9 @@ private function determineBaseURL( // Update scheme if ($scheme !== null && $scheme !== '') { - $uri->setScheme($scheme); + $uri = $uri->withScheme($scheme); } elseif ($configApp->forceGlobalSecureRequests) { - $uri->setScheme('https'); + $uri = $uri->withScheme('https'); } // Update host @@ -219,26 +202,10 @@ private function setBasePath(): void } } - /** - * @deprecated 4.4.0 - */ - public function setBaseURL(string $baseURL): void - { - throw new BadMethodCallException('Cannot use this method.'); - } - - /** - * @deprecated 4.4.0 - */ - public function setURI(?string $uri = null) - { - throw new BadMethodCallException('Cannot use this method.'); - } - /** * Returns the baseURL. * - * @interal + * @internal */ public function getBaseURL(): string { @@ -298,23 +265,21 @@ private function setRoutePath(string $routePath): void } /** - * Converts path to segments + * @return list */ private function convertToSegments(string $path): array { $tempPath = trim($path, '/'); - return ($tempPath === '') ? [] : explode('/', $tempPath); + return $tempPath === '' ? [] : explode('/', $tempPath); } /** * Sets the path portion of the URI based on segments. * * @return $this - * - * @deprecated 4.4.0 This method will be private. */ - public function refreshPath() + protected function refreshPath(): self { $allSegments = array_merge($this->baseSegments, $this->segments); $this->path = '/' . $this->filterPath(implode('/', $allSegments)); @@ -364,11 +329,7 @@ protected function applyParts(array $parts): void $this->fragment = $parts['fragment']; } - if (isset($parts['scheme'])) { - $this->setScheme(rtrim($parts['scheme'], ':/')); - } else { - $this->setScheme('http'); - } + $this->scheme = $this->withScheme($parts['scheme'] ?? 'http')->getScheme(); if (isset($parts['port'])) { // Valid port numbers are enforced by earlier parse_url or setPort() diff --git a/system/HTTP/URI.php b/system/HTTP/URI.php index d89b5b00caa5..304e06103313 100644 --- a/system/HTTP/URI.php +++ b/system/HTTP/URI.php @@ -13,7 +13,6 @@ namespace CodeIgniter\HTTP; -use CodeIgniter\Exceptions\BadMethodCallException; use CodeIgniter\Exceptions\InvalidArgumentException; use CodeIgniter\HTTP\Exceptions\HTTPException; use Config\App; @@ -37,22 +36,6 @@ class URI implements Stringable */ public const CHAR_UNRESERVED = 'a-zA-Z0-9_\-\.~'; - /** - * Current URI string - * - * @var string - * - * @deprecated 4.4.0 Not used. - */ - protected $uriString; - - /** - * The Current baseURL. - * - * @deprecated 4.4.0 Use SiteURI instead. - */ - private ?string $baseURL = null; - /** * List of URI segments. * @@ -262,7 +245,7 @@ public static function removeDotSegments(string $path): string */ public function __construct(?string $uri = null) { - $this->setURI($uri); + $this->setUri($uri); } /** @@ -275,6 +258,8 @@ public function __construct(?string $uri = null) */ public function setSilent(bool $silent = true) { + @trigger_error(sprintf('The %s method is deprecated and will be removed in CodeIgniter 5.0.', __METHOD__), E_USER_DEPRECATED); + $this->silent = $silent; return $this; @@ -298,13 +283,9 @@ public function useRawQueryString(bool $raw = true) /** * Sets and overwrites any current URI information. * - * @return URI - * * @throws HTTPException - * - * @deprecated 4.4.0 This method will be private. */ - public function setURI(?string $uri = null) + private function setUri(?string $uri = null): self { if ($uri === null) { return $this; @@ -336,9 +317,7 @@ public function setURI(?string $uri = null) * The trailing ":" character is not part of the scheme and MUST NOT be * added. * - * @see https://tools.ietf.org/html/rfc3986#section-3.1 - * - * @return string The URI scheme. + * @see https://tools.ietf.org/html/rfc3986#section-3.1 */ public function getScheme(): string { @@ -711,26 +690,6 @@ public function setAuthority(string $str) return $this; } - /** - * Sets the scheme for this URI. - * - * Because of the large number of valid schemes we cannot limit this - * to only http or https. - * - * @see https://www.iana.org/assignments/uri-schemes/uri-schemes.xhtml - * - * @return $this - * - * @deprecated 4.4.0 Use `withScheme()` instead. - */ - public function setScheme(string $str) - { - $str = strtolower($str); - $this->scheme = preg_replace('#:(//)?$#', '', $str); - - return $this; - } - /** * Return an instance with the specified scheme. * @@ -835,42 +794,12 @@ public function setPath(string $path) return $this; } - /** - * Sets the current baseURL. - * - * @interal - * - * @deprecated 4.4.0 Use SiteURI instead. - */ - public function setBaseURL(string $baseURL): void - { - $this->baseURL = $baseURL; - } - - /** - * Returns the current baseURL. - * - * @interal - * - * @deprecated 4.4.0 Use SiteURI instead. - */ - public function getBaseURL(): string - { - if ($this->baseURL === null) { - throw new BadMethodCallException('The $baseURL is not set.'); - } - - return $this->baseURL; - } - /** * Sets the path portion of the URI based on segments. * * @return $this - * - * @deprecated 4.4.0 This method will be private. */ - public function refreshPath() + protected function refreshPath(): self { $this->path = $this->filterPath(implode('/', $this->segments)); @@ -1077,11 +1006,7 @@ protected function applyParts(array $parts) $this->fragment = $parts['fragment']; } - if (isset($parts['scheme'])) { - $this->setScheme(rtrim($parts['scheme'], ':/')); - } else { - $this->setScheme('http'); - } + $this->scheme = $this->withScheme($parts['scheme'] ?? 'http')->getScheme(); if (isset($parts['port'])) { // Valid port numbers are enforced by earlier parse_url or setPort() @@ -1113,11 +1038,10 @@ public function resolveRelativeURI(string $uri) * NOTE: We don't use removeDotSegments in this * algorithm since it's already done by this line! */ - $relative = new self(); - $relative->setURI($uri); + $relative = new self($uri); if ($relative->getScheme() === $this->getScheme()) { - $relative->setScheme(''); + $relative = $relative->withScheme(''); } $transformed = clone $relative; @@ -1150,8 +1074,7 @@ public function resolveRelativeURI(string $uri) $transformed->setAuthority($this->getAuthority()); } - $transformed->setScheme($this->getScheme()); - + $transformed = $transformed->withScheme($this->getScheme()); $transformed->setFragment($relative->getFragment()); return $transformed; diff --git a/system/Language/en/HTTP.php b/system/Language/en/HTTP.php index 911e182a1fd3..7321253e7196 100644 --- a/system/Language/en/HTTP.php +++ b/system/Language/en/HTTP.php @@ -57,10 +57,6 @@ 'methodNotFound' => 'Controller method is not found: "{0}"', 'localeNotSupported' => 'Locale is not supported: {0}', - // CSRF - // @deprecated 4.0.5 use 'Security.disallowedAction' - 'disallowedAction' => 'The action you requested is not allowed.', - // Uploaded file moving 'alreadyMoved' => 'The uploaded file has already been moved.', 'invalidFile' => 'The original file is not a valid file.', diff --git a/system/Pager/Pager.php b/system/Pager/Pager.php index e1c38edf3594..c89bb7ebdd88 100644 --- a/system/Pager/Pager.php +++ b/system/Pager/Pager.php @@ -427,7 +427,7 @@ protected function calculateCurrentPage(string $group) if (array_key_exists($group, $this->segment)) { try { $this->groups[$group]['currentPage'] = (int) $this->groups[$group]['currentUri'] - ->setSilent(false)->getSegment($this->segment[$group]); + ->getSegment($this->segment[$group]); } catch (HTTPException) { $this->groups[$group]['currentPage'] = 1; } diff --git a/tests/system/HTTP/IncomingRequestTest.php b/tests/system/HTTP/IncomingRequestTest.php index 509cf69643d2..aec26069fdcf 100644 --- a/tests/system/HTTP/IncomingRequestTest.php +++ b/tests/system/HTTP/IncomingRequestTest.php @@ -174,16 +174,6 @@ public function testCanGrabServerVars(): void $this->assertNull($this->request->getServer('TESTY')); } - public function testCanGrabEnvVars(): void - { - $server = $this->getPrivateProperty($this->request, 'globals'); - $server['env']['TEST'] = 5; - $this->setPrivateProperty($this->request, 'globals', $server); - - $this->assertSame('5', $this->request->getEnv('TEST')); - $this->assertNull($this->request->getEnv('TESTY')); - } - public function testCanGrabCookieVars(): void { service('superglobals')->setCookie('TEST', '5'); diff --git a/tests/system/HTTP/SiteURITest.php b/tests/system/HTTP/SiteURITest.php index 1208edaf05b9..15e835b92d2c 100644 --- a/tests/system/HTTP/SiteURITest.php +++ b/tests/system/HTTP/SiteURITest.php @@ -13,7 +13,6 @@ namespace CodeIgniter\HTTP; -use CodeIgniter\Exceptions\BadMethodCallException; use CodeIgniter\Exceptions\ConfigException; use CodeIgniter\HTTP\Exceptions\HTTPException; use CodeIgniter\Test\CIUnitTestCase; @@ -386,17 +385,6 @@ public function testSetSegmentOutOfRange(): void $uri->setSegment(4, 'four'); } - public function testSetSegmentSilentOutOfRange(): void - { - $config = new App(); - $uri = new SiteURI($config); - $uri->setPath('one/method'); - $uri->setSilent(); - - $uri->setSegment(4, 'four'); - $this->assertSame(['one', 'method'], $uri->getSegments()); - } - public function testSetSegmentZero(): void { $this->expectException(HTTPException::class); @@ -472,26 +460,6 @@ public function testGetTotalSegments(): void $this->assertSame(0, $uri->getTotalSegments()); } - public function testSetURI(): void - { - $this->expectException(BadMethodCallException::class); - - $config = new App(); - $uri = new SiteURI($config); - - $uri->setURI('http://another.site.example.jp/'); - } - - public function testSetBaseURI(): void - { - $this->expectException(BadMethodCallException::class); - - $config = new App(); - $uri = new SiteURI($config); - - $uri->setBaseURL('http://another.site.example.jp/'); - } - public function testGetBaseURL(): void { $config = new App(); diff --git a/tests/system/HTTP/URITest.php b/tests/system/HTTP/URITest.php index c449d13af65c..a624a8996fd2 100644 --- a/tests/system/HTTP/URITest.php +++ b/tests/system/HTTP/URITest.php @@ -68,14 +68,6 @@ public function testSegmentOutOfRange(): void $uri->getSegment(5); } - public function testSegmentOutOfRangeWithSilent(): void - { - $url = 'http://abc.com/a123/b/c'; - $uri = new URI($url); - - $this->assertSame('', $uri->setSilent()->getSegment(22)); - } - public function testSegmentOutOfRangeWithDefaultValue(): void { $this->expectException(HTTPException::class); @@ -85,40 +77,6 @@ public function testSegmentOutOfRangeWithDefaultValue(): void $uri->getSegment(22, 'something'); } - public function testSegmentOutOfRangeWithSilentAndDefaultValue(): void - { - $url = 'http://abc.com/a123/b/c'; - $uri = new URI($url); - - $this->assertSame('something', $uri->setSilent()->getSegment(22, 'something')); - } - - public function testSegmentsWithDefaultValueAndSilent(): void - { - $uri = new URI('http://hostname/path/to'); - $uri->setSilent(); - - $this->assertSame(['path', 'to'], $uri->getSegments()); - $this->assertSame('path', $uri->getSegment(1)); - $this->assertSame('to', $uri->getSegment(2, 'different')); - $this->assertSame('script', $uri->getSegment(3, 'script')); - $this->assertSame('', $uri->getSegment(3)); - - $this->assertSame(2, $uri->getTotalSegments()); - } - - public function testSegmentOutOfRangeWithDefaultValuesAndSilent(): void - { - $uri = new URI('http://hostname/path/to/script'); - $uri->setSilent(); - - $this->assertSame('', $uri->getSegment(22)); - $this->assertSame('something', $uri->getSegment(33, 'something')); - - $this->assertSame(3, $uri->getTotalSegments()); - $this->assertSame(['path', 'to', 'script'], $uri->getSegments()); - } - public function testCanCastAsString(): void { $url = 'http://username:password@hostname:9090/path?arg=value#anchor'; @@ -222,21 +180,18 @@ public function testMissingScheme(): void public function testSchemeSub(): void { - $url = 'example.com'; - $uri = new URI('http://' . $url); - $uri->setScheme('x'); + $uri = (new URI('http://example.com'))->withScheme('x'); - $this->assertSame('x://' . $url, (string) $uri); + $this->assertSame('x://example.com', (string) $uri); } public function testSetSchemeSetsValue(): void { $url = 'http://example.com/path'; - $uri = new URI($url); - - $uri->setScheme('https'); + $uri = (new URI($url))->withScheme('https'); $this->assertSame('https', $uri->getScheme()); + $expected = 'https://example.com/path'; $this->assertSame($expected, (string) $uri); } @@ -347,16 +302,6 @@ public function testSetPortInvalidValues(): void $uri->setPort(70000); } - public function testSetPortInvalidValuesSilent(): void - { - $url = 'http://example.com/path'; - $uri = new URI($url); - - $uri->setSilent()->setPort(70000); - - $this->assertNull($uri->getPort()); - } - public function testSetPortTooSmall(): void { $url = 'http://example.com/path'; @@ -383,9 +328,7 @@ public function testCatchesBadPort(): void { $this->expectException(HTTPException::class); - $url = 'http://username:password@hostname:90909/path?arg=value#anchor'; - $uri = new URI(); - $uri->setURI($url); + new URI('http://username:password@hostname:90909/path?arg=value#anchor'); } public function testSetPathSetsValue(): void @@ -593,16 +536,6 @@ public function testSetQueryThrowsErrorWhenFragmentPresent(): void $uri->setQuery('?key=value#fragment'); } - public function testSetQueryThrowsErrorWhenFragmentPresentSilent(): void - { - $url = 'http://example.com/path'; - $uri = new URI($url); - - $uri->setSilent()->setQuery('?key=value#fragment'); - - $this->assertSame('', $uri->getQuery()); - } - /** * @param string $url * @param string $expected @@ -1034,17 +967,6 @@ public function testSetBadSegment(): void $uri->setSegment(6, 'banana'); } - public function testSetBadSegmentSilent(): void - { - $base = 'http://example.com/foo/bar/baz'; - $uri = new URI($base); - $segments = $uri->getSegments(); - - $uri->setSilent()->setSegment(6, 'banana'); - - $this->assertSame($segments, $uri->getSegments()); - } - // Exploratory testing, investigating https://github.com/codeigniter4/CodeIgniter4/issues/2016 public function testBasedNoIndex(): void @@ -1176,23 +1098,10 @@ public function testEmptyURIPath(): void public function testSetURI(): void { - $url = ':'; - $uri = new URI(); - $this->expectException(HTTPException::class); - $this->expectExceptionMessage(lang('HTTP.cannotParseURI', [$url])); - - $uri->setURI($url); - } - - public function testSetURISilent(): void - { - $url = ':'; - $uri = new URI(); - - $uri->setSilent()->setURI($url); + $this->expectExceptionMessage(lang('HTTP.cannotParseURI', [':'])); - $this->assertTrue(true); + new URI(':'); } public function testCreateURIStringNoArguments(): void diff --git a/user_guide_src/source/changelogs/v4.8.0.rst b/user_guide_src/source/changelogs/v4.8.0.rst index 2d027886e922..0bb5fb77b722 100644 --- a/user_guide_src/source/changelogs/v4.8.0.rst +++ b/user_guide_src/source/changelogs/v4.8.0.rst @@ -124,6 +124,21 @@ Removed Deprecated Items - ``CodeIgniter\Filters\Filters::$arguments`` (deprecated since v4.6.0) - ``CodeIgniter\Filters\Filters::$argumentsClass`` (deprecated since v4.6.0) - ``CodeIgniter\Filters\Filters::getArguments()`` (deprecated since v4.6.0) +- **HTTP:** Removed the following properties and methods deprecated: + - ``CodeIgniter\HTTP\Message::getHeaders()`` (deprecated since v4.0.5) + - ``CodeIgniter\HTTP\Message::getHeader()`` (deprecated since v4.0.5) + - ``CodeIgniter\HTTP\RequestTrait::getEnv()`` (deprecated since v4.4.4) + - ``CodeIgniter\HTTP\URI::$uriString`` (deprecated since v4.4.0) + - ``CodeIgniter\HTTP\URI::$baseURL`` (deprecated since v4.4.0) + - ``CodeIgniter\HTTP\URI::setBaseURL()`` (deprecated since v4.4.0) + - ``CodeIgniter\HTTP\URI::getBaseURL()`` (deprecated since v4.4.0) + - ``CodeIgniter\HTTP\URI::setURI()`` (deprecated since v4.4.0) + - ``CodeIgniter\HTTP\URI::setScheme()`` (deprecated since v4.4.0) + - ``CodeIgniter\HTTP\URI::refreshPath()`` (deprecated since v4.4.0) + - ``CodeIgniter\HTTP\SiteURI::$segments`` (deprecated since v4.4.0) + - ``CodeIgniter\HTTP\SiteURI::setBaseURL()`` (deprecated since v4.4.0) + - ``CodeIgniter\HTTP\SiteURI::setURI()`` (deprecated since v4.4.0) + - ``CodeIgniter\HTTP\SiteURI::refreshPath()`` (deprecated since v4.4.0) - **Security:** Removed the following properties and methods deprecated: - ``CodeIgniter\Security\SecurityInterface::sanitizeFilename()`` (deprecated since v4.6.2) - ``CodeIgniter\Security\Security::sanitizeFilename()`` (deprecated since v4.6.2) @@ -213,6 +228,7 @@ Message Changes - Removed deprecated language keys tied to removed exception constructors: - ``Core.missingExtension`` (``FrameworkException::forMissingExtension()``) - ``HTTP.cannotSetCache`` (``DownloadException::forCannotSetCache()``) + - ``HTTP.disallowedAction`` - ``HTTP.invalidSameSiteSetting`` (``HTTPException::forInvalidSameSiteSetting()``) - ``Security.invalidSameSite`` (``SecurityException::forInvalidSameSite()``) - ``Session.invalidSameSiteSetting`` (``SessionException::forInvalidSameSiteSetting()``) @@ -229,6 +245,7 @@ Deprecations - **CLI:** The ``CLI::parseCommandLine()`` method is now deprecated and will be removed in a future release. The ``CLI`` class now uses the new ``CommandLineParser`` class to handle command-line argument parsing. - **HTTP:** The ``CLIRequest::parseCommand()`` method is now deprecated and will be removed in a future release. The ``CLIRequest`` class now uses the new ``CommandLineParser`` class to handle command-line argument parsing. +- **HTTP:** ``URI::setSilent()`` is now hard deprecated. This method was only previously marked as deprecated. It will now trigger a deprecation notice when used. ********** Bugs Fixed diff --git a/user_guide_src/source/incoming/request.rst b/user_guide_src/source/incoming/request.rst index 64c427f1b0d3..45875584e546 100644 --- a/user_guide_src/source/incoming/request.rst +++ b/user_guide_src/source/incoming/request.rst @@ -35,28 +35,6 @@ Class Reference .. important:: This method takes into account the ``Config\App::$proxyIPs`` setting and will return the reported client IP address by the HTTP header for the allowed IP address. - .. php:method:: isValidIP($ip[, $which = '']) - - .. deprecated:: 4.0.5 - Use :doc:`../libraries/validation` instead. - - .. important:: This method is deprecated. It will be removed in future releases. - - :param string $ip: IP address - :param string $which: IP protocol (``ipv4`` or ``ipv6``) - :returns: true if the address is valid, false if not - :rtype: bool - - Takes an IP address as input and returns true or false (boolean) depending - on whether it is valid or not. - - .. note:: The $request->getIPAddress() method above automatically validates the IP address. - - .. literalinclude:: request/002.php - - Accepts an optional second string parameter of ``ipv4`` or ``ipv6`` to specify - an IP format. The default checks for both formats. - .. php:method:: getMethod() :returns: HTTP request method @@ -101,27 +79,6 @@ Class Reference .. literalinclude:: request/005.php - .. php:method:: getEnv([$index = null[, $filter = null[, $flags = null]]]) - - .. deprecated:: 4.4.4 This method does not work from the beginning. Use - :php:func:`env()` instead. - - :param mixed $index: Value name - :param int $filter: The type of filter to apply. A list of filters can be found in `PHP manual `__. - :param int|array $flags: Flags to apply. A list of flags can be found in `PHP manual `__. - :returns: ``$_ENV`` item value if found, null if not - :rtype: mixed - - This method is identical to the ``getPost()``, ``getGet()`` and ``getCookie()`` methods from the - :doc:`IncomingRequest Class <./incomingrequest>`, only it fetches env data (``$_ENV``): - - .. literalinclude:: request/006.php - - To return an array of multiple ``$_ENV`` values, pass all the required keys - as an array. - - .. literalinclude:: request/007.php - .. php:method:: setGlobal($method, $value) :param string $method: Method name diff --git a/user_guide_src/source/incoming/request/002.php b/user_guide_src/source/incoming/request/002.php deleted file mode 100644 index 4b2e39489f72..000000000000 --- a/user_guide_src/source/incoming/request/002.php +++ /dev/null @@ -1,7 +0,0 @@ -isValidIP($ip)) { - echo 'Not Valid'; -} else { - echo 'Valid'; -} diff --git a/user_guide_src/source/incoming/request/006.php b/user_guide_src/source/incoming/request/006.php deleted file mode 100644 index b503574b79cc..000000000000 --- a/user_guide_src/source/incoming/request/006.php +++ /dev/null @@ -1,3 +0,0 @@ -getEnv('some_data'); diff --git a/user_guide_src/source/incoming/request/007.php b/user_guide_src/source/incoming/request/007.php deleted file mode 100644 index aa1ad285e0bd..000000000000 --- a/user_guide_src/source/incoming/request/007.php +++ /dev/null @@ -1,3 +0,0 @@ -getEnv(['CI_ENVIRONMENT', 'S3_BUCKET']); diff --git a/user_guide_src/source/libraries/uri.rst b/user_guide_src/source/libraries/uri.rst index d0e05d247971..ce66cd695da5 100644 --- a/user_guide_src/source/libraries/uri.rst +++ b/user_guide_src/source/libraries/uri.rst @@ -238,8 +238,7 @@ You can also set a different default value for a particular segment by using the .. literalinclude:: uri/024.php .. note:: You can get the last +1 segment. When you try to get the last +2 or - more segment, an exception will be thrown by default. You could prevent - throwing exceptions with the ``setSilent()`` method. + more segment, an exception will be thrown by default. You can get a count of the total segments: @@ -256,4 +255,8 @@ Disable Throwing Exceptions By default, some methods of this class may throw an exception. If you want to disable it, you can set a special flag that will prevent throwing exceptions. +.. deprecated:: 4.4.0 + This method is deprecated and will be removed in a future version. + It is recommended to handle exceptions properly instead of disabling them. + .. literalinclude:: uri/027.php diff --git a/user_guide_src/source/libraries/uri/024.php b/user_guide_src/source/libraries/uri/024.php index 61a951db93c3..6a835b814946 100644 --- a/user_guide_src/source/libraries/uri/024.php +++ b/user_guide_src/source/libraries/uri/024.php @@ -8,7 +8,3 @@ echo $uri->getSegment(4, 'bar'); // will throw an exception echo $uri->getSegment(5, 'baz'); -// will print 'baz' -echo $uri->setSilent()->getSegment(5, 'baz'); -// will print '' (empty string) -echo $uri->setSilent()->getSegment(5); diff --git a/utils/phpstan-baseline/loader.neon b/utils/phpstan-baseline/loader.neon index 78a665b0b346..60c71993ab4b 100644 --- a/utils/phpstan-baseline/loader.neon +++ b/utils/phpstan-baseline/loader.neon @@ -1,4 +1,4 @@ -# total 2042 errors +# total 2036 errors includes: - argument.type.neon diff --git a/utils/phpstan-baseline/method.alreadyNarrowedType.neon b/utils/phpstan-baseline/method.alreadyNarrowedType.neon index f3c373da1f4a..974f33a134e7 100644 --- a/utils/phpstan-baseline/method.alreadyNarrowedType.neon +++ b/utils/phpstan-baseline/method.alreadyNarrowedType.neon @@ -1,4 +1,4 @@ -# total 22 errors +# total 21 errors parameters: ignoreErrors: @@ -47,11 +47,6 @@ parameters: count: 1 path: ../../tests/system/HTTP/RequestTest.php - - - message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertTrue\(\) with true will always evaluate to true\.$#' - count: 1 - path: ../../tests/system/HTTP/URITest.php - - message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertIsString\(\) with string will always evaluate to true\.$#' count: 1 diff --git a/utils/phpstan-baseline/missingType.iterableValue.neon b/utils/phpstan-baseline/missingType.iterableValue.neon index 0885c21afa75..d661381dd2d0 100644 --- a/utils/phpstan-baseline/missingType.iterableValue.neon +++ b/utils/phpstan-baseline/missingType.iterableValue.neon @@ -1,4 +1,4 @@ -# total 1242 errors +# total 1237 errors parameters: ignoreErrors: @@ -2772,11 +2772,6 @@ parameters: count: 1 path: ../../system/HTTP/IncomingRequest.php - - - message: '#^Method CodeIgniter\\HTTP\\Message\:\:getHeader\(\) return type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/HTTP/Message.php - - message: '#^Method CodeIgniter\\HTTP\\Message\:\:setHeader\(\) has parameter \$value with no value type specified in iterable type array\.$#' count: 1 @@ -2892,16 +2887,6 @@ parameters: count: 1 path: ../../system/HTTP/Request.php - - - message: '#^Method CodeIgniter\\HTTP\\Request\:\:getEnv\(\) has parameter \$flags with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/HTTP/Request.php - - - - message: '#^Method CodeIgniter\\HTTP\\Request\:\:getEnv\(\) has parameter \$index with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/HTTP/Request.php - - message: '#^Method CodeIgniter\\HTTP\\Request\:\:getServer\(\) has parameter \$flags with no value type specified in iterable type array\.$#' count: 1 @@ -2987,11 +2972,6 @@ parameters: count: 1 path: ../../system/HTTP/SiteURI.php - - - message: '#^Method CodeIgniter\\HTTP\\SiteURI\:\:convertToSegments\(\) return type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/HTTP/SiteURI.php - - message: '#^Method CodeIgniter\\HTTP\\SiteURI\:\:parseRelativePath\(\) return type has no value type specified in iterable type array\.$#' count: 1 @@ -3007,11 +2987,6 @@ parameters: count: 1 path: ../../system/HTTP/SiteURI.php - - - message: '#^Property CodeIgniter\\HTTP\\SiteURI\:\:\$baseSegments type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/HTTP/SiteURI.php - - message: '#^Method CodeIgniter\\HTTP\\URI\:\:setQueryArray\(\) has parameter \$query with no value type specified in iterable type array\.$#' count: 1