|
2 | 2 |
|
3 | 3 | namespace PHPStan\Parallel; |
4 | 4 |
|
| 5 | +use Phar; |
5 | 6 | use PHPStan\Command\Output; |
6 | 7 | use PHPStan\DependencyInjection\AutowiredService; |
7 | 8 | use PHPStan\Diagnose\DiagnoseExtension; |
|
18 | 19 | * process and skips the application re-boot a spawned one pays. It requires: |
19 | 20 | * |
20 | 21 | * - pcntl/posix functions (not available on Windows — always spawn there) |
21 | | - * - the turbo extension, active with the expected version. A forked worker |
22 | | - * inherits the parent's extensions, so the spawn-time `-d extension=` |
23 | | - * injection cannot reach it — TurboProcessRestarter re-executes the main |
24 | | - * process with the distributed binary loaded when needed. The extension |
25 | | - * also arms the phar-fork-guard: libphar serves phar:// reads through one |
26 | | - * shared per-archive fd whose seek cursor forked processes race on, |
27 | | - * corrupting reads — the guard gives each forked child a private cursor. |
28 | | - * Without it, running from a phar would corrupt analysis, so no turbo |
29 | | - * means spawn. |
| 22 | + * - when running from a phar, the turbo extension, active with the expected |
| 23 | + * version. The extension arms the phar-fork-guard: libphar serves phar:// |
| 24 | + * reads through one shared per-archive fd whose seek cursor forked |
| 25 | + * processes race on, corrupting reads — the guard gives each forked child |
| 26 | + * a private cursor. TurboProcessRestarter re-executes the main process |
| 27 | + * with the distributed binary loaded when needed (a forked worker inherits |
| 28 | + * the parent's extensions; the spawn-time `-d extension=` injection cannot |
| 29 | + * reach it). Outside a phar there is nothing to guard, and no turbo is |
| 30 | + * lost by forking either: the distributed binaries only exist next to a |
| 31 | + * phar, so spawned workers of a source checkout run without turbo too — |
| 32 | + * an ini-loaded extension is inherited by fork like any other. |
30 | 33 | * - OPcache + JIT off — their shared memory is not safe to populate |
31 | 34 | * concurrently from forked children and doing so corrupts analysis |
32 | 35 | * results. |
@@ -68,8 +71,8 @@ private function getDisabledReason(): ?string |
68 | 71 | return 'pcntl/posix functions are not available'; |
69 | 72 | } |
70 | 73 |
|
71 | | - if (!TurboExtensionEnabler::isActive()) { |
72 | | - return 'the turbo extension is not active (see the Turbo extension section)'; |
| 74 | + if (Phar::running(false) !== '' && !TurboExtensionEnabler::isActive()) { |
| 75 | + return 'running from a phar without the active turbo extension (its fork guard protects phar:// reads in forked children)'; |
73 | 76 | } |
74 | 77 |
|
75 | 78 | if ($this->isOpcacheOrJitEnabled()) { |
|
0 commit comments