Skip to content

Commit a6700d4

Browse files
committed
Merge remote-tracking branch 'upstream/master' into feature/improve-sniff-code-error-message
2 parents d0d3449 + ac4987e commit a6700d4

File tree

66 files changed

+304
-196
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+304
-196
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,5 +66,6 @@ Add any other context about the problem here.
6666
## Please confirm
6767

6868
- [ ] I have searched the issue list and am not opening a duplicate issue.
69+
- [ ] I have read the [Contribution Guidelines](https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/.github/CONTRIBUTING.md) and this is not a [support question](https://github.com/PHPCSStandards/PHP_CodeSniffer/discussions).
6970
- [ ] I confirm that this bug is a bug in PHP_CodeSniffer and not in one of the external standards.
7071
- [ ] I have verified the issue still exists in the `master` branch of PHP_CodeSniffer.

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
blank_issues_enabled: true
2+
contact_links:
3+
- name: Community Support
4+
url: https://github.com/PHPCSStandards/PHP_CodeSniffer/discussions?discussions_q=-category%3AAnnouncements
5+
about: Support questions belong in Discussions, not in the issue tracker.

.github/ISSUE_TEMPLATE/feature_request.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ code samples of what should *not* be flagged.
2121
## Additional context (optional)
2222
<!-- Add any other context or screenshots about the feature request here. -->
2323

24+
- [ ] I have read the [Contribution Guidelines](https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/.github/CONTRIBUTING.md) and this is not a [support question](https://github.com/PHPCSStandards/PHP_CodeSniffer/discussions).
2425
- [ ] I intend to create a pull request to implement this feature.

.github/workflows/label-merge-conflicts.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
push:
66
branches:
77
- master
8+
- 4.0
89
# Check conflicts in new PRs and for resolved conflicts due to an open PR being updated.
910
pull_request_target:
1011
types:
@@ -20,7 +21,8 @@ jobs:
2021
name: Check PRs for merge conflicts
2122

2223
steps:
23-
- uses: mschilde/auto-label-merge-conflicts@master
24+
- name: Check PRs for merge conflicts
25+
uses: eps1lon/actions-label-merge-conflict@v3
2426
with:
25-
CONFLICT_LABEL_NAME: "Status: has merge conflict"
26-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27+
dirtyLabel: "Status: has merge conflict"
28+
repoToken: ${{ secrets.GITHUB_TOKEN }}

src/Config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1556,7 +1556,7 @@ public static function setConfigData($key, $value, $temp=false)
15561556
// standards paths are added to the autoloader.
15571557
if ($key === 'installed_paths') {
15581558
$installedStandards = Standards::getInstalledStandardDetails();
1559-
foreach ($installedStandards as $name => $details) {
1559+
foreach ($installedStandards as $details) {
15601560
Autoload::addSearchPath($details['path'], $details['namespace']);
15611561
}
15621562
}

src/Filters/Filter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ protected function shouldProcessFile($path)
179179
// complete extension list and make sure one is allowed.
180180
$extensions = [];
181181
array_shift($fileParts);
182-
foreach ($fileParts as $part) {
182+
while (empty($fileParts) === false) {
183183
$extensions[implode('.', $fileParts)] = 1;
184184
array_shift($fileParts);
185185
}

src/Reporter.php

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,29 @@ public function cacheFileReport(File $phpcsFile)
329329
*
330330
* @param \PHP_CodeSniffer\Files\File $phpcsFile The file that has been processed.
331331
*
332-
* @return array
332+
* @return array<string, string|int|array> Prepared report data.
333+
* The format of prepared data is as follows:
334+
* ```
335+
* array(
336+
* 'filename' => string The name of the current file.
337+
* 'errors' => int The number of errors seen in the current file.
338+
* 'warnings' => int The number of warnings seen in the current file.
339+
* 'fixable' => int The number of fixable issues seen in the current file.
340+
* 'messages' => array(
341+
* int <Line number> => array(
342+
* int <Column number> => array(
343+
* int <Message index> => array(
344+
* 'message' => string The error/warning message.
345+
* 'source' => string The full error code for the message.
346+
* 'severity' => int The severity of the message.
347+
* 'fixable' => bool Whether this error/warning is auto-fixable.
348+
* 'type' => string The type of message. Either 'ERROR' or 'WARNING'.
349+
* )
350+
* )
351+
* )
352+
* )
353+
* )
354+
* ```
333355
*/
334356
public function prepareFileReport(File $phpcsFile)
335357
{

src/Reports/Cbf.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@ class Cbf implements Report
2828
* and FALSE if it ignored the file. Returning TRUE indicates that the file and
2929
* its data should be counted in the grand totals.
3030
*
31-
* @param array $report Prepared report data.
32-
* @param \PHP_CodeSniffer\Files\File $phpcsFile The file being reported on.
33-
* @param bool $showSources Show sources?
34-
* @param int $width Maximum allowed line width.
31+
* @param array<string, string|int|array> $report Prepared report data.
32+
* See the {@see Report} interface for a detailed specification.
33+
* @param \PHP_CodeSniffer\Files\File $phpcsFile The file being reported on.
34+
* @param bool $showSources Show sources?
35+
* @param int $width Maximum allowed line width.
3536
*
3637
* @return bool
3738
* @throws \PHP_CodeSniffer\Exceptions\DeepExitException

src/Reports/Checkstyle.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,11 @@ class Checkstyle implements Report
2424
* and FALSE if it ignored the file. Returning TRUE indicates that the file and
2525
* its data should be counted in the grand totals.
2626
*
27-
* @param array $report Prepared report data.
28-
* @param \PHP_CodeSniffer\Files\File $phpcsFile The file being reported on.
29-
* @param bool $showSources Show sources?
30-
* @param int $width Maximum allowed line width.
27+
* @param array<string, string|int|array> $report Prepared report data.
28+
* See the {@see Report} interface for a detailed specification.
29+
* @param \PHP_CodeSniffer\Files\File $phpcsFile The file being reported on.
30+
* @param bool $showSources Show sources?
31+
* @param int $width Maximum allowed line width.
3132
*
3233
* @return bool
3334
*/

src/Reports/Code.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@ class Code implements Report
2525
* and FALSE if it ignored the file. Returning TRUE indicates that the file and
2626
* its data should be counted in the grand totals.
2727
*
28-
* @param array $report Prepared report data.
29-
* @param \PHP_CodeSniffer\Files\File $phpcsFile The file being reported on.
30-
* @param bool $showSources Show sources?
31-
* @param int $width Maximum allowed line width.
28+
* @param array<string, string|int|array> $report Prepared report data.
29+
* See the {@see Report} interface for a detailed specification.
30+
* @param \PHP_CodeSniffer\Files\File $phpcsFile The file being reported on.
31+
* @param bool $showSources Show sources?
32+
* @param int $width Maximum allowed line width.
3233
*
3334
* @return bool
3435
*/
@@ -121,8 +122,8 @@ public function generateFileReport($report, File $phpcsFile, $showSources=false,
121122

122123
// Determine the longest error message we will be showing.
123124
$maxErrorLength = 0;
124-
foreach ($report['messages'] as $line => $lineErrors) {
125-
foreach ($lineErrors as $column => $colErrors) {
125+
foreach ($report['messages'] as $lineErrors) {
126+
foreach ($lineErrors as $colErrors) {
126127
foreach ($colErrors as $error) {
127128
$length = strlen($error['message']);
128129
if ($showSources === true) {
@@ -264,7 +265,7 @@ public function generateFileReport($report, File $phpcsFile, $showSources=false,
264265

265266
echo str_repeat('-', $width).PHP_EOL;
266267

267-
foreach ($lineErrors as $column => $colErrors) {
268+
foreach ($lineErrors as $colErrors) {
268269
foreach ($colErrors as $error) {
269270
$padding = ($maxLineNumLength - strlen($line));
270271
echo 'LINE '.str_repeat(' ', $padding).$line.': ';

0 commit comments

Comments
 (0)