Skip to content

self::$counter++ used as an expression yields the incremented value instead of the old one #192

Closed

Description

@blacktrs

Summary

self::$counter++ used as an expression yields the incremented value instead of the old one.

Repro

<?php
class C
{
    private static int $counter = 0;

    public function next(): int
    {
        return self::$counter++;
    }

    public function label(string $name): string
    {
        return $name . '_' . self::$counter++;
    }
}

$c = new C();
echo $c->next(), $c->next(), ' ', $c->label('a'), ' ', $c->label('a'), "\n";

Expected (php)

01 a_2 a_3

Actual (manticore 25811c88, Darwin arm64)

12 a_3 a_4

Tracking

Known-bug repro: tests/aot/repro/wrong/static_property_post_increment_returns_new_value.php — bash tests/aot/xfail.sh -k static_property_post_increment_returns_new_value reports XFAIL while this is open and XPASS once it is fixed; then move the repro into tests/aot/cases/ and close this issue.

Activity

  1. added
    bug
    wrong-answer
    on Oct 11, 2026
  2. added a commit that references this issue on Oct 14, 2026
    2fe0c50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugwrong-answer

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions