Skip to content
This repository was archived by the owner on Aug 1, 2023. It is now read-only.

Commit e32d354

Browse files
committed
Fix codegen to not depend on namespace fallback
1 parent 5c47ca4 commit e32d354

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/RouterCLILookupCodegenBuilder.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,13 +194,13 @@ private function getInitCode(): string {
194194
HackBuilderValues::immSet(HackBuilderValues::literal()),
195195
)
196196
->startForeachLoop('$autoloader_candidates', null, '$candidate')
197-
->startIfBlock('file_exists($candidate)')
197+
->startIfBlock('\\file_exists($candidate)')
198198
->addAssignment('$autoloader', '$candidate', HackBuilderValues::literal())
199199
->addLine('break;')
200200
->endIfBlock()
201201
->endForeachLoop()
202202
->startIfBlock('$autoloader === null')
203-
->addLine('fwrite(STDERR, "Can\'t find autoloader.\n");')
203+
->addLine('\\fwrite(\\STDERR, "Can\'t find autoloader.\n");')
204204
->addLine('exit(1);')
205205
->endIfBlock()
206206
->addLine('require_once($autoloader);')
@@ -220,7 +220,7 @@ private function getMainMethod(): CodegenMethod {
220220
HackBuilderValues::literal(),
221221
)
222222
->startIfBlock('$path === null')
223-
->addLine('fprintf(STDERR, "Usage: %s PATH\n", $argv[0]);')
223+
->addLine('\\fprintf(\\STDERR, "Usage: %s PATH\n", $argv[0]);')
224224
->addLine('exit(1);')
225225
->endIfBlock()
226226
->addAssignment(
@@ -229,7 +229,7 @@ private function getMainMethod(): CodegenMethod {
229229
HackBuilderValues::literal(),
230230
)
231231
->startIfBlock('$controllers->isEmpty()')
232-
->addLine('printf("No controller found for \'%s\'.\n", $path);')
232+
->addLine('\\printf("No controller found for \'%s\'.\n", $path);')
233233
->addLine('exit(1);')
234234
->endIfBlock()
235235
->startForeachLoop('$controllers', '$method', '$controller')
@@ -238,7 +238,7 @@ private function getMainMethod(): CodegenMethod {
238238
'$this->prettifyControllerName($controller)',
239239
HackBuilderValues::literal(),
240240
)
241-
->addLine('printf("%-8s %s\n", $method.\':\', $pretty);')
241+
->addLine('\\printf("%-8s %s\n", $method.\':\', $pretty);')
242242
->endForeachLoop()
243243
->getCode()
244244
);

tests/examples/codegen/lookup-path.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* To re-generate this file run vendor/phpunit/phpunit/phpunit
88
*
99
*
10-
* @partially-generated SignedSource<<b246f714d429fe5492522d5e9759fbfd>>
10+
* @partially-generated SignedSource<<394f3dc7b352d127b17bdb87263351ef>>
1111
*/
1212
namespace Facebook\HackRouter\CodeGen\Tests\Generated;
1313
/* BEGIN MANUAL SECTION init */
@@ -26,13 +26,13 @@ private function getRouter(
2626

2727
private function prettifyControllerName(string $controller): string {
2828
/* BEGIN MANUAL SECTION MySiteRouterCLILookup::prettifyControllerName */
29-
$parts = \explode('\\', $controller);
29+
$parts = explode('\\', $controller);
3030
invariant(
31-
\count($parts) > 3,
31+
count($parts) > 3,
3232
'Too few NS parts found; expected everything to be in example NS',
3333
);
3434
$first = $parts[0];
35-
$last = \array_pop(&$parts);
35+
$last = array_pop(&$parts);
3636
return '\\'.$first.'\\...\\'.$last;
3737
/* END MANUAL SECTION */
3838
}

0 commit comments

Comments
 (0)