Skip to content

Commit

Permalink
support laravel 11
Browse files Browse the repository at this point in the history
  • Loading branch information
recca0120 committed Mar 12, 2024
1 parent 902f92d commit ef0448c
Show file tree
Hide file tree
Showing 22 changed files with 26 additions and 56 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [ '7.2', '7.3', '7.4', '8.0', '8.1' ]
php: [ '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3' ]
stability: [ prefer-stable ]

name: PHP ${{ matrix.php }} - ${{ matrix.stability }}
Expand Down
18 changes: 9 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
],
"require": {
"php": ">=5.5.9",
"illuminate/config": "^5.1|^6.0|^7.0|^8.0|^9.0|^10.0",
"illuminate/console": "^5.1|^6.0|^7.0|^8.0|^9.0|^10.0",
"illuminate/database": "^5.1|^6.0|^7.0|^8.0|^9.0|^10.0",
"illuminate/events": "^5.1|^6.0|^7.0|^8.0|^9.0|^10.0",
"illuminate/filesystem": "^5.1|^6.0|^7.0|^8.0|^9.0|^10.0",
"illuminate/routing": "^5.1|^6.0|^7.0|^8.0|^9.0|^10.0",
"illuminate/view": "^5.1|^6.0|^7.0|^8.0|^9.0|^10.0",
"symfony/finder": "^2.7|^3.0|^4.0|^5.0|^6.0",
"illuminate/config": "^5.1|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0",
"illuminate/console": "^5.1|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0",
"illuminate/database": "^5.1|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0",
"illuminate/events": "^5.1|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0",
"illuminate/filesystem": "^5.1|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0",
"illuminate/routing": "^5.1|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0",
"illuminate/view": "^5.1|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0",
"symfony/finder": "^2.7|^3.0|^4.0|^5.0|^6.0|^7.0",
"webmozart/glob": "^4.1"
},
"require-dev": {
Expand Down Expand Up @@ -63,4 +63,4 @@
]
}
}
}
}
1 change: 0 additions & 1 deletion src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class Application extends ConsoleApplication
* Run an Artisan console command by name.
*
* @param string $command
* @param array $parameters
* @param OutputInterface $outputBuffer
* @return int
*
Expand Down
2 changes: 0 additions & 2 deletions src/Console/Commands/Artisan.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ class Artisan extends Command

