Skip to content

Commit eab5077

Browse files
committed
tests: add phar test case
1 parent cba1906 commit eab5077

File tree

3 files changed

+232
-12
lines changed

3 files changed

+232
-12
lines changed

tests/phar/data/absolute_1.out

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ Version main
44
-------------
55

66

7-
Parsing Models\LaravelModel total: 1 error
8-
Parsing IPv4Address total: 1 error
9-
Parsing SuperCoolLibrary\Meta total: 1 error
10-
Parsing Net_Sample total: 3 errors
7+
Parsing Foo\Foo total: 19 errors
8+
Parsing Models\LaravelModel total: 20 errors
9+
Parsing IPv4Address total: 20 errors
10+
Parsing SuperCoolLibrary\Meta total: 20 errors
11+
Parsing Net_Sample total: 22 errors
1112
Parsing done
1213

1314
Rendering Global index.html
@@ -21,20 +22,24 @@ Rendering Global search.html
2122
Rendering Global doctum.js
2223
Rendering Namespace [Global Namespace]
2324
Rendering Namespace Foo
25+
Rendering Namespace Illuminate
26+
Rendering Namespace Illuminate\Database
27+
Rendering Namespace Illuminate\Database\Eloquent
2428
Rendering Namespace Models
2529
Rendering Namespace SuperCoolLibrary
2630
Rendering Class Foo\Foo
2731
Rendering Class IPv4Address
32+
Rendering Class Illuminate\Database\Eloquent\Builder
2833
Rendering Class Models\LaravelModel
2934
Rendering Class Net_Sample
3035
Rendering Class SuperCoolLibrary\Meta
3136
Rendering done
3237

3338

3439
Version Updated C Removed C
35-
main 5 0
40+
main 6 0
3641

3742

3843
Version Updated C Updated N Removed C Removed N
39-
main 5 4 0 0
44+
main 6 7 0 0
4045

tests/phar/data/relative_1.out

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ Version main
44
-------------
55

66

7-
Parsing Models\LaravelModel total: 1 error
8-
Parsing IPv4Address total: 1 error
9-
Parsing SuperCoolLibrary\Meta total: 1 error
10-
Parsing Net_Sample total: 3 errors
7+
Parsing Foo\Foo total: 19 errors
8+
Parsing Models\LaravelModel total: 20 errors
9+
Parsing IPv4Address total: 20 errors
10+
Parsing SuperCoolLibrary\Meta total: 20 errors
11+
Parsing Net_Sample total: 22 errors
1112
Parsing done
1213

1314
Rendering Global index.html
@@ -21,20 +22,24 @@ Rendering Global search.html
2122
Rendering Global doctum.js
2223
Rendering Namespace [Global Namespace]
2324
Rendering Namespace Foo
25+
Rendering Namespace Illuminate
26+
Rendering Namespace Illuminate\Database
27+
Rendering Namespace Illuminate\Database\Eloquent
2428
Rendering Namespace Models
2529
Rendering Namespace SuperCoolLibrary
2630
Rendering Class Foo\Foo
2731
Rendering Class IPv4Address
32+
Rendering Class Illuminate\Database\Eloquent\Builder
2833
Rendering Class Models\LaravelModel
2934
Rendering Class Net_Sample
3035
Rendering Class SuperCoolLibrary\Meta
3136
Rendering done
3237

3338

3439
Version Updated C Removed C
35-
main 5 0
40+
main 6 0
3641

3742

3843
Version Updated C Updated N Removed C Removed N
39-
main 5 4 0 0
44+
main 6 7 0 0
4045

