Welcome Guest, Not a member yet? Register   Sign In
source code says Request::getMethod() is deprecated, what to use?
#11

Anyway to hide/suppress deprecated warnings you may do this

error_reporting(E_ALL ^ E_DEPRECATED);
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#12

(This post was last modified: 03-29-2023, 09:30 AM by alphastudiofr.)

+1 on not using @deprecated in the docblock when the function as a whole is not deprecated.

phpDocument defines the tag as meaning the element associated with the docblock is deprecated (in this case the method as a whole, not just one of its functionalities):
https://docs.phpdoc.org/3.0/guide/refere...deprecated

IDEs implement the same logic, leading to the method showing as strike through in the code and other various warnings.

For instance in PhpStorm, hovering the method, you do get the detailed comment on the $upper functionality if you read through, but the main message is "Method 'getMethod' is deprecated".

[Image: getmethod.png]

Triggering the wrong warning is never a good strategy. Deprecated warnings are useful when they can lead to a fix. In this case, there is no fix, so you're left with a permanent warning, and the idea that CodeIgniter's code triggers false alarms that you just have to ignore... Never a good thing if awareness is what you want to achieve.
Reply
#13

@alphastudiofr Thank you for your opinion.
We don't think the current way is the best.
If you have a better way to inform CI4 users that, please send a PR.
https://github.com/codeigniter4/CodeIgni...request.md
Reply
#14

I recommend to use the new is() method.
https://codeigniter.com/user_guide/incom...st.html#is
Reply
#15

(This post was last modified: 12-07-2023, 04:21 AM by objecttothis.)

(07-19-2021, 05:02 AM)MGatner Wrote: 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?

Sorry for the necro, but it seems the way to possibly deprecate the parameter is to overload the function without the parameter, then keep the deprecation notice on this one but not on the overloaded function... nevermind, I just realized that overloading in php is ... a-typical. https://www.php.net/manual/en/language.o...oading.php
Reply
#16

We will remove the deprecated feature in 4.5.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB