Skip to content

Regression: ctype_*() — enum case operands return true not false (re-#8962, ext/standard/ctype.c) #8995

Description

@PurHur

Category

stdlib | regression (re-#8962)

Problem

Zend ctype_*() returns false when the operand is an enum case object (not a string). This compiler coerces backed enum cases to their backing string and returns true — e.g. ctype_alpha(E::A) with E::A = 'abc' → true instead of false.

Issue #8962 was closed; repro still wrong on VM (verified 2026-06-16).

php-src reference

Repro

test/repro/maintainer_gap_ctype_enum.php:

<?php
enum E: string { case A = 'abc'; case B = '123'; }

var_dump(ctype_alpha(E::A));
var_dump(ctype_digit(E::B));
var_dump(ctype_alnum(E::A));
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php test/repro/maintainer_gap_ctype_enum.php
php bin/vm.php test/repro/maintainer_gap_ctype_enum.php
'
Call Zend PHP 8.x VM (2026-06-16)
ctype_alpha(E::A) bool(false) bool(true)
ctype_digit(E::B) bool(false) bool(true)
ctype_alnum(E::A) bool(false) bool(true)

Scope

  • ext/ctype/*.php VM handlers — reject enum case objects before backing coercion (shared guard like VmMath::rejectEnumCaseOperand)
  • ext/ctype/JitCtype*.php — match VM at JIT compile time when operand type is provably enum
  • Registration: ext/ctype/Module.php

Done when

  • Repro matches Zend line-for-line on VM
  • Compliance PHPT: test/compliance/cases/stdlib/ctype_enum_operand.phpt
  • Capability matrix unchanged (functions already registered)

Activity

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

    area:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web apps

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions