Skip to content

Commit

Permalink
Merge pull request #2584 from dpfaffenbauer/issue/2582
Browse files Browse the repository at this point in the history
[Core] Pimcore 11.1 and 11.2 compatibility and psalm update
  • Loading branch information
dpfaffenbauer authored Mar 15, 2024
2 parents b814c70 + 4ec2090 commit 8359728
Show file tree
Hide file tree
Showing 29 changed files with 185 additions and 101 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
PIMCORE_KERNEL_CLASS=Kernel
APP_DEBUG=1
3 changes: 1 addition & 2 deletions .github/workflows/behat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,11 @@ jobs:
PIMCORE_INSTALL_MYSQL_DATABASE: "coreshop_test"
PIMCORE_INSTALL_MYSQL_PORT: "3306"
PIMCORE_KERNEL_CLASS: 'Kernel'
PIMCORE_CLASS_DIRECTORY: 'var/tmp/behat/var/classes'

strategy:
matrix:
php: [ 8.1, 8.2 ]
pimcore: [ ^11.1 ]
pimcore: [ ~11.1.0, ~11.2.0 ]
dependencies: [ highest ]
exclude:
- php: 8.1
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/behat_ui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,11 @@ jobs:
PANTHER_EXTERNAL_BASE_URI: "http://localhost:9080/index_test.php"
PANTHER_CHROME_ARGUMENTS: "--disable-dev-shm-usage"
PIMCORE_KERNEL_CLASS: 'Kernel'
PIMCORE_CLASS_DIRECTORY: 'var/tmp/behat/var/classes'

strategy:
matrix:
php: [ 8.1, 8.2 ]
pimcore: [ ^11.1 ]
pimcore: [ ~11.1.0, ~11.2.0 ]
dependencies: [ highest ]
exclude:
- php: 8.1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/packages_bundles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
fail-fast: false
matrix:
php: [ 8.1, 8.2 ]
pimcore: [ ^11.1 ]
pimcore: [ ~11.1.0, ~11.2.0 ]
dependencies: [ highest ]
package: "${{ fromJson(needs.list.outputs.packages) }}"
exclude:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/packages_components.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
fail-fast: false
matrix:
php: [ 8.1, 8.2 ]
pimcore: [ ^11.1 ]
pimcore: [ ~11.1.0, ~11.2.0 ]
dependencies: [ highest ]
package: "${{ fromJson(needs.list.outputs.packages) }}"
exclude:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
strategy:
matrix:
php: [ 8.1, 8.2 ]
pimcore: [ ^11.1 ]
pimcore: [ ~11.1.0, ~11.2.0 ]
dependencies: [ highest ]
exclude:
- php: 8.1
Expand Down
7 changes: 0 additions & 7 deletions behat-bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,6 @@
);
}

if (!defined('TESTS_PATH')) {
define('TESTS_PATH', __DIR__);
}

define('PIMCORE_CLASS_DIRECTORY', __DIR__ . '/var/tmp/behat/var/classes');
define('PIMCORE_TEST', true);

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
Expand Down
41 changes: 17 additions & 24 deletions bin/console
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,27 @@
* @license https://www.coreshop.org/license GPLv3 and CCL
*/

ob_get_clean();

