Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
keradus committed Apr 18, 2021
1 parent f0157f2 commit 77724d4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Tokenizer/Token.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

namespace PhpCsFixer\Tokenizer;

use PhpCsFixer\Utils;

/**
* Representation of single token.
* As a token prototype you should understand a single element generated by token_get_all.
Expand Down Expand Up @@ -613,7 +615,7 @@ public function toArray()
*/
public function toJson(array $options = null)
{
$options = array_reduce($options, function ($carry, $item) { return $carry | $item; }, 0) ?: (JSON_PRETTY_PRINT | JSON_NUMERIC_CHECK);
$options = $options ? Utils::calculateBitmask($options) : (JSON_PRETTY_PRINT | JSON_NUMERIC_CHECK);
$jsonResult = json_encode($this->toArray(), $options);

if (JSON_ERROR_NONE !== json_last_error()) {
Expand Down

0 comments on commit 77724d4

Please sign in to comment.