safe icon indicating copy to clipboard operation
safe copied to clipboard

Imagick

Open Sarke opened this issue 7 years ago • 2 comments

It's a common extension and lots of their methods return false on failure, which is frustrating.

How would I go about adding it?

Great repo btw!

Sarke avatar Feb 27 '19 22:02 Sarke

The current implementation of Safe rewrite only functions, and could not cover the Imagick classes.

Unless refactoring Safe in order to take Class into account and generate something like:

namespace Safe;
class Imagick extends \Imagick
{
   public function fooBar(type $arg)
   {
      error_clear_last();
      $result = parent::fooBar($arg);
      if ($result === false) {
        throw ApacheException::createFromPhpError();
      }
      return $result;
   }
}

ping @moufmouf what do you think?

edit: duplicate of #7

jderusse avatar Feb 28 '19 07:02 jderusse

Exactly! Overloading classes is harder than overloading functions and I haven't had time to crack the issue yet.

If anyone is feeling up to the task, do not hesitate to give me a hand :)

moufmouf avatar Mar 06 '19 14:03 moufmouf