-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Process] Deprecate using values that are not string for Process::setStdin and ProcessBuilder::setInput #10930
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
Conversation
{ | ||
if (null !== $input && !is_string($input)) { | ||
if (is_scalar($input) || (is_object($input) && method_exists($input, '__toString'))) { | ||
trigger_error(sprintf('% only accepts stream resource and string as input.'), E_USER_DEPRECATED); |
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.
stream resources are not accepted
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.
and I would not forbid passing another scalar but just cast it when setting it. PHP does not have strict types for scalars
PR rebased and updated, comments addressed. |
@@ -971,3 +971,4 @@ UPGRADE FROM 2.x to 3.0 | |||
|
|||
* Process::setStdin() and Process::getStdin() have been removed. Use | |||
Process::setInput() and Process::getInput() that works the same way. | |||
* Process::setInput and ProcessBuilder::setInput do not accept non-scalar types. |
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.
missing ()
at the end of the method name (same below).
PR Updated, comments addressed |
@@ -87,7 +87,12 @@ public static function escapeArgument($argument) | |||
public static function validateInput($caller, $input) | |||
{ | |||
if (null !== $input) { | |||
if (is_scalar($input) || (is_object($input) && method_exists($input, '__toString'))) { | |||
if (is_object($input) && method_exists($input, '__toString')) { | |||
trigger_error(sprintf('% only accepts string as input.', $caller), E_USER_DEPRECATED); |
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.
we don't trigger deprecation errors for stuff working until 3.0. We will only do it the last minor release before 3.0
…Stdin and ProcessBuilder::setInput
PR updated, @stof comments addressed |
…or Process::setStdin and ProcessBuilder::setInput (romainneutron) This PR was merged into the 2.4-dev branch. Discussion ---------- [Process] Deprecate using values that are not string for Process::setStdin and ProcessBuilder::setInput | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | yes | Tests pass? | yes | Fixed tickets | n/a | License | MIT This deprecates passing a `Process` input any value that is not a strict string. This needs #10929 to be merged. I don't know if the use of `trigger_error` is correct or should be removed. Commits ------- 9887b83 [Process] Deprecate using values that are not string for Process::setStdin and ProcessBuilder::setInput
This deprecates passing a
Process
input any value that is not a strict string. This needs #10929 to be merged.I don't know if the use of
trigger_error
is correct or should be removed.