10000 Workaround disabled "var_dump" by nicolas-grekas · Pull Request #47086 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Workaround disabled "var_dump" #47086

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

Merged
merged 1 commit into from
Jul 27, 2022
Merged
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
2 changes: 1 addition & 1 deletion src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public function shutdown()
if (class_exists(DebugClassLoader::class, false)) {
DebugClassLoader::checkClasses();
}
$currErrorHandler = set_error_handler('var_dump');
$currErrorHandler = set_error_handler('is_int');
restore_error_handler();

if ($currErrorHandler !== [$this, 'handleError']) {
Expand Down
6 changes: 3 additions & 3 deletions src/Symfony/Component/Debug/ErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ public function screamAt($levels, $replace = false)
private function reRegister(int $prev)
{
if ($prev !== $this->thrownErrors | $this->loggedErrors) {
$handler = set_error_handler('var_dump');
$handler = set_error_handler('is_int');
$handler = \is_array($handler) ? $handler[0] : null;
restore_error_handler();
Comment on lines -358 to 360
Copy link
Contributor

Choose a reason for hiding this comment

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

If ever is_int was called, it would throw an ArgumentCountError, so a few questions:

  • Is that actually a good thing?
  • Are there reasons for not passing null here? or e.g. function () {}?
  • Would it be safer to move up the restore_{error|exception}_handler(); immediately after the set_{error|exception}_handler call, with no operation in-between?
  • Should add get_error_handler() and get_exception_handler() php/php-src#969 be revived?

Copy link
Member Author
@nicolas-grekas nicolas-grekas Jul 28, 2022

Choose a reason for hiding this comment

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

Should php/php-src#969 be revived?

Maybe. For your other questions, they're mostly theoretical at the moment so I wouldn't care much :)

if ($handler === $this) {
Expand Down Expand Up @@ -490,7 +490,7 @@ public function handleError($type, $message, $file, $line)
$log = 0;
} else {
if (\PHP_VERSION_ID < (\PHP_VERSION_ID < 70400 ? 70316 : 70404)) {
$currentErrorHandler = set_error_handler('var_dump');
$currentErrorHandler = set_error_handler('is_int');
restore_error_handler();
}

Expand Down Expand Up @@ -601,7 +601,7 @@ public static function handleFatalError(array $error = null)
$sameHandlerLimit = 10;

while (!\is_array($handler) || !$handler[0] instanceof self) {
$handler = set_exception_handler('var_dump');
$handler = set_exception_handler('is_int');
restore_exception_handler();

if (!$handler) {
Expand Down
6 changes: 3 additions & 3 deletions src/Symfony/Component/ErrorHandler/ErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ public function screamAt(int $levels, bool $replace = false): int
private function reRegister(int $prev): void
{
if ($prev !== $this->thrownErrors | $this->loggedErrors) {
$handler = set_error_handler('var_dump');
$handler = set_error_handler('is_int');
$handler = \is_array($handler) ? $handler[0] : null;
restore_error_handler();
if ($handler === $this) {
Expand Down Expand Up @@ -522,7 +522,7 @@ public function handleError(int $type, string $message, string $file, int $line)
$log = 0;
} else {
if (\PHP_VERSION_ID < (\PHP_VERSION_ID < 70400 ? 70316 : 70404)) {
$currentErrorHandler = set_error_handler('var_dump');
$currentErrorHandler = set_error_handler('is_int');
restore_error_handler();
}

Expand Down Expand Up @@ -639,7 +639,7 @@ public static function handleFatalError(array $error = null): void
$sameHandlerLimit = 10;

while (!\is_array($handler) || !$handler[0] instanceof self) {
$handler = set_exception_handler('var_dump');
$handler = set_exception_handler('is_int');
restore_exception_handler();

if (!$handler) {
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/HttpClient/HttpClientTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ private static function prepareRequest(?string $method, ?string $url, array $opt
}

// Validate on_progress
if (!\is_callable($onProgress = $options['on_progress'] ?? 'var_dump')) {
if (isset($options['on_progress']) && !\is_callable($onProgress = $options['on_progress'])) {
throw new InvalidArgumentException(sprintf('Option "on_progress" must be callable, "%s" given.', \is_object($onProgress) ? \get_class($onProgress) : \gettype($onProgress)));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class DebugHandlersListener implements EventSubscriberInterface
*/
public function __construct(callable $exceptionHandler = null, LoggerInterface $logger = null, $levels = \E_ALL, ?int $throwAt = \E_ALL, bool $scream = true, $fileLinkFormat = null, bool $scope = true)
{
$handler = set_exception_handler('var_dump');
$handler = set_exception_handler('is_int');
$this->earlyHandler = \is_array($handler) ? $handler[0] : null;
restore_exception_handler();

Expand All @@ -80,7 +80,7 @@ public function configure(Event $event = null)
}
$this->firstCall = $this->hasTerminatedWithException = false;

$handler = set_exception_handler('var_dump');
$handler = set_exception_handler('is_int');
$handler = \is_array($handler) ? $handler[0] : null;
restore_exception_handler();

Expand Down
0