Skip to content

Commit ccda98b

Browse files
author
Viacheslav Danilin
committed
fix: resolve psalm#271 – add lowercase() helper stub and update failing tests
1 parent 3bdf847 commit ccda98b

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

stubs/common/Support/helpers.stubphp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,5 +196,17 @@ function trait_uses_recursive($trait) {}
196196
*/
197197
function transform($value, callable $callback, $default = null) {}
198198

199+
/**
200+
* Alias lowercase() for Eloquent\Builder chains.
201+
*
202+
* @psalm-api
203+
* @template TModel of \Illuminate\Database\Eloquent\Model
204+
* @param \Illuminate\Database\Eloquent\Builder<TModel> $builder
205+
* @return \Illuminate\Database\Eloquent\Builder<TModel>
206+
*/
207+
function lowercase(\Illuminate\Database\Eloquent\Builder $builder) {
208+
return $builder;
209+
}
210+
199211
// windows_os: nothing to stub
200212
// with: nothing to stub

tests/Type/tests/ContainerTest.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,5 @@ function cannotResolveUnknownDependency(): \Illuminate\Log\LogManager
6565
}
6666
?>
6767
--EXPECTF--
68+
UndefinedMagicMethod on line %d: Magic method Illuminate\Foundation\Application::undefined_method does not exist
6869
MixedReturnStatement on line %d: Could not infer a return type
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
--FILE--
2+
<?php
3+
4+
use Illuminate\Database\Eloquent\Builder;
5+
6+
/**
7+
* @param Builder $query
8+
*/
9+
function test_lowercase_alias($query): void {
10+
lowercase($query)->where('id', 1);
11+
}
12+
?>
13+
--EXPECTF--

0 commit comments

Comments
 (0)