Skip to content

Commit d747a33

Browse files
authored
Merge pull request #13 from TysonAndre/support-50
Support and test AST version 50
2 parents 5c65130 + 6f33d01 commit d747a33

13 files changed

+869
-273
lines changed

.phan/config.php

Lines changed: 247 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,247 @@
1+
<?php
2+
3+
use \Phan\Issue;
4+
5+
/**
6+
* This configuration will be read and overlayed on top of the
7+
* default configuration. Command line arguments will be applied
8+
* after this file is read.
9+
*
10+
* @see src/Phan/Config.php
11+
* See Config for all configurable options.
12+
*
13+
* A Note About Paths
14+
* ==================
15+
*
16+
* Files referenced from this file should be defined as
17+
*
18+
* ```
19+
* Config::projectPath('relative_path/to/file')
20+
* ```
21+
*
22+
* where the relative path is relative to the root of the
23+
* project which is defined as either the working directory
24+
* of the phan executable or a path passed in via the CLI
25+
* '-d' flag.
26+
*/
27+
return [
28+
29+
// If true, missing properties will be created when
30+
// they are first seen. If false, we'll report an
31+
// error message.
32+
"allow_missing_properties" => false,
33+
34+
// Allow null to be cast as any type and for any
35+
// type to be cast to null.
36+
"null_casts_as_any_type" => false,
37+
38+
// If enabled, scalars (int, float, bool, string, null)
39+
// are treated as if they can cast to each other.
40+
'scalar_implicit_cast' => false,
41+
42+
// If true, seemingly undeclared variables in the global
43+
// scope will be ignored. This is useful for projects
44+
// with complicated cross-file globals that you have no
45+
// hope of fixing.
46+
'ignore_undeclared_variables_in_global_scope' => false,
47+
48+
// Backwards Compatibility Checking
49+
'backward_compatibility_checks' => false,
50+
51+
// If enabled, check all methods that override a
52+
// parent method to make sure its signature is
53+
// compatible with the parent's. This check
54+
// can add quite a bit of time to the analysis.
55+
'analyze_signature_compatibility' => true,
56+
57+
// Set to true in order to attempt to detect dead
58+
// (unreferenced) code. Keep in mind that the
59+
// results will only be a guess given that classes,
60+
// properties, constants and methods can be referenced
61+
// as variables (like `$class->$property` or
62+
// `$class->$method()`) in ways that we're unable
63+
// to make sense of.
64+
'dead_code_detection' => false,
65+
66+
// Run a quick version of checks that takes less
67+
// time
68+
"quick_mode" => false,
69+
70+
// Enable or disable support for generic templated
71+
// class types.
72+
'generic_types_enabled' => true,
73+
74+
// By default, Phan will not analyze all node types
75+
// in order to save time. If this config is set to true,
76+
// Phan will dig deeper into the AST tree and do an
77+
// analysis on all nodes, possibly finding more issues.
78+
//
79+
// See \Phan\Analysis::shouldVisit for the set of skipped
80+
// nodes.
81+
'should_visit_all_nodes' => true,
82+
83+
'runkit_superglobals' => ['_DATE', '_RK'],
84+
85+
'globals_type_map' => [
86+
'_DATE' => '\\DateTime',
87+
'_RK' => '\\RunkitGlobal',
88+
],
89+
90+
// The minimum severity level to report on. This can be
91+
// set to Issue::SEVERITY_LOW, Issue::SEVERITY_NORMAL or
92+
// Issue::SEVERITY_CRITICAL.
93+
'minimum_severity' => Issue::SEVERITY_LOW,
94+
95+
// Add any issue types (such as 'PhanUndeclaredMethod')
96+
// here to inhibit them from being reported
97+
'suppress_issue_types' => [
98+
// 'PhanUndeclaredMethod',
99+
],
100+
101+
// If empty, no filter against issues types will be applied.
102+
// If non-empty, only issues within the list will be emitted
103+
// by Phan.
104+
'whitelist_issue_types' => [
105+
// 'PhanAccessMethodPrivate',
106+
// 'PhanAccessMethodProtected',
107+
// 'PhanAccessNonStaticToStatic',
108+
// 'PhanAccessPropertyPrivate',
109+
// 'PhanAccessPropertyProtected',
110+
// 'PhanAccessSignatureMismatch',
111+
// 'PhanAccessSignatureMismatchInternal',
112+
// 'PhanAccessStaticToNonStatic',
113+
// 'PhanCompatibleExpressionPHP7',
114+
// 'PhanCompatiblePHP7',
115+
// 'PhanContextNotObject',
116+
// 'PhanDeprecatedClass',
117+
// 'PhanDeprecatedFunction',
118+
// 'PhanDeprecatedProperty',
119+
// 'PhanEmptyFile',
120+
// 'PhanNonClassMethodCall',
121+
// 'PhanNoopArray',
122+
// 'PhanNoopClosure',
123+
// 'PhanNoopConstant',
124+
// 'PhanNoopProperty',
125+
// 'PhanNoopVariable',
126+
// 'PhanParamRedefined',
127+
// 'PhanParamReqAfterOpt',
128+
// 'PhanParamSignatureMismatch',
129+
// 'PhanParamSignatureMismatchInternal',
130+
// 'PhanParamSpecial1',
131+
// 'PhanParamSpecial2',
132+
// 'PhanParamSpecial3',
133+
// 'PhanParamSpecial4',
134+
// 'PhanParamTooFew',
135+
// 'PhanParamTooFewInternal',
136+
// 'PhanParamTooMany',
137+
// 'PhanParamTooManyInternal',
138+
// 'PhanParamTypeMismatch',
139+
// 'PhanParentlessClass',
140+
// 'PhanRedefineClass',
141+
// 'PhanRedefineClassInternal',
142+
// 'PhanRedefineFunction',
143+
// 'PhanRedefineFunctionInternal',
144+
// 'PhanStaticCallToNonStatic',
145+
// 'PhanSyntaxError',
146+
// 'PhanTraitParentReference',
147+
// 'PhanTypeArrayOperator',
148+
// 'PhanTypeArraySuspicious',
149+
// 'PhanTypeComparisonFromArray',
150+
// 'PhanTypeComparisonToArray',
151+
// 'PhanTypeConversionFromArray',
152+
// 'PhanTypeInstantiateAbstract',
153+
// 'PhanTypeInstantiateInterface',
154+
// 'PhanTypeInvalidLeftOperand',
155+
// 'PhanTypeInvalidRightOperand',
156+
// 'PhanTypeMismatchArgument',
157+
// 'PhanTypeMismatchArgumentInternal',
158+
// 'PhanTypeMismatchDefault',
159+
// 'PhanTypeMismatchForeach',
160+
// 'PhanTypeMismatchProperty',
161+
// 'PhanTypeMismatchReturn',
162+
// 'PhanTypeMissingReturn',
163+
// 'PhanTypeNonVarPassByRef',
164+
// 'PhanTypeParentConstructorCalled',
165+
// 'PhanTypeVoidAssignment',
166+
// 'PhanUnanalyzable',
167+
// 'PhanUndeclaredClass',
168+
// 'PhanUndeclaredClassCatch',
169+
// 'PhanUndeclaredClassConstant',
170+
// 'PhanUndeclaredClassInstanceof',
171+
// 'PhanUndeclaredClassMethod',
172+
// 'PhanUndeclaredClassReference',
173+
// 'PhanUndeclaredConstant',
174+
// 'PhanUndeclaredExtendedClass',
175+
// 'PhanUndeclaredFunction',
176+
// 'PhanUndeclaredInterface',
177+
// 'PhanUndeclaredMethod',
178+
// 'PhanUndeclaredProperty',
179+
// 'PhanUndeclaredStaticMethod',
180+
// 'PhanUndeclaredStaticProperty',
181+
// 'PhanUndeclaredTrait',
182+
// 'PhanUndeclaredTypeParameter',
183+
// 'PhanUndeclaredTypeProperty',
184+
// 'PhanUndeclaredVariable',
185+
// 'PhanUnreferencedClass',
186+
// 'PhanUnreferencedConstant',
187+
// 'PhanUnreferencedMethod',
188+
// 'PhanUnreferencedProperty',
189+
// 'PhanVariableUseClause',
190+
],
191+
192+
// A list of files to include in analysis
193+
'file_list' => [
194+
// 'vendor/phpunit/phpunit/src/Framework/TestCase.php',
195+
],
196+
197+
// A file list that defines files that will be excluded
198+
// from parsing and analysis and will not be read at all.
199+
//
200+
// This is useful for excluding hopelessly unanalyzable
201+
// files that can't be removed for whatever reason.
202+
'exclude_file_list' => [],
203+
204+
// The number of processes to fork off during the analysis
205+
// phase.
206+
'processes' => 1,
207+
208+
// A list of directories that should be parsed for class and
209+
// method information. After excluding the directories
210+
// defined in exclude_analysis_directory_list, the remaining
211+
// files will be statically analyzed for errors.
212+
//
213+
// Thus, both first-party and third-party code being used by
214+
// your application should be included in this list.
215+
'directory_list' => [
216+
'src',
217+
'vendor/nikic/php-parser/lib',
218+
],
219+
220+
// A directory list that defines files that will be excluded
221+
// from static analysis, but whose class and method
222+
// information should be included.
223+
//
224+
// Generally, you'll want to include the directories for
225+
// third-party code (such as "vendor/") in this list.
226+
//
227+
// n.b.: If you'd like to parse but not analyze 3rd
228+
// party code, directories containing that code
229+
// should be added to the `directory_list` as
230+
// to `exclude_analysis_directory_list`.
231+
"exclude_analysis_directory_list" => [
232+
'vendor/nikic/php-parser/lib',
233+
],
234+
235+
// A list of plugin files to execute
236+
'plugins' => [
237+
// NOTE: src/Phan/Language/Internal/FunctionSignatureMap.php mixes value without key as return type with values having keys deliberately.
238+
'vendor/etsy/phan/.phan/plugins/AlwaysReturnPlugin.php', // (TODO: make BlockExitStatus more reliable)
239+
'vendor/etsy/phan/.phan/plugins/DollarDollarPlugin.php',
240+
'vendor/etsy/phan/.phan/plugins/DuplicateArrayKeyPlugin.php',
241+
'vendor/etsy/phan/.phan/plugins/UnreachableCodePlugin.php', // (TODO: make BlockExitStatus more reliable)
242+
// NOTE: This plugin only produces correct results when
243+
// Phan is run on a single core (-j1).
244+
// '.phan/plugins/UnusedSuppressionPlugin.php',
245+
],
246+
247+
];

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ install:
1515
- composer --prefer-dist install
1616

