Compare commits

...

5 Commits

Author SHA1 Message Date
philipp lang bd6f4001e6 Update phpstan baseline
continuous-integration/drone/push Build was killed Details
2025-03-31 02:01:00 +02:00
philipp lang 34bb336d86 Lint 2025-03-31 01:58:54 +02:00
philipp lang 2a34fd8f5c Update tex package 2025-03-31 01:56:22 +02:00
philipp lang 6ba8809f95 Add doctypes 2025-03-31 01:56:18 +02:00
philipp lang f19f748c11 Add Data Eloquent casting 2025-03-31 01:49:15 +02:00
9 changed files with 106 additions and 9 deletions

View File

@ -3,11 +3,11 @@
namespace App\Form\Data;
use App\Fileshare\Data\FileshareResourceData;
use App\Form\Fields\Field;
use Spatie\LaravelData\Attributes\MapInputName;
use Spatie\LaravelData\Attributes\MapOutputName;
use Spatie\LaravelData\Data;
use Spatie\LaravelData\Mappers\SnakeCaseMapper;
use Spatie\LaravelData\Support\EloquentCasts\DataEloquentCast;
#[MapInputName(SnakeCaseMapper::class)]
#[MapOutputName(SnakeCaseMapper::class)]
@ -16,4 +16,13 @@ class ExportData extends Data
public function __construct(public ?FileshareResourceData $root = null, public ?string $groupBy = null, public ?string $toGroupField = null)
{
}
/**
* @param array<int, mixed> $arguments
* @return DataEloquentCast<self>
*/
public static function castUsing(array $arguments): DataEloquentCast
{
return new DataEloquentCast(static::class, $arguments);
}
}

View File

@ -8,6 +8,7 @@ use Illuminate\Support\Collection;
use Spatie\LaravelData\Data;
use Spatie\LaravelData\Attributes\WithCast;
use Spatie\LaravelData\Attributes\WithTransformer;
use Spatie\LaravelData\Support\EloquentCasts\DataEloquentCast;
class FormConfigData extends Data
{
@ -29,4 +30,13 @@ class FormConfigData extends Data
new FieldCollection([])
);
}
/**
* @param array<int, mixed> $arguments
* @return DataEloquentCast<self>
*/
public static function castUsing(array $arguments): DataEloquentCast
{
return new DataEloquentCast(static::class, $arguments);
}
}

View File

@ -11,12 +11,14 @@ class Authenticate extends Middleware
*
* @param \Illuminate\Http\Request $request
*
* @return void
* @return string|null
*/
protected function redirectTo($request)
{
if (!$request->expectsJson()) {
return route('login');
}
return null;
}
}

View File

@ -6,6 +6,7 @@ use Spatie\LaravelData\Data;
use Spatie\LaravelData\DataCollection;
use Spatie\MediaLibrary\MediaCollections\Models\Media;
use Spatie\LaravelData\Attributes\DataCollectionOf;
use Spatie\LaravelData\Support\EloquentCasts\DataEloquentCast;
class Condition extends Data
{
@ -42,4 +43,13 @@ class Condition extends Data
{
return $this->mode === ConditionMode::ALL;
}
/**
* @param array<int, mixed> $arguments
* @return DataEloquentCast<self>
*/
public static function castUsing(array $arguments): DataEloquentCast
{
return new DataEloquentCast(static::class, $arguments);
}
}

View File

@ -3,6 +3,7 @@
namespace App\Lib\Editor;
use Spatie\LaravelData\Data;
use Spatie\LaravelData\Support\EloquentCasts\DataEloquentCast;
/** @todo replace blocks with actual block data classes */
class EditorData extends Data implements Editorable
@ -83,4 +84,13 @@ class EditorData extends Data implements Editorable
{
return $this;
}
/**
* @param array<int, mixed> $arguments
* @return DataEloquentCast<self>
*/
public static function castUsing(array $arguments): DataEloquentCast
{
return new DataEloquentCast(static::class, $arguments);
}
}

12
composer.lock generated
View File

