ArgumentCountError PHP Origin: Application & API OSI layer 7 · Application Last updated 12 Oct 2026

Fatal error: Uncaught ArgumentCountError: Too few arguments to function foo(), 1 passed and exactly 2 expected

A function was called with fewer arguments than it requires.

Exact message you may see Too few arguments to function
Seen on: PHP

Meaning

Since PHP 7.1 missing required arguments throw ArgumentCountError. Common after adding a parameter to a function or constructor without updating every caller — including dependency-injection containers.

Common causes

  • New required parameter added; old callers not updated
  • Constructor injection missing a dependency
  • Callback invoked with fewer arguments than it declares

⚡ Quick fix

  1. Update callers or give the new parameter a default value
  2. Register the missing dependency in your DI container
  3. Make callback parameters optional

Detailed fix by platform

PHP

  1. Search the codebase for the function name after changing a signature; PHPStan reports mismatched calls

How to diagnose

  1. Function — Name and expected count in the message
  2. Caller — The stack trace's next frame

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Application & API. Errors that are often confused with or caused by this one (click to open):

42883 function — ERROR: function x(text) does not exist — No function matches the given name and argument types (PostgreSQL)42883 functionAllowed memory size exhausted — PHP Fatal error: Allowed memory size of X bytes exhausted (PHP)Allowed memory size e…Call to member function on null — Fatal error: Uncaught Error: Call to a member function x() on null (PHP)Call to member functi…Call to undefined function — PHP Fatal error: Uncaught Error: Call to undefined function (PHP)Call to undefined fun…Call to undefined function (WordPress) — WordPress: Fatal error: Uncaught Error: Call to undefined function wp_get_current_user() / add_action() / get_header() (WordPress)Call to undefined fun…Cannot redeclare — Fatal error: Cannot redeclare function foo() (previously declared in …) (PHP)Cannot redeclareCannot use object as array — Fatal error: Uncaught Error: Cannot use object of type stdClass as array (PHP)Cannot use object as …Composer memory — Composer: PHP Fatal error: Allowed memory size of 1610612736 bytes exhausted (PHP)Composer memoryArgumentC…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.