Skip to content

Commit d844576

Browse files
committed
Update this project's tests, add an appveyor config
1 parent 56b8701 commit d844576

File tree

10 files changed

+242
-195
lines changed

10 files changed

+242
-195
lines changed

.phan/config.php

Lines changed: 69 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@
3939
// are treated as if they can cast to each other.
4040
'scalar_implicit_cast' => false,
4141

42+
// If this has entries, scalars (int, float, bool, string, null)
43+
// are allowed to perform the casts listed.
44+
// E.g. ['int' => ['float', 'string'], 'float' => ['int'], 'string' => ['int'], 'null' => ['string']]
45+
// allows casting null to a string, but not vice versa.
46+
// (subset of scalar_implicit_cast)
47+
'scalar_implicit_partial' => [],
48+
4249
// If true, seemingly undeclared variables in the global
4350
// scope will be ignored. This is useful for projects
4451
// with complicated cross-file globals that you have no
@@ -48,12 +55,55 @@
4855
// Backwards Compatibility Checking
4956
'backward_compatibility_checks' => false,
5057

58+
// If true, check to make sure the return type declared
59+
// in the doc-block (if any) matches the return type
60+
// declared in the method signature. This process is
61+
// slow.
62+
'check_docblock_signature_return_type_match' => true,
63+
64+
// If true, check to make sure the return type declared
65+
// in the doc-block (if any) matches the return type
66+
// declared in the method signature. This process is
67+
// slow.
68+
'check_docblock_signature_param_type_match' => true,
69+
70+
// (*Requires check_docblock_signature_param_type_match to be true*)
71+
// If true, make narrowed types from phpdoc params override
72+
// the real types from the signature, when real types exist.
73+
// (E.g. allows specifying desired lists of subclasses,
74+
// or to indicate a preference for non-nullable types over nullable types)
75+
// Affects analysis of the body of the method and the param types passed in by callers.
76+
'prefer_narrowed_phpdoc_param_type' => true,
77+
78+
// (*Requires check_docblock_signature_return_type_match to be true*)
79+
// If true, make narrowed types from phpdoc returns override
80+
// the real types from the signature, when real types exist.
81+
// (E.g. allows specifying desired lists of subclasses,
82+
// or to indicate a preference for non-nullable types over nullable types)
83+
// Affects analysis of return statements in the body of the method and the return types passed in by callers.
84+
'prefer_narrowed_phpdoc_return_type' => true,
85+
5186
// If enabled, check all methods that override a
5287
// parent method to make sure its signature is
5388
// compatible with the parent's. This check
5489
// can add quite a bit of time to the analysis.
90+
// This will also check if final methods are overridden, etc.
5591
'analyze_signature_compatibility' => true,
5692

93+
// This setting maps case insensitive strings to union types.
94+
// This is useful if a project uses phpdoc that differs from the phpdoc2 standard.
95+
// If the corresponding value is the empty string, Phan will ignore that union type (E.g. can ignore 'the' in `@return the value`)
96+
// If the corresponding value is not empty, Phan will act as though it saw the corresponding unionTypes(s) when the keys show up in a UnionType of @param, @return, @var, @property, etc.
97+
//
98+
// This matches the **entire string**, not parts of the string.
99+
// (E.g. `@return the|null` will still look for a class with the name `the`, but `@return the` will be ignored with the below setting)
100+
//
101+
// (These are not aliases, this setting is ignored outside of doc comments).
102+
// (Phan does not check if classes with these names exist)
103+
//
104+
// Example setting: ['unknown' => '', 'number' => 'int|float', 'char' => 'string', 'long' => 'int', 'the' => '']
105+
'phpdoc_type_mapping' => [ ],
106+
57107
// Set to true in order to attempt to detect dead
58108
// (unreferenced) code. Keep in mind that the
59109
// results will only be a guess given that classes,
@@ -71,22 +121,6 @@
71121
// class types.
72122
'generic_types_enabled' => true,
73123

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-
90124
// The minimum severity level to report on. This can be
91125
// set to Issue::SEVERITY_LOW, Issue::SEVERITY_NORMAL or
92126
// Issue::SEVERITY_CRITICAL.
@@ -102,98 +136,22 @@
102136
// If non-empty, only issues within the list will be emitted
103137
// by Phan.
104138
'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',
190139
],
191140

192141
// A list of files to include in analysis
193142
'file_list' => [
194143
// 'vendor/phpunit/phpunit/src/Framework/TestCase.php',
195144
],
196145

146+
// A regular expression to match files to be excluded
147+
// from parsing and analysis and will not be read at all.
148+
//
149+
// This is useful for excluding groups of test or example
150+
// directories/files, unanalyzable files, or files that
151+
// can't be removed for whatever reason.
152+
// (e.g. '@Test\.php$@', or '@vendor/.*/(tests|Tests)/@')
153+
'exclude_file_regex' => '@^vendor/.*/(tests|Tests)/@',
154+
197155
// A file list that defines files that will be excluded
198156
// from parsing and analysis and will not be read at all.
199157
//
@@ -229,19 +187,23 @@
229187
// should be added to the `directory_list` as
230188
// to `exclude_analysis_directory_list`.
231189
"exclude_analysis_directory_list" => [
232-
'vendor/nikic/php-parser/lib',
190+
'vendor',
233191
],
234192

