Skip to content

Commit 25e9c93

Browse files
committed
Run phpcbf, sync changes with phan
And update tests
1 parent ece35cc commit 25e9c93

15 files changed

+488
-309
lines changed

src/TolerantASTConverter/Bootstrap.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php declare(strict_types=1);
1+
<?php
2+
3+
declare(strict_types=1);
24

35
// Listen for all errors
46
error_reporting(E_ALL);

src/TolerantASTConverter/Cache.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php declare(strict_types=1);
1+
<?php
2+
3+
declare(strict_types=1);
24

35
namespace TolerantASTConverter;
46

@@ -22,5 +24,5 @@ public function getIfExists(string $key);
2224
* @param T $value
2325
* @return bool true if successfully saved
2426
*/
25-
public function save(string $key, $value) : bool;
27+
public function save(string $key, $value): bool;
2628
}

src/TolerantASTConverter/InvalidNodeException.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php declare(strict_types=1);
1+
<?php
2+
3+
declare(strict_types=1);
24

35
namespace TolerantASTConverter;
46

src/TolerantASTConverter/NodeDumper.php

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php declare(strict_types=1);
1+
<?php
2+
3+
declare(strict_types=1);
24

35
namespace TolerantASTConverter;
46

@@ -60,15 +62,15 @@ public function __construct(string $file_contents, bool $include_offset = false,
6062
/**
6163
* Should this include the byte offset in the file where the node occurred?
6264
*/
63-
public function setIncludeOffset(bool $include_offset) : void
65+
public function setIncludeOffset(bool $include_offset): void
6466
{
6567
$this->include_offset = $include_offset;
6668
}
6769

6870
/**
6971
* Should this include the token kind (default is just the text of the token)
7072
*/
71-
public function setIncludeTokenKind(bool $include_token_kind) : void
73+
public function setIncludeTokenKind(bool $include_token_kind): void
7274
{
7375
$this->include_token_kind = $include_token_kind;
7476
}
@@ -77,7 +79,7 @@ public function setIncludeTokenKind(bool $include_token_kind) : void
7779
* Sets the text used for indentation (e.g. 4 spaces)
7880
* @suppress PhanUnreferencedPublicMethod
7981
*/
80-
public function setIndent(string $indent) : void
82+
public function setIndent(string $indent): void
8183
{
8284
$this->indent = $indent;
8385
}
@@ -86,7 +88,7 @@ public function setIndent(string $indent) : void
8688
* Converts the class name of $ast_node to a short string describing that class name.
8789
* Removes the common `Microsoft\\PhpParser\\` prefix
8890
*/
89-
public static function dumpClassName(Node $ast_node) : string
91+
public static function dumpClassName(Node $ast_node): string
9092
{
9193
$name = get_class($ast_node);
9294
if (\stripos($name, 'Microsoft\\PhpParser\\') === 0) {
@@ -100,7 +102,7 @@ public static function dumpClassName(Node $ast_node) : string
100102
* Converts the class name of $token to a short string describing that class name.
101103
* Removes the common `Microsoft\\PhpParser\\` prefix
102104
*/
103-
public static function dumpTokenClassName(Token $token) : string
105+
public static function dumpTokenClassName(Token $token): string
104106
{
105107
$name = get_class($token);
106108
if (\stripos($name, 'Microsoft\\PhpParser\\') === 0) {
@@ -115,7 +117,7 @@ public static function dumpTokenClassName(Token $token) : string
115117
* @param string $padding (to be echoed before the current node
116118
* @throws Exception for invalid $ast_node values
117119
*/
118-
public function dumpTreeAsString($ast_node, string $key = '', string $padding = '') : string
120+
public function dumpTreeAsString($ast_node, string $key = '', string $padding = ''): string
119121
{
120122
if ($ast_node instanceof Node) {
121123
$first_part = \sprintf(
@@ -156,7 +158,7 @@ public function dumpTreeAsString($ast_node, string $key = '', string $padding =
156158
* @throws Exception for invalid $ast_node values
157159
* @suppress PhanUnreferencedPublicMethod
158160
*/
159-
public function dumpTree($ast_node, string $key = '', string $padding = '') : void
161+
public function dumpTree($ast_node, string $key = '', string $padding = ''): void
160162
{
161163
echo $this->dumpTreeAsString($ast_node, $key, $padding);
162164
}

src/TolerantASTConverter/ParseResult.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php declare(strict_types=1);
1+
<?php
2+
3+
declare(strict_types=1);
24

35
namespace TolerantASTConverter;
46

src/TolerantASTConverter/StringUtil.php

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php declare(strict_types=1);
1+
<?php
2+
3+
declare(strict_types=1);
24

35
namespace TolerantASTConverter;
46

@@ -73,7 +75,7 @@ final class StringUtil
7375
*
7476
* @return string The parsed string
7577
*/
76-
public static function parse(string $str) : string
78+
public static function parse(string $str): string
7779
{
7880
$c = $str[0];
7981
if ($c === '<') {
@@ -103,7 +105,7 @@ public static function parse(string $str) : string
103105
* Converts a fragment of raw (possibly indented)
104106
* heredoc to the string that the PHP interpreter would treat it as.
105107
*/
106-
public static function parseHeredoc(string $str) : string
108+
public static function parseHeredoc(string $str): string
107109
{
108110
// TODO: handle dos newlines
109111
// TODO: Parse escape sequences
@@ -135,7 +137,7 @@ public static function parseHeredoc(string $str) : string
135137
* @return string String with escape sequences parsed
136138
* @throws InvalidNodeException for invalid code points
137139
*/
138-
public static function parseEscapeSequences($str, ?string $quote) : string
140+
public static function parseEscapeSequences($str, ?string $quote): string
139141
{
140142
if (!is_string($str)) {
141143
// Invalid AST input; give up
@@ -150,7 +152,7 @@ public static function parseEscapeSequences($str, ?string $quote) : string
150152
/**
151153
* @param list<string> $matches
152154
*/
153-
static function (array $matches) : string {
155+
static function (array $matches): string {
154156
$str = $matches[1];
155157

156158
if (isset(self::REPLACEMENTS[$str])) {
@@ -179,7 +181,7 @@ static function (array $matches) : string {
179181
*
180182
* @throws InvalidNodeException for invalid code points
181183
*/
182-
private static function codePointToUtf8(int $num) : string
184+
private static function codePointToUtf8(int $num): string
183185
{
184186
if ($num <= 0x7F) {
185187
return chr($num);
@@ -202,7 +204,7 @@ private static function codePointToUtf8(int $num) : string
202204
* @param string|int|float|bool|null|array|object $value
203205
* Source: Phan\Library\StringUtil
204206
*/
205-
public static function jsonEncode($value) : string
207+
public static function jsonEncode($value): string
206208
{
207209
$result = \json_encode($value, \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE | \JSON_PARTIAL_OUTPUT_ON_ERROR);
208210
return \is_string($result) ? $result : '(invalid data)';

0 commit comments

Comments
 (0)