Skip to content

Conversation

@staabm
Copy link
Contributor

@staabm staabm commented Jan 15, 2026

@staabm
Copy link
Contributor Author

staabm commented Jan 15, 2026

hmm alternatively it could be the other way arround. adding non-empty-array to the array when array_key_exists()

@staabm
Copy link
Contributor Author

staabm commented Jan 16, 2026

stumbled over #3937 today .. need to have another look

ok, I think its fine.

@staabm staabm marked this pull request as draft January 16, 2026 14:03
@staabm staabm marked this pull request as ready for review January 16, 2026 14:39
@phpstan-bot
Copy link
Collaborator

This pull request has been marked as ready for review.

public function accepts(Type $type, bool $strictTypes): AcceptsResult
{
if ($type instanceof CompoundType) {
return $type->isAcceptedBy($this, $strictTypes);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this. All Accessory types do this. So it has to stay.

But you can do another condition before this one, like AccessoryNonEmptyStringType does:

	public function accepts(Type $type, bool $strictTypes): AcceptsResult
	{
		if ($type->isNonEmptyString()->yes()) {
			return AcceptsResult::createYes();
		}
		if ($type instanceof CompoundType) {
			return $type->isAcceptedBy($this, $strictTypes);
		}

		return new AcceptsResult($type->isNonEmptyString(), []);
	}

You can also try doing the same thing (call related method before instanceof CompoundType) in other Accessory types so they all still look the same..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

non-empty-array&hasOffset has unexpected type compatiiblity

3 participants