Compare commits

..

No commits in common. "d06ae7acb55d35192da36c695eb34b7ca2f685ef" and "71903936a3e1df50bca80b5e974af0d1c6453704" have entirely different histories.

13 changed files with 46 additions and 95 deletions

View File

@ -25,7 +25,7 @@ class ContributionFactory
]; ];
/** /**
* @return Collection<int, array{title: string, class: class-string<ContributionDocument>}> * @return Collection<int, array{title: mixed, class: mixed}>
*/ */
public function compilerSelect(): Collection public function compilerSelect(): Collection
{ {

View File

@ -8,6 +8,9 @@ use Sabre\CardDAV\Backend\AbstractBackend;
use Sabre\DAV\PropPatch; use Sabre\DAV\PropPatch;
use Sabre\VObject\Component\VCard; use Sabre\VObject\Component\VCard;
/**
* @template M as array{lastmodified: int, etag: string, uri: string, id: int, size: int}
*/
class AddressBookBackend extends AbstractBackend class AddressBookBackend extends AbstractBackend
{ {
/** /**
@ -112,7 +115,7 @@ class AddressBookBackend extends AbstractBackend
* *
* @param mixed $addressbookId * @param mixed $addressbookId
* *
* @return array<int, AddressBookCard> * @return array<int, M>
*/ */
public function getCards($addressbookId): array public function getCards($addressbookId): array
{ {
@ -130,7 +133,7 @@ class AddressBookBackend extends AbstractBackend
* @param mixed $addressBookId * @param mixed $addressBookId
* @param string $cardUri * @param string $cardUri
* *
* @return AddressBookCard|bool * @return M
*/ */
public function getCard($addressBookId, $cardUri) public function getCard($addressBookId, $cardUri)
{ {
@ -245,7 +248,7 @@ class AddressBookBackend extends AbstractBackend
} }
/** /**
* @return AddressBookCard * @return M
*/ */
private function cardMeta(Member $member): array private function cardMeta(Member $member): array
{ {

View File

@ -12,9 +12,6 @@ class ListFilesAction
{ {
use AsAction; use AsAction;
/**
* @return DataCollection<int, ResourceData>
*/
public function handle(ActionRequest $request, Fileshare $fileshare): DataCollection public function handle(ActionRequest $request, Fileshare $fileshare): DataCollection
{ {
return ResourceData::collection($fileshare->type->getSubDirectories($request->input('parent')))->wrap('data'); return ResourceData::collection($fileshare->type->getSubDirectories($request->input('parent')))->wrap('data');

View File

@ -2,9 +2,10 @@
namespace App\Fileshare\ConnectionTypes; namespace App\Fileshare\ConnectionTypes;
use App\Fileshare\Data\ResourceData;
use Illuminate\Filesystem\FilesystemAdapter; use Illuminate\Filesystem\FilesystemAdapter;
use Illuminate\Support\Collection;
use Spatie\LaravelData\Data; use Spatie\LaravelData\Data;
use Spatie\LaravelData\DataCollection;
abstract class ConnectionType extends Data abstract class ConnectionType extends Data
{ {
@ -29,7 +30,10 @@ abstract class ConnectionType extends Data
*/ */
public static function forSelect(): array public static function forSelect(): array
{ {
return self::types() return collect(glob(base_path('app/Fileshare/ConnectionTypes/*')))
->map(fn ($file) => 'App\\Fileshare\\ConnectionTypes\\' . pathinfo($file, PATHINFO_FILENAME))
->filter(fn ($file) => $file !== static::class)
->values()
->map(fn ($file) => ['id' => $file, 'name' => $file::title(), 'defaults' => $file::defaults(), 'fields' => $file::fields()]) ->map(fn ($file) => ['id' => $file, 'name' => $file::title(), 'defaults' => $file::defaults(), 'fields' => $file::fields()])
->toArray(); ->toArray();
} }
@ -43,15 +47,4 @@ abstract class ConnectionType extends Data
return $filesystem->directories($parent ?: '/'); return $filesystem->directories($parent ?: '/');
} }
/**
* @return Collection<int, class-string<ConnectionType>>
*/
private static function types(): Collection
{
return collect(glob(base_path('app/Fileshare/ConnectionTypes/*')))
->map(fn ($file) => 'App\\Fileshare\\ConnectionTypes\\' . pathinfo($file, PATHINFO_FILENAME))
->filter(fn ($file) => $file !== static::class)
->values();
}
} }

View File

@ -7,7 +7,7 @@ use Spatie\LaravelData\Data;
class ResourceData extends Data class ResourceData extends Data
{ {
public function __construct(public string $name, public string $path, public string $parent) public function __construct(public $name, public $path, public $parent)
{ {
} }
@ -17,7 +17,7 @@ class ResourceData extends Data
return self::from([ return self::from([
'path' => $dir, 'path' => $dir,
'name' => pathinfo($dir, PATHINFO_BASENAME), 'name' => pathinfo($dir, PATHINFO_FILENAME),
'parent' => pathinfo($dir, PATHINFO_DIRNAME), 'parent' => pathinfo($dir, PATHINFO_DIRNAME),
]); ]);
} }

View File

@ -8,7 +8,7 @@ use App\Lib\HasMeta;
use Illuminate\Http\Resources\Json\JsonResource; use Illuminate\Http\Resources\Json\JsonResource;
/** /**
* @mixin Fileshare * @mixin FileshareConnection
*/ */
class FileshareResource extends JsonResource class FileshareResource extends JsonResource
{ {

View File

@ -10,7 +10,7 @@ use Spatie\LaravelData\Support\DataProperty;
class FieldCollectionCast implements Cast class FieldCollectionCast implements Cast
{ {
/** /**
* @param array<int, array<string, string>> $value * @param array<int, array<string, mixed>> $value
* @param array<string, mixed> $context * @param array<string, mixed> $context
* @return FieldCollection * @return FieldCollection
*/ */

View File

@ -79,9 +79,6 @@ abstract class Field extends Data
->toArray(); ->toArray();
} }
/**
* @return class-string<Field>
*/
public static function classFromType(string $type): ?string public static function classFromType(string $type): ?string
{ {
/** @var class-string<Field> */ /** @var class-string<Field> */

@ -1 +1 @@
Subproject commit 84103d40521d77f936635a7f992cf1ae4b01dafe Subproject commit b8164cd3d204412cd3be95cbf29b9fcc3d23a77d

View File

@ -25,7 +25,6 @@ parameters:
MailgatewayCustomField: 'array{name: string, label: string, type: string, storeValidator: string, updateValidator: string, default: string}' MailgatewayCustomField: 'array{name: string, label: string, type: string, storeValidator: string, updateValidator: string, default: string}'
MailgatewayParsedCustomField: 'array{name: string, label: string, type: string, storeValidator: string, updateValidator: string, default: string, is_required: bool}' MailgatewayParsedCustomField: 'array{name: string, label: string, type: string, storeValidator: string, updateValidator: string, default: string, is_required: bool}'
SluggableConfig: 'array<string, array{source: array<int, string>}>' SluggableConfig: 'array<string, array{source: array<int, string>}>'
AddressBookCard: 'array{lastmodified: int, etag: string, uri: string, id: int, size: int}'
ignoreErrors: ignoreErrors:
- -
@ -33,6 +32,11 @@ parameters:
count: 1 count: 1
path: app/Activity.php path: app/Activity.php
-
message: "#^Method App\\\\Dav\\\\AddressBookBackend\\:\\:getCard\\(\\) should return M of array\\{lastmodified\\: int, etag\\: string, uri\\: string, id\\: int, size\\: int\\} but returns false\\.$#"
count: 1
path: app/Dav/AddressBookBackend.php
- -
message: "#^Method App\\\\Dav\\\\AddressBookBackend\\:\\:getMultipleCards\\(\\) has parameter \\$uris with no value type specified in iterable type array\\.$#" message: "#^Method App\\\\Dav\\\\AddressBookBackend\\:\\:getMultipleCards\\(\\) has parameter \\$uris with no value type specified in iterable type array\\.$#"
count: 1 count: 1
@ -158,6 +162,17 @@ parameters:
count: 1 count: 1
path: database/factories/NationalityFactory.php path: database/factories/NationalityFactory.php
-
message: "#^Call to an undefined method Phake\\\\Proxies\\\\StubberProxy.*#"
-
message: "#^Call to an undefined method Phake\\\\Proxies\\\\VerifierProxy.*#"
-
message: "#^PHPDoc tag @param has invalid value \\(\\<class\\-string\\> \\$class\\)\\: Unexpected token \"\\<\", expected type at offset 18$#"
count: 1
path: tests/TestCase.php
- -
message: "#^Parameter \\#1 \\$api of class App\\\\Initialize\\\\InitializeGroups constructor expects Zoomyboy\\\\LaravelNami\\\\Api, PHPUnit\\\\Framework\\\\MockObject\\\\Stub given\\.$#" message: "#^Parameter \\#1 \\$api of class App\\\\Initialize\\\\InitializeGroups constructor expects Zoomyboy\\\\LaravelNami\\\\Api, PHPUnit\\\\Framework\\\\MockObject\\\\Stub given\\.$#"
count: 6 count: 6
@ -448,6 +463,16 @@ parameters:
count: 1 count: 1
path: tests/Feature/Member/DavTest.php path: tests/Feature/Member/DavTest.php
-
message: "#^Return type of call to method Illuminate\\\\Support\\\\Collection\\<int,class\\-string\\<App\\\\Contribution\\\\Documents\\\\ContributionDocument\\>\\>\\:\\:map\\(\\) contains unresolvable type\\.$#"
count: 1
path: app/Contribution/ContributionFactory.php
-
message: "#^Return type of call to method Illuminate\\\\Support\\\\Collection\\<int,class\\-string\\<App\\\\Setting\\\\LocalSettings\\>\\>\\:\\:map\\(\\) contains unresolvable type\\.$#"
count: 1
path: app/Setting/SettingFactory.php
- -
message: "#^Access to an undefined property Illuminate\\\\Database\\\\Eloquent\\\\Model\\:\\:\\$email\\.$#" message: "#^Access to an undefined property Illuminate\\\\Database\\\\Eloquent\\\\Model\\:\\:\\$email\\.$#"
count: 2 count: 2
@ -517,53 +542,3 @@ parameters:
message: "#^Unable to resolve the template type TValue in call to function collect$#" message: "#^Unable to resolve the template type TValue in call to function collect$#"
count: 1 count: 1
path: app/Form/Fields/NamiField.php path: app/Form/Fields/NamiField.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, string\\>\\.$#"
count: 1
path: app/Fileshare/ConnectionTypes/ConnectionType.php
-
message: "#^Call to an undefined method Phake\\\\Proxies\\\\StubberProxy\\:\\:check\\(\\)\\.$#"
count: 1
path: tests/Feature/Mailgateway/IndexTest.php
-
message: "#^Call to an undefined method Phake\\\\Proxies\\\\StubberProxy\\:\\:setCredentials\\(\\)\\.$#"
count: 1
path: tests/Feature/Mailgateway/IndexTest.php
-
message: "#^Call to an undefined method Phake\\\\Proxies\\\\StubberProxy\\:\\:check\\(\\)\\.$#"
count: 2
path: tests/Feature/Mailgateway/MailmanTypeTest.php
-
message: "#^Call to an undefined method Phake\\\\Proxies\\\\StubberProxy\\:\\:setCredentials\\(\\)\\.$#"
count: 2
path: tests/Feature/Mailgateway/MailmanTypeTest.php
-
message: "#^Call to an undefined method Phake\\\\Proxies\\\\StubberProxy\\:\\:setOwner\\(\\)\\.$#"
count: 1
path: tests/Feature/Mailgateway/MailmanTypeTest.php
-
message: "#^Call to an undefined method Phake\\\\Proxies\\\\StubberProxy\\:\\:setOwner\\(\\)\\.$#"
count: 2
path: tests/Feature/Mailgateway/StoreTest.php
-
message: "#^Call to an undefined method Phake\\\\Proxies\\\\StubberProxy\\:\\:setParams\\(\\)\\.$#"
count: 3
path: tests/Feature/Mailgateway/StoreTest.php
-
message: "#^Call to an undefined method Phake\\\\Proxies\\\\StubberProxy\\:\\:works\\(\\)\\.$#"
count: 3
path: tests/Feature/Mailgateway/StoreTest.php
-
message: "#^Call to an undefined method Phake\\\\Proxies\\\\VerifierProxy\\:\\:handle\\(\\)\\.$#"
count: 2
path: tests/Feature/Member/NamiPutMemberActionTest.php

View File

@ -64,17 +64,4 @@ class FileshareFilesActionTest extends FileshareTestCase
->assertJsonPath('data.0.path', '/lala/dd/ee') ->assertJsonPath('data.0.path', '/lala/dd/ee')
->assertJsonPath('data.0.parent', '/lala/dd'); ->assertJsonPath('data.0.parent', '/lala/dd');
} }
public function testItGetsFilesWithDot(): void
{
$this->withoutExceptionHandling()->login()->loginNami()->withOwncloudUser('badenpowell', 'secret')
->withDirs('badenpowell', ['/1. aa']);
$connection = Fileshare::factory()
->type(OwncloudConnection::from(['user' => 'badenpowell', 'password' => 'secret', 'base_url' => env('TEST_OWNCLOUD_DOMAIN')]))
->create();
$this->postJson(route('api.fileshare.files', ['fileshare' => $connection]), ['parent' => '/'])
->assertJsonPath('data.0.name', '1. aa');
}
} }

View File

@ -93,8 +93,7 @@ abstract class TestCase extends BaseTestCase
} }
/** /**
* @template M of object * @param <class-string> $class
* @param class-string<M> $class
*/ */
public function stubIo(string $class, callable $mocker): self public function stubIo(string $class, callable $mocker): self
{ {

View File

@ -10,7 +10,7 @@ use Symfony\Component\HttpFoundation\File\File;
* @method self assertPdfPageCount(int $count) * @method self assertPdfPageCount(int $count)
* @method self assertPdfName(string $filename) * @method self assertPdfName(string $filename)
* @method self assertHasJsonPath(string $path) * @method self assertHasJsonPath(string $path)
* @method self assertComponent(string $component) * @method self assertComponnet(string $component)
* @method File getFile() * @method File getFile()
*/ */
class TestResponse class TestResponse