Skip to content

Commit

Permalink
fix(phpstab): adapt phpstan package for extension use (#3727)
Browse files Browse the repository at this point in the history
- fix "Stub file does not exist" error message as reported in
  <flarum/docs#441 (comment)>
- fix "Ignored error pattern was not matched in reported errors" error
  messages as reported in
  <flarum/docs#441 (comment)>
  • Loading branch information
n-peugnet authored Feb 8, 2023
1 parent f98654a commit 04af6c4
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 37 deletions.
62 changes: 31 additions & 31 deletions larastan-extension.neon
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
parameters:
stubFiles:
- ../../vendor/nunomaduro/larastan/stubs/Enumerable.stub
- ../../vendor/nunomaduro/larastan/stubs/EloquentBuilder.stub
- ../../vendor/nunomaduro/larastan/stubs/Collection.stub
- ../../vendor/nunomaduro/larastan/stubs/EloquentCollection.stub
- ../../vendor/nunomaduro/larastan/stubs/Factory.stub
- ../../vendor/nunomaduro/larastan/stubs/Model.stub
- ../../vendor/nunomaduro/larastan/stubs/Gate.stub
- ../../vendor/nunomaduro/larastan/stubs/Relation.stub
- ../../vendor/nunomaduro/larastan/stubs/BelongsTo.stub
- ../../vendor/nunomaduro/larastan/stubs/BelongsToMany.stub
- ../../vendor/nunomaduro/larastan/stubs/HasOneOrMany.stub
- ../../vendor/nunomaduro/larastan/stubs/HasMany.stub
- ../../vendor/nunomaduro/larastan/stubs/HasOne.stub
- ../../vendor/nunomaduro/larastan/stubs/HasOneThrough.stub
- ../../vendor/nunomaduro/larastan/stubs/HasManyThrough.stub
- ../../vendor/nunomaduro/larastan/stubs/Mailable.stub
- ../../vendor/nunomaduro/larastan/stubs/MorphOne.stub
- ../../vendor/nunomaduro/larastan/stubs/MorphOneOrMany.stub
- ../../vendor/nunomaduro/larastan/stubs/MorphTo.stub
- ../../vendor/nunomaduro/larastan/stubs/MorphToMany.stub
- ../../vendor/nunomaduro/larastan/stubs/MorphMany.stub
- ../../vendor/nunomaduro/larastan/stubs/Helpers.stub
- ../../vendor/nunomaduro/larastan/stubs/HigherOrderProxies.stub
- ../../vendor/nunomaduro/larastan/stubs/QueryBuilder.stub
- ../../vendor/nunomaduro/larastan/stubs/Facades.stub
- ../../vendor/nunomaduro/larastan/stubs/Pagination.stub
- ../../vendor/nunomaduro/larastan/stubs/Contracts/Pagination.stub
- ../../vendor/nunomaduro/larastan/stubs/Contracts/Support.stub
- ../../vendor/nunomaduro/larastan/stubs/Redis/Connection.stub
- ../../vendor/nunomaduro/larastan/stubs/Logger.stub
- ../../vendor/nunomaduro/larastan/stubs/EnumeratesValues.stub
- %rootDir%/../../nunomaduro/larastan/stubs/Enumerable.stub
- %rootDir%/../../nunomaduro/larastan/stubs/EloquentBuilder.stub
- %rootDir%/../../nunomaduro/larastan/stubs/Collection.stub
- %rootDir%/../../nunomaduro/larastan/stubs/EloquentCollection.stub
- %rootDir%/../../nunomaduro/larastan/stubs/Factory.stub
- %rootDir%/../../nunomaduro/larastan/stubs/Model.stub
- %rootDir%/../../nunomaduro/larastan/stubs/Gate.stub
- %rootDir%/../../nunomaduro/larastan/stubs/Relation.stub
- %rootDir%/../../nunomaduro/larastan/stubs/BelongsTo.stub
- %rootDir%/../../nunomaduro/larastan/stubs/BelongsToMany.stub
- %rootDir%/../../nunomaduro/larastan/stubs/HasOneOrMany.stub
- %rootDir%/../../nunomaduro/larastan/stubs/HasMany.stub
- %rootDir%/../../nunomaduro/larastan/stubs/HasOne.stub
- %rootDir%/../../nunomaduro/larastan/stubs/HasOneThrough.stub
- %rootDir%/../../nunomaduro/larastan/stubs/HasManyThrough.stub
- %rootDir%/../../nunomaduro/larastan/stubs/Mailable.stub
- %rootDir%/../../nunomaduro/larastan/stubs/MorphOne.stub
- %rootDir%/../../nunomaduro/larastan/stubs/MorphOneOrMany.stub
- %rootDir%/../../nunomaduro/larastan/stubs/MorphTo.stub
- %rootDir%/../../nunomaduro/larastan/stubs/MorphToMany.stub
- %rootDir%/../../nunomaduro/larastan/stubs/MorphMany.stub
- %rootDir%/../../nunomaduro/larastan/stubs/Helpers.stub
- %rootDir%/../../nunomaduro/larastan/stubs/HigherOrderProxies.stub
- %rootDir%/../../nunomaduro/larastan/stubs/QueryBuilder.stub
- %rootDir%/../../nunomaduro/larastan/stubs/Facades.stub
- %rootDir%/../../nunomaduro/larastan/stubs/Pagination.stub
- %rootDir%/../../nunomaduro/larastan/stubs/Contracts/Pagination.stub
- %rootDir%/../../nunomaduro/larastan/stubs/Contracts/Support.stub
- %rootDir%/../../nunomaduro/larastan/stubs/Redis/Connection.stub
- %rootDir%/../../nunomaduro/larastan/stubs/Logger.stub
- %rootDir%/../../nunomaduro/larastan/stubs/EnumeratesValues.stub
universalObjectCratesClasses:
- Illuminate\Http\Request
earlyTerminatingFunctionCalls:
Expand Down
18 changes: 12 additions & 6 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
parameters:
ignoreErrors:
# Remove this group below with larastan 2.0 (i.e Flarum 2.0)
- "#Relation '[A-z_-]+' is not found in [A-z\_]+ model.#"
- '#^Parameter \#1 \$query of method [A-z_<>\\]+\:\:union\(\) expects [A-z_<> .,|\\]+ given\.$#'
- '#^Parameter \#1 \$query of method [A-z_<>\\]+\:\:joinSub\(\) expects [A-z_<> .,|\\]+ given\.$#'
- message: "#Relation '[A-z_-]+' is not found in [A-z\_]+ model.#"
reportUnmatched: false
- message: '#^Parameter \#1 \$query of method [A-z_<>\\]+\:\:union\(\) expects [A-z_<> .,|\\]+ given\.$#'
reportUnmatched: false
- message: '#^Parameter \#1 \$query of method [A-z_<>\\]+\:\:joinSub\(\) expects [A-z_<> .,|\\]+ given\.$#'
reportUnmatched: false

# We ignore this because resolve can either take a class name as the generic return type or just a binding name.
- "#Template type T of function resolve[()]{2} is not referenced in a parameter.#"
- message: "#Template type T of function resolve[()]{2} is not referenced in a parameter.#"
reportUnmatched: false

# We ignore new static errors because we want extensibility.
# @TODO: needs discussion.
- "#^Unsafe usage of new static[()]{2}.$#"
- message: "#^Unsafe usage of new static[()]{2}.$#"
reportUnmatched: false

# ConnectionInterface lacks methods that exist in the implementation,
# yet we don't want to inject the implementation.
- '#^Call to an undefined method Illuminate\\Database\\ConnectionInterface\:\:[A-z0-9_]+\(\)\.$#'
- message: '#^Call to an undefined method Illuminate\\Database\\ConnectionInterface\:\:[A-z0-9_]+\(\)\.$#'
reportUnmatched: false

0 comments on commit 04af6c4

Please sign in to comment.