Skip to content

array_replace() of an int-valued literal and an (array)$object throws "Argument must be of type int, string given". #258

Closed

Description

@blacktrs

Summary

array_replace() of an int-valued literal and an (array)$object throws "Argument must be of type int, string given".

Repro

<?php
class Ex extends \RuntimeException { protected string $t = 'x'; }
function f(object $o): int { $a = (array) $o; return \count(array_replace(['z' => 1], $a)); }
echo f(new Ex('m')), "\n";

Expected (php)

9

Actual (manticore 2b2190b5, Darwin arm64)


[exit code 255]
PHP Fatal error:  Uncaught TypeError: Argument must be of type int, string given

Tracking

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

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