Commit 04671a87 authored by catch's avatar catch
Browse files

fix: #3636099 commit-code-check.sh fails if PHPStan ignores all the files

By: alexpott
By: xjm
By: mstrelan
By: quietone
(cherry picked from commit af90f36e)
parent 18d97b14
Loading
Loading
Loading
Loading
Loading
+10 −2
Changes for core/scripts/dev/commit-code-check.sh: 10 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -245,7 +245,15 @@
else
  # Only run PHPStan on changed files locally.
  printf "\nRunning PHPStan on changed files.\n"
  php -d apc.enabled=0 -d apc.enable_cli=0 vendor/bin/phpstan analyze --no-progress --configuration="$TOP_LEVEL/core/phpstan-partial.neon" $ABS_FILES $memory_limit
  PHPSTAN_OUTPUT=$(php -d apc.enabled=0 -d apc.enable_cli=0 vendor/bin/phpstan analyze --no-progress --configuration="$TOP_LEVEL/core/phpstan-partial.neon" $ABS_FILES $memory_limit 2>&1)
  PHPSTAN_STATUS=$?
  printf "%s\n" "$PHPSTAN_OUTPUT"
  # PHPStan exits with an error when every changed file is excluded from
  # analysis, for example when only *.api.php files changed.
  if [[ $PHPSTAN_STATUS -ne 0 && "$PHPSTAN_OUTPUT" == *"No files found to analyse"* ]]; then
    PHPSTAN_STATUS=0
  fi
  (exit $PHPSTAN_STATUS)
fi

if [ "$?" -ne "0" ]; then
@@ -360,7 +368,7 @@
TWIG_FILES=""
for FILE in $FILES; do
  if [[ -f "$TOP_LEVEL/$FILE" ]]; then
    if [[ $FILE =~ \.(inc|install|module|php|profile|test|theme|yml)$ ]]; then
    if [[ $FILE =~ \.(inc|install|module|php|profile|test|theme|yml)$ ]] && [[ $FILE != "core/.phpstan-baseline.php" ]]; then
      PHP_FILES="$PHP_FILES $TOP_LEVEL/$FILE"
    fi
    if [[ $FILE =~ \.(yml|js)$ ]]; then