Skip to content
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

Token::toJson() - remove parameter #5644

Merged
merged 1 commit into from Apr 18, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 2 additions & 19 deletions src/Tokenizer/Token.php
Expand Up @@ -462,26 +462,9 @@ public function toArray(): array
];
}

/**
* @param null|string[] $options JSON encode option
*/
public function toJson(?array $options = null): string
public function toJson(): string
{
if (null !== $options) {
Utils::triggerDeprecation(sprintf('Arguments of "%s()" is deprecated since 2.19 and will be removed in 3.0.', __METHOD__));
}

static $defaultOptions = null;

if (null === $options) {
if (null === $defaultOptions) {
$defaultOptions = Utils::calculateBitmask(['JSON_PRETTY_PRINT', 'JSON_NUMERIC_CHECK']);
}

$options = $defaultOptions;
} else {
$options = Utils::calculateBitmask($options);
}
$options = Utils::calculateBitmask(['JSON_PRETTY_PRINT', 'JSON_NUMERIC_CHECK']);

$jsonResult = json_encode($this->toArray(), $options);

Expand Down