/**
* __construct.
*
* @param ArtisanContract $artisan
*/
public function __construct(ArtisanContract $artisan)
{
Expand Down
2 changes: 0 additions & 2 deletions src/Console/Commands/Cleanup.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ class Cleanup extends Command

/**
* __construct.
*
* @param Filesystem $files
*/
public function __construct(Filesystem $files)
{
Expand Down
2 changes: 0 additions & 2 deletions src/Console/Commands/Composer.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ class Composer extends Command

/**
* __construct.
*
* @param \Illuminate\Filesystem\Filesystem $files
*/
public function __construct(Filesystem $files)
{
Expand Down
7 changes: 0 additions & 7 deletions src/Console/Commands/Find.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ class Find extends Command

/**
* __construct.
*
* @param Finder $finder
* @param Filesystem $files
*/
public function __construct(Finder $finder, Filesystem $files)
{
Expand All @@ -58,10 +55,6 @@ public function __construct(Finder $finder, Filesystem $files)

/**
* run.
*
* @param InputInterface $input
* @param OutputInterface $output
* @return int
*/
public function run(InputInterface $input, OutputInterface $output): int
{
Expand Down
2 changes: 0 additions & 2 deletions src/Console/Commands/Mysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ class Mysql extends Command

/**
* __construct.
*
* @param DatabaseManager $databaseManager
*/
public function __construct(DatabaseManager $databaseManager)
{
Expand Down
2 changes: 0 additions & 2 deletions src/Console/Commands/Tail.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ class Tail extends Command

/**
* __construct.
*
* @param Filesystem $files
*/
public function __construct(Filesystem $files)
{
Expand Down
2 changes: 0 additions & 2 deletions src/Console/Commands/Vi.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ class Vi extends Command

/**
* __construct.
*
* @param Filesystem $files
*/
public function __construct(Filesystem $files)
{
Expand Down
9 changes: 0 additions & 9 deletions src/Http/Controllers/TerminalController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ class TerminalController extends Controller
/**
* index.
*
* @param Kernel $kernel
* @param Request $request
* @param ResponseFactory $responseFactory
* @param string $view
* @return Response
*
Expand All @@ -39,9 +36,6 @@ public function index(Kernel $kernel, Request $request, ResponseFactory $respons
/**
* rpc response.
*
* @param Kernel $kernel
* @param Request $request
* @param ResponseFactory $responseFactory
* @return JsonResponse
*
* @throws Exception
Expand All @@ -60,9 +54,6 @@ public function endpoint(Kernel $kernel, Request $request, ResponseFactory $resp
/**
* media.
*
* @param Request $request
* @param ResponseFactory $responseFactory
* @param Filesystem $files
* @param string $file
* @return Response
*/
Expand Down
3 changes: 0 additions & 3 deletions src/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ class Kernel implements KernelContract
/**
* Create a new console kernel instance.
*
* @param Application $artisan
* @param array $config
*/
public function __construct(Artisan $artisan, $config = [])
Expand Down Expand Up @@ -87,7 +86,6 @@ public function handle($input, $output = null)
* Run an Artisan console command by name.
*
* @param string $command
* @param array $parameters
* @param OutputInterface $outputBuffer
* @return int
*
Expand All @@ -104,7 +102,6 @@ public function call($command, array $parameters = [], $outputBuffer = null)
* Queue an Artisan console command by name.
*
* @param string $command
* @param array $parameters
* @return void
*/
public function queue($command, array $parameters = [])
Expand Down
8 changes: 4 additions & 4 deletions src/ProcessUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@ public static function escapeArgument($argument)
// @see https://bugs.php.net/bug.php?id=43784
// @see https://bugs.php.net/bug.php?id=49446
if ('\\' === DIRECTORY_SEPARATOR) {
if ('' === $argument) {
if ($argument === '') {
return '""';
}
$escapedArgument = '';
$quote = false;
foreach (preg_split('/(")/', $argument, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE) as $part) {
if ('"' === $part) {
if ($part === '"') {
$escapedArgument .= '\\"';
} elseif (self::isSurroundedBy($part, '%')) {
// Avoid environment variable expansion
$escapedArgument .= '^%"'.substr($part, 1, -1).'"^%';
} else {
// escape trailing backslash
if ('\\' === substr($part, -1)) {
if (substr($part, -1) === '\\') {
$part .= '\\';
}
$quote = true;
Expand All @@ -61,6 +61,6 @@ public static function escapeArgument($argument)
*/
protected static function isSurroundedBy($arg, $char)
{
return 2 < strlen($arg) && $char === $arg[0] && $char === $arg[strlen($arg) - 1];
return strlen($arg) > 2 && $char === $arg[0] && $char === $arg[strlen($arg) - 1];
}
}
6 changes: 0 additions & 6 deletions src/TerminalServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ class TerminalServiceProvider extends ServiceProvider

/**
* Bootstrap any application services.
*
* @param Request $request
* @param Router $router
*/
public function boot(Request $request, Router $router)
{
Expand Down Expand Up @@ -64,7 +61,6 @@ public function register()
/**
* register routes.
*
* @param Router $router
* @param array $config
*/
protected function handleRoutes(Router $router, $config = [])
Expand All @@ -91,8 +87,6 @@ protected function handlePublishes()
}

/**
* @param Request $request
* @param $config
* @return bool
*/
private function allowWhiteList(Request $request, $config)
Expand Down
5 changes: 4 additions & 1 deletion tests/Console/Commands/ArtisanTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public function test_artisan_migrate_refresh_command()
$commandTester = new CommandTester($command);

$commandTester->execute(['--command' => 'migrate:fresh'], []);
$commandTester->assertCommandIsSuccessful();
}

public function test_artisan_vendor_publish_command()
Expand All @@ -59,6 +60,7 @@ public function test_artisan_vendor_publish_command()
$commandTester = new CommandTester($command);

$commandTester->execute(['--command' => 'vendor:publish'], []);
$commandTester->assertCommandIsSuccessful();
}

public function test_not_supported_command()
Expand All @@ -74,10 +76,10 @@ public function test_not_supported_command()
$commandTester = new CommandTester($command);

$commandTester->execute(['--command' => 'down'], []);
$commandTester->assertCommandIsSuccessful();
}

/**
* @param Container $laravel
* @return Kernel
*/
private function getKernel(Container $laravel)
Expand All @@ -93,6 +95,7 @@ private function getLaravel($version = 'testing')
{
$laravel = m::mock(new Container());
$laravel->shouldReceive('version')->andReturn($version);
$laravel->shouldReceive('runningUnitTests')->andReturn(false);

return $laravel;
}
Expand Down
4 changes: 3 additions & 1 deletion tests/Console/Commands/ArtisanTinkerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Recca0120\Terminal\Tests\Console\Commands;

use Illuminate\Container\Container;
use Mockery;
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use PHPUnit\Framework\TestCase;
use Recca0120\Terminal\Console\Commands\ArtisanTinker;
Expand Down Expand Up @@ -69,7 +70,8 @@ protected function lf($content)
*/
private function executeCommand($cmd)
{
$container = new Container;
$container = Mockery::mock(new Container);
$container->shouldReceive('runningUnitTests')->andReturn(false);
$command = new ArtisanTinker();
$command->setLaravel($container);

Expand Down
1 change: 1 addition & 0 deletions tests/Console/Commands/CleanupTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ public function test_cleanup_file()
$root = vfsStream::setup('root', null, $this->structure);
$container = m::mock(new Container);
$container->shouldReceive('basePath')->andReturn($basePath = $root->url());
$container->shouldReceive('runningUnitTests')->andReturn(false);
Container::setInstance($container);

$command = new Cleanup(new Filesystem);
Expand Down
1 change: 1 addition & 0 deletions tests/Console/Commands/FindTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ protected function giveCommand()
$root = vfsStream::setup('root', null, $this->structure);
$container = m::mock(new Container);
$container->shouldReceive('basePath')->andReturn($root->url());
$container->shouldReceive('runningUnitTests')->andReturn(false);
Container::setInstance($container);

$command = new Find(new Finder, new Filesystem);
Expand Down
1 change: 1 addition & 0 deletions tests/Console/Commands/MysqlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class MysqlTest extends TestCase
public function testHandle()
{
$container = m::mock(new Container);
$container->shouldReceive('runningUnitTests')->andReturn(false);
Container::setInstance($container);
$sql = 'SELECT * FROM users;';
$databaseManager = m::mock(DatabaseManager::class);
Expand Down
1 change: 1 addition & 0 deletions tests/Console/Commands/TailTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ private function getCommand()
$root = $this->giveRoot();
$container = m::mock(new Container);
$container->shouldReceive('basePath')->andReturn($root->url());
$container->shouldReceive('runningUnitTests')->andReturn(false);
$container->instance('path.storage', $root->url());
Container::setInstance($container);

Expand Down
1 change: 1 addition & 0 deletions tests/Console/Commands/ViTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ private function getContainer()
{
$container = m::mock(new Container());
$container->shouldReceive('basePath')->andReturn('foo/');
$container->shouldReceive('runningUnitTests')->andReturn(false);
Container::setInstance($container);

return $container;
Expand Down
2 changes: 0 additions & 2 deletions tests/KernelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ public function test_call_method()

/**
* @depends test_call_method
*
* @param array $parameters
*/
public function test_output_method(array $parameters)
{
Expand Down

0 comments on commit ef0448c

Please sign in to comment.