Skip to content

Commit b73fe99

Browse files
committed
Fix v6.2.0 release
1 parent 3c9a59c commit b73fe99

File tree

4 files changed

+61
-7
lines changed

4 files changed

+61
-7
lines changed

.editorconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@ root = true
22

33
[*]
44
charset = utf-8
5+
end_of_line = lf
56
indent_size = 4
67
indent_style = space
78
insert_final_newline = true
89
trim_trailing_whitespace = true
10+
block_comment_start = /*
11+
block_comment = *
12+
block_comment_end = */
913

1014
[*.yml]
1115
indent_size = 2

functionMap62.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
*
99
* '<function_name>' => ['<return_type>', '<arg_name>'=>'<arg_type>']
1010
*
11+
* For classes:
12+
*
13+
* '<class_name>' => [null, '<arg_name>'=>'<arg_type>']
14+
*
1115
* @link https://github.com/phpstan/phpstan-src/blob/1.5.x/resources/functionMap.php
1216
*/
1317
return [
@@ -48,4 +52,18 @@
4852
'wp_slash' => ['T', '@phpstan-template'=>'T', 'value'=>'T'],
4953
'wp_unschedule_event' => ['bool|WP_Error', 'args'=>$cronArgsType],
5054
'wp_unslash' => ['T', '@phpstan-template'=>'T', 'value'=>'T'],
55+
'WP_REST_Request' => [null, '@phpstan-template'=>'T of array', '@phpstan-implements'=>'ArrayAccess<key-of<T>, value-of<T>>'],
56+
'WP_REST_Request::offsetExists' => ['bool', 'offset'=>'@param key-of<T>'],
57+
'WP_REST_Request::offsetGet' => ['T[TOffset]', '@phpstan-template'=>'TOffset of key-of<T>', 'offset'=>'TOffset'],
58+
'WP_REST_Request::offsetSet' => ['void', '@phpstan-template'=>'TOffset of key-of<T>', 'offset'=>'TOffset', 'value'=>'T[TOffset]'],
59+
'WP_REST_Request::offsetUnset' => ['void', '@phpstan-template'=>'TOffset of key-of<T>', 'offset'=>'TOffset'],
60+
'WP_Theme' => [null, '@phpstan-type'=>"ThemeKey 'Name'|'Version'|'Status'|'Title'|'Author'|'Author Name'|'Author URI'|'Description'|'Template'|'Stylesheet'|'Template Files'|'Stylesheet Files'|'Template Dir'|'Stylesheet Dir'|'Screenshot'|'Tags'|'Theme Root'|'Theme Root URI'|'Parent Theme'"],
61+
'WP_Theme::offsetExists' => ['($offset is ThemeKey ? true : false)'],
62+
'WP_Theme::offsetGet' => ['($offset is ThemeKey ? mixed : null)'],
63+
'WP_Block_List' => [null, '@phpstan-implements'=>'ArrayAccess<int, WP_Block>'],
64+
'WP_Block_List::offsetExists' => ['bool', 'offset'=>'int'],
65+
'WP_Block_List::offsetGet' => ['WP_Block|null', 'offset'=>'int'],
66+
'WP_Block_List::offsetSet' => ['void', 'offset'=>'int|null'],
67+
'WP_Block_List::offsetUnset' => ['void', 'offset'=>'int'],
68+
'is_wp_error' => ['bool', '@phpstan-assert-if-true'=>'\WP_Error $thing']
5169
];

