Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2d364d7

Browse files
Fix undefined XMLReader properties with local phpstorm-stubs patch
1 parent 59ae706 commit 2d364d7

File tree

6 files changed

+166
-8
lines changed

6 files changed

+166
-8
lines changed

‎composer.json‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@
9595
"jetbrains/phpstorm-stubs": [
9696
"patches/PDO.patch",
9797
"patches/ReflectionProperty.patch",
98-
"patches/SessionHandler.patch"
98+
"patches/SessionHandler.patch",
99+
"patches/xmlreader.patch",
100+
"patches/dom_c.patch"
99101
]
100102
}
101103
},

‎composer.lock‎

Lines changed: 6 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎patches/dom_c.patch‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--- dom/dom_c.php 2024年01月02日 12:04:54
2+
+++ dom/dom_c.php 2024年01月21日 10:41:56
3+
@@ -1347,6 +1347,14 @@
4+
*/
5+
class DOMNamedNodeMap implements IteratorAggregate, Countable
6+
{
7+
+
8+
+ /**
9+
+ * The number of nodes in the map. The range of valid child node indices is 0 to length - 1 inclusive.
10+
+ * @var int
11+
+ * @readonly
12+
+ */
13+
+ #[PhpStormStubsElementAvailable(from: '8.1')]
14+
+ public $length;
15+
/**
16+
* Retrieves a node specified by name
17+
* @link https://php.net/manual/en/domnamednodemap.getnameditem.php

‎patches/xmlreader.patch‎

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
--- xmlreader/xmlreader.php 2024年01月21日 10:44:31
2+
+++ xmlreader/xmlreader.php 2024年01月21日 10:48:24
3+
@@ -28,7 +28,119 @@
4+
*/
5+
class XMLReader
6+
{
7+
+ /**
8+
+ * The number of attributes on the node
9+
+ * @var int
10+
+ * @readonly
11+
+ */
12+
+ #[PhpStormStubsElementAvailable(from: '8.1')]
13+
+ public $attributeCount;
14+
+
15+
+ /**
16+
+ * The base URI of the node
17+
+ * @var string
18+
+ * @readonly
19+
+ */
20+
+ #[PhpStormStubsElementAvailable(from: '8.1')]
21+
+ public $baseURI;
22+
+
23+
+ /**
24+
+ * Depth of the node in the tree, starting at 0
25+
+ * @var int
26+
+ * @readonly
27+
+ */
28+
+ #[PhpStormStubsElementAvailable(from: '8.1')]
29+
+ public $depth;
30+
+
31+
+ /**
32+
+ * Indicates if node has attributes
33+
+ * @var bool
34+
+ * @readonly
35+
+ */
36+
+ #[PhpStormStubsElementAvailable(from: '8.1')]
37+
+ public $hasAttributes;
38+
+
39+
+ /**
40+
+ * Indicates if node has a text value
41+
+ * @var bool
42+
+ * @readonly
43+
+ */
44+
+ #[PhpStormStubsElementAvailable(from: '8.1')]
45+
+ public $hasValue;
46+
+
47+
+ /**
48+
+ * Indicates if attribute is defaulted from DTD
49+
+ * @var bool
50+
+ * @readonly
51+
+ */
52+
+ #[PhpStormStubsElementAvailable(from: '8.1')]
53+
+ public $isDefault;
54+
+
55+
+ /**
56+
+ * Indicates if node is an empty element tag
57+
+ * @var bool
58+
+ * @readonly
59+
+ */
60+
+ #[PhpStormStubsElementAvailable(from: '8.1')]
61+
+ public $isEmptyElement;
62+
+
63+
+ /**
64+
+ * The local name of the node
65+
+ * @var string
66+
+ * @readonly
67+
+ */
68+
+ #[PhpStormStubsElementAvailable(from: '8.1')]
69+
+ public $localName;
70+
+
71+
/**
72+
+ * The qualified name of the node
73+
+ * @var string
74+
+ * @readonly
75+
+ */
76+
+ #[PhpStormStubsElementAvailable(from: '8.1')]
77+
+ public $name;
78+
+
79+
+ /**
80+
+ * The URI of the namespace associated with the node
81+
+ * @var string
82+
+ * @readonly
83+
+ */
84+
+ #[PhpStormStubsElementAvailable(from: '8.1')]
85+
+ public $namespaceURI;
86+
+
87+
+ /**
88+
+ * The node type for the node
89+
+ * @var int
90+
+ * @readonly
91+
+ */
92+
+ #[PhpStormStubsElementAvailable(from: '8.1')]
93+
+ public $nodeType;
94+
+
95+
+ /**
96+
+ * The prefix of the namespace associated with the node
97+
+ * @var string
98+
+ * @readonly
99+
+ */
100+
+ #[PhpStormStubsElementAvailable(from: '8.1')]
101+
+ public $prefix;
102+
+
103+
+ /**
104+
+ * The text value of the node
105+
+ * @var string
106+
+ * @readonly
107+
+ */
108+
+ #[PhpStormStubsElementAvailable(from: '8.1')]
109+
+ public $value;
110+
+
111+
+ /**
112+
+ * The xml:lang scope which the node resides
113+
+ * @var string
114+
+ * @readonly
115+
+ */
116+
+ #[PhpStormStubsElementAvailable(from: '8.1')]
117+
+ public $xmlLang;
118+
+
119+
+ /**
120+
* No node type
121+
*/
122+
public const NONE = 0;

‎tests/PHPStan/Rules/Properties/AccessPropertiesRuleTest.php‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -929,4 +929,12 @@ public function testRequireExtends(): void
929929
]);
930930
}
931931

932+
public function testBug8629(): void
933+
{
934+
$this->checkThisOnly = false;
935+
$this->checkUnionTypes = true;
936+
$this->checkDynamicProperties = true;
937+
$this->analyse([__DIR__ . '/data/bug-8629.php'], []);
938+
}
939+
932940
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace Bug8629;
4+
5+
use XMLReader;
6+
7+
function (): void {
8+
$reader = new XMLReader();
9+
var_dump($reader->nodeType);
10+
};

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /