Skip to content

Commit

Permalink
feat: add trigger_error E_USER_DEPRECATED
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed Nov 19, 2023
1 parent cb35ef7 commit 4dd4218
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions system/Filters/Filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,11 @@ 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 "' . $method . '" is deprecated. Use uppercase HTTP method like "GET".',
E_USER_DEPRECATED
);

$found = true;
$method = strtolower($method);
}
Expand Down
7 changes: 7 additions & 0 deletions system/Router/RouteCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -1012,6 +1012,13 @@ 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 "GET".',
E_USER_DEPRECATED
);
}

/**
* @TODO We should use correct uppercase verb.
* @deprecated 4.5.0
Expand Down
7 changes: 7 additions & 0 deletions system/Test/FeatureTestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ 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 "GET".',
E_USER_DEPRECATED
);
}

/**
* @TODO For backward compatibility. Remove strtolower() in the future.
* @deprecated 4.5.0
Expand Down

0 comments on commit 4dd4218

Please sign in to comment.