Skip to content

Commit 42f16e0

Browse files
authored
Merge pull request #13 from TysonAndre/sync-phan-changes
Synchronize this repo with Phan's changes and coding style
2 parents 530ee56 + 9269560 commit 42f16e0

16 files changed

+789
-423
lines changed

.phan/config.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use \Phan\Issue;
44

55
/**
6-
* This configuration will be read and overlayed on top of the
6+
* This configuration will be read and overlaid on top of the
77
* default configuration. Command line arguments will be applied
88
* after this file is read.
99
*

.travis.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@ php:
44
- 7.0
55
- 7.1
66
- 7.2
7+
- 7.3
8+
9+
dist: xenial
710

811
cache:
912
directories:
1013
- $HOME/.composer/cache
14+
- $HOME/.cache/phan-ast/build
1115

1216
before_install:
1317
- ./tests/setup.sh
@@ -18,7 +22,7 @@ install:
1822

1923
# Install phan separately because the tolerant-php-parser version may be behind.
2024
script:
21-
- composer create-project phan/phan=0.12.4 ~/phan-install; ~/phan-install/phan
25+
- composer create-project phan/phan=1.2.1 ~/phan-install; ~/phan-install/phan
2226
- ./test
2327

2428
branches:

composer.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818
},
1919
"require": {
2020
"php": ">=7.0",
21-
"Microsoft/tolerant-php-parser": "0.0.12"
21+
"Microsoft/tolerant-php-parser": "0.0.16"
2222
},
2323
"require-dev": {
2424
"phpunit/phpunit": "^6.4"
2525
},
2626
"suggest": {
27-
"ext-ast": "~0.1.5",
28-
"phan/phan": "^1.0.0"
27+
"ext-ast": "~0.1.5||~1.0.0",
28+
"phan/phan": "^1.2.1"
2929
},
3030
"autoload": {
3131
"psr-4": {"TolerantASTConverter\\": "src/TolerantASTConverter"}

composer.lock

+76-17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dump.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ function dump_expr(string $expr) {
7070
$ast_node = $parser->parseSourceFile($expr);
7171
foreach ($ast_node->getDescendantNodes() as $descendant) {
7272
// echo "unsetting " . get_class($descendant) . $descendant->getStart() . "\n";
73-
unset($descendant->parent);
73+
$descendant->parent = null;
7474
}
7575

7676
$ast_node->parent = null;

phpcs.xml

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?xml version="1.0"?>
2+
<!-- This is a ruleset for https://github.com/squizlabs/PHP_CodeSniffer -->
3+
<!-- Usage: phpcs.phar \-\-standard=path/toruleset.xml path/to/file_or_folder.php (Can't have double hyphen in xml comment) -->
4+
<!-- phpcbf.phar can be used to automatically fix many issues -->
5+
<!-- Use this with PHP_CodeSniffer 3.3.0 or newer -->
6+
<!-- Source: https://github.com/phan/phan/blob/master/phpcs.xml -->
7+
<ruleset name="Custom Standard">
8+
<description>Coding standard for Phan</description>
9+
<config name="installed_paths" value="../../slevomat/coding-standard"/>
10+
<rule ref="SlevomatCodingStandard.Classes.ModernClassNameReference" />
11+
<rule ref="SlevomatCodingStandard.Commenting.EmptyComment" />
12+
<!-- TODO: Enable
13+
<rule ref="SlevomatCodingStandard.ControlStructures.DisallowEmpty" />
14+
-->
15+
<rule ref="SlevomatCodingStandard.Namespaces.UseDoesNotStartWithBackslash" />
16+
<rule ref="SlevomatCodingStandard.Namespaces.UselessAlias" />
17+
<rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses">
18+
<properties>
19+
<property name="psr12Compatible" type="bool" value="true" />
20+
</properties>
21+
</rule>
22+
<rule ref="SlevomatCodingStandard.Operators.RequireCombinedAssignmentOperator" />
23+
<rule ref="SlevomatCodingStandard.PHP.TypeCast" />
24+
<rule ref="SlevomatCodingStandard.PHP.UselessSemicolon" />
25+
26+
<rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes" >
27+
<properties>
28+
<property name="spacesCountAroundEqualsSign" type="bool" value="false" />
29+
</properties>
30+
<exclude name="SlevomatCodingStandard.TypeHints.DeclareStrictTypes.IncorrectWhitespaceAfterDeclare" />
31+
<exclude name="SlevomatCodingStandard.TypeHints.DeclareStrictTypes.IncorrectWhitespaceBetweenOpenTagAndDeclare" />
32+
<exclude name="SlevomatCodingStandard.TypeHints.DeclareStrictTypes.IncorrectStrictTypesFormat" />
33+
</rule>
34+
<rule ref="SlevomatCodingStandard.TypeHints.LongTypeHints" />
35+
<!-- <rule ref="SlevomatCodingStandard.Namespaces.FullyQualifiedGlobalFunctions" /> doesn't account for 'use function...' statements, don't use that -->
36+
<!-- TODO: Look into SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing once PSR-12 is back into review -->
37+
38+
<!-- Look into SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingTraversableParameterTypeHintSpecification if it ever supports generic arrays+array shapes - Or just add this functionality to Phan's annotation plugin -->
39+
40+
<rule ref="PSR1" />
41+
<rule ref="PSR2">
42+
<exclude name="Generic.Files.LineLength.TooLong" />
43+
<!-- We put class initialization in the same file as methods -->
44+
<exclude name="PSR1.Files.SideEffects.FoundWithSymbols" />
45+
<exclude name="PSR1.Classes.ClassDeclaration.MultipleClasses" />
46+
</rule>
47+
48+
<rule ref="PSR12" />
49+
<!-- Arbitrary increase of the line length limit -->
50+
<rule ref="Generic.Files.LineLength">
51+
<properties>
52+
<property name="lineLimit" value="150"/>
53+
<property name="absoluteLineLimit" value="200"/>
54+
</properties>
55+
</rule>
56+
</ruleset>

src/TolerantASTConverter/Bootstrap.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55

66
// Add the root to the include path
77
define('CLASS_DIR', __DIR__ . '/../');
8-
set_include_path(get_include_path().PATH_SEPARATOR.CLASS_DIR);
8+
set_include_path(get_include_path() . PATH_SEPARATOR . CLASS_DIR);
99

1010
// Use the composer autoloader
1111
foreach ([
12-
__DIR__.'/../../vendor/autoload.php', // autoloader is in this project
13-
__DIR__.'/../../../../../vendor/autoload.php', // autoloader is in parent project
12+
__DIR__ . '/../../vendor/autoload.php', // autoloader is in this project
13+
__DIR__ . '/../../../../../vendor/autoload.php', // autoloader is in parent project
1414
] as $file) {
1515
if (file_exists($file)) {
1616
echo "Found the autoloader at $file\n";

src/TolerantASTConverter/StringUtil.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22

33
namespace TolerantASTConverter;
44

5+
use Error;
56
use function chr;
67
use function hexdec;
78
use function octdec;
89

9-
use Error;
10-
1110
/**
1211
* This class is based on code from https://github.com/nikic/PHP-Parser/blob/master/lib/PhpParser/Node/Scalar/String_.php
1312
*

0 commit comments

Comments
 (0)