Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

SandavHeena's avatar

PHP Deprecated message only on server

PHP Deprecated: Optional parameter $importLastOccurrenceOnly declared before required parameter $param is implicitly treated as a required parameter. This error not getting on local but on server.

0 likes
9 replies
gych's avatar

The error tells you exactly what the issue is

You need to declare optional parameters after required paramaters.

Here is an example:

function index($param, $importLastOccurrenceOnly = 'value')
gych's avatar

@SandavHeena Change it on local to, it can give you unexpected results when those params are not in the right order. That's why this is deprecated.

Which PHP version do you use locally and on the server?

gych's avatar

@SandavHeena Is this exactly the same version both on local and on server ? This is deprecated since PHP version 8.0

SandavHeena's avatar

@gych protected function importDataRows( TimestampRange $importTimestamps, array $toExclude = null, array $uniqueConstraint = null, $importLastOccurrenceOnly = false, $param ): array {

gych's avatar

@SandavHeena Strange that you're not getting the error on local but anyways its good to change it to this:

protected function importDataRows(TimestampRange $importTimestamps, $param, array $toExclude = null, array $uniqueConstraint = null, $importLastOccurrenceOnly = false): array {

Also change this at places in your code where you call this method so the parameters are added in the right order.

Please or to participate in this conversation.