Skip to content

Commit daa503d

Browse files
committed
Add example .phan config
1 parent 2c91523 commit daa503d

File tree

2 files changed

+248
-4
lines changed

2 files changed

+248
-4
lines changed

.phan/config.php

Lines changed: 238 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,238 @@
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+
// The minimum severity level to report on. This can be
75+
// set to Issue::SEVERITY_LOW, Issue::SEVERITY_NORMAL or
76+
// Issue::SEVERITY_CRITICAL.
77+
'minimum_severity' => Issue::SEVERITY_LOW,
78+
79+
// Add any issue types (such as 'PhanUndeclaredMethod')
80+
// here to inhibit them from being reported
81+
'suppress_issue_types' => [
82+
// 'PhanUndeclaredMethod',
83+
// 'PhanTypeMismatchProperty',
84+
// 'PhanUndeclaredProperty'
85+
],
86+
87+
// If empty, no filter against issues types will be applied.
88+
// If non-empty, only issues within the list will be emitted
89+
// by Phan.
90+
'whitelist_issue_types' => [
91+
// 'PhanAccessMethodPrivate',
92+
// 'PhanAccessMethodProtected',
93+
// 'PhanAccessNonStaticToStatic',
94+
// 'PhanAccessPropertyPrivate',
95+
// 'PhanAccessPropertyProtected',
96+
// 'PhanAccessSignatureMismatch',
97+
// 'PhanAccessSignatureMismatchInternal',
98+
// 'PhanAccessStaticToNonStatic',
99+
// 'PhanCompatibleExpressionPHP7',
100+
// 'PhanCompatiblePHP7',
101+
// 'PhanContextNotObject',
102+
// 'PhanDeprecatedClass',
103+
// 'PhanDeprecatedFunction',
104+
// 'PhanDeprecatedProperty',
105+
// 'PhanEmptyFile',
106+
// 'PhanNonClassMethodCall',
107+
// 'PhanNoopArray',
108+
// 'PhanNoopClosure',
109+
// 'PhanNoopConstant',
110+
// 'PhanNoopProperty',
111+
// 'PhanNoopVariable',
112+
// 'PhanParamRedefined',
113+
// 'PhanParamReqAfterOpt',
114+
// 'PhanParamSignatureMismatch',
115+
// 'PhanParamSignatureMismatchInternal',
116+
// 'PhanParamSpecial1',
117+
// 'PhanParamSpecial2',
118+
// 'PhanParamSpecial3',
119+
// 'PhanParamSpecial4',
120+
// 'PhanParamTooFew',
121+
// 'PhanParamTooFewInternal',
122+
// 'PhanParamTooMany',
123+
// 'PhanParamTooManyInternal',
124+
// 'PhanParamTypeMismatch',
125+
// 'PhanParentlessClass',
126+
// 'PhanRedefineClass',
127+
// 'PhanRedefineClassInternal',
128+
// 'PhanRedefineFunction',
129+
// 'PhanRedefineFunctionInternal',
130+
// 'PhanStaticCallToNonStatic',
131+
// 'PhanSyntaxError',
132+
// 'PhanTraitParentReference',
133+
// 'PhanTypeArrayOperator',
134+
// 'PhanTypeArraySuspicious',
135+
// 'PhanTypeComparisonFromArray',
136+
// 'PhanTypeComparisonToArray',
137+
// 'PhanTypeConversionFromArray',
138+
// 'PhanTypeInstantiateAbstract',
139+
// 'PhanTypeInstantiateInterface',
140+
// 'PhanTypeInvalidLeftOperand',
141+
// 'PhanTypeInvalidRightOperand',
142+
// 'PhanTypeMismatchArgument',
143+
// 'PhanTypeMismatchArgumentInternal',
144+
// 'PhanTypeMismatchDefault',
145+
// 'PhanTypeMismatchForeach',
146+
// 'PhanTypeMismatchProperty',
147+
// 'PhanTypeMismatchReturn',
148+
// 'PhanTypeMissingReturn',
149+
// 'PhanTypeNonVarPassByRef',
150+
// 'PhanTypeParentConstructorCalled',
151+
// 'PhanTypeVoidAssignment',
152+
// 'PhanUnanalyzable',
153+
// 'PhanUndeclaredClass',
154+
// 'PhanUndeclaredClassCatch',
155+
// 'PhanUndeclaredClassConstant',
156+
// 'PhanUndeclaredClassInstanceof',
157+
// 'PhanUndeclaredClassMethod',
158+
// 'PhanUndeclaredClassReference',
159+
// 'PhanUndeclaredConstant',
160+
// 'PhanUndeclaredExtendedClass',
161+
// 'PhanUndeclaredFunction',
162+
// 'PhanUndeclaredInterface',
163+
// 'PhanUndeclaredMethod',
164+
// 'PhanUndeclaredProperty',
165+
// 'PhanUndeclaredStaticMethod',
166+
// 'PhanUndeclaredStaticProperty',
167+
// 'PhanUndeclaredTrait',
168+
// 'PhanUndeclaredTypeParameter',
169+
// 'PhanUndeclaredTypeProperty',
170+
// 'PhanUndeclaredVariable',
171+
// 'PhanUnreferencedClass',
172+
// 'PhanUnreferencedConstant',
173+
// 'PhanUnreferencedMethod',
174+
// 'PhanUnreferencedProperty',
175+
// 'PhanVariableUseClause',
176+
],
177+
178+
// A list of files to include in analysis
179+
'file_list' => [
180+
// 'vendor/phpunit/phpunit/src/Framework/TestCase.php',
181+
],
182+
183+
// A file list that defines files that will be excluded
184+
// from parsing and analysis and will not be read at all.
185+
//
186+
// This is useful for excluding hopelessly unanalyzable
187+
// files that can't be removed for whatever reason.
188+
'exclude_file_list' => [
189+
],
190+
191+
// The number of processes to fork off during the analysis
192+
// phase.
193+
'processes' => 1,
194+
195+
// A list of directories that should be parsed for class and
196+
// method information. After excluding the directories
197+
// defined in exclude_analysis_directory_list, the remaining
198+
// files will be statically analyzed for errors.
199+
//
200+
// Thus, both first-party and third-party code being used by
201+
// your application should be included in this list.
202+
'directory_list' => [
203+
'src',
204+
],
205+
206+
// List of case-insensitive file extensions supported by Phan.
207+
// (e.g. php, html, htm)
208+
'analyzed_file_extensions' => ['php'],
209+
210+
// A directory list that defines files that will be excluded
211+
// from static analysis, but whose class and method
212+
// information should be included.
213+
//
214+
// Generally, you'll want to include the directories for
215+
// third-party code (such as "vendor/") in this list.
216+
//
217+
// n.b.: If you'd like to parse but not analyze 3rd
218+
// party code, directories containing that code
219+
// should be added to the `directory_list` as
220+
// to `exclude_analysis_directory_list`.
221+
"exclude_analysis_directory_list" => [
222+
// 'src/custom',
223+
],
224+
225+
// A list of plugin files to execute
226+
'plugins' => [
227+
'vendor/etsy/phan/.phan/plugins/AlwaysReturnPlugin.php',
228+
'vendor/etsy/phan/.phan/plugins/DollarDollarPlugin.php',
229+
'vendor/etsy/phan/.phan/plugins/DuplicateArrayKeyPlugin.php',
230+
// NOTE: src/Phan/Language/Internal/FunctionSignatureMap.php mixes value without key as return type with values having keys deliberately.
231+
// '.phan/plugins/DuplicateArrayKeyPlugin.php',
232+
233+
// NOTE: This plugin only produces correct results when
234+
// Phan is run on a single core (-j1).
235+
// '.phan/plugins/UnusedSuppressionPlugin.php',
236+
],
237+
238+
];

.travis.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,18 @@ php:
55
- 7.1
66

77
env:
8-
- VALIDATION=false
9-
- VALIDATION=true
8+
- TYPE=UNIT_TEST
9+
- TYPE=VALIDATION
10+
- TYPE=STATIC_ANALYSIS
1011

1112
os:
1213
- linux
1314

1415
matrix:
1516
fast_finish: true
1617
allow_failures:
17-
- env: VALIDATION=true
18+
- env: TYPE=VALIDATION
19+
- env: TYPE=STATIC_ANALYSIS
1820

1921
cache:
2022
directories:
@@ -30,8 +32,12 @@ before_script:
3032
script:
3133
- composer validate
3234
- |
33-
if [[ $VALIDATION = true ]]; then
35+
if [[ $TYPE = VALIDATION ]]; then
3436
./vendor/bin/phpunit --testsuite validation
37+
elif [[ $TYPE = STATIC_ANALYSIS ]]; then
38+
pecl install -f ast-0.1.5
39+
composer require --dev etsy/phan=0.8.6
40+
vendor/etsy/phan/phan --color
3541
else
3642
./vendor/bin/phpunit --testsuite invariants
3743
./vendor/bin/phpunit --testsuite grammar

0 commit comments

Comments
 (0)