visitor62.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
use phpDocumentor\Reflection\Type;
1111
use PhpParser\Comment\Doc;
1212
use PhpParser\Node;
13+
use PhpParser\Node\Identifier;
14+
use PhpParser\Node\Stmt\Class_;
1315
use PhpParser\Node\Stmt\ClassMethod;
1416
use PhpParser\Node\Stmt\Function_;
1517
use PhpParser\Node\Stmt\Property;
@@ -262,7 +264,7 @@ public function enterNode(Node $node)
262264
{
263265
parent::enterNode($node);
264266

265-
if (!($node instanceof Function_) && !($node instanceof ClassMethod) && !($node instanceof Property)) {
267+
if (!($node instanceof Function_) && !($node instanceof ClassMethod) && !($node instanceof Property) && !($node instanceof Class_)) {
266268
return null;
267269
}
268270

@@ -305,7 +307,7 @@ public function enterNode(Node $node)
305307

306308
private static function getNodeName(Node $node): string
307309
{
308-
if (($node instanceof Function_) || ($node instanceof ClassMethod)) {
310+
if ((($node instanceof Function_) || ($node instanceof ClassMethod) || ($node instanceof Class_)) && $node->name instanceof Identifier) {
309311
return $node->name->name;
310312
}
311313

@@ -341,7 +343,7 @@ private function postProcessNode(Node $node): void
341343
}
342344
}
343345

344-
if (! ($node instanceof Function_) && ! ($node instanceof ClassMethod) && ! ($node instanceof Property)) {
346+
if (! ($node instanceof Function_) && ! ($node instanceof ClassMethod) && ! ($node instanceof Property) && ! ($node instanceof Class_)) {
345347
return;
346348
}
347349

@@ -646,10 +648,12 @@ private function getAdditionalTagsFromMap(string $symbolName): array
646648
);
647649
}
648650

649-
$additions[] = sprintf(
650-
'@phpstan-return %s',
651-
$returnType
652-
);
651+
if ($returnType) {
652+
$additions[] = sprintf(
653+
'@phpstan-return %s',
654+
$returnType
655+
);
656+
}
653657

654658
return $additions;
655659
}

