File: Fluent.php

package info (click to toggle)
php-laravel-framework 10.48.29%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 19,188 kB
  • sloc: php: 232,347; sh: 167; makefile: 46
file content (22 lines) | stat: -rw-r--r-- 1,045 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?php

use Illuminate\Support\Fluent;

use function PHPStan\Testing\assertType;

$fluent = new Fluent(['name' => 'Taylor', 'age' => 25, 'user' => new User]);

assertType('Illuminate\Support\Fluent<string, int|string|User>', $fluent);
assertType('Illuminate\Support\Fluent<string, string>', new Fluent(['name' => 'Taylor']));
assertType('Illuminate\Support\Fluent<string, int>', new Fluent(['age' => 25]));
assertType('Illuminate\Support\Fluent<string, User>', new Fluent(['user' => new User]));

assertType('int|string|User|null', $fluent['name']);
assertType('int|string|User|null', $fluent['age']);
assertType('int|string|User|null', $fluent['age']);
assertType('int|string|User|null', $fluent->get('name'));
assertType('int|string|User|null', $fluent->get('foobar'));
assertType('int|string|User', $fluent->get('foobar', 'zonda'));
assertType('array<string, int|string|User>', $fluent->getAttributes());
assertType('array<string, int|string|User>', $fluent->toArray());
assertType('array<string, int|string|User>', $fluent->jsonSerialize());