Skip to content

Commit 85b43b8

Browse files
committed
PHPStan 2.0
1 parent 3443916 commit 85b43b8

File tree

10 files changed

+66
-18
lines changed

10 files changed

+66
-18
lines changed

composer.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,18 @@
2222
"spatie/laravel-package-tools": "^1.13.0"
2323
},
2424
"require-dev": {
25-
"driftingly/rector-laravel": "^1.2.6",
26-
"larastan/larastan": "^2.9.14",
25+
"driftingly/rector-laravel": "^2.0.2",
26+
"larastan/larastan": "^3.1",
2727
"laravel/pint": "^1.21.0",
2828
"nunomaduro/collision": "^8.6.1",
2929
"orchestra/testbench": "^9.11 || ^10.0",
3030
"phpstan/extension-installer": "^1.4.3",
31-
"phpstan/phpstan-deprecation-rules": "^1.2.1",
32-
"phpstan/phpstan-phpunit": "^1.4.2",
33-
"phpstan/phpstan-strict-rules": "^1.6.2",
31+
"phpstan/phpstan-deprecation-rules": "^2.0.1",
32+
"phpstan/phpstan-phpunit": "^2.0.4",
33+
"phpstan/phpstan-strict-rules": "^2.0.3",
3434
"phpunit/phpunit": "^11.5.10",
3535
"psr/log": "^3.0.2",
36-
"rector/rector": "^1.2.10",
36+
"rector/rector": "^2.0.9",
3737
"sentry/sentry": "^4.10.0",
3838
"symfony/http-client": "^6.4.19"
3939
},

phpstan-baseline.neon

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,73 @@
11
parameters:
22
ignoreErrors:
33
-
4-
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
4+
message: '#^Construct empty\(\) is not allowed\. Use more strict comparison\.$#'
5+
identifier: empty.notAllowed
56
count: 1
67
path: src/Commands/IndexCommand.php
78

89
-
9-
message: "#^Only booleans are allowed in a negated boolean, mixed given\\.$#"
10+
message: '#^Only booleans are allowed in a negated boolean, mixed given\.$#'
11+
identifier: booleanNot.exprNotBoolean
1012
count: 1
1113
path: src/Commands/IndexCommand.php
1214

1315
-
14-
message: "#^Unable to resolve the template type TKey in call to function collect$#"
16+
message: '#^Unable to resolve the template type TKey in call to function collect$#'
17+
identifier: argument.templateType
1518
count: 1
1619
path: src/Events/EventHandler.php
1720

1821
-
19-
message: "#^Unable to resolve the template type TValue in call to function collect$#"
22+
message: '#^Unable to resolve the template type TValue in call to function collect$#'
23+
identifier: argument.templateType
2024
count: 1
2125
path: src/Events/EventHandler.php
2226

2327
-
24-
message: "#^Call to an undefined method Illuminate\\\\Database\\\\Eloquent\\\\Model\\|Limenet\\\\LaravelElasticaBridge\\\\Model\\\\ElasticsearchableInterface\\:\\:getElasticsearchId\\(\\)\\.$#"
28+
message: '#^Call to an undefined method Illuminate\\Database\\Eloquent\\Model\|Limenet\\LaravelElasticaBridge\\Model\\ElasticsearchableInterface\:\:getElasticsearchId\(\)\.$#'
29+
identifier: method.notFound
2530
count: 1
2631
path: src/Index/AbstractIndex.php
2732

2833
-
29-
message: "#^Casting to string something that's already string\\.$#"
34+
message: '#^Casting to string something that''s already string\.$#'
35+
identifier: cast.useless
3036
count: 1
3137
path: src/Index/AbstractIndex.php
3238

3339
-
34-
message: "#^Method Limenet\\\\LaravelElasticaBridge\\\\Index\\\\AbstractIndex\\:\\:getMapping\\(\\) return type has no value type specified in iterable type array\\.$#"
40+
message: '#^Method Limenet\\LaravelElasticaBridge\\Index\\AbstractIndex\:\:getMapping\(\) return type has no value type specified in iterable type array\.$#'
41+
identifier: missingType.iterableValue
3542
count: 1
3643
path: src/Index/AbstractIndex.php
3744

3845
-
39-
message: "#^Method Limenet\\\\LaravelElasticaBridge\\\\Index\\\\AbstractIndex\\:\\:getSettings\\(\\) return type has no value type specified in iterable type array\\.$#"
46+
message: '#^Method Limenet\\LaravelElasticaBridge\\Index\\AbstractIndex\:\:getSettings\(\) return type has no value type specified in iterable type array\.$#'
47+
identifier: missingType.iterableValue
4048
count: 1
4149
path: src/Index/AbstractIndex.php
4250

4351
-
44-
message: "#^Method Limenet\\\\LaravelElasticaBridge\\\\Index\\\\IndexInterface\\:\\:getMapping\\(\\) return type has no value type specified in iterable type array\\.$#"
52+
message: '#^Method Limenet\\LaravelElasticaBridge\\Index\\IndexInterface\:\:getMapping\(\) return type has no value type specified in iterable type array\.$#'
53+
identifier: missingType.iterableValue
4554
count: 1
4655
path: src/Index/IndexInterface.php
4756

