Skip to content

Commit a9c4368

Browse files
[9.x] Adds type checking (#705)
* Adds type checking * Apply fixes from StyleCI --------- Co-authored-by: StyleCI Bot <[email protected]>
1 parent adc3228 commit a9c4368

File tree

5 files changed

+58
-1
lines changed

5 files changed

+58
-1
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
.gitignore export-ignore
1515
.styleci.yml export-ignore
1616
CHANGELOG.md export-ignore
17+
phpstan.neon.dist export-ignore
1718
phpunit.xml.dist export-ignore
1819
RELEASE.md export-ignore
1920
UPGRADE.md export-ignore
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: static analysis
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- '*.x'
8+
pull_request:
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
tests:
15+
runs-on: ubuntu-22.04
16+
17+
strategy:
18+
fail-fast: true
19+
20+
name: Static Analysis
21+
22+
steps:
23+
- name: Checkout code
24+
uses: actions/checkout@v3
25+
26+
- name: Setup PHP
27+
uses: shivammathur/setup-php@v2
28+
with:
29+
php-version: 8.2
30+
tools: composer:v2
31+
coverage: none
32+
33+
- name: Install dependencies
34+
uses: nick-fields/retry@v2
35+
with:
36+
timeout_minutes: 5
37+
max_attempts: 5
38+
command: composer update --prefer-stable --prefer-dist --no-interaction --no-progress
39+
40+
- name: Execute type checking
41+
run: vendor/bin/phpstan

composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@
2424
"illuminate/support": "^8.0|^9.0|^10.0"
2525
},
2626
"require-dev": {
27+
"algolia/algoliasearch-client-php": "^3.2",
2728
"meilisearch/meilisearch-php": "^0.19",
2829
"mockery/mockery": "^1.0",
29-
"php-http/guzzle7-adapter": "^1.0",
3030
"orchestra/testbench": "^6.17|^7.0|^8.0",
31+
"php-http/guzzle7-adapter": "^1.0",
32+
"phpstan/phpstan": "^1.10",
3133
"phpunit/phpunit": "^9.3"
3234
},
3335
"autoload": {

phpstan.neon.dist

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
parameters:
2+
paths:
3+
- config
4+
- src
5+
6+
level: 0
7+
8+
ignoreErrors:
9+
- "#\\(void\\) is used.#"
10+
- "#MeiliSearch\\\\Client referenced with incorrect case#"
11+
- "#MeiliSearch\\\\MeiliSearch referenced with incorrect case#"

src/SearchableScope.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public function extend(EloquentBuilder $builder)
4848
});
4949

5050
HasManyThrough::macro('searchable', function ($chunk = null) {
51+
/** @var HasManyThrough $this */
5152
$this->chunkById($chunk ?: config('scout.chunk.searchable', 500), function ($models) {
5253
$models->filter->shouldBeSearchable()->searchable();
5354

@@ -56,6 +57,7 @@ public function extend(EloquentBuilder $builder)
5657
});
5758

5859
HasManyThrough::macro('unsearchable', function ($chunk = null) {
60+
/** @var HasManyThrough $this */
5961
$this->chunkById($chunk ?: config('scout.chunk.searchable', 500), function ($models) {
6062
$models->unsearchable();
6163

0 commit comments

Comments
 (0)