Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
],
"require": {
"php": "^8.0",
"driftingly/rector-laravel": "^2.1",
"illuminate/contracts": "^11.0|^12.0",
"spatie/laravel-package-tools": "^1.9.2"
},
Expand Down
12 changes: 8 additions & 4 deletions database/factories/PostFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,26 @@

use Oddvalue\LaravelDrafts\Tests\app\Models\Post;

/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<Post>
*/
class PostFactory extends \Illuminate\Database\Eloquent\Factories\Factory
{
protected $model = Post::class;

/**
* @inheritDoc
* @return array<string, mixed>
* @phpstan-ignore method.childReturnType
*/
public function definition()
public function definition(): array
{
return [
'title' => $this->faker->sentence,
'is_current' => true,
];
}

public function draft()
public function draft(): static
{
return $this->state(function () {
return [
Expand All @@ -29,7 +33,7 @@ public function draft()
});
}

public function published()
public function published(): static
{
return $this->state(function () {
return [
Expand Down
8 changes: 6 additions & 2 deletions database/factories/PostSectionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@

use Oddvalue\LaravelDrafts\Tests\app\Models\PostSection;

/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<PostSection>
*/
class PostSectionFactory extends \Illuminate\Database\Eloquent\Factories\Factory
{
protected $model = PostSection::class;

/**
* @inheritDoc
* @return array<string, mixed>
* @phpstan-ignore method.childReturnType
*/
public function definition()
public function definition(): array
{
return [
'content' => $this->faker->paragraph,
Expand Down
8 changes: 4 additions & 4 deletions database/factories/SoftDeletingPostFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ class SoftDeletingPostFactory extends PostFactory
protected $model = SoftDeletingPost::class;

/**
* @inheritDoc
* @return array<string, mixed>
*/
public function definition()
public function definition(): array
{
return [
'title' => $this->faker->sentence,
];
}

public function draft()
public function draft(): static
{
return $this->state(function () {
return [
Expand All @@ -28,7 +28,7 @@ public function draft()
});
}

public function published()
public function published(): static
{
return $this->state(function () {
return [
Expand Down
8 changes: 6 additions & 2 deletions database/factories/TagFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@

use Oddvalue\LaravelDrafts\Tests\app\Models\Tag;

/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<Tag>
*/
class TagFactory extends \Illuminate\Database\Eloquent\Factories\Factory
{
protected $model = Tag::class;

/**
* @inheritDoc
* @return array<string, mixed>
* @phpstan-ignore method.childReturnType
*/
public function definition()
public function definition(): array
{
return [
'name' => $this->faker->word(),
Expand Down
193 changes: 0 additions & 193 deletions phpstan-baseline.neon

This file was deleted.

79 changes: 75 additions & 4 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
includes:
- phpstan-baseline.neon

parameters:
level: 4
level: 10
paths:
- src
- config
Expand All @@ -11,3 +8,77 @@ parameters:
tmpDir: build/phpstan
checkOctaneCompatibility: true
checkModelProperties: true
ignoreErrors:
# Trait method calls in closures - PHPStan doesn't recognize trait methods on $model parameter
-
message: '#Call to an undefined method Illuminate\\Database\\Eloquent\\Model::(getIsCurrentColumn|setPublisher|generateUuid|getIsPublishedColumn|publish|newRevision|setLive|revisions|getUuidColumn|isCurrent|drafts|getQualifiedIsPublishedColumn)\(\)#'
paths:
- src/Concerns/*.php
- src/Scopes/*.php
reportUnmatched: false
# Method chaining on dynamic relations
-
message: '#Cannot call method (current|excludeRevision|withDrafts|withoutCurrent|onlyDrafts|published|merge|pluck|take|whereNotIn|delete|get|each|sync|create|getAttributes|getDraftableAttributes|where|first|replicate) on mixed#'
paths:
- src/Concerns/*.php
reportUnmatched: false
# Access to undefined constants in trait context
-
message: '#Access to undefined constant#'
paths:
- src/Concerns/*.php
reportUnmatched: false
# Method return types in trait context
-
message: '#Method Oddvalue\\LaravelDrafts\\Tests\\app\\Models\\[A-Za-z]+::[a-zA-Z]+\(\) (should return|return type)#'
paths:
- src/Concerns/*.php
reportUnmatched: false
# HasFactory generic type - these models define factory types via newFactory() method
-
message: '#Class Oddvalue\\LaravelDrafts\\Tests\\app\\Models\\[A-Za-z]+ uses generic trait Illuminate\\Database\\Eloquent\\Factories\\HasFactory but does not specify its types: TFactory#'
paths:
- tests/app/Models/*.php
reportUnmatched: false
# ArrayShape attribute
-
message: '#Attribute class JetBrains\\PhpStorm\\ArrayShape does not exist#'
paths:
- src/Concerns/*.php
reportUnmatched: false
# Argument type issues in trait context
-
message: '#Parameter .* expects .*, (mixed|array|Closure\|string|class-string\|object) given#'
paths:
- src/Concerns/*.php
reportUnmatched: false
# Method not found errors in Scopes
-
message: '#Call to an undefined method Illuminate\\Database\\Eloquent\\Builder::(withDrafts|withoutDrafts)#'
paths:
- src/Scopes/*.php
reportUnmatched: false
# withoutGlobalScope argument type in macros
-
message: '#Parameter \#1 \$scope of method Illuminate\\Database\\Eloquent\\Builder.*::withoutGlobalScope\(\) expects.*Illuminate\\Database\\Eloquent\\Builder.*given#'
paths:
- src/Scopes/*.php
reportUnmatched: false
# HasMany relation methods
-
message: '#Call to an undefined method Illuminate\\Database\\Eloquent\\Relations\\HasMany.*::(withDrafts|onlyDrafts|published)\(\)#'
paths:
- src/Concerns/*.php
reportUnmatched: false
# array_map callback type
-
message: '#Parameter \#1 \$callback of function array_map expects#'
paths:
- src/Concerns/*.php
reportUnmatched: false
# where() argument types in scopes
-
message: '#Parameter \#1 \$column of method Illuminate\\Database\\Eloquent\\Builder.*::where\(\) expects#'
paths:
- src/Scopes/*.php
reportUnmatched: false
Loading