if (file_exists($a = getcwd() . '/vendor/autoload.php')) {
include $a;
} elseif (file_exists($a = __DIR__ . '/../../../../vendor/autoload.php')) {
include $a;
} elseif (file_exists($a = __DIR__ . '/../vendor/autoload.php')) {
include $a;
use Pimcore\Bootstrap;
use Pimcore\Console\Application;

if (file_exists($a = getcwd() . '/vendor/autoload_runtime.php')) {
require_once $a;
} elseif (file_exists($a = __DIR__ . '/../vendor/autoload_runtime.php')) {
require_once $a;
} elseif (file_exists($a = __DIR__ . '/../../../../vendor/autoload_runtime.php')) {
require_once $a;
} elseif (file_exists($a = __DIR__ . '/../autoload_runtime.php')) {
require_once $a;
} else {
fwrite(STDERR, 'Cannot locate autoloader; please run "composer install"' . PHP_EOL);
exit(1);
throw new LogicException('Symfony Runtime is missing. Try running "composer require symfony/runtime".');
}

\Pimcore\Bootstrap::setProjectRoot();

define('PIMCORE_CONSOLE', true);

Bootstrap::setProjectRoot();

$input = new \Symfony\Component\Console\Input\ArgvInput();
if (null !== $env = $input->getParameterOption(['--env', '-e'], null, true)) {
putenv('APP_ENV='.$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $env);
}

if ($input->hasParameterOption('--no-debug', true)) {
putenv('APP_DEBUG='.$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = '0');
}
return static function (array $context) {
$kernel = Bootstrap::startupCli();

/** @var \Pimcore\Kernel $kernel */
$kernel = \Pimcore\Bootstrap::startupCli();
$application = new \Pimcore\Console\Application($kernel);
$application->run();
return new Application($kernel);
};
10 changes: 6 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
"pimcore/newsletter-bundle": "^1.0",
"pimcore/pimcore": "^11.1",
"rinvex/countries": "^7.3",
"sebastian/diff": "^4.0 | ^5.0",
"sebastian/diff": "^4.0 | ^5.0 | ^6.0",
"stof/doctrine-extensions-bundle": "^1.6",
"sylius/theme-bundle": "^2.2",
"symfony/dotenv": "^6.3",
Expand All @@ -130,11 +130,12 @@
"phpstan/phpstan-doctrine": "^1.3.40",
"phpstan/phpstan-symfony": "^1.3.2",
"phpstan/phpstan-webmozart-assert": "^1.2.4",
"phpunit/phpunit": "^9.5",
"phpunit/phpunit": "^10.0",
"robertfausk/behat-panther-extension": "^1.0",
"symfony/panther": "^2.0",
"symfony/runtime": "^6.3",
"symplify/easy-coding-standard": "^11.1",
"vimeo/psalm": "^4.10"
"vimeo/psalm": "^5.23"
},
"conflict": {
"jms/serializer-bundle": "4.1.0"
Expand Down Expand Up @@ -179,7 +180,8 @@
"config": {
"sort-packages": true,
"allow-plugins": {
"phpstan/extension-installer": false
"phpstan/extension-installer": false,
"symfony/runtime": true
}
}
}
1 change: 1 addition & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ parameters:
- '/Method CoreShop\\Bundle\\ResourceBundle\\Routing\\ResourceLoader::getResolver\(\) should return Symfony\\Component\\Config\\Loader\\LoaderResolverInterface but return statement is missing./'
- '/PHPDoc type string of property CoreShop\\Bundle\\PayumBundle\\Request\\GetStatus::\$status is not covariant with PHPDoc type int of overridden property Payum\\Core\\Request\\BaseGetStatus::\$status./'
- '/Method CoreShop\\Bundle\\ResourceBundle\\Controller\\AdminController::getSubscribedServices\(\) should return non-empty-array<string|Symfony\\Contracts\\Service\\Attribute\\SubscribedService> but returns array<string>./'
- '/Pimcore\\Model\\DataObject\\ClassDefinition\\DynamicOptionsProvider\\MultiSelectOptionsProviderInterface is marked deprecated/'

# Pimcore BC Breaks
- '/Class Pimcore\\Bundle\\AdminBundle\\Helper\\GridHelperService not found/'
Expand Down
60 changes: 60 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,21 @@
</projectFiles>

<issueHandlers>
<RiskyCast>
<errorLevel type="info">
<directory name="src/CoreShop/*" />
</errorLevel>
</RiskyCast>
<RiskyTruthyFalsyComparison>
<errorLevel type="info">
<directory name="src/CoreShop/*" />
</errorLevel>
</RiskyTruthyFalsyComparison>
<MissingTemplateParam>
<errorLevel type="info">
<directory name="src/CoreShop/*" />
</errorLevel>
</MissingTemplateParam>
<!-- level 3 issues - slightly lazy code writing, but probably low false-negatives -->
<UndefinedDocblockClass>
<errorLevel type="suppress">
Expand Down Expand Up @@ -65,6 +80,8 @@
<referencedClass name="Symfony\Component\Security\Core\User\AdvancedUserInterface" />
<referencedClass name="Pimcore\Bundle\AdminBundle\Controller\AdminControllerInterface" />
<referencedClass name="Symfony\Component\DependencyInjection\ContainerAwareInterface" />
<referencedClass name="Payum\Core\Security\GenericTokenFactoryInterface" />
<referencedClass name="Pimcore\Model\DataObject\ClassDefinition\DynamicOptionsProvider\MultiSelectOptionsProviderInterface" />
</errorLevel>
</DeprecatedInterface>
<DeprecatedMethod>
Expand All @@ -83,6 +100,18 @@
<referencedMethod name="Doctrine\DBAL\Query\QueryBuilder::getQueryPart" />
</errorLevel>
</DeprecatedMethod>
<UndefinedInterfaceMethod>
<errorLevel type="info">
<referencedMethod name="Symfony\Component\Config\Definition\Builder\NodeParentInterface::end" />
<referencedMethod name="Symfony\Component\Config\Definition\Builder\NodeParentInterface::scalarNode" />
<referencedMethod name="Symfony\Component\Config\Definition\Builder\NodeDefinition::scalarPrototype" />
<referencedMethod name="Symfony\Component\Config\Definition\Builder\NodeParentInterface::arrayNode" />
<referencedMethod name="Symfony\Component\Config\Definition\Builder\NodeParentInterface::integerNode" />
<referencedMethod name="Symfony\Component\Config\Definition\Builder\NodeDefinition::scalarPrototype" />
<referencedMethod name="Symfony\Component\Config\Definition\Builder\NodeParentInterface::booleanNode" />
<referencedMethod name="Symfony\Component\Config\Definition\Builder\NodeParentInterface::variableNode" />
</errorLevel>
</UndefinedInterfaceMethod>

