-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #125: Fix deprecated locale function calls.
By @laryn, @drupix, and @indigoxela (GHA code).
- Loading branch information
Showing
10 changed files
with
218 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
<?php | ||
|
||
namespace PHP_CodeSniffer\Reports; | ||
|
||
use PHP_CodeSniffer\Files\File; | ||
/** | ||
* | ||
*/ | ||
class Github implements Report { | ||
|
||
/** | ||
* Generate a partial report for a single processed file. | ||
* | ||
* Function should return TRUE if it printed or stored data about the file | ||
* and FALSE if it ignored the file. Returning TRUE indicates that the file and | ||
* its data should be counted in the grand totals. | ||
* | ||
* @param array $report | ||
* Prepared report data. | ||
* @param \PHP_CodeSniffer\File $phpcsFile | ||
* The file being reported on. | ||
* @param bool $showSources | ||
* Show sources? | ||
* @param int $width | ||
* Maximum allowed line width. | ||
* | ||
* @return bool | ||
*/ | ||
public function generateFileReport($report, File $phpcsFile, $showSources=FALSE, $width=80) | ||
{ | ||
if ($report['errors'] === 0 && $report['warnings'] === 0) { | ||
// Nothing to print. | ||
return FALSE; | ||
} | ||
|
||
foreach ($report['messages'] as $line => $lineErrors) { | ||
foreach ($lineErrors as $column => $colErrors) { | ||
foreach ($colErrors as $error) { | ||
$type = strtolower($error['type']); | ||
$file = $report['filename']; | ||
$message = $error['message']; | ||
echo "::$type file=$file,line=$line,col=$column::$message" . PHP_EOL; | ||
} | ||
} | ||
} | ||
|
||
return TRUE; | ||
|
||
}//end generateFileReport() | ||
|
||
|
||
/** | ||
* Generates a GitHub Actions report. | ||
* | ||
* @param string $cachedData | ||
* Any partial report data that was returned from | ||
* generateFileReport during the run. | ||
* @param int $totalFiles | ||
* Total number of files processed during the run. | ||
* @param int $totalErrors | ||
* Total number of errors found during the run. | ||
* @param int $totalWarnings | ||
* Total number of warnings found during the run. | ||
* @param int $totalFixable | ||
* Total number of problems that can be fixed. | ||
* @param bool $showSources | ||
* Show sources? | ||
* @param int $width | ||
* Maximum allowed line width. | ||
* @param bool $interactive | ||
* Are we running in interactive mode? | ||
* @param bool $toScreen | ||
* Is the report being printed to screen? | ||
* | ||
* @return void | ||
*/ | ||
public function generate( | ||
$cachedData, | ||
$totalFiles, | ||
$totalErrors, | ||
$totalWarnings, | ||
$totalFixable, | ||
$showSources=FALSE, | ||
$width=80, | ||
$interactive=FALSE, | ||
$toScreen=TRUE | ||
) { | ||
echo $cachedData; | ||
|
||
}//end generate() | ||
|
||
|
||
}//end class |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<VirtualHost *:80> | ||
# Variables in this file will be substituted in step "Setup Apache". | ||
DocumentRoot _PWD | ||
|
||
<Directory _PWD> | ||
AllowOverride All | ||
Require all granted | ||
</Directory> | ||
|
||
<FilesMatch ".+\.php$"> | ||
SetHandler "proxy:unix:/run/php/php_PHP_V-fpm.sock|fcgi://localhost" | ||
</FilesMatch> | ||
</VirtualHost> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
/** | ||
* @file | ||
* Custom settings for test runs. | ||
*/ | ||
|
||
// Never send telemetry data. | ||
$settings['telemetry_enabled'] = FALSE; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
parameters: | ||
ignoreErrors: | ||
- | ||
message: "#^$#" | ||
count: 1 | ||
path: ../../xmlsitemap.module |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# The baseline file is generated with phpstan and contains known errors that | ||
# don't need to show up in every report. | ||
# If a problem got fixed, the file should be re-generated. | ||
# @see https://phpstan.org/user-guide/baseline | ||
# includes: | ||
# - baseline.neon | ||
# @see https://phpstan.org/config-reference | ||
parameters: | ||
level: 0 | ||
scanDirectories: | ||
- ../../../../core | ||
- ../../ | ||
fileExtensions: | ||
- module | ||
- inc | ||
- install | ||
- test | ||
excludePaths: | ||
- *.tpl.php | ||
- *.api.php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,53 @@ | ||
name: Coding Standards | ||
on: [push, pull_request] | ||
name: Code Checks | ||
on: [pull_request] | ||
jobs: | ||
phpcs: | ||
name: Run phpcs | ||
runs-on: ubuntu-18.04 | ||
codechecks: | ||
name: PHPStan and phpcs | ||
runs-on: ubuntu-20.04 | ||
timeout-minutes: 15 | ||
steps: | ||
- name: Setup env | ||
run: | | ||
echo "REPO_NAME=${PWD##*/}" >> $GITHUB_ENV | ||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: '7.2' | ||
php-version: 8.1 | ||
# No composer nor xdebug, but we need our commandline tools. | ||
tools: none, phpstan, phpcs | ||
coverage: none | ||
|
||
- uses: actions/checkout@v2 | ||
# The checkout action refuses to put it outside, so we have to do it in | ||
# two steps. | ||
- name: Checkout coding standard | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: backdrop-ops/phpcs | ||
ref: 1.0.0 | ||
path: phpcs | ||
- name: Move standard outside current dir | ||
run: mv phpcs .. | ||
|
||
- 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 | ||
# Core code is necessary for phpstan. | ||
- name: Checkout Backdrop core | ||
uses: actions/checkout@v4 | ||
with: | ||
path: ${{ steps.composer-cache.outputs.dir }} | ||
key: ${{ runner.os }}-composer-${{ hashFiles('./composer.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-composer- | ||
- name: Composer install coder_sniffer | ||
run: composer install --ansi --prefer-dist --no-interaction --no-progress | ||
repository: backdrop/backdrop | ||
|
||
- name: Backdrop coding standards | ||
run: > | ||
vendor/bin/phpcs -n | ||
--standard=vendor/backdrop/coder/coder_sniffer/Backdrop | ||
--ignore="vendor/*,xmlsitemap.xmlsitemap.inc" | ||
--extensions=install,module,php,inc . | ||
- name: Checkout module | ||
uses: actions/checkout@v4 | ||
with: | ||
path: modules/${{ env.REPO_NAME }} | ||
|
||
- name: Run PHPStan | ||
run: | | ||
cd modules/${{ env.REPO_NAME }} | ||
phpstan analyze -c .github/phpstan/phpstan.neon --error-format=github --no-progress . | ||
# We run phpcs even if phpstan fails. | ||
- name: Run CodeSniffer | ||
if: ${{ always() }} | ||
run: | | ||
cd modules/${{ env.REPO_NAME }} | ||
phpcs --standard=../../../phpcs/Backdrop --report=.github/misc/Github.php -n --basepath=. * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters