Skip to content

Commit 70af077

Browse files
committed
Merge remote-tracking branch 'upstream/main'
2 parents 41b24b0 + 3ccba97 commit 70af077

17 files changed

+169
-37
lines changed

SECURITY.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<!-- BEGIN MICROSOFT SECURITY.MD V0.0.8 BLOCK -->
2+
3+
## Security
4+
5+
Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/).
6+
7+
If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://aka.ms/opensource/security/definition), please report it to us as described below.
8+
9+
## Reporting Security Issues
10+
11+
**Please do not report security vulnerabilities through public GitHub issues.**
12+
13+
Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/opensource/security/create-report).
14+
15+
If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/opensource/security/pgpkey).
16+
17+
You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://aka.ms/opensource/security/msrc).
18+
19+
Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue:
20+
21+
* Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
22+
* Full paths of source file(s) related to the manifestation of the issue
23+
* The location of the affected source code (tag/branch/commit or direct URL)
24+
* Any special configuration required to reproduce the issue
25+
* Step-by-step instructions to reproduce the issue
26+
* Proof-of-concept or exploit code (if possible)
27+
* Impact of the issue, including how an attacker might exploit the issue
28+
29+
This information will help us triage your report more quickly.
30+
31+
If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://aka.ms/opensource/security/bounty) page for more details about our active programs.
32+
33+
## Preferred Languages
34+
35+
We prefer all communications to be in English.
36+
37+
## Policy
38+
39+
Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/opensource/security/cvd).
40+
41+
<!-- END MICROSOFT SECURITY.MD BLOCK -->

composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,8 @@
1818
],
1919
"autoload": {
2020
"psr-4": { "Microsoft\\PhpParser\\": ["src/"] }
21+
},
22+
"autoload-dev": {
23+
"psr-4": { "Microsoft\\PhpParser\\Tests\\Unit\\": ["tests/unit/"] }
2124
}
2225
}

docs/HowItWorks.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ Note that for this error case, it is more of an art than a science. That is to s
306306
would add special casing for anticipated scenarios, rather than construct some general-purpose rule.
307307
308308
#### Other notes
309-
* Just as it's imporant to understand the assumptions that *will* hold true,
309+
* Just as it's important to understand the assumptions that *will* hold true,
310310
it is also important to understand the assumptions that will not hold true.
311311
One such **non-invariant** is that not every token generated by the lexer ends up in the tree.
312312
@@ -387,6 +387,6 @@ existing, more battle-tested, work to validate our own correctness.
387387
degree of variance, we should set up some infrastructure to help us ensure that performance work results in a statistically
388388
significant boost and works on a wide variety of machine configurations.
389389
* Fuzz testing - test the parser against automatically generated inputs to exercise edge cases in a bulk fashion, and
390-
and ensure expected properties of the tree.
390+
ensure expected properties of the tree.
391391
* Community feedback - try and get the parser in the hands of as many people as possible so we can validate a
392392
wide range of use cases. The Syntax Visualizer tool is one tool to help us increase reach.

docs/Overview.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,5 +75,5 @@ all incorrect constructs (e.g. including a non-constant expression as the defaul
7575
a method parameter). Instead, it attaches these errors on a post-parse walk of the tree.
7676

7777
## Next Steps
78-
Check out the [Readme](../README.md) and [Getting Started](GettingStarted.md) pages for more information on how consume
79-
the parser, or the [How It Works](HowItWorks.md) section if you want to dive deeper into the implementation.
78+
Check out the [Readme](../README.md) and [Getting Started](GettingStarted.md) pages for more information on how to
79+
consume the parser, or the [How It Works](HowItWorks.md) section if you want to dive deeper into the implementation.

phpstan.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
parameters:
2-
level: 3
2+
level: 4
33
paths:
44
- src/
55
ignoreErrors:

src/DiagnosticsProvider.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ public static function checkDiagnostics($node) {
5151
if ($node instanceof Node) {
5252
return $node->getDiagnosticForNode();
5353
}
54+
55+
/** @phpstan-ignore-next-line because it says "unreachable" statement */
5456
return null;
5557
}
5658

src/Node.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -437,10 +437,7 @@ public function getLastChild() {
437437
public function getDescendantNodeAtPosition(int $pos) {
438438
foreach ($this->getChildNodes() as $child) {
439439
if ($child->containsPosition($pos)) {
440-
$node = $child->getDescendantNodeAtPosition($pos);
441-
if (!is_null($node)) {
442-
return $node;
443-
}
440+
return $child->getDescendantNodeAtPosition($pos);
444441
}
445442
}
446443

@@ -590,6 +587,7 @@ public function getNamespaceDefinition() {
590587
? $this
591588
: $this->getFirstAncestor(NamespaceDefinition::class, SourceFileNode::class);
592589

590+
/** @phpstan-ignore-next-line result is always false -- not sure this can happen */
593591
if ($namespaceDefinition instanceof NamespaceDefinition && !($namespaceDefinition->parent instanceof SourceFileNode)) {
594592
$namespaceDefinition = $namespaceDefinition->getFirstAncestor(SourceFileNode::class);
595593
}

src/Node/Expression/ArgumentExpression.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
namespace Microsoft\PhpParser\Node\Expression;
88

9+
use Microsoft\PhpParser\MissingToken;
910
use Microsoft\PhpParser\Node\Expression;
1011
use Microsoft\PhpParser\Token;
1112

@@ -19,7 +20,7 @@ class ArgumentExpression extends Expression {
1920
/** @var Token|null */
2021
public $dotDotDotToken;
2122

22-
/** @var Expression|null null for first-class callable syntax */
23+
/** @var Expression|MissingToken|null for first-class callable syntax */
2324
public $expression;
2425

2526
const CHILD_NAMES = [

src/Node/InterfaceBaseClause.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use Microsoft\PhpParser\Token;
1111

1212
class InterfaceBaseClause extends Node {
13-
/** @var Token */
13+
/** @var Token|null */
1414
public $extendsKeyword;
1515

1616
/** @var DelimitedList\QualifiedNameList */

src/Node/NamespaceUseGroupClause.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
class NamespaceUseGroupClause extends Node {
1313

14-
/** @var Token */
14+
/** @var Token|null */
1515
public $functionOrConst;
1616
/** @var QualifiedName */
1717
public $namespaceName;

0 commit comments

Comments
 (0)