<InternalMethod>
<errorLevel type="info">
Expand Down Expand Up @@ -151,9 +180,40 @@
<referencedMethod name="Symfony\Component\Config\Definition\Builder\VariableNodeDefinition::scalarNode" />
<referencedMethod name="Symfony\Component\Config\Definition\Builder\VariableNodeDefinition::variableNode" />
<referencedMethod name="Symfony\Component\Config\Definition\Builder\VariableNodeDefinition::scalarPrototype" />
<referencedMethod name="Symfony\Component\Config\Definition\Builder\NodeDefinition::scalarPrototype" />
</errorLevel>
</PossiblyUndefinedMethod>

<UndefinedMethod>
<errorLevel type="info">
<referencedMethod name="Symfony\Component\Config\Definition\Builder\NodeDefinition::children" />
<referencedMethod name="Symfony\Component\Config\Definition\Builder\NodeDefinition::scalarPrototype" />
</errorLevel>
</UndefinedMethod>

<AmbiguousConstantInheritance>
<errorLevel type="info">
<referencedConstant name="CoreShop\Component\Core\Model\Payment::STATE_NEW" />
<referencedConstant name="CoreShop\Component\Core\Model\Payment::STATE_AUTHORIZED" />
<referencedConstant name="CoreShop\Component\Core\Model\Payment::STATE_PROCESSING" />
<referencedConstant name="CoreShop\Component\Core\Model\Payment::STATE_COMPLETED" />
<referencedConstant name="CoreShop\Component\Core\Model\Payment::STATE_FAILED" />
<referencedConstant name="CoreShop\Component\Core\Model\Payment::STATE_CANCELLED" />
<referencedConstant name="CoreShop\Component\Core\Model\Payment::STATE_REFUNDED" />
<referencedConstant name="CoreShop\Component\Core\Model\Payment::STATE_UNKNOWN" />
<referencedConstant name="CoreShop\Bundle\CoreBundle\Pimcore\Repository\WishlistRepository::ORDER_ASCENDING" />
<referencedConstant name="CoreShop\Bundle\StorageListBundle\Pimcore\Repository\PimcoreStorageListRepository::ORDER_ASCENDING" />
<referencedConstant name="CoreShop\Bundle\WishlistBundle\Pimcore\Repository\WishlistRepository::ORDER_ASCENDING" />
<referencedConstant name="CoreShop\Bundle\OrderBundle\Pimcore\Repository\OrderRepository::ORDER_ASCENDING" />
<referencedConstant name="CoreShop\Bundle\ProductQuantityPriceRulesBundle\Doctrine\ORM\ProductQuantityPriceRuleRepository::ORDER_ASCENDING" />
<referencedConstant name="CoreShop\Bundle\CoreBundle\Pimcore\Repository\WishlistRepository::ORDER_DESCENDING" />
<referencedConstant name="CoreShop\Bundle\StorageListBundle\Pimcore\Repository\PimcoreStorageListRepository::ORDER_DESCENDING" />
<referencedConstant name="CoreShop\Bundle\WishlistBundle\Pimcore\Repository\WishlistRepository::ORDER_DESCENDING" />
<referencedConstant name="CoreShop\Bundle\OrderBundle\Pimcore\Repository\OrderRepository::ORDER_DESCENDING" />
<referencedConstant name="CoreShop\Bundle\ProductQuantityPriceRulesBundle\Doctrine\ORM\ProductQuantityPriceRuleRepository::ORDER_DESCENDING" />
</errorLevel>
</AmbiguousConstantInheritance>

