From f92f091694dfa27280c4bf8c9532bada90bc7b0b Mon Sep 17 00:00:00 2001 From: ping-yee <611077101@mail.nknu.edu.tw> Date: Sat, 24 Jun 2023 21:54:17 +0900 Subject: [PATCH 01/14] docs: Replace type `mixed` in system. --- system/BaseModel.php | 2 +- system/CodeIgniter.php | 2 +- system/Common.php | 8 ++++---- system/Model.php | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/system/BaseModel.php b/system/BaseModel.php index 26b6952291e4..8d5b4276eb43 100644 --- a/system/BaseModel.php +++ b/system/BaseModel.php @@ -1711,7 +1711,7 @@ protected function transformDataToArray($data, string $type): array * * @param string $name Name * - * @return mixed + * @return array|bool|int|object|string|null */ public function __get(string $name) { diff --git a/system/CodeIgniter.php b/system/CodeIgniter.php index 829b65ea952b..5285a9293ae1 100644 --- a/system/CodeIgniter.php +++ b/system/CodeIgniter.php @@ -732,7 +732,7 @@ public static function cache(int $time) * Caches the full response from the current request. Used for * full-page caching for very high performance. * - * @return mixed + * @return bool */ public function cachePage(Cache $config) { diff --git a/system/Common.php b/system/Common.php index 8d366973f14d..bdc937af2aa7 100644 --- a/system/Common.php +++ b/system/Common.php @@ -65,8 +65,8 @@ function app_timezone(): string * cache()->save('foo', 'bar'); * $foo = cache('bar'); * - * @return CacheInterface|mixed - * @phpstan-return ($key is null ? CacheInterface : mixed) + * @return array|bool|CacheInterface|float|int|object|string|null + * @phpstan-return ($key is null ? CacheInterface : array|bool|float|int|object|string|null) */ function cache(?string $key = null) { @@ -1003,7 +1003,7 @@ function session(?string $val = null) * - $timer = service('timer') * - $timer = \CodeIgniter\Config\Services::timer(); * - * @param mixed ...$params + * @param array|bool|float|int|object|string|null ...$params * * @return object */ @@ -1017,7 +1017,7 @@ function service(string $name, ...$params) /** * Always returns a new instance of the class. * - * @param mixed ...$params + * @param array|bool|float|int|object|string|null ...$params * * @return object|null */ diff --git a/system/Model.php b/system/Model.php index 80e4bb48a34c..c28bf2b9da1c 100644 --- a/system/Model.php +++ b/system/Model.php @@ -792,7 +792,7 @@ protected function objectToRawArray($data, bool $onlyChanged = true, bool $recur * * @param string $name Name * - * @return mixed + * @return array|BaseBuilder|bool|int|object|string|null */ public function __get(string $name) { @@ -821,7 +821,7 @@ public function __isset(string $name): bool * Provides direct access to method in the builder (if available) * and the database connection. * - * @return mixed + * @return array|BaseBuilder|bool|float|int|object|string|null */ public function __call(string $name, array $params) { From 1db90c402bded14b1ff5f269cde7275e9eb1e5d0 Mon Sep 17 00:00:00 2001 From: Jozef Rebjak Date: Mon, 26 Jun 2023 13:07:39 +0200 Subject: [PATCH 02/14] fix: skip http proxy added header --- system/HTTP/CURLRequest.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/system/HTTP/CURLRequest.php b/system/HTTP/CURLRequest.php index 377f51e46006..616ef143fde8 100644 --- a/system/HTTP/CURLRequest.php +++ b/system/HTTP/CURLRequest.php @@ -387,6 +387,10 @@ public function send(string $method, string $url) $output = substr($output, strpos($output, $breakString) + 4); } + if (strpos($output, 'HTTP/1.1 200 Connection established') === 0) { + $output = substr($output, strpos($output, $breakString) + 4); + } + // If request and response have Digest if (isset($this->config['auth'][2]) && $this->config['auth'][2] === 'digest' && strpos($output, 'WWW-Authenticate: Digest') !== false) { $output = substr($output, strpos($output, $breakString) + 4); From 9a41f6b18c6e6e6ff8cdb34f4e82e11481d5ec9b Mon Sep 17 00:00:00 2001 From: Jozef Rebjak Date: Mon, 26 Jun 2023 13:52:36 +0200 Subject: [PATCH 03/14] test: add testSendProxied --- tests/system/HTTP/CURLRequestTest.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/system/HTTP/CURLRequestTest.php b/tests/system/HTTP/CURLRequestTest.php index 92c43cc58461..41ebee307374 100644 --- a/tests/system/HTTP/CURLRequestTest.php +++ b/tests/system/HTTP/CURLRequestTest.php @@ -718,6 +718,18 @@ public function testSendContinued() $this->assertSame('Hi there', $response->getBody()); } + public function testSendProxied() + { + $request = $this->getRequest([ + 'base_uri' => 'http://www.foo.com/api/v1/', + 'delay' => 100, + ]); + + $request->setOutput("HTTP/1.1 200 Connection established:\x0d\x0a\x0d\x0aHi there"); + $response = $request->get('answer'); + $this->assertSame('Hi there', $response->getBody()); + } + /** * See: https://github.com/codeigniter4/CodeIgniter4/issues/3261 */ From 8d023d9255822e05c2b4622125518eec7348ce59 Mon Sep 17 00:00:00 2001 From: Jozef Rebjak Date: Mon, 26 Jun 2023 13:55:32 +0200 Subject: [PATCH 04/14] fix: testSendProxied typo --- tests/system/HTTP/CURLRequestTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/system/HTTP/CURLRequestTest.php b/tests/system/HTTP/CURLRequestTest.php index 41ebee307374..d1ae4ea5db06 100644 --- a/tests/system/HTTP/CURLRequestTest.php +++ b/tests/system/HTTP/CURLRequestTest.php @@ -725,7 +725,7 @@ public function testSendProxied() 'delay' => 100, ]); - $request->setOutput("HTTP/1.1 200 Connection established:\x0d\x0a\x0d\x0aHi there"); + $request->setOutput("HTTP/1.1 200 Connection established\x0d\x0a\x0d\x0aHi there"); $response = $request->get('answer'); $this->assertSame('Hi there', $response->getBody()); } From a20365b9c9877a4f6cc050403889439a69099371 Mon Sep 17 00:00:00 2001 From: Jozef Rebjak Date: Mon, 26 Jun 2023 14:02:04 +0200 Subject: [PATCH 05/14] test: improve testSendProxied --- tests/system/HTTP/CURLRequestTest.php | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/tests/system/HTTP/CURLRequestTest.php b/tests/system/HTTP/CURLRequestTest.php index d1ae4ea5db06..d90b8847cbb6 100644 --- a/tests/system/HTTP/CURLRequestTest.php +++ b/tests/system/HTTP/CURLRequestTest.php @@ -718,18 +718,6 @@ public function testSendContinued() $this->assertSame('Hi there', $response->getBody()); } - public function testSendProxied() - { - $request = $this->getRequest([ - 'base_uri' => 'http://www.foo.com/api/v1/', - 'delay' => 100, - ]); - - $request->setOutput("HTTP/1.1 200 Connection established\x0d\x0a\x0d\x0aHi there"); - $response = $request->get('answer'); - $this->assertSame('Hi there', $response->getBody()); - } - /** * See: https://github.com/codeigniter4/CodeIgniter4/issues/3261 */ @@ -777,6 +765,21 @@ public function testSendContinuedWithManyHeaders() $this->assertSame(200, $response->getStatusCode()); } + public function testSendProxied() + { + $request = $this->getRequest([ + 'base_uri' => 'http://www.foo.com/api/v1/', + 'delay' => 100, + ]); + + $output = "HTTP/1.1 200 Connection established +Proxy-Agent: Fortinet-Proxy/1.0\x0d\x0a\x0d\x0aHTTP/1.1 200 OK\x0d\x0a\x0d\x0aHi there"; + $request->setOutput($output); + + $response = $request->get('answer'); + $this->assertSame('Hi there', $response->getBody()); + } + /** * See: https://github.com/codeigniter4/CodeIgniter4/issues/7394 */ From e17ebddf11b7867bdf47529828404cc9d961c485 Mon Sep 17 00:00:00 2001 From: Christoph Potas Date: Mon, 26 Jun 2023 18:57:59 +0200 Subject: [PATCH 06/14] Fix sqlsrv default port connection refuse ~ ignore default port when constructr hostname for sqlsrv driver --- system/Database/SQLSRV/Connection.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/Database/SQLSRV/Connection.php b/system/Database/SQLSRV/Connection.php index 4e0ca987df9a..445c6bf5426b 100755 --- a/system/Database/SQLSRV/Connection.php +++ b/system/Database/SQLSRV/Connection.php @@ -121,7 +121,7 @@ public function connect(bool $persistent = false) unset($connection['UID'], $connection['PWD']); } - if (strpos($this->hostname, ',') === false && $this->port !== '') { + if (strpos($this->hostname, ',') === false && $this->port !== '' && (int)$this->port !== 1433) { $this->hostname .= ', ' . $this->port; } From 29d6ddd2c26cd516800430ae880ae585eceba2bb Mon Sep 17 00:00:00 2001 From: Christoph Potas Date: Tue, 27 Jun 2023 12:14:58 +0200 Subject: [PATCH 07/14] Confirm Style Guide ~ add missing space (style guide) --- system/Database/SQLSRV/Connection.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/Database/SQLSRV/Connection.php b/system/Database/SQLSRV/Connection.php index 445c6bf5426b..555b0a21c3f1 100755 --- a/system/Database/SQLSRV/Connection.php +++ b/system/Database/SQLSRV/Connection.php @@ -121,7 +121,7 @@ public function connect(bool $persistent = false) unset($connection['UID'], $connection['PWD']); } - if (strpos($this->hostname, ',') === false && $this->port !== '' && (int)$this->port !== 1433) { + if (strpos($this->hostname, ',') === false && $this->port !== '' && (int) $this->port !== 1433) { $this->hostname .= ', ' . $this->port; } From a7b97ad34e2198229708ddc440399174ebf237df Mon Sep 17 00:00:00 2001 From: Christoph Potas Date: Wed, 28 Jun 2023 15:11:34 +0200 Subject: [PATCH 08/14] Provide default port configuration information to the documentation ~ remove old port changes + add port config information to the documentation --- system/Database/SQLSRV/Connection.php | 2 +- user_guide_src/source/database/configuration.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/system/Database/SQLSRV/Connection.php b/system/Database/SQLSRV/Connection.php index 555b0a21c3f1..4e0ca987df9a 100755 --- a/system/Database/SQLSRV/Connection.php +++ b/system/Database/SQLSRV/Connection.php @@ -121,7 +121,7 @@ public function connect(bool $persistent = false) unset($connection['UID'], $connection['PWD']); } - if (strpos($this->hostname, ',') === false && $this->port !== '' && (int) $this->port !== 1433) { + if (strpos($this->hostname, ',') === false && $this->port !== '') { $this->hostname .= ', ' . $this->port; } diff --git a/user_guide_src/source/database/configuration.rst b/user_guide_src/source/database/configuration.rst index bdb6320d0bb3..d2b6b893abe6 100644 --- a/user_guide_src/source/database/configuration.rst +++ b/user_guide_src/source/database/configuration.rst @@ -174,7 +174,7 @@ Explanation of Values: **compress** Whether or not to use client compression (``MySQLi`` only). **strictOn** true/false (boolean) - Whether to force "Strict Mode" connections, good for ensuring strict SQL while developing an application (``MySQLi`` only). -**port** The database port number. +**port** The database port number - Empty for default port (or dynamic port with ``SQLSRV``) **foreignKeys** true/false (boolean) - Whether or not to enable Foreign Key constraint (``SQLite3`` only). .. important:: SQLite3 Foreign Key constraint is disabled by default. From 2753ad7d89b70896f199a51798f89a417134ce0d Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 29 Jun 2023 16:57:14 +0900 Subject: [PATCH 09/14] docs: fix @param --- system/CodeIgniter.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/CodeIgniter.php b/system/CodeIgniter.php index 2a777474c56e..5f51a2e175a5 100644 --- a/system/CodeIgniter.php +++ b/system/CodeIgniter.php @@ -732,7 +732,7 @@ public static function cache(int $time) * Caches the full response from the current request. Used for * full-page caching for very high performance. * - * @return mixed + * @return bool */ public function cachePage(Cache $config) { @@ -918,7 +918,7 @@ protected function createController() * 2. PHP CLI: accessed by CLI via php public/index.php, arguments become URI segments, * sent to Controllers via Routes, output varies * - * @param mixed $class + * @param Controller $class * * @return false|ResponseInterface|string|void */ From 757de43da5813a62633e1ce183dd0527d8f39c7f Mon Sep 17 00:00:00 2001 From: puschie286 Date: Thu, 29 Jun 2023 10:39:51 +0200 Subject: [PATCH 10/14] Update user_guide_src/source/database/configuration.rst Co-authored-by: kenjis --- user_guide_src/source/database/configuration.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/database/configuration.rst b/user_guide_src/source/database/configuration.rst index d2b6b893abe6..077231fa3dca 100644 --- a/user_guide_src/source/database/configuration.rst +++ b/user_guide_src/source/database/configuration.rst @@ -174,7 +174,7 @@ Explanation of Values: **compress** Whether or not to use client compression (``MySQLi`` only). **strictOn** true/false (boolean) - Whether to force "Strict Mode" connections, good for ensuring strict SQL while developing an application (``MySQLi`` only). -**port** The database port number - Empty for default port (or dynamic port with ``SQLSRV``) +**port** The database port number - Empty string ``''`` for default port (or dynamic port with ``SQLSRV``). **foreignKeys** true/false (boolean) - Whether or not to enable Foreign Key constraint (``SQLite3`` only). .. important:: SQLite3 Foreign Key constraint is disabled by default. From 70f566f5224af1b5ef35844f44ef91b22e8b1c4a Mon Sep 17 00:00:00 2001 From: ping-yee <611077101@mail.nknu.edu.tw> Date: Thu, 29 Jun 2023 18:24:08 +0800 Subject: [PATCH 11/14] docs: Add the type. --- system/BaseModel.php | 2 +- system/Model.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/system/BaseModel.php b/system/BaseModel.php index 8d5b4276eb43..06b8190f037f 100644 --- a/system/BaseModel.php +++ b/system/BaseModel.php @@ -1711,7 +1711,7 @@ protected function transformDataToArray($data, string $type): array * * @param string $name Name * - * @return array|bool|int|object|string|null + * @return array|bool|float|int|object|string|null */ public function __get(string $name) { diff --git a/system/Model.php b/system/Model.php index c28bf2b9da1c..b60bb966dd85 100644 --- a/system/Model.php +++ b/system/Model.php @@ -792,7 +792,7 @@ protected function objectToRawArray($data, bool $onlyChanged = true, bool $recur * * @param string $name Name * - * @return array|BaseBuilder|bool|int|object|string|null + * @return array|BaseBuilder|bool|float|int|object|string|null */ public function __get(string $name) { @@ -821,7 +821,7 @@ public function __isset(string $name): bool * Provides direct access to method in the builder (if available) * and the database connection. * - * @return array|BaseBuilder|bool|float|int|object|string|null + * @return $this|array|BaseBuilder|bool|float|int|object|string|null */ public function __call(string $name, array $params) { From fccea01ba9185dd6592a1177b41a2fdea4a0a2fc Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 29 Jun 2023 21:20:00 +0900 Subject: [PATCH 12/14] fix: remove incorrect param type in number_to_roman() --- system/Helpers/number_helper.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/Helpers/number_helper.php b/system/Helpers/number_helper.php index c61229dad345..32dd4e09d68c 100644 --- a/system/Helpers/number_helper.php +++ b/system/Helpers/number_helper.php @@ -173,9 +173,9 @@ function format_number(float $num, int $precision = 1, ?string $locale = null, a /** * Convert a number to a roman numeral. * - * @param string $num it will convert to int + * @param int|string $num it will convert to int */ - function number_to_roman(string $num): ?string + function number_to_roman($num): ?string { static $map = [ 'M' => 1000, From 41dbea0c02e9dbda3fa2feaeab54084ac8604205 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 29 Jun 2023 21:23:02 +0900 Subject: [PATCH 13/14] docs: align comments --- user_guide_src/source/helpers/number_helper/009.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/user_guide_src/source/helpers/number_helper/009.php b/user_guide_src/source/helpers/number_helper/009.php index 0a520a198943..a55daa265677 100644 --- a/user_guide_src/source/helpers/number_helper/009.php +++ b/user_guide_src/source/helpers/number_helper/009.php @@ -1,5 +1,5 @@ Date: Thu, 29 Jun 2023 21:23:23 +0900 Subject: [PATCH 14/14] docs: update reference --- user_guide_src/source/helpers/number_helper.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/user_guide_src/source/helpers/number_helper.rst b/user_guide_src/source/helpers/number_helper.rst index d43967c502f7..0528aa07eee1 100644 --- a/user_guide_src/source/helpers/number_helper.rst +++ b/user_guide_src/source/helpers/number_helper.rst @@ -92,7 +92,7 @@ The following functions are available: .. php:function:: number_to_roman($num) - :param string $num: The number want to convert + :param int|string $num: The number want to convert :returns: The roman number converted from given parameter :rtype: string|null @@ -101,4 +101,4 @@ The following functions are available: .. literalinclude:: number_helper/009.php This function only handles numbers in the range 1 through 3999. - It will return null for any value outside that range. + It will return ``null`` for any value outside that range.