beberlei / assert

Thin assertion library for use in libraries and business-model
Other
2.41k stars 188 forks source link

add assertion to check if an extension is loaded. #201

Closed abacaphiliac closed 7 years ago

abacaphiliac commented 7 years ago

i could use such an assertion in factory code to generate a helpful message about which extension to install rather than letting PHP fail with a missing class error:

22:18 $ /usr/local/Cellar/php71/7.1.0_11/bin/php -r "new \Memcached;"
PHP Fatal error:  Uncaught Error: Class 'Memcached' not found in Command line code:1
Stack trace:
#0 {main}
  thrown in Command line code on line 1

Fatal error: Uncaught Error: Class 'Memcached' not found in Command line code on line 1

Error: Class 'Memcached' not found in Command line code on line 1

Call Stack:
    0.0001     346408   1. {main}() Command line code:0