Skip to content

Commit b54f2d6

Browse files
committed
fix
1 parent e2e50b0 commit b54f2d6

File tree

7 files changed

+36
-55
lines changed

7 files changed

+36
-55
lines changed

src/Loader.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ public static function load(string $path)
2929
return new WordPressLoader($path);
3030
}
3131

32+
if (PimcoreLoader::supports($path)) {
33+
return new PimcoreLoader($path);
34+
}
35+
3236
if (ComposerLoader::supports($path)) {
3337
return new ComposerLoader($path);
3438
}

src/Loaders/BaseLoader.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ public function init()
1717
'configFile' => null,
1818
]);
1919
$config->setUpdateCheck(Checker::NEVER);
20+
$config->setRawOutput(true);
21+
$config->setInteractiveMode(Configuration::INTERACTIVE_MODE_DISABLED);
22+
2023
if (class_exists('Illuminate\Support\Collection') && class_exists('Laravel\Tinker\TinkerCaster')) {
2124
$config->getPresenter()->addCasters([
2225
\Illuminate\Support\Collection::class => 'Laravel\Tinker\TinkerCaster::castCollection',
@@ -32,7 +35,6 @@ public function init()
3235
\Illuminate\Foundation\Application::class => 'Laravel\Tinker\TinkerCaster::castApplication',
3336
]);
3437
}
35-
$config->setRawOutput(true);
3638

3739
$this->tinker = new Tinker(new CustomOutputModifier(), $config);
3840
}

src/Loaders/LaravelLoader.php

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,6 @@ public function __construct(string $path)
2525
parent::__construct($path);
2626
$this->app = require_once $path . '/bootstrap/app.php';
2727
$this->app->make('Illuminate\Contracts\Console\Kernel')->bootstrap();
28-
$classAliases = require $path . '/vendor/composer/autoload_classmap.php';
29-
$vendorPath = dirname($path . '/vendor/composer/autoload_classmap.php', 2);
30-
foreach ($classAliases as $class => $path) {
31-
if (!str_contains($class, '\\')) {
32-
continue;
33-
}
34-
if (str_starts_with($path, $vendorPath)) {
35-
continue;
36-
}
37-
try {
38-
class_alias($class, class_basename($class));
39-
} catch (Throwable $e) {
40-
}
41-
}
4228
}
4329

4430
/**

src/Loaders/LoaderInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function init();
2727

2828
/**
2929
* @param string $code
30-
* @return void
30+
* @return string
3131
*/
3232
public function execute(string $code);
3333
}

src/Loaders/PimcoreLoader.php

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,34 @@
11
<?php
22

3-
declare(strict_types=1);
4-
53
namespace TweakPHP\Client\Loaders;
64

5+
use Composer\InstalledVersions;
6+
77
class PimcoreLoader extends BaseLoader
88
{
99
public function __construct(string $path)
1010
{
11-
// Include the Composer autoloader
1211
require_once $path . '/vendor/autoload.php';
1312

14-
\Pimcore\Bootstrap::setProjectRoot();
15-
\Pimcore\Bootstrap::bootstrap();
16-
\Pimcore\Bootstrap::kernel();
13+
if (class_exists('\Pimcore\Bootstrap')) {
14+
\Pimcore\Bootstrap::setProjectRoot();
15+
\Pimcore\Bootstrap::bootstrap();
16+
\Pimcore\Bootstrap::kernel();
17+
}
1718
}
1819

19-
2020
public function name(): string
2121
{
2222
return 'Pimcore';
2323
}
2424

2525
public function version(): string
2626
{
27-
return \Composer\InstalledVersions::getPrettyVersion('pimcore/pimcore');
27+
return InstalledVersions::getPrettyVersion('pimcore/pimcore');
2828
}
2929

30+
public static function supports(string $path): bool
31+
{
32+
return file_exists($path . '/vendor/autoload.php') && file_exists($path . '/vendor/pimcore/pimcore');
33+
}
3034
}

src/Loaders/SymfonyLoader.php

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,13 @@ class SymfonyLoader extends ComposerLoader
66
{
77
private $kernel;
88

9-
/**
10-
* @param string $path
11-
* @return bool
12-
*/
139
public static function supports(string $path): bool
1410
{
15-
return file_exists($path . '/vendor/autoload.php') && file_exists($path . '/symfony.lock') && file_exists($path . '/src/Kernel.php');
11+
return file_exists($path . '/vendor/autoload.php') &&
12+
file_exists($path . '/symfony.lock') &&
13+
file_exists($path . '/src/Kernel.php');
1614
}
1715

18-
/**
19-
* @param string $path
20-
*/
2116
public function __construct(string $path)
2217
{
2318
parent::__construct($path);
@@ -34,36 +29,24 @@ public function __construct(string $path)
3429
$this->kernel->boot();
3530
}
3631

37-
/**
38-
* Find the application's Kernel class dynamically.
39-
*
40-
* @param string $path
41-
* @return string
42-
*/
4332
private function findKernelClass(string $path): string
4433
{
45-
$kernelFile = $path . '/src/Kernel.php';
46-
if (!file_exists($kernelFile)) {
47-
throw new \RuntimeException('Kernel.php file not found in the src directory.');
48-
}
34+
require_once $path . '/src/Kernel.php';
4935

50-
require_once $kernelFile;
5136
return 'App\\Kernel';
5237
}
5338

54-
/**
55-
* @return string
56-
*/
5739
public function name(): string
5840
{
5941
return 'Symfony';
6042
}
6143

62-
/**
63-
* @return string
64-
*/
6544
public function version(): string
6645
{
67-
return \Symfony\Component\HttpKernel\Kernel::VERSION;
46+
if (class_exists('Symfony\Component\HttpKernel\Kernel')) {
47+
return \Symfony\Component\HttpKernel\Kernel::VERSION;
48+
}
49+
50+
return '';
6851
}
6952
}

src/Tinker.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,14 @@ public function __construct(OutputModifier $outputModifier, $config)
2727
public function execute(string $phpCode): string
2828
{
2929
$phpCode = $this->removeComments($phpCode);
30-
31-
$this->shell->addInput($phpCode);
3230

33-
$closure = new ExecutionLoopClosure($this->shell);
34-
35-
$closure->execute();
31+
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
32+
$this->shell->execute($phpCode);
33+
} else {
34+
$this->shell->addInput($phpCode);
35+
$closure = new ExecutionLoopClosure($this->shell);
36+
$closure->execute();
37+
}
3638

3739
$output = $this->cleanOutput($this->output->fetch());
3840

0 commit comments

Comments
 (0)