@@ -984,7 +984,7 @@ public function getMethodSynopsisFilename(): string {
984
984
}
985
985
986
986
public function getAttributeName (): string {
987
- return $ this ->name ->toString ();
987
+ return strtolower ( $ this ->name ->toString () );
988
988
}
989
989
990
990
public function __toString (): string {
@@ -1032,7 +1032,7 @@ public function getMethodSynopsisFilename(): string {
1032
1032
}
1033
1033
1034
1034
public function getAttributeName (): string {
1035
- return $ this ->methodName ;
1035
+ return strtolower ( $ this ->methodName ) ;
1036
1036
}
1037
1037
1038
1038
public function __toString (): string {
@@ -3598,7 +3598,11 @@ function findEquivalentFuncInfo(array $generatedFuncInfos, FuncInfo $funcInfo):
3598
3598
return null ;
3599
3599
}
3600
3600
3601
- /** @param iterable $infos */
3601
+ /**
3602
+ * @template T
3603
+ * @param iterable<T> $infos
3604
+ * @param Closure(T): string|null $codeGenerator
3605
+ */
3602
3606
function generateCodeWithConditions (
3603
3607
iterable $ infos , string $ separator , Closure $ codeGenerator ): string {
3604
3608
$ code = "" ;
@@ -3636,7 +3640,7 @@ function generateArgInfoCode(
3636
3640
$ generatedFuncInfos = [];
3637
3641
$ code .= generateCodeWithConditions (
3638
3642
$ fileInfo ->getAllFuncInfos (), "\n" ,
3639
- function (FuncInfo $ funcInfo ) use (&$ generatedFuncInfos ) {
3643
+ static function (FuncInfo $ funcInfo ) use (&$ generatedFuncInfos ) {
3640
3644
/* If there already is an equivalent arginfo structure, only emit a #define */
3641
3645
if ($ generatedFuncInfo = findEquivalentFuncInfo ($ generatedFuncInfos , $ funcInfo )) {
3642
3646
$ code = sprintf (
@@ -3658,7 +3662,7 @@ function (FuncInfo $funcInfo) use(&$generatedFuncInfos) {
3658
3662
$ generatedFunctionDeclarations = [];
3659
3663
$ code .= generateCodeWithConditions (
3660
3664
$ fileInfo ->getAllFuncInfos (), "" ,
3661
- function (FuncInfo $ funcInfo ) use ($ fileInfo , &$ generatedFunctionDeclarations ) {
3665
+ static function (FuncInfo $ funcInfo ) use ($ fileInfo , &$ generatedFunctionDeclarations ) {
3662
3666
$ key = $ funcInfo ->getDeclarationKey ();
3663
3667
if (isset ($ generatedFunctionDeclarations [$ key ])) {
3664
3668
return null ;
@@ -3683,6 +3687,7 @@ function (FuncInfo $funcInfo) use($fileInfo, &$generatedFunctionDeclarations) {
3683
3687
$ attributeInitializationCode = generateAttributeInitialization ($ fileInfo , $ classEntriesWithSensitiveParams );
3684
3688
3685
3689
if ($ attributeInitializationCode !== "" || !empty ($ fileInfo ->constInfos )) {
3690
+ $ classEntriesWithSensitiveParams = array_unique ($ classEntriesWithSensitiveParams );
3686
3691
$ code .= "\nstatic void register_ {$ stubFilenameWithoutExtension }_symbols(int module_number " ;
3687
3692
foreach ($ classEntriesWithSensitiveParams as $ ce ) {
3688
3693
$ code .= ", zend_class_entry * $ ce " ;
@@ -3732,7 +3737,7 @@ function generateFunctionEntries(?Name $className, array $funcInfos): string {
3732
3737
}
3733
3738
3734
3739
$ code .= "\n\nstatic const zend_function_entry {$ functionEntryName }[] = { \n" ;
3735
- $ code .= generateCodeWithConditions ($ funcInfos , "" , function (FuncInfo $ funcInfo ) {
3740
+ $ code .= generateCodeWithConditions ($ funcInfos , "" , static function (FuncInfo $ funcInfo ) {
3736
3741
return $ funcInfo ->getFunctionEntry ();
3737
3742
});
3738
3743
$ code .= "\tZEND_FE_END \n" ;
@@ -3742,27 +3747,31 @@ function generateFunctionEntries(?Name $className, array $funcInfos): string {
3742
3747
}
3743
3748
3744
3749
function generateAttributeInitialization (FileInfo $ fileInfo , array &$ classEntriesWithSensitiveParams ): string {
3745
- $ code = "" ;
3750
+ return generateCodeWithConditions (
3751
+ $ fileInfo ->getAllFuncInfos (),
3752
+ "" ,
3753
+ static function (FuncInfo $ funcInfo ) use (&$ classEntriesWithSensitiveParams ) {
3754
+ $ code = null ;
3755
+
3756
+ foreach ($ funcInfo ->args as $ index => $ arg ) {
3757
+ if (!$ arg ->isSensitive ) {
3758
+ continue ;
3759
+ }
3746
3760
3747
- foreach ($ fileInfo ->getAllFuncInfos () as $ funcInfo ) {
3748
- foreach ($ funcInfo ->args as $ index => $ arg ) {
3749
- if (!$ arg ->isSensitive ) {
3750
- continue ;
3751
- }
3761
+ if ($ funcInfo ->name instanceof MethodName) {
3762
+ $ classEntry = "class_entry_ " . str_replace ("\\" , "_ " , $ funcInfo ->name ->className ->toString ());
3763
+ $ functionTable = "& {$ classEntry }->function_table " ;
3764
+ $ classEntriesWithSensitiveParams [] = $ classEntry ;
3765
+ } else {
3766
+ $ functionTable = "CG(function_table) " ;
3767
+ }
3752
3768
3753
- if ($ funcInfo ->name instanceof MethodName) {
3754
- $ classEntry = "class_entry_ " . str_replace ("\\" , "_ " , $ funcInfo ->name ->className ->toString ());
3755
- $ functionTable = "& {$ classEntry }->function_table " ;
3756
- $ classEntriesWithSensitiveParams [] = $ classEntry ;
3757
- } else {
3758
- $ functionTable = "CG(function_table) " ;
3769
+ $ code .= " zend_mark_function_parameter_as_sensitive( $ functionTable, \"" . $ funcInfo ->name ->getAttributeName () . "\", $ index); \n" ;
3759
3770
}
3760
3771
3761
- $ code .= " zend_mark_function_parameter_as_sensitive( $ functionTable , \"" . $ funcInfo -> name -> getAttributeName () . "\" , $ index ); \n" ;
3772
+ return $ code ;
3762
3773
}
3763
- }
3764
-
3765
- return $ code ;
3774
+ );
3766
3775
}
3767
3776
3768
3777
/** @param FuncInfo<string, FuncInfo> $funcInfos */
@@ -3772,7 +3781,7 @@ function generateOptimizerInfo(array $funcInfos): string {
3772
3781
3773
3782
$ code .= "static const func_info_t func_infos[] = { \n" ;
3774
3783
3775
- $ code .= generateCodeWithConditions ($ funcInfos , "" , function (FuncInfo $ funcInfo ) {
3784
+ $ code .= generateCodeWithConditions ($ funcInfos , "" , static function (FuncInfo $ funcInfo ) {
3776
3785
return $ funcInfo ->getOptimizerInfo ();
3777
3786
});
3778
3787
@@ -4169,7 +4178,7 @@ function initPhpParser() {
4169
4178
installPhpParser ($ version , $ phpParserDir );
4170
4179
}
4171
4180
4172
- spl_autoload_register (function (string $ class ) use ($ phpParserDir ) {
4181
+ spl_autoload_register (function (string $ class ) use ($ phpParserDir ) {
4173
4182
if (strpos ($ class , "PhpParser \\" ) === 0 ) {
4174
4183
$ fileName = $ phpParserDir . "/lib/ " . str_replace ("\\" , "/ " , $ class ) . ".php " ;
4175
4184
require $ fileName ;
0 commit comments