1--TEST-- 2Bug #73789 (Strange behavior of class constants in switch/case block) 3--EXTENSIONS-- 4opcache 5ctype 6--FILE-- 7<?php 8class Lexer 9{ 10 const T_NONE = 1; 11 const T_STRING = 2; 12 const T_DOT = 8; 13 public function getType($value): int 14 { 15 $type = self::T_NONE; 16 switch (true) { 17 case ctype_alpha($value[0]): 18 $name = 'Lexer::T_' . strtoupper($value); 19 $type = constant($name); 20 if ($type > 100) { 21 return $type; 22 } 23 return self::T_STRING; 24 case $value === '.': 25 return self::T_DOT; 26 default: 27 } 28 return $type; 29 } 30} 31var_dump((new Lexer())->getType("dot")); 32?> 33--EXPECT-- 34int(2) 35