Skip to content

Commit 857a449

Browse files
Merge pull request #46 from youwe-petervanderwal/feat/pimcore-phpstan
Feat/pimcore phpstan
2 parents 39d880c + 6373d3d commit 857a449

File tree

7 files changed

+74
-9
lines changed

7 files changed

+74
-9
lines changed

CHANGELOG.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515
- Upstream projects not having phpunit installed will install phpunit with an @stable version.
1616
- Added support for Drupal configuration and templates.
1717
- Migration docs for migration from v2 to v3 of the testing suite.
18-
- Option to use PHP CS Fixer instead of PHPCS
19-
- Pimcore coding standards with [PER coding standards](https://www.php-fig.org/per/coding-style/)
20-
- Added support for an Allow List within the Security Checker.
18+
- Option to use PHP CS Fixer instead of PHPCS.
19+
- Pimcore coding standards with [PER coding standards](https://www.php-fig.org/per/coding-style/).
20+
- Added support for an Allow List within the Security Checker.
21+
- Pimcore PHPStan default config.
2122

2223
### Changed
2324
- [BREAKING] The composer.json configurations `config.youwe-testing-suite.type` and `config.mediact-testing-suite.type`

config/pimcore/grumphp.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,4 @@ parameters:
99
phpcs.enabled: false
1010
phpcsfixer.enabled: true
1111

12-
# securitychecker.allow_list:
13-
# - CVE-2002-0121 # Add a jira ticket indicating when this vulnerability will be fixed (update/upgrade will be
14-
# performed). Within that ticket explain this (new) vulnerability.
12+
phpstan.level: 6
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
// Using same bootstrap as Pimcore (Bundles) uses themselves for PHPStan
6+
// phpcs:disable PSR1.Files.SideEffects.FoundWithSymbols
7+
8+
if (file_exists(__DIR__ . '/../../../../../vendor/autoload.php')) {
9+
define('PIMCORE_PROJECT_ROOT', __DIR__ . '/../../../../..');
10+
} elseif (getenv('PIMCORE_PROJECT_ROOT')) {
11+
if (file_exists(getenv('PIMCORE_PROJECT_ROOT') . '/vendor/autoload.php')) {
12+
define('PIMCORE_PROJECT_ROOT', getenv('PIMCORE_PROJECT_ROOT'));
13+
} else {
14+
throw new \Exception('Invalid Pimcore project root "' . getenv('PIMCORE_PROJECT_ROOT') . '"');
15+
}
16+
} else {
17+
throw new \Exception(
18+
'Unknown configuration! Pimcore project root not found, please set env variable PIMCORE_PROJECT_ROOT.'
19+
);
20+
}
21+
22+
include PIMCORE_PROJECT_ROOT . '/vendor/autoload.php';
23+
\Pimcore\Bootstrap::setProjectRoot();
24+
\Pimcore\Bootstrap::bootstrap();
25+
26+
if (!defined('PIMCORE_TEST')) {
27+
define('PIMCORE_TEST', true);
28+
}

phpstan.neon

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
parameters:
22
excludePaths:
3+
- config/pimcore/phpstan-bootstrap.php
34
- src/installers.php
45
- tests/*
56
ignoreErrors:

src/Installer/PackagesInstaller.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ class PackagesInstaller implements InstallerInterface
5555
'updateDependencies' => true,
5656
]
5757
],
58+
'pimcore' => [
59+
'phpstan/phpstan-symfony' => [
60+
'version' => '@stable',
61+
'updateDependencies' => true,
62+
],
63+
],
5864
];
5965

6066
/**
Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,13 @@
11
imports:
2-
- resource: 'vendor/youwe/testing-suite/config/pimcore/grumphp.yml'
2+
- resource: 'vendor/youwe/testing-suite/config/pimcore/grumphp.yml'
3+
4+
parameters:
5+
# phpstan.level: 6 # The default PHPStan level for Pimcore is 6, but you might want to lower it for your project
6+
# when you're working towards stricter rules (and then increment it with every refactoring).
7+
# See https://phpstan.org/user-guide/rule-levels for more explanation about the different levels.
8+
# - For Pimcore 10.4 till 10.x: suggest to use level 5 maximum
9+
# - For Pimcore 10.0 till 10.3.x: suggest to use level 4 maximum
10+
11+
# securitychecker.allow_list:
12+
# - CVE-2002-0121 # Add a jira ticket indicating when this vulnerability will be fixed (update/upgrade will be
13+
# performed). Within that ticket explain this (new) vulnerability.
Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
includes:
2+
- vendor/phpstan/phpstan-symfony/extension.neon
3+
14
parameters:
2-
excludes_analyse:
3-
# - %rootDir%/../../../path/to/exclude/*
5+
excludePaths:
6+
# Symfony files
7+
- %rootDir%/../../../bin/console
8+
- %rootDir%/../../../public/index.php
9+
# Full var folder, contains all kind of auto-generated files (e.g. cache, generated Pimcore DataObject classes)
10+
- %rootDir%/../../../var/*
11+
# Configuration written by Pimcore (which is written either to var/ or to config/pimcore/ depending on settings)
12+
- %rootDir%/../../../config/pimcore/*
13+
# Unit tests
14+
- %rootDir%/../../../tests/fixtures/*
15+
# Deployer (which would be nice if it is correct too, but does need its own composer install, therefore excluding)
16+
- %rootDir%/../../../build/deployer/*
17+
18+
# Custom excludes
19+
# - %rootDir%/../../../path/to/exclude/*
20+
21+
# Point PHPStan to internal constants that are bootstrapped
22+
bootstrapFiles:
23+
- ./vendor/youwe/testing-suite/config/pimcore/phpstan-bootstrap.php

0 commit comments

Comments
 (0)