Hi all,
On Mon, Feb 3, 2014 at 7:55 PM, Yasuo Ohgaki <[email protected]> wrote:
> We may extend declare() more. For example, loaded extensions.
>
> declare(module='pgsql,openssl');
>
> With this, we could eliminate code like
>
> if (!extension_loaded('foo')) {
> die('You need foo module');
> }
> if (!extension_loaded('bar')) {
> die('You need bar module');
> }
>
> With opcache loaded extension check may be completely skipped.
>
> Evaluation at compile time and run time differs.
>
Similar thing could be achieved with new assert() w/o any overheads.
https://wiki.php.net/rfc/expectations
assert('version_compare(PHP_VERSION, "5.5.0", ">=")', 'You
need PHP 5.5.0
or later');
Since assert() only accepts expression, it might be nice to have
declare('assert') {
if (!extension_loaded('foo')) {
echo 'You need foo module';
return FALSE;
}
if (!extension_loaded('bar')) {
echo 'You need bar module';
return FALSE
}
return TRUE;
}
Usual PHP code might be easier to write complex assertion.
It may be possible to share most of the new assertion code.
Just an idea.
What do you think Dmitry?
Regards,
--
Yasuo Ohgaki
[email protected]