Hi!
These changes look valid to me, nice catch :+1: : )
Sadly the CI doesn't run anymore, which seems not related to your changes.
Hi all and thanks for this great tool!
Run into a little thing with enums
and string
s
Minimal example:
<?php
namespace App\Bar;
enum Foo: string
{
case A = 'B';
}
$enum = 'App\Bar\Foo';
/** @var \BackedEnum $x */
$x = $enum::tryFrom('B');
echo $x->value;
https://psalm.dev/r/7fdff8e8eb
will tell String cannot be used as a class
on line 13, however it works fine in PHP :)
this also happens for cases like $someEnumString::cases()
thanks for the fast reply :+1: I'll refactor : )
Hi all and thanks for this great tool!
Run into a little thing with enums
and string
s
Minimal example:
<?php
namespace App\Bar;
enum Foo: string
{
case A = 'B';
}
$enum = 'App\Bar\Foo';
/** @var \BackedEnum $x */
$x = $enum::tryFrom('B');
echo $x->value;
https://psalm.dev/r/7fdff8e8eb
will tell String cannot be used as a class
on line 13, however it works fine in PHP :)
this also happens for cases like $someEnumString::cases()
I've no plans picking this one up anytime soon sadly. So if anyone else wants to pick it up would be great, :+1: might be wise to discuss the expected behavior with maintainers first before putting time in it.
I haven't checked anything for a long time so I cannot say what the state is of https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/pull/6629 If you are up for it, please have a look @Wirone :) but also, feel free to start from scratch, what ever works best for you :+1:
nice one @Wirone :+1: :tada:
I wouldn't increase the scope of the library with output formatters.
The lib creates strings in the well known/documented diff
format, this should allow any to process the output and apply what ever operation on it (like adding console coloring and sending it to the console).
Hi all!
Thanks for the great tool :)
I've run in a little thingy related to array_walk
and references
.
Consider this code:
<?php declare(strict_types = 1);
/**
* @return array<
* array{
* "guid": string
* }
* >
*/
function foo(): array
{
$a = [1 ,2 ,3];
$b = $a;
array_walk(
$b,
static fn(int &$x): array => $x = ['guid' => 'foo'],
);
return $b;
}
$z = foo();
var_dump($z);
die;
reports:
19 | Function foo() should return array<array{guid: string}> but returns array{1, 2, 3}.
https://phpstan.org/r/c5281446-f880-4f85-9e65-97c6a89f1d8f
I wasn't expecting this.
Yes, PHPStan is one of our most reliable reviewers in a bunch of projects, very busy bee! : D
it is all here https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/pull/6624 , if anyone is interested in finishing it