Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 506... Línea 506...
506
                            $state = 'id_name';
506
                            $state = 'id_name';
507
                    }
507
                    }
508
                    break;
508
                    break;
509
                case 'id_name':
509
                case 'id_name':
510
                    switch ($token[0]) {
510
                    switch ($token[0]) {
511
                        // named arguments...
511
                        case $token[0] === ':' && ! in_array($context, ['instanceof', 'new'], true):
512
                        case ':':
-
 
513
                            if ($lastState === 'closure' && $context === 'root') {
512
                            if ($lastState === 'closure' && $context === 'root') {
514
                                $state = 'closure';
513
                                $state = 'closure';
515
                                $code .= $id_start.$token;
514
                                $code .= $id_start.$token;
516
                            }
515
                            }
Línea 679... Línea 678...
679
 
678
 
680
        $this->isShortClosure = $isShortClosure;
679
        $this->isShortClosure = $isShortClosure;
681
        $this->isBindingRequired = $isUsingThisObject;
680
        $this->isBindingRequired = $isUsingThisObject;
Línea 682... Línea -...
682
        $this->isScopeRequired = $isUsingScope;
-
 
683
 
681
        $this->isScopeRequired = $isUsingScope;
684
        if (PHP_VERSION_ID >= 80100) {
682
 
Línea 685... Línea 683...
685
            $attributesCode = array_map(function ($attribute) {
683
        $attributesCode = array_map(function ($attribute) {
686
                $arguments = $attribute->getArguments();
684
            $arguments = $attribute->getArguments();
687
 
685
 
Línea 688... Línea 686...
688
                $name = $attribute->getName();
686
            $name = $attribute->getName();
689
                $arguments = implode(', ', array_map(function ($argument, $key) {
687
            $arguments = implode(', ', array_map(function ($argument, $key) {
690
                    $argument = sprintf("'%s'", str_replace("'", "\\'", $argument));
688
                $argument = sprintf("'%s'", str_replace("'", "\\'", $argument));
Línea 691... Línea 689...
691
 
689
 
692
                    if (is_string($key)) {
690
                if (is_string($key)) {
Línea 693... Línea 691...
693
                        $argument = sprintf('%s: %s', $key, $argument);
691
                    $argument = sprintf('%s: %s', $key, $argument);
694
                    }
692
                }
Línea 695... Línea 693...
695
 
693
 
696
                    return $argument;
694
                return $argument;
697
                }, $arguments, array_keys($arguments)));
-
 
698
 
695
            }, $arguments, array_keys($arguments)));
Línea 699... Línea 696...
699
                return "#[$name($arguments)]";
696
 
Línea 700... Línea 697...
700
            }, $this->getAttributes());
697
            return "#[$name($arguments)]";
Línea 714... Línea 711...
714
     *
711
     *
715
     * @return array
712
     * @return array
716
     */
713
     */
717
    protected static function getBuiltinTypes()
714
    protected static function getBuiltinTypes()
718
    {
715
    {
719
        // PHP 8.1
-
 
720
        if (PHP_VERSION_ID >= 80100) {
-
 
721
            return ['array', 'callable', 'string', 'int', 'bool', 'float', 'iterable', 'void', 'object', 'mixed', 'false', 'null', 'never'];
716
        return ['array', 'callable', 'string', 'int', 'bool', 'float', 'iterable', 'void', 'object', 'mixed', 'false', 'null', 'never'];
722
        }
-
 
723
 
-
 
724
        // PHP 8
-
 
725
        if (\PHP_MAJOR_VERSION === 8) {
-
 
726
            return ['array', 'callable', 'string', 'int', 'bool', 'float', 'iterable', 'void', 'object', 'mixed', 'false', 'null'];
-
 
727
        }
-
 
728
 
-
 
729
        // PHP 7
-
 
730
        switch (\PHP_MINOR_VERSION) {
-
 
731
            case 0:
-
 
732
                return ['array', 'callable', 'string', 'int', 'bool', 'float'];
-
 
733
            case 1:
-
 
734
                return ['array', 'callable', 'string', 'int', 'bool', 'float', 'iterable', 'void'];
-
 
735
            default:
-
 
736
                return ['array', 'callable', 'string', 'int', 'bool', 'float', 'iterable', 'void', 'object'];
-
 
737
        }
-
 
738
    }
717
    }
Línea 739... Línea 718...
739
 
718
 
740
    /**
719
    /**
741
     * Gets the use variables by the closure.
720
     * Gets the use variables by the closure.
Línea 805... Línea 784...
805
 
784
 
806
        return $this->isScopeRequired;
785
        return $this->isScopeRequired;
Línea 807... Línea 786...
807
    }
786
    }
808
 
787
 
809
    /**
788
    /**
810
     * The the hash of the current file name.
789
     * The hash of the current file name.
811
     *
790
     *
812
     * @return string
791
     * @return string
813
     */
792
     */
Línea 1134... Línea 1113...
1134
                            break;
1113
                            break;
1135
                        case '}':
1114
                        case '}':
1136
                            if (--$open == 0) {
1115
                            if (--$open == 0) {
1137
                                if (! $structIgnore) {
1116
                                if (! $structIgnore) {
1138
                                    $structures[] = [
1117
                                    $structures[] = [
1139
                                        'type'  => $structType,
1118
                                        'type' => $structType,
1140
                                        'name'  => $structName,
1119
                                        'name' => $structName,
1141
                                        'start' => $startLine,
1120
                                        'start' => $startLine,
1142
                                        'end'   => $endLine,
1121
                                        'end' => $endLine,
1143
                                    ];
1122
                                    ];
1144
                                }
1123
                                }
1145
                                $structIgnore = false;
1124
                                $structIgnore = false;
1146
                                $state = 'start';
1125
                                $state = 'start';
1147
                            }
1126
                            }
Línea 1168... Línea 1147...
1168
     */
1147
     */
1169
    protected function getClosureNamespaceName()
1148
    protected function getClosureNamespaceName()
1170
    {
1149
    {
1171
        $ns = $this->getNamespaceName();
1150
        $ns = $this->getNamespaceName();
Línea -... Línea 1151...
-
 
1151
 
-
 
1152
        $name = $this->getName();
1172
 
1153
 
-
 
1154
        // First class callables...
-
 
1155
        if ($name !== '{closure}'
-
 
1156
            && ! str_contains($name, '{closure:/')
-
 
1157
            && ! str_contains($name, '{closure:\\')
1173
        // First class callables...
1158
            && empty($ns)
1174
        if ($this->getName() !== '{closure}' && empty($ns) && ! is_null($this->getClosureScopeClass())) {
1159
            && ! is_null($this->getClosureScopeClass())) {
1175
            $ns = $this->getClosureScopeClass()->getNamespaceName();
1160
            $ns = $this->getClosureScopeClass()->getNamespaceName();
Línea 1176... Línea 1161...
1176
        }
1161
        }
1177
 
1162