![]() |
source code says Request::getMethod() is deprecated, what to use? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: source code says Request::getMethod() is deprecated, what to use? (/showthread.php?tid=78685) Pages:
1
2
|
source code says Request::getMethod() is deprecated, what to use? - sneakyimp - 02-25-2021 The source code says Request::getMethod() is deprecated. What should we use instead? PHP Code: /** RE: source code says Request::getMethod() is deprecated, what to use? - mlurie - 02-25-2021 The method is not deprecated, the optional [$upper] parameter is deprecated. In the future the request method name will only be returned in lower case. You may review the documentation here: https://codeigniter.com/user_guide/incoming/request.html?highlight=getmethod#getMethod. RE: source code says Request::getMethod() is deprecated, what to use? - sneakyimp - 02-25-2021 (02-25-2021, 06:01 PM)mlurie Wrote: The method is not deprecated, the optional [$upper] parameter is deprecated.Perhaps someone needs to change the comments and remove that @deprecated bit then. In my IDE, this results in the method being displayed in strikethrough text: Quote:@deprecated The $upper functionality will be removed and this will revert to its PSR-7 equivalent RE: source code says Request::getMethod() is deprecated, what to use? - CCAldo - 07-16-2021 Having the same issue: ![]() RE: source code says Request::getMethod() is deprecated, what to use? - MGatner - 07-16-2021 The point of the deprecation is to make sure developers are aware of the change coming in the next major release. I’m sorry for the visual issue with your IDE but it has accomplished that goal very nicely. RE: source code says Request::getMethod() is deprecated, what to use? - paliz - 07-16-2021 use this $method = $_SERVER['REQUEST_METHOD']; RE: source code says Request::getMethod() is deprecated, what to use? - CCAldo - 07-19-2021 But if you're not using a paramater you still got this error. Also it seems that some users would be triggered to uses a non-CodeIgniter function instead. And that would not be the way to handle this case. Made some adjustments: PHP Code: /** And this trows this when using the $upper-param (in development environments) ![]() Seems a better way? RE: source code says Request::getMethod() is deprecated, what to use? - MGatner - 07-19-2021 We are working on a framework-wide implementation for handling use of deprecated features. This would definitely be the kind of approach it would take. I don’t use an IDE so I obviously don’t have this problem - but how much of an issue is it really? I was under the impression you just got a little flag saying “deprecated” or something. Anyone have references for best practices or other framework handling did deprecating a parameter while leaving the method/function? RE: source code says Request::getMethod() is deprecated, what to use? - CCAldo - 07-19-2021 Its not a huge issue. Its just triggers the user to chose an alternative function. The issue is that the error message isn't always clear. PhpStorm shows a strikethrough with the notice: Method 'getMethod' is deprecated. Visual Code has a line under it, with notice: 'getMethod' is depricated. https://imgur.com/a/4PHcoKk It's possible to remove all deprecated notices with some settings: (in Visual Code) Code: { Only found this: https://stackoverflow.com/questions/27005219/is-it-possible-to-deprecate-method-parameters-in-php RE: source code says Request::getMethod() is deprecated, what to use? - Anglin George - 07-30-2021 if ($this->request->getMethod() == 'post') { } instead we can use if ($this->request->getPost()) { } Hope it helps. (CI4 solution) |