Re: Deprecated functions

From: Date: Wed, 10 Sep 2014 05:59:07 +0000
Subject: Re: Deprecated functions
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-77130@lists.php.net to get a copy of this message
Hi! Maybe it will be better to do this in another way: introduce an RFC to add 'deprecated' keyword into the syntax like 'final' or 'protected'. There are many frameworks that want to deprecate some methods or classes. Currently it's only possible via "@deprecated" tag in the phpDoc-block, but this tag doesn't influence on method invocation, so no warnings are generated. Symfony uses trigger_error($message, E_USER_DEPRECATED) explicitly in deprecated methods to trigger this warning (see https://github.com/symfony/symfony/pull/6180), but this is not a transparent solution. This can be look like this: class Test { deprecated protected $someProperty; deprecated public function foo() {} public function bar() {} } deprecated class OldStuff {} deprecated function someOldFunction() {} This RFC will give more control over 'deprecated' functionality and can be easily tested. Thoughts? 2014-09-10 9:42 GMT+04:00 Tjerk Meesters <tjerk.meesters@gmail.com>: > Hi, > > When I was fixing test cases on my kill-ereg branch I noticed a > Reflection test case for ReflectionFunction::isDeprecated(). > > The problem with such a test case is that you’d be chasing deprecated functions to tests > against as we move along; this is the current list of deprecated functions as taken from a typical > 5.4 installation: > > Since 4.1.0: call_user_method, call_user_method_array > Since 4.3.7: mysql_list_tables, mysql_listtables > Since 5.3 : ereg, ereg_replace, eregi, eregi_replace, split, spliti, sql_regcase, > mysql_db_query, magic_quotes_runtime, set_magic_quotes_runtime, set_socket_blocking > Since 5.4 : mysql_list_dbs > > The above are, as far as I’m concerned, all potential candidates for removal in PHP 7, so in > order to reliably test a deprecated function I would suggest introducing a hidden function with this > signature: > > void __deprecated__() { } > > And mark that function as eternally deprecated using the ZEND_ACC_DEPRECATED flag. > > Thoughts?

« previous php.internals (#77130) next »