Skip to content

Commit a0d8033

Browse files
authored
Prefix with "Restart" since the "Extension" keyword is ubiquitous in the codebase (#6796)
1 parent f4b2863 commit a0d8033

7 files changed

Lines changed: 22 additions & 22 deletions

File tree

‎bin/phpstan‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use Symfony\Component\Console\Helper\ProgressBar;
2929
require_once __DIR__ . '/../src/Turbo/TurboExtensionSelector.php';
3030
require_once __DIR__ . '/../src/Process/Restart/RestartReason.php';
3131
require_once __DIR__ . '/../src/Process/Restart/OpcacheSettings.php';
32-
require_once __DIR__ . '/../src/Process/Restart/ExtensionRegistry.php';
32+
require_once __DIR__ . '/../src/Process/Restart/RestartExtensionRegistry.php';
3333
require_once __DIR__ . '/../src/Process/Restart/IniComposer.php';
3434
require_once __DIR__ . '/../src/Process/Restart/RestartExecutor.php';
3535
require_once __DIR__ . '/../src/Process/Restart/RestartManager.php';

‎src/Command/CommandHelper.php‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
use PHPStan\Internal\DirectoryCreator;
3232
use PHPStan\Internal\DirectoryCreatorException;
3333
use PHPStan\Process\ForkedChildCrashReporter;
34-
use PHPStan\Process\Restart\ExtensionRegistry;
34+
use PHPStan\Process\Restart\RestartExtensionRegistry;
3535
use PHPStan\Process\Restart\RestartManager;
3636
use PHPStan\ShouldNotHappenException;
3737
use ReflectionClass;
@@ -105,12 +105,12 @@ public static function begin(
105105
$errorOutput = new SymfonyOutput($symfonyErrorOutput, new SymfonyStyle(new ErrorsConsoleStyle($input, $symfonyErrorOutput)));
106106

107107
if ($allowXdebug) {
108-
if (!ExtensionRegistry::isXdebugActive()) {
108+
if (!RestartExtensionRegistry::isXdebugActive()) {
109109
$errorOutput->getStyle()->note('You are running with "--xdebug" enabled, but the Xdebug PHP extension is not active. The process will not halt at breakpoints.');
110110
} else {
111111
$errorOutput->getStyle()->note("You are running with \"--xdebug\" enabled, and the Xdebug PHP extension is active.\nThe process will halt at breakpoints, but PHPStan will run much slower.\nUse this only if you are debugging PHPStan itself or your custom extensions.");
112112
}
113-
} elseif (ExtensionRegistry::isXdebugActive()) {
113+
} elseif (RestartExtensionRegistry::isXdebugActive()) {
114114
$errorOutput->getStyle()->note('The Xdebug PHP extension is active, but "--xdebug" is not used. This may slow down performance and the process will not halt at breakpoints.');
115115
} elseif ($debugEnabled && RestartManager::wasRestartedFor('xdebug')) {
116116
$errorOutput->getStyle()->note(

‎src/Process/Restart/RestartDiagnoseExtension.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public function print(Output $output): void
1717
{
1818
$output->writeLineFormatted('<info>Process restart:</info>');
1919

20-
$detected = ExtensionRegistry::describeDetectedExtensions();
20+
$detected = RestartExtensionRegistry::describeDetectedExtensions();
2121
$output->writeLineFormatted(sprintf(
2222
'Coverage/profilers found: %s',
2323
$detected === [] ? 'none' : implode(', ', $detected),
@@ -44,7 +44,7 @@ private function describeRestartIfStartedNow(): string
4444
// the diagnose command does not restart, so it reports the answer an
4545
// analyse run started the same way would get. --xdebug is a per-run
4646
// option, so it is reported as not given
47-
$reasons = ExtensionRegistry::collectReasons(false);
47+
$reasons = RestartExtensionRegistry::collectReasons(false);
4848
if ($reasons === []) {
4949
return 'no, nothing to neutralize or load';
5050
}

src/Process/Restart/ExtensionRegistry.php renamed to src/Process/Restart/RestartExtensionRegistry.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
* opentelemetry — measured free while merely loaded, and are deliberately
5656
* absent from every list here.
5757
*/
58-
final class ExtensionRegistry
58+
final class RestartExtensionRegistry
5959
{
6060

6161
/**

‎src/Process/Restart/RestartManager.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public static function collectReasons(array $argv, ?string $pharPath = null, str
162162
return [];
163163
}
164164

165-
return ExtensionRegistry::collectReasons(self::isXdebugAllowed($argv, $appName), $pharPath);
165+
return RestartExtensionRegistry::collectReasons(self::isXdebugAllowed($argv, $appName), $pharPath);
166166
}
167167

168168
/**

‎src/Turbo/TurboDiagnoseExtension.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use PHPStan\DependencyInjection\AutowiredService;
77
use PHPStan\Diagnose\DiagnoseExtension;
88
use PHPStan\Php\PhpVersion;
9-
use PHPStan\Process\Restart\ExtensionRegistry;
9+
use PHPStan\Process\Restart\RestartExtensionRegistry;
1010
use function php_uname;
1111
use function phpversion;
1212
use function sprintf;
@@ -88,7 +88,7 @@ private function describeStatus(?string $workerBinary): string
8888
{
8989
if (!TurboExtensionEnabler::isLoaded()) {
9090
if ($workerBinary !== null) {
91-
if (ExtensionRegistry::findTurboExtensionToLoad() !== null) {
91+
if (RestartExtensionRegistry::findTurboExtensionToLoad() !== null) {
9292
return 'not loaded here, loaded by the restart an analyse run performs';
9393
}
9494

‎tests/PHPStan/Process/Restart/ExtensionRegistryTest.php‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public function testCollectReasonsFor(
179179
array $expectedExtensions,
180180
): void
181181
{
182-
$reasons = ExtensionRegistry::collectReasonsFor($loadedExtensions, $iniSettings, $turboExtensionPath, $allowXdebug);
182+
$reasons = RestartExtensionRegistry::collectReasonsFor($loadedExtensions, $iniSettings, $turboExtensionPath, $allowXdebug);
183183

184184
$this->assertSame(
185185
$expectedExtensions,
@@ -191,7 +191,7 @@ public function testXdebugIsFlaggedRatherThanStripped(): void
191191
{
192192
// stripping would take xdebug_*() out of reflection and so change what
193193
// PHPStan knows about code calling them; the flag measures the same
194-
$reasons = ExtensionRegistry::collectReasonsFor(['xdebug'], ['xdebug.mode' => 'debug'], null, false);
194+
$reasons = RestartExtensionRegistry::collectReasonsFor(['xdebug'], ['xdebug.mode' => 'debug'], null, false);
195195

196196
$this->assertCount(1, $reasons);
197197
$this->assertSame([], $reasons[0]->getStrippedExtensions());
@@ -203,7 +203,7 @@ public function testXdebugIsFlaggedRatherThanStripped(): void
203203

204204
public function testPcovIsFlaggedRatherThanStripped(): void
205205
{
206-
$reasons = ExtensionRegistry::collectReasonsFor(['pcov'], ['pcov.enabled' => '1'], null, false);
206+
$reasons = RestartExtensionRegistry::collectReasonsFor(['pcov'], ['pcov.enabled' => '1'], null, false);
207207

208208
$this->assertCount(1, $reasons);
209209
$this->assertSame([], $reasons[0]->getStrippedExtensions());
@@ -214,7 +214,7 @@ public function testPcovIsFlaggedRatherThanStripped(): void
214214

215215
public function testTidewaysIsStrippedRatherThanFlagged(): void
216216
{
217-
$reasons = ExtensionRegistry::collectReasonsFor(['tideways', 'phpstan_turbo'], [], null, false);
217+
$reasons = RestartExtensionRegistry::collectReasonsFor(['tideways', 'phpstan_turbo'], [], null, false);
218218

219219
$this->assertCount(1, $reasons);
220220
$this->assertSame(['tideways'], $reasons[0]->getStrippedExtensions());
@@ -225,7 +225,7 @@ public function testTidewaysIsStrippedRatherThanFlagged(): void
225225

226226
public function testTurboIsAppendedToTheCommandLineTogetherWithItsMarker(): void
227227
{
228-
$reasons = ExtensionRegistry::collectReasonsFor([], [], self::TURBO_BINARY, false);
228+
$reasons = RestartExtensionRegistry::collectReasonsFor([], [], self::TURBO_BINARY, false);
229229

230230
$this->assertCount(1, $reasons);
231231
$this->assertSame([], $reasons[0]->getStrippedExtensions());
@@ -241,7 +241,7 @@ public function testTurboIsAppendedToTheCommandLineTogetherWithItsMarker(): void
241241
public function testOpcacheIsActivatedWhenDormant(): void
242242
{
243243
$entries = ['opcache.enable_cli=1', 'opcache.jit=disable', 'opcache.file_cache='];
244-
$reasons = ExtensionRegistry::collectReasonsFor([], [], null, false, $entries, [
244+
$reasons = RestartExtensionRegistry::collectReasonsFor([], [], null, false, $entries, [
245245
'opcache.enable_cli' => '',
246246
'opcache.jit' => 'disable',
247247
'opcache.file_cache' => '',
@@ -260,24 +260,24 @@ public function testOpcacheAlreadyConfiguredIsNotAReason(): void
260260
{
261261
$entries = ['opcache.enable_cli=1', 'opcache.jit=disable'];
262262

263-
$this->assertSame([], ExtensionRegistry::collectReasonsFor([], [], null, false, $entries, [
263+
$this->assertSame([], RestartExtensionRegistry::collectReasonsFor([], [], null, false, $entries, [
264264
'opcache.enable_cli' => '1',
265265
'opcache.jit' => 'disable',
266266
]));
267267
// no entries means OPcache is to be left alone - not loaded, preloading, or not fork-capable
268-
$this->assertSame([], ExtensionRegistry::collectReasonsFor([], [], null, false, [], []));
268+
$this->assertSame([], RestartExtensionRegistry::collectReasonsFor([], [], null, false, [], []));
269269
}
270270

271271
public function testCollectReasonsDescribesTheCurrentProcess(): void
272272
{
273273
// the test suite runs with coverage off and without the turbo binary of
274274
// a phar installation, so this only asserts that the real-process entry
275275
// point agrees with what the process actually has loaded
276-
foreach (ExtensionRegistry::collectReasons(false) as $reason) {
276+
foreach (RestartExtensionRegistry::collectReasons(false) as $reason) {
277277
$this->assertContains($reason->getExtension(), ['xdebug', 'pcov', 'uopz', 'phpstan_turbo', 'tideways', 'opcache']);
278278
}
279279

280-
$this->assertSame([], ExtensionRegistry::collectReasonsFor([], [], null, false));
280+
$this->assertSame([], RestartExtensionRegistry::collectReasonsFor([], [], null, false));
281281
}
282282

283283
public function testIsXdebugActiveRequiresTheExtension(): void
@@ -286,8 +286,8 @@ public function testIsXdebugActiveRequiresTheExtension(): void
286286
$this->markTestSkipped('xdebug is loaded in this process.');
287287
}
288288

289-
$this->assertFalse(ExtensionRegistry::isXdebugActive());
290-
foreach (ExtensionRegistry::describeDetectedExtensions() as $description) {
289+
$this->assertFalse(RestartExtensionRegistry::isXdebugActive());
290+
foreach (RestartExtensionRegistry::describeDetectedExtensions() as $description) {
291291
$this->assertStringNotContainsString('xdebug', $description);
292292
}
293293
}

0 commit comments

Comments
 (0)