Skip to content

A string passed to a native callable parameter is wrapped in a Closure, so is_string() on it answers false. #615

Open

Description

@blacktrs

Summary

A string passed to a native callable parameter is wrapped in a Closure, so is_string() on it answers false.

Repro

<?php
function kind(callable $c): string { return (is_string($c) ? "string" : (is_array($c) ? "array" : "object")) . ":" . $c("A"); }
class K { public static function lo(string $x): string { return strtolower($x); } }
echo kind("strtolower"), " ", kind(["K", "lo"]), " ", kind(fn($x) => $x . $x), "\n";

Expected (php)

string:a array:a object:AA

Actual (manticore 327267eb, Darwin arm64)

object:a object:a object:AA

Tracking

Known-bug repro: tests/aot/repro/wrong/callable_param_string_identity.php — bash tests/aot/xfail.sh -k callable_param_string_identity 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 Nov 10, 2026
  2. blacktrs commented on Nov 12, 2026

    @blacktrs
    ContributorAuthor

    Root cause found during the #655 sweep (not fixed, needs design): literal string/array callables passed to a callable param are turned into closures at lowering (LowerFns::coerceCallableArg), and callable is typed KIND_CLOSURE. Keeping the string needs callable params typed as cells plus by-name dispatch to builtins/stdlib (the erased name arm only matches user functions) — it touches every array_map('strtoupper', …) site.

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