-
-
Notifications
You must be signed in to change notification settings - Fork 76
fix: Check that the result of pcntl_waitpid is the PID of a managed process #1126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
NanoSector
wants to merge
2
commits into
PHPCSStandards:master
Choose a base branch
from
NanoSector:bugfix/1112-check-waitpid-result
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 @@ | ||
*.fixed |
This file contains hidden or 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,18 @@ | ||
<?php | ||
|
||
/** | ||
* Class containing no style errors according to the end-to-end tests phpcs.xml.dist. | ||
* | ||
* @copyright 2025 PHPCSStandards and contributors | ||
* @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence | ||
*/ | ||
|
||
namespace PHP_CodeSniffer\Tests\EndToEnd\Files; | ||
|
||
class ClassOneWithoutStyleError | ||
{ | ||
private function foo() | ||
{ | ||
return 'bar'; | ||
} | ||
} |
This file contains hidden or 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 @@ | ||
<?php | ||
|
||
/** | ||
* Class containing no style errors. | ||
* | ||
* @copyright 2025 PHPCSStandards and contributors | ||
* @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence | ||
*/ | ||
|
||
namespace PHP_CodeSniffer\Tests\EndToEnd\Files; | ||
|
||
class ClassTwoWithoutStyleError | ||
{ | ||
/** | ||
* A property. | ||
* | ||
* @var string | ||
*/ | ||
private $bar = 'baz'; | ||
} |
This file contains hidden or 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,22 @@ | ||
<?php | ||
|
||
/** | ||
* Class containing a simple style error that phpcbf can fix. | ||
* | ||
* @copyright 2025 PHPCSStandards and contributors | ||
* @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence | ||
*/ | ||
|
||
namespace PHP_CodeSniffer\Tests\EndToEnd\Files; | ||
|
||
class ClassWithStyleError | ||
{ | ||
/** | ||
* The bracket for this function is misaligned and this can be automatically fixed by phpcbf. | ||
* | ||
* @return string | ||
*/ | ||
private function foo() { | ||
return 'bar'; | ||
} | ||
} |
This file contains hidden or 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 @@ | ||
<?xml version="1.0"?> | ||
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="PHP_CodeSniffer" xsi:noNamespaceSchemaLocation="phpcs.xsd"> | ||
<description>The coding standard for end to end tests.</description> | ||
|
||
<rule ref="PSR12"/> | ||
|
||
<file>.</file> | ||
|
||
<arg name="basepath" value="."/> | ||
<arg name="colors"/> | ||
<arg name="parallel" value="75"/> | ||
<arg value="p"/> | ||
</ruleset> |
This file contains hidden or 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,38 @@ | ||
#!/usr/bin/env bash | ||
|
||
function tear_down() { | ||
rm -r tests/EndToEnd/Files/*.fixed | ||
} | ||
|
||
function test_phpcbf_is_working() { | ||
OUTPUT="$(bin/phpcbf --no-cache --standard=tests/EndToEnd/Files/phpcs.xml.dist tests/EndToEnd/Files/ClassOneWithoutStyleError.inc tests/EndToEnd/Files/ClassTwoWithoutStyleError.inc)" | ||
|
||
assert_successful_code | ||
assert_contains "No violations were found" "$OUTPUT" | ||
} | ||
|
||
function test_phpcbf_is_working_in_parallel() { | ||
OUTPUT="$(bin/phpcbf --no-cache --parallel=2 --standard=tests/EndToEnd/Files/phpcs.xml.dist tests/EndToEnd/Files/ClassOneWithoutStyleError.inc tests/EndToEnd/Files/ClassTwoWithoutStyleError.inc)" | ||
|
||
assert_successful_code | ||
assert_contains "No violations were found" "$OUTPUT" | ||
} | ||
|
||
function test_phpcbf_returns_error_on_issues() { | ||
OUTPUT="$(bin/phpcbf --no-colors --no-cache --suffix=.fixed --standard=tests/EndToEnd/Files/phpcs.xml.dist tests/EndToEnd/Files/ClassWithStyleError.inc)" | ||
assert_exit_code 1 | ||
|
||
assert_contains "F 1 / 1 (100%)" "$OUTPUT" | ||
assert_contains "A TOTAL OF 1 ERROR WERE FIXED IN 1 FILE" "$OUTPUT" | ||
} | ||
|
||
function test_phpcbf_bug_1112() { | ||
# See https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/1112 | ||
if [[ "$(uname)" == "Darwin" ]]; then | ||
# Perform some magic with `& fg` to prevent the processes from turning into a background job. | ||
assert_successful_code "$(bash -ic 'bash --init-file <(echo "echo \"Subprocess\"") -c "bin/phpcbf --no-cache --parallel=2 --standard=tests/EndToEnd/Files/phpcs.xml.dist tests/EndToEnd/Files/ClassOneWithoutStyleError.inc tests/EndToEnd/Files/ClassTwoWithoutStyleError.inc" & fg')" | ||
else | ||
# This is not needed on Linux / GitHub Actions | ||
assert_successful_code "$(bash -ic 'bash --init-file <(echo "echo \"Subprocess\"") -c "bin/phpcbf --no-cache --parallel=2 --standard=tests/EndToEnd/Files/phpcs.xml.dist tests/EndToEnd/Files/ClassOneWithoutStyleError.inc tests/EndToEnd/Files/ClassTwoWithoutStyleError.inc"')" | ||
fi | ||
} |
This file contains hidden or 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,28 @@ | ||
#!/usr/bin/env bash | ||
|
||
function test_phpcs_is_working() { | ||
assert_successful_code "$(bin/phpcs --no-cache --standard=tests/EndToEnd/Files/phpcs.xml.dist tests/EndToEnd/Files/ClassOneWithoutStyleError.inc tests/EndToEnd/Files/ClassTwoWithoutStyleError.inc)" | ||
} | ||
|
||
function test_phpcs_is_working_in_parallel() { | ||
assert_successful_code "$(bin/phpcs --no-cache --parallel=2 --standard=tests/EndToEnd/Files/phpcs.xml.dist tests/EndToEnd/Files/ClassOneWithoutStyleError.inc tests/EndToEnd/Files/ClassTwoWithoutStyleError.inc)" | ||
} | ||
|
||
function test_phpcs_returns_error_on_issues() { | ||
OUTPUT="$(bin/phpcs --no-colors --no-cache --standard=tests/EndToEnd/Files/phpcs.xml.dist tests/EndToEnd/Files/ClassWithStyleError.inc)" | ||
assert_exit_code 2 | ||
|
||
assert_contains "E 1 / 1 (100%)" "$OUTPUT" | ||
assert_contains "FOUND 1 ERROR AFFECTING 1 LINE" "$OUTPUT" | ||
} | ||
|
||
function test_phpcs_bug_1112() { | ||
# See https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/1112 | ||
if [[ "$(uname)" == "Darwin" ]]; then | ||
# Perform some magic with `& fg` to prevent the processes from turning into a background job. | ||
assert_successful_code "$(bash -ic 'bash --init-file <(echo "echo \"Subprocess\"") -c "bin/phpcs --no-cache --parallel=2 --standard=tests/EndToEnd/Files/phpcs.xml.dist tests/EndToEnd/Files/ClassOneWithoutStyleError.inc tests/EndToEnd/Files/ClassTwoWithoutStyleError.inc" & fg')" | ||
else | ||
# This is not needed on Linux / GitHub Actions | ||
assert_successful_code "$(bash -ic 'bash --init-file <(echo "echo \"Subprocess\"") -c "bin/phpcs --no-cache --parallel=2 --standard=tests/EndToEnd/Files/phpcs.xml.dist tests/EndToEnd/Files/ClassOneWithoutStyleError.inc tests/EndToEnd/Files/ClassTwoWithoutStyleError.inc"')" | ||
fi | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These annotation should not be tooling specific and
non-negative-int
andnon-empty-string
are PHPStan specific annotations.