From 375c340685b872eafaaeaac3799927014922a093 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 19 Nov 2023 19:13:07 +0900 Subject: [PATCH] feat: add trigger_error E_USER_DEPRECATED --- system/Filters/Filters.php | 6 ++++++ system/Router/RouteCollection.php | 8 ++++++++ system/Test/FeatureTestTrait.php | 8 ++++++++ 3 files changed, 22 insertions(+) diff --git a/system/Filters/Filters.php b/system/Filters/Filters.php index 23028d455b94..9019c317aa1d 100644 --- a/system/Filters/Filters.php +++ b/system/Filters/Filters.php @@ -505,6 +505,12 @@ protected function processMethods() // @deprecated 4.5.0 // @TODO remove this in the future. elseif (array_key_exists(strtolower($method), $this->config->methods)) { + @trigger_error( + 'Setting lowercase HTTP method key "' . strtolower($method) . '" is deprecated.' + . ' Use uppercase HTTP method like "' . strtoupper($method) . '".', + E_USER_DEPRECATED + ); + $found = true; $method = strtolower($method); } diff --git a/system/Router/RouteCollection.php b/system/Router/RouteCollection.php index 4195631f8ec3..05cb828976e7 100644 --- a/system/Router/RouteCollection.php +++ b/system/Router/RouteCollection.php @@ -1012,6 +1012,14 @@ public function match(array $verbs = [], string $from = '', $to = '', ?array $op } foreach ($verbs as $verb) { + if ($verb === strtolower($verb)) { + @trigger_error( + 'Passing lowercase HTTP method "' . $verb . '" is deprecated.' + . ' Use uppercase HTTP method like "' . strtoupper($verb) . '".', + E_USER_DEPRECATED + ); + } + /** * @TODO We should use correct uppercase verb. * @deprecated 4.5.0 diff --git a/system/Test/FeatureTestTrait.php b/system/Test/FeatureTestTrait.php index 6e3d4a78fcf0..a254883865ad 100644 --- a/system/Test/FeatureTestTrait.php +++ b/system/Test/FeatureTestTrait.php @@ -51,6 +51,14 @@ protected function withRoutes(?array $routes = null) $collection->resetRoutes(); foreach ($routes as $route) { + if ($route[0] === strtolower($route[0])) { + @trigger_error( + 'Passing lowercase HTTP method "' . $route[0] . '" is deprecated.' + . ' Use uppercase HTTP method like "' . strtoupper($route[0]) . '".', + E_USER_DEPRECATED + ); + } + /** * @TODO For backward compatibility. Remove strtolower() in the future. * @deprecated 4.5.0