[PATCH] add support for functions to use

From: Date: Fri, 12 Sep 2008 02:14:13 +0000
Subject: [PATCH] add support for functions to use
Groups: php.internals 
Request: Send a blank email to internals+get-40476@lists.php.net to get a copy of this message
Hi, I've just finished implementing use for functions. This patch is against PHP_5_3 and can be easily ported to HEAD. I am confident that it is quite mature and have tests in the patch to prove it. the patch is also at http://pear.php.net/~greg/usefunctions.patch.txt This patch implements the following syntax: func.inc: <?php namespace foo; function hi() { echo "hi\n"; } ?> main.php: <?php include 'func.inc'; use foo::hi, foo:hi as there; foo::hi(); hi(); there(); ?> The output is "hi\nhi\nhi\n" It can be used to alias any function, and so can also be useful for overriding an internal function and saving it: <?php namespace foo; include 'another.inc'; use function::strlen as old_strlen, function::another::strlen; ?> With this patch, function users should be a lot happier. Thanks, Greg

« previous php.internals (#40476) next »