From 64f034f14dfed9200310dfafc579b9f5662fbf7d Mon Sep 17 00:00:00 2001 From: Kentaro Ohkouchi Date: Fri, 12 Mar 2021 15:29:42 +0900 Subject: [PATCH 1/3] Add phpstan --- .github/workflows/phpstan.yml | 59 +++++++++++++++++++++++++++++++++++ phpstan.neon.dist | 51 ++++++++++++++++++++++++++++++ 2 files changed, 110 insertions(+) create mode 100644 .github/workflows/phpstan.yml create mode 100644 phpstan.neon.dist diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml new file mode 100644 index 0000000000..855a8343d3 --- /dev/null +++ b/.github/workflows/phpstan.yml @@ -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 diff --git a/phpstan.neon.dist b/phpstan.neon.dist new file mode 100644 index 0000000000..c36748cd5e --- /dev/null +++ b/phpstan.neon.dist @@ -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 From 86026bf6c48a2470a5495abe26de5615842faf75 Mon Sep 17 00:00:00 2001 From: Kentaro Ohkouchi Date: Fri, 12 Mar 2021 15:46:31 +0900 Subject: [PATCH 2/3] Fix warnings --- data/class/pages/admin/total/LC_Page_Admin_Total.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/data/class/pages/admin/total/LC_Page_Admin_Total.php b/data/class/pages/admin/total/LC_Page_Admin_Total.php index 3dbeec73c3..cf9f2f9b09 100644 --- a/data/class/pages/admin/total/LC_Page_Admin_Total.php +++ b/data/class/pages/admin/total/LC_Page_Admin_Total.php @@ -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); @@ -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); } @@ -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); } @@ -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); } @@ -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); From 462a37932f180706e2c6732b1ab7956cab25a12e Mon Sep 17 00:00:00 2001 From: Kentaro Ohkouchi Date: Fri, 12 Mar 2021 16:47:27 +0900 Subject: [PATCH 3/3] =?UTF-8?q?phpstan.neon.dist=20=E3=82=92=E3=83=91?= =?UTF-8?q?=E3=83=83=E3=82=B1=E3=83=BC=E3=82=B8=E3=81=8B=E3=82=89=E5=89=8A?= =?UTF-8?q?=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 16dfdeaa71..ae9368c7a9 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -96,6 +96,7 @@ jobs: rm -rf $GITHUB_WORKSPACE/.coveralls.yml 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