8000 [Process] Add deprecated logs on Process::setInput() and ProcessBuilder::setInput(). by tmartin · Pull Request #12725 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Process] Add deprecated logs on Process::setInput() and ProcessBuilder::setInput(). #12725

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[Process] Add deprecated logs on Process::setInput() and ProcessBuild…
…er::setInput() which does not accept non-scalar types.
  • Loading branch information
tmartin committed Nov 29, 2014
commit 8c5b1de81d9c187435329a17d4c223101c7e847b
8 changes: 8 additions & 0 deletions src/Symfony/Component/Process/Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -1092,6 +1092,7 @@ public function setStdin($stdin)
* Sets the input.
*
* This content will be passed to the underlying process standard input.
* Deprecation: As of Symfony 2.5, this method only accepts scalar values.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use a @deprecated annotation instead?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fabpot Are you sure? Adding a @deprecated would mean that the entire method is deprecated, at least the IDE will understand it this way. If so I'll have to change it in ProcessBuilder::setInput() too.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nevermind

*
* @param string|null $input The content
*
Expand All @@ -1101,6 +1102,13 @@ public function setStdin($stdin)
*/
public function setInput($input)
{
if (!is_scalar($input)) {
trigger_error(
'Passing a non-scalar input is deprecated since version 2.5 and will be removed in 3.0.',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please format it this way:

trigger_error('PropertyAccess::getPropertyAccessor() is deprecated since version 2.3 and will be removed in 3.0. Use PropertyAccess::createPropertyAccessor() instead.', E_USER_DEPRECATED);

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@timglabish I thought we have to break lines at 120 char. Are you sure?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, everything on one line.

E_USER_DEPRECATED
);
}

if ($this->isRunning()) {
throw new LogicException('Input can not be set while the process is running.');
}
Expand Down
9 changes: 8 additions & 1 deletion src/Symfony/Component/Process/ProcessBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public function addEnvironmentVariables(array $variables)
/**
* Sets the input of the process.
*
* Deprecation: As of Symfony 2.5, this method only accepts string values.
* Deprecation: As of Symfony 2.5, this method only accepts scalar values.
*
* @param string|null $input The input as a string
*
Expand All @@ -177,6 +177,13 @@ public function addEnvironmentVariables(array $variables)
*/
public function setInput($input)
{
if (!is_scalar($input)) {
trigger_error(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

format is wrong

'Passing a non-scalar input is deprecated since version 2.5 and will be removed in 3.0.',
E_USER_DEPRECATED
);
}

$this->input = ProcessUtils::validateInput(sprintf('%s::%s', __CLASS__, __FUNCTION__), $input);

return $this;
Expand Down
0