Skip to main content
2 votes
1 answer
46 views

I'm trying to define a Laravel Eloquent model with a custom scope that filters categories by a related product's vendor_id. Here's my setup: class Category extends Model { public function ...
melkmeshi's user avatar
3 votes
1 answer
101 views

I migrated project from PHP 7.4 to 8.3. I have left with 1 error in rector that I am not able to solve. $namesArray = explode($separator, $names); $namesArray = explode($separator, (string) $...
tttpapi's user avatar
  • 939
2 votes
1 answer
102 views

I'm writing a custom PHPStan rule that suggests marking a class as readonly (introduced in PHP 8.2) when it meets all the necessary conditions. One of the requirements for safely applying readonly is ...
zeroSal's user avatar
  • 131
1 vote
1 answer
191 views

Here's the code: <?php declare(strict_types=1); /** * @param array{key?: string} $options */ function hello($options) { var_dump($options); } hello([ 'WRONG_KEY' => '...', ]); I ...
Limon Monte's user avatar
  • 54.8k
0 votes
2 answers
78 views

PHPstan seems to incorrectly narrow type after if (empty(...)). \PHPStan\dumpType($_GET); // array<mixed> if (empty($_GET['ssid'])) { /* do nothing */ } \PHPStan\dumpType($_GET); // non-...
Roman Hocke's user avatar
  • 4,241
0 votes
2 answers
91 views

I've got various instances of code, building options for a dropdown dynamically with a preceding empty field: return State::all() ->map(fn (State $state) => (object) [ ...
Rikaelus's user avatar
  • 627
1 vote
1 answer
129 views

My question to get code completion working in a set of classes that I have. + abstract Model :: make(array{...}) +- SubModel +- AnotherSubModel +- ... I have an abstract Model class, and ...
Andrew Steenbuck's user avatar
0 votes
1 answer
300 views

I do not understand why phpstan (at level 9+) flags the concrete factory's makeCollection method (the last class) as returning Collection. <?php declare (strict_types=1); /** * @template ...
Doug Wilbourne's user avatar
1 vote
1 answer
102 views

I need to run tests on a certain class, but adding a method that was not originally present. Previously this need could be satisfied using MockBuilder::addMethods(), but this method has been ...
Mirko Pagliai's user avatar
0 votes
1 answer
306 views

I'm registering a custom Carbon macro in my Laravel's AppServiceProvider Carbon::macro('itFormat', static function () { return ucwords(self::this()->translatedFormat('l d/m/Y')); }); But ...
madbob's user avatar
  • 660
1 vote
1 answer
967 views

I want to annotate function, tat takes array with at least key "a" and returns the same array shape with newly added key "x". I tried using type intersection like this: /** * @...
Roman Hocke's user avatar
  • 4,241
0 votes
1 answer
101 views

I wrote a custom PHPStan rule, and a test for it. The test analyses a sample PHP class: class CustomRuleTestData { public function hasViolations() { // } public function ...
Zakaria's user avatar
  • 4,776
2 votes
0 answers
158 views

Json-like structures are quite common in php applications that deal some sort of json api. The precise type of such a structure is recursive: /** * @return null|scalar|array< null|scalar|array< ...
linepogl's user avatar
  • 9,385
1 vote
0 answers
105 views

PHPStan is not recognizing my type specification in my docblock preceeding a method. Here's the code: /** * Process (resize and save) all versions of an uploaded file * * @param UploadedFileInterface ...
Quasipickle's user avatar
  • 4,530
2 votes
1 answer
676 views

I am using larastan 3.0 with laravel. The level is 9. In this code : return view('auth.change-password', [ 'user' => $user, ]); I have this error : Parameter #1 $view of function view ...
Dom's user avatar
  • 3,506

15 30 50 per page
1
2 3 4 5
15