Re: [RFC] concept: further improvement of filter extension, "generalising" filter definitons while adding new callback filter type

From: Date: Thu, 04 May 2017 15:55:41 +0000
Subject: Re: [RFC] concept: further improvement of filter extension, "generalising" filter definitons while adding new callback filter type
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-98966@lists.php.net to get a copy of this message
On 3 May 2017 at 02:23, Martin "eto" Misuth <et.code@ethome.sk> wrote: > > there is one thing I don't know what to do about, and need your advice. What > about module name clash? I would prefer, for this alternative module, to be > named filter as well IMO that violates the principle of least astonishment - a function that has the same name as an internal PHP function doing something different. However if you really want to do that, 'overloading' internal functions can be achieved by (ab)using namespaces: namespace Foo { function filter_var($input, $filter = FILTER_DEFAULT ,$options = []) { echo "I am a custom filter function"; return $input; } } namespace Bar { use function Foo\filter_var as filter_var; $val = filter_var("someInput"); } Output is "I am a custom filter function" cheers Dan

« previous php.internals (#98966) next »