Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Laravel 9 Components #890

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
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
70 changes: 35 additions & 35 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,47 +29,47 @@
},
"require": {
"php": "^8.0",
"composer/installers": "^1.9",
"dragonmantank/cron-expression": "^3.0.2",
"composer/installers": "^2.2",
"dragonmantank/cron-expression": "^3.3",
"filp/whoops": "^2.1",
"guzzlehttp/guzzle": "^7.2",
"illuminate/auth": "^8.83",
"illuminate/broadcasting": "^8.83",
"illuminate/bus": "^8.83",
"illuminate/cache": "^8.83",
"illuminate/config": "^8.83",
"illuminate/console": "^8.83",
"illuminate/container": "^8.83",
"illuminate/cookie": "^8.83",
"illuminate/database": "^8.83",
"illuminate/encryption": "^8.83",
"illuminate/events": "^8.83",
"illuminate/filesystem": "^8.83",
"illuminate/hashing": "^8.83",
"illuminate/http": "^8.83",
"illuminate/log": "^8.83",
"illuminate/mail": "^8.83",
"illuminate/notifications": "^8.83",
"illuminate/pagination": "^8.83",
"illuminate/queue": "^8.83",
"illuminate/redis": "^8.83",
"illuminate/routing": "^8.83",
"illuminate/session": "^8.83",
"illuminate/support": "^8.83",
"illuminate/testing": "^8.83",
"illuminate/validation": "^8.83",
"illuminate/view": "^8.83",
"laravel/tinker": "^2.5",
"guzzlehttp/guzzle": "^7.5",
"illuminate/auth": "^v9.50",
"illuminate/broadcasting": "^9.50",
"illuminate/bus": "^9.50",
"illuminate/cache": "^9.50",
"illuminate/config": "^9.50",
"illuminate/console": "^9.50",
"illuminate/container": "^9.50",
"illuminate/cookie": "^9.50",
"illuminate/database": "^9.50",
"illuminate/encryption": "^9.50",
"illuminate/events": "^9.50",
"illuminate/filesystem": "^9.50",
"illuminate/hashing": "^9.50",
"illuminate/http": "^9.50",
"illuminate/log": "^9.50",
"illuminate/mail": "^9.50",
"illuminate/notifications": "^9.50",
"illuminate/pagination": "^9.50",
"illuminate/queue": "^9.50",
"illuminate/redis": "^9.50",
"illuminate/routing": "^9.50",
"illuminate/session": "^9.50",
"illuminate/support": "^9.50",
"illuminate/testing": "^9.50",
"illuminate/validation": "^9.50",
"illuminate/view": "^9.50",
"laravel/tinker": "^v2.8",
"laravel/ui": "^3.1",
"league/flysystem": "^1.1",
"league/flysystem": "^3.12",
"league/fractal": "^0.20",
"paragonie/sodium_compat": "^1.15",
"predis/predis": "^1.1",
"ramsey/uuid": "^4.1",
"predis/predis": "^2.1",
"ramsey/uuid": "^4.7",
"spatie/enum": "^3.13",
"symfony/property-access": "^5.4",
"twig/twig": " ^3.1",
"vlucas/phpdotenv": "^5.2"
"twig/twig": " ^3.5",
"vlucas/phpdotenv": "^5.5"
},
"require-dev": {
"beyondcode/laravel-dump-server": "^1.7",
Expand Down
27 changes: 23 additions & 4 deletions src/Core/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Composer\Autoload\ClassLoader;
use Illuminate\Container\Container;
use Illuminate\Contracts\Config\Repository;
use Illuminate\Contracts\Foundation\MaintenanceMode;
use Illuminate\Contracts\Foundation\Application as ApplicationContract;
use Illuminate\Contracts\Foundation\CachesConfiguration;
use Illuminate\Contracts\Foundation\CachesRoutes;
Expand All @@ -22,7 +23,7 @@
use Symfony\Component\Finder\Finder;
use Symfony\Component\Finder\SplFileInfo;
use Symfony\Component\HttpFoundation\Request as SymfonyRequest;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Response as SymfonyResponse;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpKernel\HttpKernelInterface;
Expand Down Expand Up @@ -989,9 +990,9 @@ public function getCachedConfigPath()
*
* @throws \Exception When an Exception occurs during processing
*
* @return Response A Response instance
* @return SymfonyResponse A Response instance
*/
public function handle(SymfonyRequest $request, $type = self::MASTER_REQUEST, $catch = true)
public function handle(SymfonyRequest $request, int $type = self::MAIN_REQUEST, bool $catch = true): SymfonyResponse
{
return $this[HttpKernelContract::class]->handle(Request::createFromBase($request));
}
Expand Down Expand Up @@ -1422,7 +1423,7 @@ public function abort($code, $message = '', array $headers = [])
*
* @return $this
*/
public function terminating(Closure $callback)
public function terminating($callback)
{
$this->terminatingCallbacks[] = $callback;

Expand Down Expand Up @@ -1575,6 +1576,16 @@ public function getLocale()
{
return $this['config']->get('app.locale');
}

/**
* Get the current application fallback locale.
*
* @return string
*/
public function getFallbackLocale()
{
return $this['config']->get('app.fallback_locale');
}

/**
* Check if passed locale is current locale.
Expand Down Expand Up @@ -1715,4 +1726,12 @@ public function outputJavascriptGlobal(string $name, array $data)

return $output;
}

/**
* @inerhitDoc
*/
public function maintenanceMode(): MaintenanceMode
{
// TODO: Implement maintenanceMode() method.
}
}
13 changes: 8 additions & 5 deletions src/Core/Console/VendorPublishCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Arr;
use Illuminate\Support\ServiceProvider;
use League\Flysystem\Adapter\Local;
use League\Flysystem\Local\LocalFilesystemAdapter;
use League\Flysystem\MountManager;

class VendorPublishCommand extends Command
Expand Down Expand Up @@ -201,8 +201,8 @@ protected function publishFile($from, $to)
protected function publishDirectory($from, $to)
{
$this->moveManagedFiles(new MountManager([
'from' => new \League\Flysystem\Filesystem(new Local($from)),
'to' => new \League\Flysystem\Filesystem(new Local($to)),
'from' => new \League\Flysystem\Filesystem(new LocalFilesystemAdapter($from)),
'to' => new \League\Flysystem\Filesystem(new LocalFilesystemAdapter($to)),
]));

$this->status($from, $to, 'Directory');
Expand All @@ -218,8 +218,11 @@ protected function publishDirectory($from, $to)
protected function moveManagedFiles($manager)
{
foreach ($manager->listContents('from://', true) as $file) {
if ($file['type'] === 'file' && (! $manager->has('to://' . $file['path']) || $this->option('force'))) {
$manager->put('to://' . $file['path'], $manager->read('from://' . $file['path']));
if ($file['type'] === 'file' && ( ! $manager->has('to://' . $file['path']) || $this->option('force'))) {
$manager->write(
preg_replace('{^from://}', 'to://', $file['path']),
$manager->read($file['path'])
);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Core/ExceptionHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,8 @@ public function testValidateFileMethod()
$file = $this->createMock(UploadedFile::class);
$file->method('getPathname')->willReturn('photo.jpg');
$file->method('getClientOriginalName')->willReturn('photo.jpg');
$file->method('getClientMimeType')->willReturn(null);
$file->method('getError')->willReturn(null);
$file->method('getClientMimeType')->willReturn('');
$file->method('getError')->willReturn(UPLOAD_ERR_OK);

$request = Request::create('/', 'POST', $argumentExpected, [], ['photo' => $file]);

Expand Down
7 changes: 7 additions & 0 deletions tests/Route/RoutesTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

use Illuminate\Container\Container;
use Illuminate\Routing\CallableDispatcher;
use Illuminate\Contracts\Routing\Registrar;
use Illuminate\Events\Dispatcher;
use Illuminate\Http\Request;
Expand All @@ -11,6 +12,7 @@
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Themosis\Route\Middleware\WordPressBindings;
use Themosis\Route\Router;
use Illuminate\Routing\Contracts\CallableDispatcher as CallableDispatcherContract;

class RoutesTest extends TestCase
{
Expand Down Expand Up @@ -696,6 +698,11 @@ protected function getRouter()
{
$container = new Container();
$router = new Router(new Dispatcher(), $container);

$container->singleton(CallableDispatcherContract::class, function ($app) {
return new CallableDispatcher($app);
});

$container->singleton(Registrar::class, function () use ($router) {
return $router;
});
Expand Down