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

Improve shop creator with phpstan #26

Merged
merged 1 commit into from
Nov 9, 2022
Merged
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
48 changes: 47 additions & 1 deletion .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ jobs:
name: PHP Syntax check 7.2 => 8.1
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
all_but_latest: true
access_token: ${{ github.token }}

- name: Checkout
uses: actions/[email protected]

Expand All @@ -28,3 +29,48 @@ jobs:

- name: PHP syntax checker 8.1
uses: prestashop/github-action-php-lint/8.1@master

phpstan:
permissions:
actions: write # for styfle/cancel-workflow-action to cancel/stop running workflows
contents: read # for actions/checkout to fetch code
name: PHP Static Analysis
runs-on: ubuntu-latest
strategy:
matrix:
php: [ '7.2', '7.3', '7.4', '8.0', '8.1' ]
fail-fast: false
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
mflasquin marked this conversation as resolved.
Show resolved Hide resolved
all_but_latest: true
access_token: ${{ github.token }}

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
extensions: mbstring, intl, gd, xml, dom, json, fileinfo, curl, zip, iconv, simplexml

- uses: actions/checkout@v2

- name: Get Composer Cache Directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache Composer Directory
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Composer Install
run: |
composer install --ansi --prefer-dist --no-interaction --no-progress
rm composer.lock
composer config platform.php ${{ matrix.php }}

- name: Run phpstan
run: ./vendor/bin/phpstan analyse
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"cweagans/composer-patches": "^1.7"
},
"require-dev": {
"phpunit/phpunit": "~5.2"
"phpunit/phpunit": "~5.2",
"phpstan/phpstan": "^1.9"
},
"autoload": {
"psr-4": {
Expand Down
61 changes: 60 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
parameters:
paths:
- app
- src
level: 5
parallel:
maximumNumberOfProcesses: 1
4 changes: 2 additions & 2 deletions src/Generator/EntityGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ private function getRelationFromDependencies($relationName, $entityName)
*
* @param string $relationName
*
* @return \SimpleXMLElement
* @return \SimpleXMLElement|null
*/
private function getRelationWithMatchingFieldsFromDependencies($relationName)
{
Expand Down Expand Up @@ -795,7 +795,7 @@ private function getRelationWithMatchingFieldsFromDependencies($relationName)
* @param array $relations
* @param array $relationFieldValue
*
* @return null
* @return \SimpleXMLElement|null
*/
private function getMatchingRelation(&$relations, $relationFieldValue)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Service/XMLGeneratorService.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ private static function generateXML(
*/
private static function sortModelWithDependencies(Finder $finder)
{
$dependencies = $storedDependencies = [];
$dependencies = $storedDependencies = $parentEntities = [];

foreach ($finder as $file) {
$pathName = $file->getPathname();
Expand Down