Skip to content

Commit 3559d86

Browse files
huangdijiaCopilot
andcommitted
feat: Add PHPStan type testing (#970)
* feat: add PHPStan type checking configuration and composer script Add PHPStan configuration for type assertion testing and a new composer script for running type checks. This includes: - New phpstan.types.neon.dist configuration file for type checking - New types/ directory with helper function type assertions - New composer script 'check:types' for running type analysis This enhancement allows developers to validate type assertions for helper functions and ensure type safety across the codebase. * Add comprehensive PHPStan type tests for all helper functions (#971) * Initial plan * feat: add comprehensive type tests for all helper functions Co-authored-by: huangdijia <8337659+huangdijia@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: huangdijia <8337659+huangdijia@users.noreply.github.com> * Move call() tests to Functions.php and update type assertions Deleted Command/Functions.php and moved its call() tests to Helpers/Functions.php. Updated type assertions and test cases in Helpers/Functions.php for improved accuracy and consistency with current return types. Co-Authored-By: Deeka Wong <8337659+huangdijia@users.noreply.github.com> * fix: remove unnecessary backslash from Throwable type hint in dispatch job * refactor: rename check:types script to type-testing for clarity * fix: move type-testing script to the correct position in composer.json * fix: remove unnecessary blank line before type-testing script in composer.json * feat: add Support.php with various utility classes and type assertions * fix: add return type hints for __invoke methods in ClientBuilderFactory and HubFactory * feat: add PHPStan type assertion tests for macros component (#973) * Initial plan * feat: add type assertion tests for macros component Co-authored-by: huangdijia <8337659+huangdijia@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: huangdijia <8337659+huangdijia@users.noreply.github.com> * feat: add PHPStan type testing for cache component (#972) * Initial plan * feat: add comprehensive type testing for cache component Co-authored-by: huangdijia <8337659+huangdijia@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: huangdijia <8337659+huangdijia@users.noreply.github.com> * fix: remove unused imports in Cache and Macros components * feat: update PHPStan configuration and enhance type assertions in various components * fix: update parameter type hint for Str::of method * fix: remove unused Factory method tests in Cache Manager * feat: add type testing step in CI workflow * fix: comment out unused setMultiple tests in Repository * fix: comment out unused getMultiple tests in Repository --------- Co-Authored-By: Deeka Wong <8337659+huangdijia@users.noreply.github.com> Co-Authored-By: Copilot <198982749+Copilot@users.noreply.github.com>
1 parent 3ed5d63 commit 3559d86

5 files changed

Lines changed: 383 additions & 2 deletions

File tree

output/Hyperf/Collection/Collection.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@
1313

1414
class Collection
1515
{
16+
/**
17+
* Create a new collection.
18+
*
19+
* @param mixed $items
20+
*/
21+
public function __construct($items = [])
22+
{
23+
}
24+
1625
/**
1726
* Collapse the collection of items into a single array while preserving its keys.
1827
*

output/Hyperf/Collection/LazyCollection.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,24 @@
1313

1414
class LazyCollection
1515
{
16+
/**
17+
* Create a new lazy collection instance.
18+
*
19+
* @param mixed $items
20+
* @return static
21+
*/
22+
public static function make($items = [])
23+
{
24+
}
25+
26+
/**
27+
* Determine if the collection contains a single element.
28+
* @return bool
29+
*/
30+
public function isSingle()
31+
{
32+
}
33+
1634
/**
1735
* Collapse the collection of items into a single array while preserving its keys.
1836
*
Lines changed: 302 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,302 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
/**
5+
* This file is part of friendsofhyperf/components.
6+
*
7+
* @link https://github.com/friendsofhyperf/components
8+
* @document https://github.com/friendsofhyperf/components/blob/main/README.md
9+
* @contact huangdijia@gmail.com
10+
*/
11+
12+
namespace Hyperf\HttpServer;
13+
14+
use Closure;
15+
use Hyperf\Support\Fluent;
16+
use Psr\Http\Message\ServerRequestInterface;
17+
18+
class Request
19+
{
20+
/**
21+
* Get an array of all of the files on the request.
22+
*/
23+
public function allFiles(): array
24+
{
25+
}
26+
27+
/**
28+
* Determine if the request contains a non-empty value for any of the given inputs.
29+
*
30+
* @param array|string $keys
31+
*/
32+
public function anyFilled($keys): bool
33+
{
34+
}
35+
36+
/**
37+
* Retrieve input as a boolean value.
38+
*
39+
* Returns true when value is "1", "true", "on", and "yes". Otherwise, returns false.
40+
*
41+
* @param null|string $key
42+
* @param bool $default
43+
*/
44+
public function boolean($key = null, $default = false): bool
45+
{
46+
}
47+
48+
/**
49+
* Retrieve input from the request as a collection.
50+
*/
51+
public function collect(null|array|string $key = null): \Hyperf\Collection\Collection
52+
{
53+
}
54+
55+
/**
56+
* Retrieve input from the request as a Carbon instance.
57+
*/
58+
public function date(string $key, ?string $format = null, ?string $tz = null): ?\Carbon\Carbon
59+
{
60+
}
61+
62+
/**
63+
* Get all of the input except for a specified array of items.
64+
*
65+
* @param array|mixed $keys
66+
*/
67+
public function except($keys): array
68+
{
69+
}
70+
71+
/**
72+
* @param null|Closure(ServerRequestInterface):ServerRequestInterface $closure
73+
*/
74+
public static function fake(?Closure $closure = null): ServerRequestInterface
75+
{
76+
}
77+
78+
/**
79+
* Determine if the request contains a non-empty value for an input item.
80+
*/
81+
public function filled(array|string $key): bool
82+
{
83+
}
84+
85+
public function float(string $key, $default = null): float
86+
{
87+
}
88+
89+
/**
90+
* Retrieve input from the request as a Fluent object instance.
91+
*/
92+
public function fluent(null|array|string $key = null): Fluent
93+
{
94+
}
95+
96+
/**
97+
* Determine if the request contains any of the given inputs.
98+
*/
99+
public function hasAny(array|string $keys): bool
100+
{
101+
}
102+
103+
/**
104+
* Determine if the given input key is an empty string for "has".
105+
*/
106+
public function isEmptyString(string $key): bool
107+
{
108+
}
109+
110+
/**
111+
* Determine if the request contains an empty value for an input item.
112+
*/
113+
public function isNotFilled(array|string $key): bool
114+
{
115+
}
116+
117+
/**
118+
* Get the keys for all of the input and files.
119+
*/
120+
public function keys(): array
121+
{
122+
}
123+
124+
/**
125+
* Get the host name.
126+
*/
127+
public function host(): string
128+
{
129+
}
130+
131+
public function getHost(): string
132+
{
133+
}
134+
135+
/**
136+
* Get the HTTP host being requested.
137+
*/
138+
public function httpHost(): string
139+
{
140+
}
141+
142+
public function getHttpHost(): string
143+
{
144+
}
145+
146+
public function getPort(): int
147+
{
148+
}
149+
150+
public function getPsrRequest(): ?ServerRequestInterface
151+
{
152+
}
153+
154+
public function getScheme(): string
155+
{
156+
}
157+
158+
public function isSecure(): bool
159+
{
160+
}
161+
162+
public function getSchemeAndHttpHost(): string
163+
{
164+
}
165+
166+
/**
167+
* Get the scheme and HTTP host.
168+
*/
169+
public function schemeAndHttpHost(): string
170+
{
171+
}
172+
173+
/**
174+
* Merge new input into the current request's input array.
175+
*
176+
* @return $this
177+
*/
178+
public function merge(array $input): self
179+
{
180+
}
181+
182+
/**
183+
* Merge new input into the request's input, but only when that key is missing from the request.
184+
*
185+
* @return $this
186+
*/
187+
public function mergeIfMissing(array $input): self
188+
{
189+
}
190+
191+
/**
192+
* Determine if the request is missing a given input item key.
193+
*
194+
* @param array|string $key
195+
*/
196+
public function missing($key): bool
197+
{
198+
}
199+
200+
/**
201+
* Get a subset containing the provided keys with values from the input data.
202+
*
203+
* @param array|mixed $keys
204+
*/
205+
public function only($keys): array
206+
{
207+
}
208+
209+
/**
210+
* Determine if the current request is asking for JSON.
211+
*/
212+
public function wantsJson(): bool
213+
{
214+
}
215+
216+
/**
217+
* Apply the callback if the request contains a non-empty value for the given input item key.
218+
*
219+
* @return $this|mixed
220+
*/
221+
public function whenFilled(string $key, callable $callback, ?callable $default = null)
222+
{
223+
}
224+
225+
/**
226+
* Apply the callback if the request contains the given input item key.
227+
*
228+
* @return $this|mixed
229+
*/
230+
public function whenHas(string $key, callable $callback, ?callable $default = null)
231+
{
232+
}
233+
234+
/**
235+
* Determine if the request is sending JSON.
236+
*/
237+
public function isJson(): bool
238+
{
239+
}
240+
241+
/**
242+
* Retrieve input from the request as an enum.
243+
*
244+
* @template TEnum
245+
*
246+
* @param string $key
247+
* @param class-string<TEnum> $enumClass
248+
* @return null|TEnum
249+
*/
250+
public function enum($key, $enumClass)
251+
{
252+
}
253+
254+
/**
255+
* Determine if the request contains a given input item key.
256+
*
257+
* @param array|string $key
258+
*/
259+
public function exists($key): bool
260+
{
261+
}
262+
263+
/**
264+
* Retrieve input from the request as a Stringable instance.
265+
*
266+
* @param string $key
267+
* @param mixed $default
268+
* @return \Hyperf\Stringable\Stringable
269+
*/
270+
public function str($key, $default = null)
271+
{
272+
}
273+
274+
/**
275+
* Retrieve input from the request as a Stringable instance.
276+
*
277+
* @param string $key
278+
* @param mixed $default
279+
* @return \Hyperf\Stringable\Stringable
280+
*/
281+
public function string($key, $default = null)
282+
{
283+
}
284+
285+
/**
286+
* Retrieve input as an integer value.
287+
*
288+
* @param string $key
289+
* @param int $default
290+
*/
291+
public function integer($key, $default = 0): int
292+
{
293+
}
294+
295+
public function validate(array $rules, array $messages = [], array $customAttributes = []): array
296+
{
297+
}
298+
299+
public function validateWithBag(string $errorBag, array $rules, array $messages = [], array $customAttributes = []): array
300+
{
301+
}
302+
}

0 commit comments

Comments
 (0)