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
MixedArgument for checked second array offset in 3.11.0 #3128
Labels
Comments
I found these snippets: https://psalm.dev/r/2284b270fa<?php
/**
* @todo psalm-immutable
*/
final class StudyJwtPayload
{
public const USER_ID = 'usrid';
public const STUDY_ID = 'studid';
public string $userId;
public string $studyId;
public function __construct(string $userId, string $studyId)
{
$this->userId = $userId;
$this->studyId = $studyId;
}
public static function fromClaims(array $claims): self
{
if (!isset($claims[self::USER_ID])) {
throw new \InvalidArgumentException();
}
if (!\is_string($claims[self::USER_ID])) {
throw new \InvalidArgumentException();
}
if (!isset($claims[self::STUDY_ID])) {
throw new \InvalidArgumentException();
}
if (!\is_string($claims[self::STUDY_ID])) {
throw new \InvalidArgumentException();
}
return new self($claims[self::USER_ID], $claims[self::STUDY_ID]);
}
}
|
vudaltsov
changed the title
MixedArgument for checked second array offset
MixedArgument for checked second array offset in 3.11.0
Apr 12, 2020
It's an issue with class constant offsets – explicit strings work fine: https://psalm.dev/r/772d804019 |
I found these snippets: https://psalm.dev/r/772d804019<?php
/**
* @todo psalm-immutable
*/
final class StudyJwtPayload
{
public const USER_ID = 'usrid';
public const STUDY_ID = 'studid';
public string $userId;
public string $studyId;
public function __construct(string $userId, string $studyId)
{
$this->userId = $userId;
$this->studyId = $studyId;
}
public static function fromClaims(array $claims): self
{
if (!isset($claims['usrid'])) {
throw new \InvalidArgumentException();
}
if (!\is_string($claims['usrid'])) {
throw new \InvalidArgumentException();
}
if (!isset($claims['studid'])) {
throw new \InvalidArgumentException();
}
if (!\is_string($claims['studid'])) {
throw new \InvalidArgumentException();
}
return new self($claims['usrid'], $claims['studid']);
}
}
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://psalm.dev/r/2284b270fa
The strange thing about this case is that the first array offset passes.
The text was updated successfully, but these errors were encountered: