Skip to content

Confusing error message "expecting amp" #18026

Closed
@DanielEScherzer

Description

@DanielEScherzer

Description

The following code (https://3v4l.org/oMXAL)

<?php

class Demo {
    private (set) mixed $v1;
}

Resulted in this output:

Parse error: syntax error, unexpected token ")", expecting amp in /in/oMXAL on line 4

But I expected this output instead:

Parse error: syntax error, unexpected token ")", expecting ampersand in /in/oMXAL on line 4

(or expecting "&")

Alternatively, for the limited case of wrong asymmetric visibility specification (there shouldn't be a space in private(set)) maybe mention that? But for things other than (set) the amp is still a bit confusing

PHP Version

8.3+

Operating System

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions