Too Few Arguments to Function

Fatal error: Uncaught ArgumentCountError: Too few arguments to function App\Service::calculate(), 1 passed and exactly 2 expected

Quick Answer

You are calling a function with fewer arguments than it requires. Add the missing arguments or give the parameters default values.

Why This Happens

PHP 7.1+ throws ArgumentCountError when a function receives fewer arguments than its required parameters. This replaces the older warning. It happens when you forget an argument, when a function signature changes but call sites are not updated, or when using call_user_func with the wrong number of arguments.

The Problem

function sendEmail(string $to, string $subject, string $body): void {
    // ...
}
sendEmail('user@example.com', 'Hello'); // Missing $body argument

The Fix

function sendEmail(string $to, string $subject, string $body = ''): void {
    // ...
}
sendEmail('user@example.com', 'Hello'); // Works with default body
// Or provide all arguments:
sendEmail('user@example.com', 'Hello', 'Welcome aboard!');

Step-by-Step Fix

  1. 1

    Check the function signature

    Look at the function definition to see how many parameters are required and what types they expect.

  2. 2

    Fix the call site

    Add the missing arguments to the function call, providing appropriate values for each required parameter.

  3. 3

    Add defaults if appropriate

    If an argument is often optional, add a default value to the parameter in the function definition.

Got the actual stack trace?

Paste it into our free AI explainer to get the cause and the fix for your specific case — no signup, nothing to install.

Explain my error

Bugsly catches this automatically

Bugsly's AI analyzes this error pattern in real-time, explains what went wrong in plain English, and suggests the exact fix — before your users even report it.

Try Bugsly free