1717
script:
18+
- vendor/bin/phan
1819
- ./test

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@ PHP-Parser to php-ast
33

44
[![Build Status](https://travis-ci.org/TysonAndre/php-parser-to-php-ast.svg?branch=master)](https://travis-ci.org/TysonAndre/php-parser-to-php-ast)
55

6+
This converts ASTs(Abstract Syntax Trees) from [PHP-Parser](https://github.com/nikic/PHP-Parser) to [php-ast](https://github.com/nikic/php-ast/).
7+
It can be used as a PHP-only implementation of php-ast.
8+
9+
Supported [php-ast AST versions](https://github.com/nikic/php-ast#version-changelog): 40, 50
10+
11+
Current Status
12+
--------------
13+
614
No tests are failing
715

816
- This is 90% done
@@ -31,7 +39,7 @@ Using it as an error-tolerant substitute for php-ast (e.g. for use in IDEs)
3139
Running unit tests
3240
------------------
3341

34-
To run unit tests, you must install [nikic/php-ast](https://github.com/nikic/php-ast)
42+
To run unit tests, you must install [nikic/php-ast](https://github.com/nikic/php-ast). A version supporting AST versions 40 and/or 50 should be installed (`~0.1.5` is preferred)
3543

3644
- Then run `vendor/bin/phpunit`
3745

composer.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
{
2-
"name": "tysonandre/php-parser",
3-
"description": "A php-parser to php-ast converter written in php",
2+
"name": "tysonandre/php-parser-to-php-ast",
3+
"description": "A php-parser to php-ast converter written in php. Can be used to test out projects using php-ast without compiling php-ast.",
44
"require": {
55
"php": ">=7.1",
6-
"nikic/PHP-Parser": "3.0.5"
6+
"nikic/PHP-Parser": "~3.1.0"
77
},
88
"require-dev": {
9-
"phpunit/phpunit": "^5.7"
9+
"phpunit/phpunit": "^5.7",
10+
"etsy/phan": "~0.9.4"
1011
},
1112
"suggest": {
12-
"ext-ast": "~0.1.4"
13+
"ext-ast": "~0.1.5"
1314
},
1415
"autoload": {
1516
"psr-4": {"ASTConverter\\": "src/ASTConverter"}

0 commit comments

Comments
 (0)