Skip to content

A dynamic-name store of a non-numeric string into a typed int property throws "Argument must be of type int, string given" instead of "Cannot assign string to property Tp::$x of type int" #472

Closed

Description

@blacktrs

Summary

A dynamic-name store of a non-numeric string into a typed int property throws "Argument must be of type int, string given" instead of "Cannot assign string to property Tp::$x of type int".

Repro

<?php
class Tp { public int $x = 0; }
$o = new Tp();
$set = \Closure::bind(function (string $k, string $v): void { $this->$k = $v; }, $o, 'Tp');
try { $set('x', 'abc'); echo "no error\n"; } catch (Throwable $e) { echo get_class($e), ': ', $e->getMessage(), "\n"; }

Expected (php)

TypeError: Cannot assign string to property Tp::$x of type int

Actual (manticore d1ecb013, Darwin arm64)

Error: Using $this when not in object context

Tracking

Known-bug repro: tests/aot/repro/wrong/typed_property_dynamic_store_error_text.php — bash tests/aot/xfail.sh -k typed_property_dynamic_store_error_text 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 25, 2026
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