wordpress-stubs.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30531,6 +30531,7 @@ public function __construct(array $settings = array())
3053130531
* Class representing a list of block instances.
3053230532
*
3053330533
* @since 5.5.0
30534+
* @phpstan-implements ArrayAccess<int, WP_Block>
3053430535
*/
3053530536
#[\AllowDynamicProperties]
3053630537
class WP_Block_List implements \Iterator, \ArrayAccess, \Countable
@@ -30583,6 +30584,8 @@ public function __construct($blocks, $available_context = array(), $registry = \
3058330584
*
3058430585
* @param string $index Index of block to check.
3058530586
* @return bool Whether block exists.
30587+
* @phpstan-param int $offset
30588+
* @phpstan-return bool
3058630589
*/
3058730590
#[\ReturnTypeWillChange]
3058830591
public function offsetExists($index)
@@ -30597,6 +30600,8 @@ public function offsetExists($index)
3059730600
*
3059830601
* @param string $index Index of block value to retrieve.
3059930602
* @return mixed|null Block value if exists, or null.
30603+
* @phpstan-param int $offset
30604+
* @phpstan-return WP_Block|null
3060030605
*/
3060130606
#[\ReturnTypeWillChange]
3060230607
public function offsetGet($index)
@@ -30611,6 +30616,8 @@ public function offsetGet($index)
3061130616
*
3061230617
* @param string $index Index of block value to set.
3061330618
* @param mixed $value Block value.
30619+
* @phpstan-param int|null $offset
30620+
* @phpstan-return void
3061430621
*/
3061530622
#[\ReturnTypeWillChange]
3061630623
public function offsetSet($index, $value)
@@ -30624,6 +30631,8 @@ public function offsetSet($index, $value)
3062430631
* @link https://www.php.net/manual/en/arrayaccess.offsetunset.php
3062530632
*
3062630633
* @param string $index Index of block value to unset.
30634+
* @phpstan-param int $offset
30635+
* @phpstan-return void
3062730636
*/
3062830637
#[\ReturnTypeWillChange]
3062930638
public function offsetUnset($index)
@@ -51695,6 +51704,7 @@ public function set_spacing_sizes()
5169551704
* @package WordPress
5169651705
* @subpackage Theme
5169751706
* @since 3.4.0
51707+
* @phpstan-type ThemeKey 'Name'|'Version'|'Status'|'Title'|'Author'|'Author Name'|'Author URI'|'Description'|'Template'|'Stylesheet'|'Template Files'|'Stylesheet Files'|'Template Dir'|'Stylesheet Dir'|'Screenshot'|'Tags'|'Theme Root'|'Theme Root URI'|'Parent Theme'
5169851708
*/
5169951709
#[\AllowDynamicProperties]
5170051710
final class WP_Theme implements \ArrayAccess
@@ -51784,6 +51794,7 @@ public function offsetUnset($offset)
5178451794
*
5178551795
* @param mixed $offset
5178651796
* @return bool
51797+
* @phpstan-return ($offset is ThemeKey ? true : false)
5178751798
*/
5178851799
#[\ReturnTypeWillChange]
5178951800
public function offsetExists($offset)
@@ -51803,6 +51814,7 @@ public function offsetExists($offset)
5180351814
*
5180451815
* @param mixed $offset
5180551816
* @return mixed
51817+
* @phpstan-return ($offset is ThemeKey ? mixed : null)
5180651818
*/
5180751819
#[\ReturnTypeWillChange]
5180851820
public function offsetGet($offset)
@@ -62768,6 +62780,8 @@ public function merge_with(&$other)
6276862780
* @since 4.4.0
6276962781
*
6277062782
* @link https://www.php.net/manual/en/class.arrayaccess.php
62783+
* @phpstan-template T of array
62784+
* @phpstan-implements ArrayAccess<key-of<T>, value-of<T>>
6277162785
*/
6277262786
#[\AllowDynamicProperties]
6277362787
class WP_REST_Request implements \ArrayAccess
@@ -63301,6 +63315,8 @@ public function has_valid_params()
6330163315
*
6330263316
* @param string $offset Parameter name.
6330363317
* @return bool Whether the parameter is set.
63318+
* @phpstan-param @param key-of<T> $offset
63319+
* @phpstan-return bool
6330463320
*/
6330563321
#[\ReturnTypeWillChange]
6330663322
public function offsetExists($offset)
@@ -63313,6 +63329,9 @@ public function offsetExists($offset)
6331363329
*
6331463330
* @param string $offset Parameter name.
6331563331
* @return mixed|null Value if set, null otherwise.
63332+
* @phpstan-template TOffset of key-of<T>
63333+
* @phpstan-param TOffset $offset
63334+
* @phpstan-return T[TOffset]
6331663335
*/
6331763336
#[\ReturnTypeWillChange]
6331863337
public function offsetGet($offset)
@@ -63325,6 +63344,10 @@ public function offsetGet($offset)
6332563344
*
6332663345
* @param string $offset Parameter name.
6332763346
* @param mixed $value Parameter value.
63347+
* @phpstan-template TOffset of key-of<T>
63348+
* @phpstan-param TOffset $offset
63349+
* @phpstan-param T[TOffset] $value
63350+
* @phpstan-return void
6332863351
*/
6332963352
#[\ReturnTypeWillChange]
6333063353
public function offsetSet($offset, $value)
@@ -63336,6 +63359,9 @@ public function offsetSet($offset, $value)
6333663359
* @since 4.4.0
6333763360
*
6333863361
* @param string $offset Parameter name.
63362+
* @phpstan-template TOffset of key-of<T>
63363+
* @phpstan-param TOffset $offset
63364+
* @phpstan-return void
6333963365
*/
6334063366
#[\ReturnTypeWillChange]
6334163367
public function offsetUnset($offset)
@@ -111566,6 +111592,8 @@ function wp_doing_cron()
111566111592
*
111567111593
* @param mixed $thing The variable to check.
111568111594
* @return bool Whether the variable is an instance of WP_Error.
111595+
* @phpstan-assert-if-true \WP_Error $thing
111596+
* @phpstan-return bool
111569111597
*/
111570111598
function is_wp_error($thing)
111571111599
{

0 commit comments

Comments
 (0)