Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update master from 5.x #10683

Closed
wants to merge 54 commits into from
Closed

Update master from 5.x #10683

wants to merge 54 commits into from

Conversation

weirdan
Copy link
Collaborator

@weirdan weirdan commented Feb 9, 2024

No description provided.

weirdan and others added 30 commits January 29, 2024 22:42
Before this change, calling:
```php
$classlikes->hasFullyQualifiedInterfaceName($i); // true
$classlikes->hasFullyQualifiedClassName($i); // false
$classlikes->hasFullyQualifiedInterfaceName($i); // false
```
would result in the last call returning `false`
Resolves a number of long-standing bugs ('Failed to infer case value ...')

Fixes vimeo#10374
Fixes vimeo#10560
Fixes vimeo#10643
Fixes vimeo#8978
weirdan and others added 23 commits February 6, 2024 01:24
List fail tests:

```
1) testMethodAnnotation with data set "static (string|int)[] getArray()"
Undefined array key 0

/workspaces/psalm/tests/ClassLikeDocblockParserTest.php:201

2) testMethodAnnotation with data set "static (callable() : string) getCallable()"
Undefined array key 0

/workspaces/psalm/tests/ClassLikeDocblockParserTest.php:201
```
Fix parsing for code:

```
/**
 * @method static (string|int)[] getArray()
 * @method static (callable() : string) getCallable()
 */
class MyClass {}
```

Resolved tests:

```
1) testMethodAnnotation with data set "static (string|int)[] getArray()"
2) testMethodAnnotation with data set "static (callable() : string) getCallable()"
```
Revert partial mistakenly pushed fix
ReflectionParameter::getPosition() is non-negative-int.
ReflectionMethod name property is always non-empty-string.
ReflectionAttribute::getTarget() returns Attribute::TARGET_* instead of int-mask. Even for attributes of promoted properties (https://3v4l.org/rpM1t).
*::getAttributes() always returns a list (https://3v4l.org/LYAMb).
@weirdan weirdan added the release:internal The PR will be included in 'Internal changes' section of the release notes label Feb 9, 2024
@weirdan weirdan requested review from danog and orklah February 9, 2024 22:34
Copy link

I found these snippets:

https://psalm.dev/r/edaea88e00
<?php

interface ObjectManager
{
    public function getClassMetadata(string $className): int;
}

/**
 * @method stdClass getClassMetadata(int $a)
 */
interface EntityManagerInterface extends ObjectManager
{
}


function (EntityManagerInterface $em): void
{
    $result = $em->getClassMetadata(stdClass::class);
    /** @psalm-trace $result */;
    $em->getClassMetadata('hello');
};
Psalm output (using commit 4b2c698):

INFO: Trace - 19:32 - $result: stdClass

INFO: UnusedVariable - 18:5 - $result is never referenced or the value is not used

ERROR: ImplementedReturnTypeMismatch - 9:12 - The inherited return type 'int' for ObjectManager::getClassMetadata is different to the implemented return type for ObjectManager::getclassmetadata 'stdClass'

ERROR: ImplementedParamTypeMismatch - 9:12 - Argument 1 of EntityManagerInterface::getClassMetadata has wrong type 'int', expecting 'string' as defined by ObjectManager::getClassMetadata

@weirdan weirdan changed the base branch from 5.x to master February 9, 2024 22:35
@weirdan
Copy link
Collaborator Author

weirdan commented Feb 9, 2024

Nope, this doesn't look right

@weirdan weirdan closed this Feb 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release:internal The PR will be included in 'Internal changes' section of the release notes
Projects
None yet
8 participants