Skip to content

Commit

Permalink
Improve shop creator with phpstan
Browse files Browse the repository at this point in the history
  • Loading branch information
mflasquin committed Nov 4, 2022
1 parent 485d2e9 commit 30197d5
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 6 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: PHP tests
on: [push, pull_request]
jobs:
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:
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 @@ -13,7 +13,8 @@
"ext-SimpleXML": "*"
},
"require-dev": {
"phpunit/phpunit": "~5.2"
"phpunit/phpunit": "~5.2",
"phpstan/phpstan": "^1.9"
},
"autoload": {
"psr-4": {
Expand Down
63 changes: 61 additions & 2 deletions 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

0 comments on commit 30197d5

Please sign in to comment.