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