<!-- level 5 issues - should be avoided at mosts costs... -->

<TooManyArguments>
Expand Down
28 changes: 14 additions & 14 deletions public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,27 @@
* @license https://www.coreshop.org/license GPLv3 and CCL
*/

use Pimcore\Bootstrap;
use Pimcore\Tool;
use Symfony\Component\HttpFoundation\Request;

include __DIR__ . "/../vendor/autoload.php";
//use runtime
require_once dirname(__DIR__).'/vendor/autoload_runtime.php';

\Pimcore\Bootstrap::setProjectRoot();
\Pimcore\Bootstrap::bootstrap();
Bootstrap::setProjectRoot();

$request = Request::createFromGlobals();
return function (Request $request, array $context) {

// set current request as property on tool as there's no
// request stack available yet
Tool::setCurrentRequest($request);
// set current request as property on tool as there's no
// request stack available yet
Tool::setCurrentRequest($request);

/** @var \Pimcore\Kernel $kernel */
$kernel = \Pimcore\Bootstrap::kernel();
Bootstrap::bootstrap();
$kernel = Bootstrap::kernel();

// reset current request - will be read from request stack from now on
Tool::setCurrentRequest(null);
// reset current request - will be read from request stack from now on
Tool::setCurrentRequest(null);

$response = $kernel->handle($request);
$response->send();
return $kernel;
};

$kernel->terminate($request, $response);
29 changes: 15 additions & 14 deletions public/index_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,29 @@
* @license https://www.coreshop.org/license GPLv3 and CCL
*/

use Pimcore\Bootstrap;
use Pimcore\Tool;
use Symfony\Component\HttpFoundation\Request;

define('PIMCORE_PROJECT_ROOT', __DIR__ . '/..');
$_SERVER['PIMCORE_ENVIRONMENT'] = $_SERVER['APP_ENV'] = $_SERVER['SYMFONY_ENV'] = 'test';

include __DIR__ . "/../vendor/autoload.php";
include __DIR__ . "/../behat-bootstrap.php";
//use runtime
require_once dirname(__DIR__).'/vendor/autoload_runtime.php';

$request = Request::createFromGlobals();
Bootstrap::setProjectRoot();

// set current request as property on tool as there's no
// request stack available yet
Tool::setCurrentRequest($request);
return function (Request $request, array $context) {

/** @var \Pimcore\Kernel $kernel */
$kernel = \Pimcore\Bootstrap::kernel();
// set current request as property on tool as there's no
// request stack available yet
Tool::setCurrentRequest($request);

// reset current request - will be read from request stack from now on
Tool::setCurrentRequest(null);
Bootstrap::bootstrap();
$kernel = Bootstrap::kernel();

$response = $kernel->handle($request);
$response->send();
// reset current request - will be read from request stack from now on
Tool::setCurrentRequest(null);

return $kernel;
};

$kernel->terminate($request, $response);
30 changes: 16 additions & 14 deletions public/index_test_precision.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,30 @@
* @license https://www.coreshop.org/license GPLv3 and CCL
*/


use Pimcore\Bootstrap;
use Pimcore\Tool;
use Symfony\Component\HttpFoundation\Request;

define('PIMCORE_PROJECT_ROOT', __DIR__ . '/..');
define('PIMCORE_PROJECT_ROOT', __DIR__.'/..');
$_SERVER['PIMCORE_ENVIRONMENT'] = $_SERVER['APP_ENV'] = $_SERVER['SYMFONY_ENV'] = 'test_precision';

include __DIR__ . "/../vendor/autoload.php";
include __DIR__ . "/../behat-bootstrap.php";
//use runtime
require_once dirname(__DIR__).'/vendor/autoload_runtime.php';

$request = Request::createFromGlobals();
Bootstrap::setProjectRoot();

// set current request as property on tool as there's no
// request stack available yet
Tool::setCurrentRequest($request);
return function (Request $request, array $context) {

/** @var \Pimcore\Kernel $kernel */
$kernel = \Pimcore\Bootstrap::kernel();
// set current request as property on tool as there's no
// request stack available yet
Tool::setCurrentRequest($request);

// reset current request - will be read from request stack from now on
Tool::setCurrentRequest(null);
Bootstrap::bootstrap();
$kernel = Bootstrap::kernel();

$response = $kernel->handle($request);
$response->send();
// reset current request - will be read from request stack from now on
Tool::setCurrentRequest(null);

$kernel->terminate($request, $response);
return $kernel;
};
Loading

0 comments on commit 8359728

Please sign in to comment.