193+
// By default, Phan will log error messages to stdout if PHP is using options that slow the analysis.
194+
// (e.g. PHP is compiled with --enable-debug or when using XDebug)
195+
'skip_slow_php_options_warning' => false,
196+
235197
// A list of plugin files to execute
236198
'plugins' => [
237199
// 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)
200+
'vendor/phan/phan/.phan/plugins/AlwaysReturnPlugin.php', // (TODO: make BlockExitStatus more reliable)
201+
'vendor/phan/phan/.phan/plugins/DollarDollarPlugin.php',
202+
'vendor/phan/phan/.phan/plugins/DuplicateArrayKeyPlugin.php',
203+
'vendor/phan/phan/.phan/plugins/UnreachableCodePlugin.php', // (TODO: make BlockExitStatus more reliable)
242204
// NOTE: This plugin only produces correct results when
243205
// Phan is run on a single core (-j1).
244-
// 'vendor/etsy/phan/.phan/plugins/UnusedSuppressionPlugin.php',
206+
// 'vendor/phan/phan/.phan/plugins/UnusedSuppressionPlugin.php',
245207
],
246208

247209
];

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ cache:
1010
- $HOME/.composer/cache
1111

1212
before_install:
13-
- ./tests/setup.sh
13+
- pecl install -f ast-0.1.6
14+
- phpenv config-rm xdebug.ini
1415
- composer validate
1516

1617
install:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PHP-Parser to php-ast
22
=====================
33

4-
[![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)
4+
[![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) [![Build status (Windows)](https://ci.appveyor.com/api/projects/status/41h7apxmvmkec1rj?svg=true)](https://ci.appveyor.com/project/TysonAndre/php-parser-to-php-ast)
55

66
This converts ASTs(Abstract Syntax Trees) from [PHP-Parser](https://github.com/nikic/PHP-Parser) to [php-ast](https://github.com/nikic/php-ast/).
77
It can be used as a PHP-only implementation of php-ast. It can alternatively be used as a best-effort parser for syntactically valid PHP code.

appveyor.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Based on igbinary and php-ast's appveyor config.
2+
# This tests against the latest stable minor version of PHP 7 (Currently 7.1)
3+
# The project name is the same as the build id used, e.g. https://www.appveyor.com/docs/environment-variables/
4+
5+
version: '{branch}.{build}'
6+
clone_folder: C:\projects\php-parser-to-php-ast
7+
# Don't include full git history
8+
clone_depth: 1
9+
# Test 32-bit builds
10+
platform: x86
11+
12+
branches:
13+
only:
14+
- master
15+
- 0.8
16+
- 0.9
17+
- php72
18+
19+
install:
20+
- cmd: choco feature enable -n=allowGlobalConfirmation
21+
- cmd: mkdir %APPVEYOR_BUILD_FOLDER%\bin
22+
build_script:
23+
- cmd: >-
24+
mkdir C:\projects\php
25+
26+
cd C:\projects\php
27+
28+
appveyor DownloadFile http://windows.php.net/downloads/releases/archives/php-7.1.9-nts-Win32-VC14-x86.zip
29+
30+
7z x -y php-7.1.9-nts-Win32-VC14-x86.zip
31+
32+
del /Q *.zip
33+
34+
cd C:\projects\php\ext
35+
36+
git clone --depth=1 --branch=master https://github.com/nikic/php-ast C:\projects\php-src\ext\ast
37+
38+
appveyor DownloadFile http://windows.php.net/downloads/pecl/releases/ast/0.1.6/php_ast-0.1.6-7.1-nts-vc14-x86.zip
39+
40+
7z x php_ast-0.1.6-7.1-nts-vc14-x86.zip php_ast.dll -y >nul
41+
42+
cd C:\projects\php
43+
44+
echo [PHP] > php.ini
45+
46+
echo extension_dir = "ext" >> php.ini
47+
48+
echo extension=php_ast.dll >> php.ini
49+
50+
echo extension=php_curl.dll >> php.ini
51+
52+
echo extension=php_intl.dll >> php.ini
53+
54+
echo extension=php_mbstring.dll >> php.ini
55+
56+
echo extension=php_openssl.dll >> php.ini
57+
58+
echo extension=php_soap.dll >> php.ini
59+
60+
SET PATH=c:\projects\php;%PATH%
61+
62+
echo %PATH%
63+
64+
php -v
65+
66+
php -m
67+
68+
cd C:\projects\php-parser-to-php-ast
69+
70+
appveyor DownloadFile https://getcomposer.org/composer.phar
71+
72+
test_script:
73+
- cmd: cd C:\projects\php-parser-to-php-ast
74+
- cmd: php composer.phar install
75+
# Analyze the project with phan, will error if 1 or more issues are detected
76+
- cmd: .\vendor\bin\phan
77+
# Run the remaining tests of this project
78+
- cmd: .\vendor\bin\phpunit --verbose

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
},
1616
"require-dev": {
1717
"phpunit/phpunit": "^5.7",
18-
"etsy/phan": "~0.9.4"
18+
"phan/phan": "~0.10.0"
1919
},
2020
"suggest": {
2121
"ext-ast": "~0.1.5"

0 commit comments

Comments
 (0)