Lines changed: 210 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,210 @@
1+
<?php
2+
3+
namespace Illuminate\Database\Eloquent;
4+
5+
/**
6+
* @template TModelClass of Model
7+
* @source https://github.com/netpok/larastan/blob/master/stubs/EloquentBuilder.stub
8+
* @license MIT
9+
* @copyright Nuno Maduro [email protected]
10+
*/
11+
class Builder
12+
{
13+
/** @phpstan-return TModelClass */
14+
public function getModel();
15+
16+
/**
17+
* @phpstan-param array<model-property<TModelClass>, mixed> $attributes
18+
* @phpstan-return TModelClass
19+
*/
20+
public function create(array $attributes = []);
21+
22+
/**
23+
* Create a collection of models from plain arrays.
24+
*
25+
* @param array<mixed> $items
26+
* @phpstan-return \Illuminate\Database\Eloquent\Collection<TModelClass>
27+
*/
28+
public function hydrate(array $items);
29+
30+
/**
31+
* Create a collection of models from a raw query.
32+
*
33+
* @param string $query
34+
* @param array<mixed> $bindings
35+
* @phpstan-return \Illuminate\Database\Eloquent\Collection<TModelClass>
36+
*/
37+
public function fromQuery($query, $bindings = []);
38+
39+
/**
40+
* Find a model by its primary key.
41+
*
42+
* @param mixed $id
43+
* @param array<int, (model-property<TModelClass>|'*')>|model-property<TModelClass>|'*' $columns
44+
* @phpstan-return TModelClass|\Illuminate\Database\Eloquent\Collection<TModelClass>|null
45+
*/
46+
public function find($id, $columns = ['*']);
47+
48+
/**
49+
* Find multiple models by their primary keys.
50+
*
51+
* @param \Illuminate\Contracts\Support\Arrayable|array<mixed> $ids
52+
* @param array<int, (model-property<TModelClass>|'*')>|model-property<TModelClass>|'*' $columns
53+
* @phpstan-return \Illuminate\Database\Eloquent\Collection<TModelClass>
54+
*/
55+
public function findMany($ids, $columns = ['*']);
56+
57+
/**
58+
* Find a model by its primary key or throw an exception.
59+
*
60+
* @param mixed $id
61+
* @param array<int, (model-property<TModelClass>|'*')>|model-property<TModelClass>|'*' $columns
62+
* @phpstan-return TModelClass|\Illuminate\Database\Eloquent\Collection<TModelClass>
63+
*
64+
* @throws \Illuminate\Database\Eloquent\ModelNotFoundException
65+
*/
66+
public function findOrFail($id, $columns = ['*']);
67+
68+
/**
69+
* Find a model by its primary key or return fresh model instance.
70+
*
71+
* @param mixed $id
72+
* @param array<int, (model-property<TModelClass>|'*')>|model-property<TModelClass>|'*' $columns
73+
* @phpstan-return TModelClass
74+
*/
75+
public function findOrNew($id, $columns = ['*']);
76+
77+
/**
78+
* Get the first record matching the attributes or instantiate it.
79+
*
80+
* @param array<model-property<TModelClass>, mixed> $attributes
81+
* @param array<model-property<TModelClass>, mixed> $values
82+
* @phpstan-return TModelClass
83+
*/
84+
public function firstOrNew(array $attributes = [], array $values = []);
85+
86+
/**
87+
* Get the first record matching the attributes or create it.
88+
*
89+
* @param array<model-property<TModelClass>, mixed> $attributes
90+
* @param array<model-property<TModelClass>, mixed> $values
91+
* @phpstan-return TModelClass
92+
*/
93+
public function firstOrCreate(array $attributes, array $values = []);
94+
95+
/**
96+
* Create or update a record matching the attributes, and fill it with values.
97+
*
98+
* @param array<model-property<TModelClass>, mixed> $attributes
99+
* @param array<model-property<TModelClass>, mixed> $values
100+
* @phpstan-return TModelClass
101+
*/
102+
public function updateOrCreate(array $attributes, array $values = []);
103+
104+
/**
105+
* @param array<model-property<TModelClass>, mixed> $attributes
106+
* @return \Illuminate\Database\Eloquent\Model|$this
107+
*/
108+
public function forceCreate(array $attributes);
109+
110+
/**
111+
* @param array<model-property<TModelClass>, mixed> $values
112+
* @return int
113+
*/
114+
public function update(array $values);
115+
116+
/**
117+
* Execute the query and get the first result or throw an exception.
118+
*
119+
* @param array<int, (model-property<TModelClass>|'*')>|model-property<TModelClass>|'*' $columns
120+
* @phpstan-return TModelClass
121+
*
122+
* @throws \Illuminate\Database\Eloquent\ModelNotFoundException
123+
*/
124+
public function firstOrFail($columns = ['*']);
125+
126+
/**
127+
* Execute the query and get the first result or call a callback.
128+
*
129+
* @param \Closure|array<int, (model-property<TModelClass>|'*')> $columns
130+
* @param \Closure|null $callback
131+
* @phpstan-return TModelClass|mixed
132+
*/
133+
public function firstOr($columns = ['*'], \Closure $callback = null);
134+
135+
/**
136+
* Add a basic where clause to the query.
137+
*
138+
* @param \Closure|model-property<TModelClass>|array<model-property<TModelClass>|int, mixed>|\Illuminate\Database\Query\Expression $column
139+
* @param mixed $operator
140+
* @param mixed $value
141+
* @param string $boolean
142+
* @return $this
143+
*/
144+
public function where($column, $operator = null, $value = null, $boolean = 'and');
145+
146+
/**
147+
* Add an "or where" clause to the query.
148+
*
149+
* @param \Closure|model-property<TModelClass>|array<model-property<TModelClass>|int, mixed>|\Illuminate\Database\Query\Expression $column
150+
* @param mixed $operator
151+
* @param mixed $value
152+
* @return $this
153+
*/
154+
public function orWhere($column, $operator = null, $value = null);
155+
156+
/**
157+
* Add a basic where clause to the query, and return the first result.
158+
*
159+
* @param \Closure|model-property<TModelClass>|array<model-property<TModelClass>|int, mixed>|\Illuminate\Database\Query\Expression $column
160+
* @param mixed $operator
161+
* @param mixed $value
162+
* @param string $boolean
163+
* @phpstan-return TModelClass|null
164+
*/
165+
public function firstWhere($column, $operator = null, $value = null, $boolean = 'and');
166+
167+
/**
168+
* Execute the query as a "select" statement.
169+
*
170+
* @param array<int, (model-property<TModelClass>|'*')>|model-property<TModelClass>|'*' $columns
171+
* @phpstan-return \Illuminate\Database\Eloquent\Collection<TModelClass>
172+
*/
173+
public function get($columns = ['*']);
174+
175+
/**
176+
* Get the hydrated models without eager loading.
177+
*
178+
* @param array<int, (model-property<TModelClass>|'*')>|model-property<TModelClass>|'*' $columns
179+
* @phpstan-return TModelClass[]
180+
*/
181+
public function getModels($columns = ['*']);
182+
183+
/**
184+
* Get a single column's value from the first result of a query.
185+
*
186+
* @param model-property<TModelClass>|\Illuminate\Database\Query\Expression $column
187+
* @return mixed
188+
*/
189+
public function value($column);
190+
191+
/**
192+
* Apply the callback's query changes if the given "value" is true.
193+
*
194+
* @param mixed $value
195+
* @param callable($this, mixed): null|Builder<TModelClass> $callback
196+
* @param callable($this, mixed): null|Builder<TModelClass>|null $default
197+
* @return mixed|$this
198+
*/
199+
public function when($value, $callback, $default = null);
200+
201+
/**
202+
* Apply the callback's query changes if the given "value" is false.
203+
*
204+
* @param mixed $value
205+
* @param callable($this, mixed): null|Builder<TModelClass> $callback
206+
* @param callable($this, mixed): null|Builder<TModelClass>|null $default
207+
* @return mixed|$this
208+
*/
209+
public function unless($value, $callback, $default = null);
210+
}

0 commit comments

Comments
 (0)