@ -6011,16 +6011,16 @@
},
{
"name": "nette/utils",
"version": "v4.0.5",
"version": "v4.0.6",
"source": {
"type": "git",
"url": "https://github.com/nette/utils.git",
"reference": "736c567e257dbe0fcf6ce81b4d6dbe05c6899f96"
"reference": "ce708655043c7050eb050df361c5e313cf708309"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nette/utils/zipball/736c567e257dbe0fcf6ce81b4d6dbe05c6899f96",
"reference": "736c567e257dbe0fcf6ce81b4d6dbe05c6899f96",
"url": "https://api.github.com/repos/nette/utils/zipball/ce708655043c7050eb050df361c5e313cf708309",
"reference": "ce708655043c7050eb050df361c5e313cf708309",
"shasum": ""
},
"require": {
@ -6091,9 +6091,9 @@
],
"support": {
"issues": "https://github.com/nette/utils/issues",
"source": "https://github.com/nette/utils/tree/v4.0.5"
"source": "https://github.com/nette/utils/tree/v4.0.6"
},
"time": "2024-08-07T15:39:19+00:00"
"time": "2025-03-30T21:06:30+00:00"
},
{
"name": "nikic/php-parser",

@ -1 +1 @@
Subproject commit 0c6c948378d6f28636e4de36cc2c3a62c6975440
Subproject commit ed283d97ca7680b3c27b2d75da9937f4f379e321

View File

@ -7,6 +7,7 @@ parameters:
stubFiles:
- tests/stub/phpstan/TestResponse.stub
- tests/stub/phpstan/Settings.stub
- tests/stub/phpstan/DataEloquentCast.stub
paths:
- app
@ -499,3 +500,45 @@ parameters:
message: "#^Call to an undefined method Illuminate\\\\Database\\\\Eloquent\\\\Relations\\\\Relation\\<\\*, \\*, \\*\\>\\:\\:isTrying\\(\\)\\.$#"
count: 1
path: app/Membership/TestersBlock.php
-
message: '#^Call to an undefined method Illuminate\\Database\\Eloquent\\Builder\<Illuminate\\Database\\Eloquent\\Model\>\:\:isLeader\(\)\.$#'
identifier: method.notFound
count: 1
path: app/Efz/EfzPendingBlock.php
-
message: '#^Method App\\Fileshare\\ConnectionTypes\\ConnectionType\:\:types\(\) should return Illuminate\\Support\\Collection\<int, class\-string\<App\\Fileshare\\ConnectionTypes\\ConnectionType\>\> but returns Illuminate\\Support\\Collection\<int, non\-falsy\-string\>\.$#'
identifier: return.type
count: 1
path: app/Fileshare/ConnectionTypes/ConnectionType.php
-
message: '#^Unable to resolve the template type TGroupKey in call to method Illuminate\\Support\\Collection\<int,App\\Form\\Models\\Participant\>\:\:groupBy\(\)$#'
identifier: argument.templateType
count: 1
path: app/Form/Actions/ExportSyncAction.php
-
message: '#^Parameter \#1 \$callback of method Illuminate\\Support\\Collection\<\(int\|string\),mixed\>\:\:map\(\) contains unresolvable type\.$#'
identifier: argument.unresolvableType
count: 1
path: app/Mailgateway/Resources/MailgatewayResource.php
-
message: '#^Parameter \#1 \$value of method Illuminate\\Support\\Collection\<\(int\|string\),array\<string, mixed\>\>\:\:prepend\(\) contains unresolvable type\.$#'
identifier: argument.unresolvableType
count: 1
path: app/Mailgateway/Resources/MailgatewayResource.php
-
message: '#^Call to an undefined method Illuminate\\Database\\Eloquent\\Builder\<Illuminate\\Database\\Eloquent\\Model\>\:\:isLeader\(\)\.$#'
identifier: method.notFound
count: 1
path: app/Member/PsPendingBlock.php
-
message: '#^Call to an undefined method Illuminate\\Database\\Eloquent\\Builder\<TRelatedModel of Illuminate\\Database\\Eloquent\\Model\>\:\:isTrying\(\)\.$#'
identifier: method.notFound
count: 1
path: app/Membership/TestersBlock.php

View File

@ -0,0 +1,13 @@
<?php
namespace Spatie\LaravelData\Support\EloquentCasts;
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
/**
* @template TDto
* @implements CastsAttributes<TDto, TDto>
*/
class DataEloquentCast implements CastsAttributes
{
}