title: Catching unknown named parameter errors
body: <p>Functions with missing arguments throws the <code>ArgumentCountError</code> error</p>
  <blockquote>
  <p>ArgumentCountError: Too few arguments to function ...</p>
  </blockquote>
  <p>Whereas unknown named parameter only throws a generic error</p>
  <blockquote>
  <p>Error: Unknown named parameter ...</p>
  </blockquote>
  <p>I want to catch these only these two error and so far I have the following</p>
  <pre><code>function foo(int $bar, int $baz) {}
  
  try {
      foo(...$arr); // $arr is always an associative array
  
  } catch (ArgumentCountError $error) {
      // ...
  
  } catch (Error $error) {
      if (preg_match(&quot;/^Unknown named parameter/&quot;, $e-&gt;getMessage())) {
          // ...
  
      } else {
          throw $error;
      }
  }
  </code></pre>
  <p>What alternative approaches do I have? Shouldn't <code>Unknown named parameter</code> get it's own error.</p>
  <p>Edit:</p>
  <p>For a <code>UnknownNamedParameterError</code> usage</p>
  <pre><code>try {
      $dynamicFoo(...$args);
  
  } catch (UnknownNamedParameterError $error) {
      // if needed, a check to confirm the error happened in foo
      if (($error-&gt;getTrace()[0][&quot;function&quot;] ?? null) === $dynamicFoo) {
          // Hacky but whatever
  
      }
  }
  </code></pre>