@@ -8535,6 +8535,102 @@ public function testDynamicConstantsWithNativeTypes(
85358535 );
85368536 }
85378537
8538+ public function dataMixedTypeConstants (): array
8539+ {
8540+ return [
8541+ [
8542+ 'mixed ' ,
8543+ 'MixedTypeConstants\MixedTypeConstantClass::MIXED_TYPE_CONSTANT_IN_CLASS ' ,
8544+ ],
8545+ [
8546+ "'abc123def' " ,
8547+ 'MixedTypeConstants\MixedTypeConstantClass::PURE_CONSTANT_IN_CLASS ' ,
8548+ ],
8549+ [
8550+ "'xyz' " ,
8551+ 'MixedTypeConstants\NoMixedTypeConstantClass::MIXED_TYPE_CONSTANT_IN_CLASS ' ,
8552+ ],
8553+ [
8554+ 'false ' ,
8555+ 'GLOBAL_MIXED_TYPE_CONSTANT ' ,
8556+ ],
8557+ [
8558+ '123 ' ,
8559+ 'GLOBAL_PURE_CONSTANT ' ,
8560+ ],
8561+ ];
8562+ }
8563+
8564+ /**
8565+ * @dataProvider dataMixedTypeConstants
8566+ */
8567+ public function testMixedTypeConstants (
8568+ string $ description ,
8569+ string $ expression ,
8570+ ): void
8571+ {
8572+ $ this ->assertTypes (
8573+ __DIR__ . '/data/mixed-type-constant.php ' ,
8574+ $ description ,
8575+ $ expression ,
8576+ 'die ' ,
8577+ [],
8578+ true ,
8579+ [
8580+ 'MixedTypeConstants \\MixedTypeConstantClass::MIXED_TYPE_CONSTANT_IN_CLASS ' ,
8581+ 'GLOBAL_MIXED_TYPE_CONSTANT ' ,
8582+ ],
8583+ );
8584+ }
8585+
8586+ public function dataMixedTypeConstantsWithNativeTypes (): array
8587+ {
8588+ return [
8589+ [
8590+ 'int ' ,
8591+ 'MixedTypeConstantNativeTypes\Foo::FOO ' ,
8592+ ],
8593+ [
8594+ 'int|string ' ,
8595+ 'MixedTypeConstantNativeTypes\Foo::BAR ' ,
8596+ ],
8597+ [
8598+ 'int ' ,
8599+ '$foo::FOO ' ,
8600+ ],
8601+ [
8602+ 'int|string ' ,
8603+ '$foo::BAR ' ,
8604+ ],
8605+ ];
8606+ }
8607+
8608+ /**
8609+ * @dataProvider dataMixedTypeConstantsWithNativeTypes
8610+ */
8611+ public function testMixedTypeConstantsWithNativeTypes (
8612+ string $ description ,
8613+ string $ expression ,
8614+ ): void
8615+ {
8616+ if (PHP_VERSION_ID < 80300 ) {
8617+ $ this ->markTestSkipped ('Test requires PHP 8.3. ' );
8618+ }
8619+
8620+ $ this ->assertTypes (
8621+ __DIR__ . '/data/mixed-type-constant-native-types.php ' ,
8622+ $ description ,
8623+ $ expression ,
8624+ 'die ' ,
8625+ [],
8626+ true ,
8627+ [
8628+ 'MixedTypeConstantNativeTypes\Foo::FOO ' ,
8629+ 'MixedTypeConstantNativeTypes\Foo::BAR ' ,
8630+ ],
8631+ );
8632+ }
8633+
85388634 public function dataIsset (): array
85398635 {
85408636 return [
@@ -9545,6 +9641,7 @@ public function testTryCatchScope(
95459641
95469642 /**
95479643 * @param string[] $dynamicConstantNames
9644+ * @param string[] $mixedTypeConstantNames
95489645 */
95499646 private function assertTypes (
95509647 string $ file ,
@@ -9553,6 +9650,7 @@ private function assertTypes(
95539650 string $ evaluatedPointExpression = 'die ' ,
95549651 array $ dynamicConstantNames = [],
95559652 bool $ useCache = true ,
9653+ array $ mixedTypeConstantNames = [],
95569654 ): void
95579655 {
95589656 $ assertType = function (Scope $ scope ) use ($ expression , $ description , $ evaluatedPointExpression ): void {
@@ -9587,6 +9685,7 @@ static function (Node $node, Scope $scope) use ($file, $evaluatedPointExpression
95879685 $ assertType ($ scope );
95889686 },
95899687 $ dynamicConstantNames ,
9688+ $ mixedTypeConstantNames ,
95909689 );
95919690 }
95929691
0 commit comments