Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Illuminate/Foundation/DevCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,11 @@ protected static function preventVendorRegistration(string $name)
foreach ($trace as $frame) {
$file = $frame['file'] ?? null;
$class = $frame['class'] ?? null;
$function = $frame['function'] ?? null;

if ($class === self::class && $function === 'registerDefaults') {
return;
}

if ($class === self::class) {
continue;
Expand Down
31 changes: 31 additions & 0 deletions tests/Foundation/FoundationDevCommandsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,37 @@ public function testRegisterDefaultsRegistersExpectedCommands()
$this->assertContains('vite', $names);
}

public function testRegisterDefaultsCanBeCalledFromVendorPath()
{
$basePath = realpath(__DIR__.'/../..');
$vendorFile = $basePath.'/vendor/_test_register_defaults_'.uniqid().'.php';

file_put_contents($vendorFile, <<<'PHP'
<?php
Illuminate\Foundation\DevCommands::registerDefaults();
PHP);

try {
$process = new PhpProcess(<<<EOF
<?php
require '{$basePath}/vendor/autoload.php';

\$app = new Illuminate\Foundation\Application('{$basePath}');
\$app['env'] = 'testing';

require '{$vendorFile}';

echo implode(',', array_column(Illuminate\Foundation\DevCommands::commands(), 'name'));
EOF, $basePath);

$process->run();

$this->assertSame('server,queue,logs,vite', $process->getOutput());
} finally {
unlink($vendorFile);
}
}

public function testVendorRegistrationIsPrevented()
{
$basePath = realpath(__DIR__.'/../..');
Expand Down
Loading