@@ -410,12 +410,10 @@ private function PartialStatement(PartialStatement $statement): string
410410 if ($ name instanceof SubExpression) {
411411 $ p = $ this ->SubExpression ($ name );
412412 $ this ->context ->usedDynPartial ++;
413- } elseif ( $ name instanceof PathExpression || $ name instanceof StringLiteral || $ name instanceof NumberLiteral) {
413+ } else {
414414 $ partialName = $ this ->resolvePartialName ($ name );
415415 $ p = self ::quote ($ partialName );
416416 $ this ->resolveAndCompilePartial ($ partialName );
417- } else {
418- $ p = $ this ->compileExpression ($ name );
419417 }
420418
421419 $ vars = $ this ->compilePartialParams ($ statement ->params , $ statement ->hash );
@@ -452,36 +450,29 @@ private function PartialBlockStatement(PartialBlockStatement $statement): string
452450 $ name = $ statement ->name ;
453451 $ depsBefore = count ($ this ->programDepStack [array_key_last ($ this ->programDepStack )]);
454452 $ body = $ this ->compileProgram ($ statement ->program );
455- $ partialName = null ;
456- $ found = false ;
457453
458- if ($ name instanceof PathExpression || $ name instanceof StringLiteral || $ name instanceof NumberLiteral) {
459- $ partialName = $ this ->resolvePartialName ($ name );
460- $ p = self ::quote ($ partialName );
461- $ found = ($ this ->context ->usedPartial [$ partialName ] ?? '' ) !== '' ;
462-
463- if (!$ found && !str_starts_with ($ partialName , '@partial-block ' )) {
464- $ cnt = $ this ->resolvePartial ($ partialName );
465- if ($ cnt !== null ) {
466- $ this ->context ->usedPartial [$ partialName ] = $ cnt ;
467- $ this ->compilePartialTemplate ($ partialName , $ cnt );
468- $ found = true ;
469- }
470- }
454+ $ partialName = $ this ->resolvePartialName ($ name );
455+ $ p = self ::quote ($ partialName );
456+ $ found = ($ this ->context ->usedPartial [$ partialName ] ?? '' ) !== '' ;
471457
472- // Mark as known for runtime resolution; not added to partialCode so $blockParams scope is preserved.
473- $ this ->context ->usedPartial [$ partialName ] ??= '' ;
474- } else {
475- $ p = $ this ->compileExpression ($ name );
458+ if (!$ found && !str_starts_with ($ partialName , '@partial-block ' )) {
459+ $ cnt = $ this ->resolvePartial ($ partialName );
460+ if ($ cnt !== null ) {
461+ $ this ->context ->usedPartial [$ partialName ] = $ cnt ;
462+ $ this ->compilePartialTemplate ($ partialName , $ cnt );
463+ $ found = true ;
464+ }
476465 }
477466
467+ // Mark as known for runtime resolution; not added to partialCode so $blockParams scope is preserved.
468+ $ this ->context ->usedPartial [$ partialName ] ??= '' ;
478469 $ vars = $ this ->compilePartialParams ($ statement ->params , $ statement ->hash );
479470
480471 // Capture $blockParams and any hoisted program vars so the partial block body can access them.
481472 $ useVars = $ this ->buildInlineUseClause ($ depsBefore );
482473 $ bodyClosure = self ::templateClosure ($ body , useVars: $ useVars );
483474
484- if ($ partialName !== null && !$ found ) {
475+ if (!$ found ) {
485476 // Register the block body as a fallback partial only if no runtime partial with this name exists yet.
486477 $ parts [] = "(isset( \$cx->inlinePartials[ $ p]) || isset( \$cx->partials[ $ p]) ? '' : "
487478 . self ::getRuntimeFunc ('setInlinePartial ' , "\$cx, $ p, $ bodyClosure " ) . ') ' ;
@@ -798,7 +789,7 @@ private function buildBasePath(bool $data, int $depth): string
798789 /**
799790 * Resolve the name of a non-SubExpression partial reference.
800791 */
801- private function resolvePartialName (PathExpression |StringLiteral | NumberLiteral $ name ): string
792+ private function resolvePartialName (PathExpression |Literal $ name ): string
802793 {
803794 return $ name instanceof PathExpression ? $ name ->original : $ this ->getLiteralKeyName ($ name );
804795 }
0 commit comments