Skip to content

Commit

Permalink
Merge pull request #447 from nanasess/use-phpstan
Browse files Browse the repository at this point in the history
PHPStan による静的解析の導入
  • Loading branch information
okazy authored Mar 24, 2021
2 parents dbf84f5 + 462a379 commit 8f9d879
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 5 deletions.
1 change: 1 addition & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ jobs:
rm -rf $GITHUB_WORKSPACE/.editorconfig
rm -rf $GITHUB_WORKSPACE/.php_cs.dist
rm -rf $GITHUB_WORKSPACE/phpunit.xml.dist
rm -rf $GITHUB_WORKSPACE/phpstan.neon.dist
rm -rf $GITHUB_WORKSPACE/app.json
rm -rf $GITHUB_WORKSPACE/Procfile
rm -rf $GITHUB_WORKSPACE/build.xml
Expand Down
59 changes: 59 additions & 0 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: PHPStan
on:
push:
branches:
- '*'
tags:
- '*'
paths:
- '**'
- '!*.md'
pull_request:
paths:
- '**'
- '!*.md'

jobs:
phpstan:
name: PHPStan

runs-on: ubuntu-latest
services:
postgres:
image: postgres:12
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: postgres
ports:
- 5432:5432
# needed because the postgres container does not provide a healthcheck
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- name: "Checkout"
uses: actions/checkout@v2
- name: Setup PHP
uses: nanasess/setup-php@master
with:
php-version: '8.0'
- name: composer install
run: |
sudo composer selfupdate
composer install --dev --no-interaction -o --apcu-autoloader
composer require --dev --ignore-platform-req=php phpstan/phpstan
- name: Setup to EC-CUBE
env:
DB: pgsql
USER: postgres
DBUSER: postgres
DBPASS: password
DBNAME: eccube_db
DBPORT: 5432
HTTP_URL: http://localhost:8085/
HTTPS_URL: http://localhost:8085/
run: |
./eccube_install.sh ${DB}
- name: PHPStan
run: data/vendor/bin/phpstan analyze data/ --error-format=github
10 changes: 5 additions & 5 deletions data/class/pages/admin/total/LC_Page_Admin_Total.php
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ public function lfGetOrderMember($type, $sdate, $edate)
}
}

$tpl_image = DRAW_IMAGE ? $this->lfGetGraphPie($arrTotalResults, 'member_name', 'member', '(売上比率)', $sdate, $edate) : '';
$tpl_image = defined('DRAW_IMAGE') && DRAW_IMAGE ? $this->lfGetGraphPie($arrTotalResults, 'member_name', 'member', '(売上比率)', $sdate, $edate) : '';


return array($arrTotalResults, $tpl_image);
Expand Down Expand Up @@ -619,7 +619,7 @@ public function lfGetOrderProducts($type, $sdate, $edate)
$objQuery->setOrder('total DESC');
$arrTotalResults = $objQuery->select($col, $from, $where, $arrWhereVal);

$tpl_image = DRAW_IMAGE ? $this->lfGetGraphPie($arrTotalResults, 'product_name', 'products_' . $type, '(売上比率)', $sdate, $edate) : '';
$tpl_image = defined('DRAW_IMAGE') && DRAW_IMAGE ? $this->lfGetGraphPie($arrTotalResults, 'product_name', 'products_' . $type, '(売上比率)', $sdate, $edate) : '';

return array($arrTotalResults, $tpl_image);
}
Expand Down Expand Up @@ -657,7 +657,7 @@ public function lfGetOrderJob($type, $sdate, $edate)

}

$tpl_image = DRAW_IMAGE ? $this->lfGetGraphPie($arrTotalResults, 'job_name', 'job_' . $type, '(売上比率)', $sdate, $edate) : '';
$tpl_image = defined('DRAW_IMAGE') && DRAW_IMAGE ? $this->lfGetGraphPie($arrTotalResults, 'job_name', 'job_' . $type, '(売上比率)', $sdate, $edate) : '';

return array($arrTotalResults, $tpl_image);
}
Expand Down Expand Up @@ -695,7 +695,7 @@ public function lfGetOrderAge($type, $sdate, $edate)

}

$tpl_image = DRAW_IMAGE ? $this->lfGetGraphBar($arrTotalResults, 'age_name', 'age_' . $type, '(年齢)', '(売上合計)', $sdate, $edate) : '';
$tpl_image = defined('DRAW_IMAGE') && DRAW_IMAGE ? $this->lfGetGraphBar($arrTotalResults, 'age_name', 'age_' . $type, '(年齢)', '(売上合計)', $sdate, $edate) : '';

return array($arrTotalResults, $tpl_image);
}
Expand Down Expand Up @@ -750,7 +750,7 @@ public function lfGetOrderTerm($type, $sdate, $edate)

$arrTotalResults = $this->lfAddBlankLine($arrTotalResults, $type, $sdate, $edate);

$tpl_image = DRAW_IMAGE ? $this->lfGetGraphLine($arrTotalResults, 'str_date', 'term_' . $type, $xtitle, $ytitle, $sdate, $edate, $xincline) : '';
$tpl_image = defined('DRAW_IMAGE') && DRAW_IMAGE ? $this->lfGetGraphLine($arrTotalResults, 'str_date', 'term_' . $type, $xtitle, $ytitle, $sdate, $edate, $xincline) : '';

$arrTotalResults = $this->lfAddTotalLine($arrTotalResults);

Expand Down
51 changes: 51 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
parameters:
level: 1
bootstrapFiles:
- tests/require.php
excludePaths:
- data/Smarty/templates_c/*
- data/module/SOAP/*
- data/vendor/*
- data/downloads/*
- data/module/Calendar/Engine/PearDate.php
- data/class/helper/SC_Helper_Mobile.php
- data/class/SC_MobileEmoji.php
- data/class/SC_MobileImage.php
- data/**/flycheck_*.php
ignoreErrors:
-
message: "#^Call to an undefined static method PEAR\\:\\:raiseError\\(\\)\\.$#"
paths:
- data/module/HTTP/Request.php
- data/module/Net/SMTP.php
- data/module/Calendar/Calendar.php
- data/module/Calendar/Decorator.php
- data/module/Calendar/Factory.php
-
message: "#^Call to an undefined method Net_Socket\\:\\:raiseError\\(\\)\\.$#"
path: data/module/Net/Socket.php
-
message: "#^Call to static method factory\\(\\) on an unknown class Auth_SASL\\.$#"
path: data/module/Net/SMTP.php
-
message: "#^Call to static method dayOfWeek\\(\\) on an unknown class Date_Calc\\.#"
path: data/module/Calendar/Util/Textual.php
# -
# message: "#^Constant SMARTY_PLUGINS_DIR not found\\.$#"
# path: data/smarty_extends/*
-
message: "#^Function smarty_function_escape_special_chars not found\\.$#"
path: data/smarty_extends/*
-
message: "#^Variable \\$values in isset\\(\\) is always null\\.$#"
paths:
- data/smarty_extends/function.html_radios_ex.php
- data/smarty_extends/function.html_checkboxes_ex.php
-
message: "#^Undefined variable\\: \\$tags$#"
paths:
- data/smarty_extends/function.html_radios_ex.php
- data/smarty_extends/function.html_checkboxes_ex.php
-
message: "#^Variable \\$SJIS_widths might not be defined\\.$#"
path: data/class/helper/SC_Helper_FPDI.php

0 comments on commit 8f9d879

Please sign in to comment.