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 375c340
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
6 changes: 6 additions & 0 deletions system/Filters/Filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
8 changes: 8 additions & 0 deletions system/Router/RouteCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions system/Test/FeatureTestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 375c340

Please sign in to comment.