Skip to content

Commit a3a2ff3

Browse files
committed
+ param $errorCode and its value in providers @ testValidate()
* fix test throwing error code `40001` before throwing the expecting `40004` @ `validate40004Provider()` * merge method `testAddDefaultParamsThenValidate()` into `testValidate()` @ `Tests\Feature\App\Http\PostsQuery \ParamsValidatorTest` * simplify `if` with null coalescing `??` @ `App\Exceptions\Handler->convertValidationExceptionToResponse()` * including `thecodingmachine/phpstan-safe-rule` @ phpstan.neon $ ./vendor/bin/phan --init --init-level=1 @ be
1 parent 5efbd64 commit a3a2ff3

File tree

4 files changed

+410
-29
lines changed

4 files changed

+410
-29
lines changed

be/.phan/config.php

Lines changed: 388 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,388 @@
1+
<?php
2+
3+
use Phan\Issue;
4+
5+
/**
6+
* This configuration file was automatically generated by 'phan --init --init-level=1'
7+
*
8+
* TODOs (added by 'phan --init'):
9+
*
10+
* - Go through this file and verify that there are no missing/unnecessary files/directories.
11+
* (E.g. this only includes direct composer dependencies - You may have to manually add indirect composer dependencies to 'directory_list')
12+
* - Look at 'plugins' and add or remove plugins if appropriate (see https://github.com/phan/phan/tree/v5/.phan/plugins#plugins)
13+
* - Add global suppressions for pre-existing issues to suppress_issue_types (https://github.com/phan/phan/wiki/Tutorial-for-Analyzing-a-Large-Sloppy-Code-Base)
14+
* - Consider setting up a baseline if there are a large number of pre-existing issues (see `phan --extended-help`)
15+
*
16+
* This configuration will be read and overlaid on top of the
17+
* default configuration. Command line arguments will be applied
18+
* after this file is read.
19+
*
20+
* @see https://github.com/phan/phan/wiki/Phan-Config-Settings for all configurable options
21+
* @see https://github.com/phan/phan/tree/v5/src/Phan/Config.php
22+
*
23+
* A Note About Paths
24+
* ==================
25+
*
26+
* Files referenced from this file should be defined as
27+
*
28+
* ```
29+
* Config::projectPath('relative_path/to/file')
30+
* ```
31+
*
32+
* where the relative path is relative to the root of the
33+
* project which is defined as either the working directory
34+
* of the phan executable or a path passed in via the CLI
35+
* '-d' flag.
36+
*/
37+
return [
38+
39+
// The PHP version that the codebase will be checked for compatibility against.
40+
// For best results, the PHP binary used to run Phan should have the same PHP version.
41+
// (Phan relies on Reflection for some types, param counts,
42+
// and checks for undefined classes/methods/functions)
43+
//
44+
// Supported values: `'5.6'`, `'7.0'`, `'7.1'`, `'7.2'`, `'7.3'`, `'7.4'`,
45+
// `'8.0'`, `'8.1'`, `'8.2'`, `'8.3'`, `null`.
46+
// If this is set to `null`,
47+
// then Phan assumes the PHP version which is closest to the minor version
48+
// of the php executable used to execute Phan.
49+
//
50+
// Note that the **only** effect of choosing `'5.6'` is to infer that functions removed in php 7.0 exist.
51+
// (See `backward_compatibility_checks` for additional options)
52+
// Automatically inferred from composer.json requirement for "php" of "^8.3"
53+
'target_php_version' => '8.1',
54+
55+
// If enabled, missing properties will be created when
56+
// they are first seen. If false, we'll report an
57+
// error message if there is an attempt to write
58+
// to a class property that wasn't explicitly
59+
// defined.
60+
'allow_missing_properties' => false,
61+
62+
// If enabled, null can be cast to any type and any
63+
// type can be cast to null. Setting this to true
64+
// will cut down on false positives.
65+
'null_casts_as_any_type' => false,
66+
67+
// If enabled, allow null to be cast as any array-like type.
68+
//
69+
// This is an incremental step in migrating away from `null_casts_as_any_type`.
70+
// If `null_casts_as_any_type` is true, this has no effect.
71+
'null_casts_as_array' => false,
72+
73+
// If enabled, allow any array-like type to be cast to null.
74+
// This is an incremental step in migrating away from `null_casts_as_any_type`.
75+
// If `null_casts_as_any_type` is true, this has no effect.
76+
'array_casts_as_null' => false,
77+
78+
// If enabled, scalars (int, float, bool, string, null)
79+
// are treated as if they can cast to each other.
80+
// This does not affect checks of array keys. See `scalar_array_key_cast`.
81+
'scalar_implicit_cast' => false,
82+
83+
// If enabled, any scalar array keys (int, string)
84+
// are treated as if they can cast to each other.
85+
// E.g. `array<int,stdClass>` can cast to `array<string,stdClass>` and vice versa.
86+
// Normally, a scalar type such as int could only cast to/from int and mixed.
87+
'scalar_array_key_cast' => false,
88+
89+
// If this has entries, scalars (int, float, bool, string, null)
90+
// are allowed to perform the casts listed.
91+
//
92+
// E.g. `['int' => ['float', 'string'], 'float' => ['int'], 'string' => ['int'], 'null' => ['string']]`
93+
// allows casting null to a string, but not vice versa.
94+
// (subset of `scalar_implicit_cast`)
95+
'scalar_implicit_partial' => [],
96+
97+
// If enabled, Phan will warn if **any** type in a method invocation's object
98+
// is definitely not an object,
99+
// or if **any** type in an invoked expression is not a callable.
100+
// Setting this to true will introduce numerous false positives
101+
// (and reveal some bugs).
102+
'strict_method_checking' => true,
103+
104+
// If enabled, Phan will warn if **any** type of the object expression for a property access
105+
// does not contain that property.
106+
'strict_object_checking' => true,
107+
108+
// If enabled, Phan will warn if **any** type in the argument's union type
109+
// cannot be cast to a type in the parameter's expected union type.
110+
// Setting this to true will introduce numerous false positives
111+
// (and reveal some bugs).
112+
'strict_param_checking' => true,
113+
114+
// If enabled, Phan will warn if **any** type in a property assignment's union type
115+
// cannot be cast to a type in the property's declared union type.
116+
// Setting this to true will introduce numerous false positives
117+
// (and reveal some bugs).
118+
'strict_property_checking' => true,
119+
120+
// If enabled, Phan will warn if **any** type in a returned value's union type
121+
// cannot be cast to the declared return type.
122+
// Setting this to true will introduce numerous false positives
123+
// (and reveal some bugs).
124+
'strict_return_checking' => true,
125+
126+
// If true, seemingly undeclared variables in the global
127+
// scope will be ignored.
128+
//
129+
// This is useful for projects with complicated cross-file
130+
// globals that you have no hope of fixing.
131+
'ignore_undeclared_variables_in_global_scope' => false,
132+
133+
// Set this to false to emit `PhanUndeclaredFunction` issues for internal functions that Phan has signatures for,
134+
// but aren't available in the codebase, or from Reflection.
135+
// (may lead to false positives if an extension isn't loaded)
136+
//
137+
// If this is true(default), then Phan will not warn.
138+
//
139+
// Even when this is false, Phan will still infer return values and check parameters of internal functions
140+
// if Phan has the signatures.
141+
'ignore_undeclared_functions_with_known_signatures' => false,
142+
143+
// Backwards Compatibility Checking. This is slow
144+
// and expensive, but you should consider running
145+
// it before upgrading your version of PHP to a
146+
// new version that has backward compatibility
147+
// breaks.
148+
//
149+
// If you are migrating from PHP 5 to PHP 7,
150+
// you should also look into using
151+
// [php7cc (no longer maintained)](https://github.com/sstalle/php7cc)
152+
// and [php7mar](https://github.com/Alexia/php7mar),
153+
// which have different backwards compatibility checks.
154+
//
155+
// If you are still using versions of php older than 5.6,
156+
// `PHP53CompatibilityPlugin` may be worth looking into if you are not running
157+
// syntax checks for php 5.3 through another method such as
158+
// `InvokePHPNativeSyntaxCheckPlugin` (see .phan/plugins/README.md).
159+
'backward_compatibility_checks' => false,
160+
161+
// If true, check to make sure the return type declared
162+
// in the doc-block (if any) matches the return type
163+
// declared in the method signature.
164+
'check_docblock_signature_return_type_match' => true,
165+
166+
// This setting maps case-insensitive strings to union types.
167+
//
168+
// This is useful if a project uses phpdoc that differs from the phpdoc2 standard.
169+
//
170+
// If the corresponding value is the empty string,
171+
// then Phan will ignore that union type (E.g. can ignore 'the' in `@return the value`)
172+
//
173+
// If the corresponding value is not empty,
174+
// then Phan will act as though it saw the corresponding UnionTypes(s)
175+
// when the keys show up in a UnionType of `@param`, `@return`, `@var`, `@property`, etc.
176+
//
177+
// This matches the **entire string**, not parts of the string.
178+
// (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)
179+
//
180+
// (These are not aliases, this setting is ignored outside of doc comments).
181+
// (Phan does not check if classes with these names exist)
182+
//
183+
// Example setting: `['unknown' => '', 'number' => 'int|float', 'char' => 'string', 'long' => 'int', 'the' => '']`
184+
'phpdoc_type_mapping' => [],
185+
186+
// Set to true in order to attempt to detect dead
187+
// (unreferenced) code. Keep in mind that the
188+
// results will only be a guess given that classes,
189+
// properties, constants and methods can be referenced
190+
// as variables (like `$class->$property` or
191+
// `$class->$method()`) in ways that we're unable
192+
// to make sense of.
193+
//
194+
// To more aggressively detect dead code,
195+
// you may want to set `dead_code_detection_prefer_false_negative` to `false`.
196+
'dead_code_detection' => false,
197+
198+
// Set to true in order to attempt to detect unused variables.
199+
// `dead_code_detection` will also enable unused variable detection.
200+
//
201+
// This has a few known false positives, e.g. for loops or branches.
202+
'unused_variable_detection' => true,
203+
204+
// Set to true in order to attempt to detect redundant and impossible conditions.
205+
//
206+
// This has some false positives involving loops,
207+
// variables set in branches of loops, and global variables.
208+
'redundant_condition_detection' => true,
209+
210+
// If enabled, Phan will act as though it's certain of real return types of a subset of internal functions,
211+
// even if those return types aren't available in reflection (real types were taken from php 7.3 or 8.0-dev, depending on target_php_version).
212+
//
213+
// Note that with php 7 and earlier, php would return null or false for many internal functions if the argument types or counts were incorrect.
214+
// As a result, enabling this setting with target_php_version 8.0 may result in false positives for `--redundant-condition-detection` when codebases also support php 7.x.
215+
'assume_real_types_for_internal_functions' => true,
216+
217+
// If true, this runs a quick version of checks that takes less
218+
// time at the cost of not running as thorough
219+
// of an analysis. You should consider setting this
220+
// to true only when you wish you had more **undiagnosed** issues
221+
// to fix in your code base.
222+
//
223+
// In quick-mode the scanner doesn't rescan a function
224+
// or a method's code block every time a call is seen.
225+
// This means that the problem here won't be detected:
226+
//
227+
// ```php
228+
// <?php
229+
// function test($arg):int {
230+
// return $arg;
231+
// }
232+
// test("abc");
233+
// ```
234+
//
235+
// This would normally generate:
236+
//
237+
// ```
238+
// test.php:3 PhanTypeMismatchReturn Returning type string but test() is declared to return int
239+
// ```
240+
//
241+
// The initial scan of the function's code block has no
242+
// type information for `$arg`. It isn't until we see
243+
// the call and rescan `test()`'s code block that we can
244+
// detect that it is actually returning the passed in
245+
// `string` instead of an `int` as declared.
246+
'quick_mode' => false,
247+
248+
// Override to hardcode existence and types of (non-builtin) globals in the global scope.
249+
// Class names should be prefixed with `\`.
250+
//
251+
// (E.g. `['_FOO' => '\FooClass', 'page' => '\PageClass', 'userId' => 'int']`)
252+
'globals_type_map' => [],
253+
254+
// The minimum severity level to report on. This can be
255+
// set to `Issue::SEVERITY_LOW`, `Issue::SEVERITY_NORMAL` or
256+
// `Issue::SEVERITY_CRITICAL`. Setting it to only
257+
// critical issues is a good place to start on a big
258+
// sloppy mature code base.
259+
'minimum_severity' => Issue::SEVERITY_LOW,
260+
261+
// Add any issue types (such as `'PhanUndeclaredMethod'`)
262+
// to this list to inhibit them from being reported.
263+
'suppress_issue_types' => [],
264+
265+
// A regular expression to match files to be excluded
266+
// from parsing and analysis and will not be read at all.
267+
//
268+
// This is useful for excluding groups of test or example
269+
// directories/files, unanalyzable files, or files that
270+
// can't be removed for whatever reason.
271+
// (e.g. `'@Test\.php$@'`, or `'@vendor/.*/(tests|Tests)/@'`)
272+
'exclude_file_regex' => '@^vendor/.*/(tests?|Tests?)/@',
273+
274+
// A list of files that will be excluded from parsing and analysis
275+
// and will not be read at all.
276+
//
277+
// This is useful for excluding hopelessly unanalyzable
278+
// files that can't be removed for whatever reason.
279+
'exclude_file_list' => [],
280+
281+
// A directory list that defines files that will be excluded
282+
// from static analysis, but whose class and method
283+
// information should be included.
284+
//
285+
// Generally, you'll want to include the directories for
286+
// third-party code (such as "vendor/") in this list.
287+
//
288+
// n.b.: If you'd like to parse but not analyze 3rd
289+
// party code, directories containing that code
290+
// should be added to the `directory_list` as well as
291+
// to `exclude_analysis_directory_list`.
292+
'exclude_analysis_directory_list' => [
293+
'vendor/',
294+
],
295+
296+
// Enable this to enable checks of require/include statements referring to valid paths.
297+
// The settings `include_paths` and `warn_about_relative_include_statement` affect the checks.
298+
'enable_include_path_checks' => true,
299+
300+
// The number of processes to fork off during the analysis
301+
// phase.
302+
'processes' => 1,
303+
304+
// List of case-insensitive file extensions supported by Phan.
305+
// (e.g. `['php', 'html', 'htm']`)
306+
'analyzed_file_extensions' => [
307+
'php',
308+
],
309+
310+
// You can put paths to stubs of internal extensions in this config option.
311+
// If the corresponding extension is **not** loaded, then Phan will use the stubs instead.
312+
// Phan will continue using its detailed type annotations,
313+
// but load the constants, classes, functions, and classes (and their Reflection types)
314+
// from these stub files (doubling as valid php files).
315+
// Use a different extension from php to avoid accidentally loading these.
316+
// The `tools/make_stubs` script can be used to generate your own stubs (compatible with php 7.0+ right now)
317+
//
318+
// (e.g. `['xdebug' => '.phan/internal_stubs/xdebug.phan_php']`)
319+
'autoload_internal_extension_signatures' => [],
320+
321+
// A list of plugin files to execute.
322+
//
323+
// Plugins which are bundled with Phan can be added here by providing their name (e.g. `'AlwaysReturnPlugin'`)
324+
//
325+
// Documentation about available bundled plugins can be found [here](https://github.com/phan/phan/tree/v5/.phan/plugins).
326+
//
327+
// Alternately, you can pass in the full path to a PHP file with the plugin's implementation (e.g. `'vendor/phan/phan/.phan/plugins/AlwaysReturnPlugin.php'`)
328+
'plugins' => [
329+
'AlwaysReturnPlugin',
330+
'DollarDollarPlugin',
331+
'DuplicateArrayKeyPlugin',
332+
'DuplicateExpressionPlugin',
333+
'PregRegexCheckerPlugin',
334+
'PrintfCheckerPlugin',
335+
'SleepCheckerPlugin',
336+
'UnreachableCodePlugin',
337+
'UseReturnValuePlugin',
338+
'EmptyStatementListPlugin',
339+
'StrictComparisonPlugin',
340+
'LoopVariableReusePlugin',
341+
],
342+
343+
// A list of directories that should be parsed for class and
344+
// method information. After excluding the directories
345+
// defined in `exclude_analysis_directory_list`, the remaining
346+
// files will be statically analyzed for errors.
347+
//
348+
// Thus, both first-party and third-party code being used by
349+
// your application should be included in this list.
350+
'directory_list' => [
351+
'../tbclient.protobuf/tbm_php/GPBMetadata',
352+
'../tbclient.protobuf/tbm_php/TbClient',
353+
'app',
354+
'vendor/barryvdh/laravel-debugbar/src',
355+
'vendor/barryvdh/laravel-ide-helper/src',
356+
'vendor/friendsofphp/php-cs-fixer/src',
357+
'vendor/google/protobuf/src/GPBMetadata/Google/Protobuf',
358+
'vendor/google/protobuf/src/Google/Protobuf',
359+
'vendor/google/recaptcha/src/ReCaptcha',
360+
'vendor/infection/infection/src',
361+
'vendor/larastan/larastan/src',
362+
'vendor/laravel/framework/src/Illuminate',
363+
'vendor/nunomaduro/collision/src',
364+
'vendor/phan/phan/src/Phan',
365+
'vendor/phpmd/phpmd/src/main/php',
366+
'vendor/phpstan/extension-installer/src',
367+
'vendor/phpstan/phpstan-deprecation-rules/src',
368+
'vendor/phpstan/phpstan-strict-rules/src',
369+
'vendor/phpunit/phpunit/src',
370+
'vendor/psalm/plugin-laravel/src',
371+
'vendor/spatie/laravel-collection-macros/src',
372+
'vendor/spatie/laravel-ignition/src',
373+
'vendor/spatie/regex/src',
374+
'vendor/thecodingmachine/phpstan-safe-rule/src',
375+
'vendor/thecodingmachine/safe/deprecated/Exceptions',
376+
'vendor/thecodingmachine/safe/generated/Exceptions',
377+
'vendor/thecodingmachine/safe/lib/Exceptions',
378+
'vendor/vimeo/psalm/src/Psalm',
379+
],
380+
381+
// A list of individual files to include in analysis
382+
// with a path relative to the root directory of the
383+
// project.
384+
'file_list' => [
385+
'vendor/thecodingmachine/safe/lib/DateTime.php',
386+
'vendor/thecodingmachine/safe/lib/DateTimeImmutable.php',
387+
],
388+
];

0 commit comments

Comments
 (0)