# PHP Fatal error: Uncaught ValueError: x(): Argument #1 ($y) must be ... (PHP 8)

**Code:** `Uncaught ValueError` · **Category:** PHP · **Seen on:** PHP

A built-in function received a value of the right type but an invalid content.

## Meaning

PHP 8 converted many warnings into `ValueError`, for example `array_combine` with different lengths, `str_repeat` with a negative count, `mb_substr` with bad encoding or `max([])`.

## Common causes

- Empty array passed to `max()`/`min()`
- Negative or zero length/count argument
- `array_combine` with different sized arrays
- Invalid encoding or flag value

## Quick fix

1. Validate arguments before calling
2. Read the message for the argument number and rule
3. Handle empty collections explicitly

## Detailed fix by platform

### PHP

1. `if ($items) { $m = max($items); }`

## How to diagnose

1. **Function** — Which?
2. **Argument** — Which number?
3. **Data** — Empty or out of range?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/php/php-valueerror-uncaught)
