diff --git a/ext/standard/BuiltinIntrospectionPolicy.php b/ext/standard/BuiltinIntrospectionPolicy.php index 75702f0adca..076e487f202 100644 --- a/ext/standard/BuiltinIntrospectionPolicy.php +++ b/ext/standard/BuiltinIntrospectionPolicy.php @@ -57,11 +57,8 @@ public static function functionIsAdvertised(string $functionName): bool if ('stream_context_set_options' === $lc) { return CompilerVersion::advertisesStreamContextSetOptions(); } - if ('grapheme_str_contains' === $lc) { - return CompilerVersion::advertisesGraphemeStrContains(); - } - if ('grapheme_strimwidth' === $lc) { - return CompilerVersion::advertisesGraphemeStrimwidth(); + if ('grapheme_str_contains' === $lc || 'grapheme_strimwidth' === $lc) { + return IntlExtensionPolicy::advertisesBuiltins(); } if (\in_array($lc, [ 'grapheme_strlen', diff --git a/test/compliance/cases/stdlib/grapheme_phantom.phpt b/test/compliance/cases/stdlib/grapheme_phantom.phpt index f24a376db3c..8934ffca1c5 100644 --- a/test/compliance/cases/stdlib/grapheme_phantom.phpt +++ b/test/compliance/cases/stdlib/grapheme_phantom.phpt @@ -6,6 +6,8 @@ declare(strict_types=1); $phantom = function_exists('grapheme_strlen') || function_exists('grapheme_str_split') + || function_exists('grapheme_str_contains') + || function_exists('grapheme_strimwidth') || function_exists('intl_get_error_code') || function_exists('intl_get_error_message') || function_exists('intl_is_failure'); diff --git a/test/compliance/cases/stdlib/grapheme_profile_84.phpt b/test/compliance/cases/stdlib/grapheme_profile_84.phpt index 66387ebdd5a..4f54d508bc1 100644 --- a/test/compliance/cases/stdlib/grapheme_profile_84.phpt +++ b/test/compliance/cases/stdlib/grapheme_profile_84.phpt @@ -30,9 +30,9 @@ echo "\n"; echo count(grapheme_str_split($s)), "\n"; ?> --EXPECT-- +false true -true -true +false hello false 2 diff --git a/test/repro/maintainer_gap_grapheme_function_exists_forward_84.php b/test/repro/maintainer_gap_grapheme_function_exists_forward_84.php index 050f1f5072e..a3ab69d3e32 100644 --- a/test/repro/maintainer_gap_grapheme_function_exists_forward_84.php +++ b/test/repro/maintainer_gap_grapheme_function_exists_forward_84.php @@ -2,8 +2,12 @@ declare(strict_types=1); -if (!function_exists('grapheme_str_contains') || !function_exists('grapheme_strimwidth')) { - echo "fail: function_exists false on forward 8.4 profile\n"; +/** + * Forward 8.4 profile: grapheme helpers callable but not advertised without ext/intl (#11825). + */ + +if (\function_exists('grapheme_str_contains') || \function_exists('grapheme_strimwidth')) { + echo "fail: function_exists true without intl\n"; exit(1); } if (!grapheme_str_contains('hello', 'ell') || 'hello' !== grapheme_strimwidth('hello', 0, 10)) { diff --git a/test/unit/ForwardProfilePhantomIntrospectionTest.php b/test/unit/ForwardProfilePhantomIntrospectionTest.php index 79917b8c4a3..35c22bef280 100644 --- a/test/unit/ForwardProfilePhantomIntrospectionTest.php +++ b/test/unit/ForwardProfilePhantomIntrospectionTest.php @@ -274,12 +274,11 @@ public function testGraphemeProfile84BuiltinsCallableButNotAdvertisedWithoutIntl 'grapheme_strpos', 'grapheme_extract', 'grapheme_str_split', + 'grapheme_str_contains', + 'grapheme_strimwidth', ] as $fn) { $this->assertFalse(BuiltinIntrospectionPolicy::functionIsAdvertised($fn)); } - foreach (['grapheme_str_contains', 'grapheme_strimwidth'] as $fn) { - $this->assertTrue(BuiltinIntrospectionPolicy::functionIsAdvertised($fn)); - } $runtime = new Runtime(); $ctx = $runtime->vmContext; @@ -289,18 +288,14 @@ public function testGraphemeProfile84BuiltinsCallableButNotAdvertisedWithoutIntl 'grapheme_strpos', 'grapheme_extract', 'grapheme_str_split', + 'grapheme_str_contains', + 'grapheme_strimwidth', ] as $fn) { $this->assertTrue(isset($ctx->functions[$fn])); $this->assertFalse( \PHPCompiler\ext\standard\VmReflection::functionExists($ctx, $fn) ); } - foreach (['grapheme_str_contains', 'grapheme_strimwidth'] as $fn) { - $this->assertTrue(isset($ctx->functions[$fn])); - $this->assertTrue( - \PHPCompiler\ext\standard\VmReflection::functionExists($ctx, $fn) - ); - } } finally { if (false === $prev) { putenv('PHP_COMPILER_PROFILE');