Uploaded image for project: 'PHP Driver: Extension'
  1. PHP Driver: Extension
  2. PHPC-1699

Ensure all zpp errors are proxied by InvalidArgumentException

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 1.9.0-rc1, 1.9.0
    • Affects Version/s: None
    • Component/s: None
    • None

      The extension has long documented that its methods throw MongoDB\Driver\Exception\InvalidArgumentException for argument parsing errors. We can reconsider this in 2.0, but that is the current state of the extension (for better or for worse).

      Most all constructors temporarily define a custom error handler around zend_parse_parameters to convert emitted warnings into exceptions, which works for PHP 7.0 and earlier. Since PHP 7.1, it became possible for zpp to throw a TypeError, which was accounted for in cbca068 for PHPC-1435; however, not many tests were exposed to this. As of PHP 8, zpp now also throws an ArgumentCountError, which did affect many tests.

      For consistency with our own documentation, I'd suggest we proxy all Errors thrown by zpp with a InvalidArgumentException. The original Error will still be accessible as the previous exception.

      Note: Many non-constructor methods do not define a custom error handler, so those methods may still emit warnings (particularly on PHP 7.x, but likely not on PHP 8). We can consider fixing that as well if we want to enforce total consistency.

            Assignee:
            andreas.braun@mongodb.com Andreas Braun
            Reporter:
            jmikola@mongodb.com Jeremy Mikola
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: