Skip to content

Commit 8803614

Browse files
committed
[TwigComponent] Fix ComponentTokenParser on 32-bits
1 parent 3e99eb2 commit 8803614

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/TwigComponent/src/Twig/ComponentTokenParser.php

+9-1
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,14 @@ private function generateEmbeddedTemplateIndex(string $file, int $line): int
118118
$this->lineAndFileCounts[$fileAndLine] = 0;
119119
}
120120

121-
return crc32($fileAndLine).++$this->lineAndFileCounts[$fileAndLine];
121+
$index = crc32($fileAndLine).++$this->lineAndFileCounts[$fileAndLine];
122+
123+
if (4 === \PHP_INT_SIZE) {
124+
// On 32-bit PHP, the index can be negative or greater than PHP_INT_MAX
125+
// we need to convert it to a positive 32-bit integer
126+
$index = fmod(abs($index), \PHP_INT_MAX) + 1;
127+
}
128+
129+
return (int) $index;
122130
}
123131
}

0 commit comments

Comments
 (0)