Skip to content

Migration guide PHP8.5 - New Features - NoDiscard - error in code #5008

@germainpigeon

Description

@germainpigeon

From manual page: https://php.net/migration85.new-features


There is:

<?php

#[\NoDiscard]
function concat(string $a, string $b): string {
     return a + b;
}

But it does:
Fatal error: Uncaught Error: Undefined constant "a"

There should be:

<?php

#[\NoDiscard]
function concat(string $a, string $b): string {
     return $a + $b;
}

(with added "$"s)

-      return a + b;
+      return $a + $b;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions