File tree Expand file tree Collapse file tree 2 files changed +84
-0
lines changed Expand file tree Collapse file tree 2 files changed +84
-0
lines changed Original file line number Diff line number Diff line change @@ -116,3 +116,14 @@ function logger($message = null, array $context = [])
116116
117117 return app('log')->debug($message, $context);
118118}
119+
120+ /**
121+ * Get / set the specified configuration value.
122+ *
123+ * If an array is passed as the key, we will assume you want to set an array of values.
124+ *
125+ * @param array<string, mixed>|string|null $key
126+ * @param mixed $default
127+ * @return ($key is null ? \Illuminate\Config\Repository : ($key is array ? null : mixed))
128+ */
129+ function config($key = null, $default = null) {}
Original file line number Diff line number Diff line change 1+ Feature : Config helper
2+ The global config helper will return a strict type
3+
4+ Background :
5+ Given I have the following config
6+ """
7+ <?xml version="1.0"?>
8+ <psalm errorLevel="1">
9+ <projectFiles>
10+ <directory name="."/>
11+ <ignoreFiles> <directory name="../../vendor"/> </ignoreFiles>
12+ </projectFiles>
13+ <plugins>
14+ <pluginClass class="Psalm\LaravelPlugin\Plugin"/>
15+ </plugins>
16+ </psalm>
17+ """
18+ And I have the following code preamble
19+ """
20+ <?php declare(strict_types=1);
21+ """
22+
23+ Scenario : config with no arguments returns a repository instance
24+ Given I have the following code
25+ """
26+ function test(): \Illuminate\Config\Repository {
27+ return config();
28+ }
29+ """
30+ When I run Psalm
31+ Then I see no errors
32+
33+ Scenario : config with one argument
34+ Given I have the following code
35+ """
36+ /**
37+ * @return mixed
38+ */
39+ function test()
40+ {
41+ return config('app.name');
42+ }
43+ """
44+ When I run Psalm
45+ Then I see no errors
46+
47+ Scenario : config with first null argument and second argument provided
48+ Given I have the following code
49+ """
50+ /**
51+ * @return mixed
52+ */
53+ function test()
54+ {
55+ return config('app.non-existent', false);
56+ }
57+ """
58+ When I run Psalm
59+ Then I see no errors
60+
61+ Scenario : config setting at runtime
62+ Given I have the following code
63+ """
64+ /**
65+ * @return null
66+ */
67+ function test()
68+ {
69+ return config(['app.non-existent' => false]);
70+ }
71+ """
72+ When I run Psalm
73+ Then I see no errors
You can’t perform that action at this time.
0 commit comments