4857
-
49-
message: "#^Method Limenet\\\\LaravelElasticaBridge\\\\Index\\\\IndexInterface\\:\\:getSettings\\(\\) return type has no value type specified in iterable type array\\.$#"
58+
message: '#^Method Limenet\\LaravelElasticaBridge\\Index\\IndexInterface\:\:getSettings\(\) return type has no value type specified in iterable type array\.$#'
59+
identifier: missingType.iterableValue
5060
count: 1
5161
path: src/Index/IndexInterface.php
5262

5363
-
54-
message: "#^Cannot access offset 'events' on Illuminate\\\\Contracts\\\\Foundation\\\\Application\\.$#"
64+
message: '#^Cannot access offset ''events'' on Illuminate\\Contracts\\Foundation\\Application\.$#'
65+
identifier: offsetAccess.nonOffsetAccessible
5566
count: 1
5667
path: src/LaravelElasticaBridgeServiceProvider.php
68+
69+
-
70+
message: '#^Method Limenet\\LaravelElasticaBridge\\Tests\\App\\Elasticsearch\\CustomerIndex\:\:getMapping\(\) return type has no value type specified in iterable type array\.$#'
71+
identifier: missingType.iterableValue
72+
count: 1
73+
path: tests/App/Elasticsearch/CustomerIndex.php

phpstan.neon.dist

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,14 @@ parameters:
66
paths:
77
- src
88
- config
9+
- tests/App
910

1011
tmpDir: build/phpstan
1112
checkOctaneCompatibility: true
1213
checkModelProperties: true
13-
checkMissingIterableValueType: true
1414

15+
ignoreErrors:
16+
-
17+
message: '#^Called ''env'' outside of the config directory which returns null when the config is cached, use ''config''\.$#'
18+
identifier: larastan.noEnvCallsOutsideOfConfig
19+
path: config/elastica-bridge.php

tests/App/Elasticsearch/AllIndex.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Limenet\LaravelElasticaBridge\Index\AbstractIndex;
88
use Limenet\LaravelElasticaBridge\Tests\App\Models\Customer;
99
use Limenet\LaravelElasticaBridge\Tests\App\Models\Invoice;
10+
use Limenet\LaravelElasticaBridge\Tests\App\Models\Order;
1011
use Limenet\LaravelElasticaBridge\Tests\App\Models\Product;
1112

1213
class AllIndex extends AbstractIndex

tests/App/Models/Customer.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
class Customer extends Model implements ElasticsearchableInterface
1616
{
1717
use ElasticsearchableTrait;
18+
19+
/** @use HasFactory<CustomerFactory> */
1820
use HasFactory;
1921

2022
public function toElasticsearch(IndexInterface $indexConfig): array
@@ -27,6 +29,9 @@ public function shouldIndex(IndexInterface $indexConfig): bool
2729
return ($this->id % 2) === 0;
2830
}
2931

32+
/**
33+
* @return Factory<self>
34+
*/
3035
protected static function newFactory(): Factory
3136
{
3237
return CustomerFactory::new();

tests/App/Models/Invoice.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,19 @@
1515
class Invoice extends Model implements ElasticsearchableInterface
1616
{
1717
use ElasticsearchableTrait;
18+
19+
/** @use HasFactory<InvoiceFactory> */
1820
use HasFactory;
21+
1922
use HasUuids;
2023

2124
protected $primaryKey = 'uuid';
2225

2326
public $incrementing = false;
2427

28+
/**
29+
* @return Factory<self>
30+
*/
2531
protected static function newFactory(): Factory
2632
{
2733
return InvoiceFactory::new();

tests/App/Models/Product.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,13 @@
1414
class Product extends Model implements ElasticsearchableInterface
1515
{
1616
use ElasticsearchableTrait;
17+
18+
/** @use HasFactory<ProductFactory> */
1719
use HasFactory;
1820

21+
/**
22+
* @return Factory<self>
23+
*/
1924
protected static function newFactory(): Factory
2025
{
2126
return ProductFactory::new();

tests/database/factories/CustomerFactory.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
use Illuminate\Database\Eloquent\Factories\Factory;
88
use Limenet\LaravelElasticaBridge\Tests\App\Models\Customer;
99

10+
/**
11+
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\Limenet\LaravelElasticaBridge\Tests\App\Models\Customer>
12+
*/
1013
class CustomerFactory extends Factory
1114
{
1215
protected $model = Customer::class;

tests/database/factories/InvoiceFactory.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
use Illuminate\Database\Eloquent\Factories\Factory;
88
use Limenet\LaravelElasticaBridge\Tests\App\Models\Invoice;
99

10+
/**
11+
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\Limenet\LaravelElasticaBridge\Tests\App\Models\Invoice>
12+
*/
1013
class InvoiceFactory extends Factory
1114
{
1215
protected $model = Invoice::class;

tests/database/factories/ProductFactory.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
use Illuminate\Database\Eloquent\Factories\Factory;
88
use Limenet\LaravelElasticaBridge\Tests\App\Models\Product;
99

10+
/**
11+
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\Limenet\LaravelElasticaBridge\Tests\App\Models\Product>
12+
*/
1013
class ProductFactory extends Factory
1114
{
1215
protected $model = Product::class;

0 commit comments

Comments
 (0)