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

FN: Append item to property is not checked #2689

Closed
adaamz opened this issue Dec 7, 2019 · 6 comments
Closed

FN: Append item to property is not checked #2689

adaamz opened this issue Dec 7, 2019 · 6 comments
Labels
Milestone

Comments

@adaamz
Copy link
Contributor

adaamz commented Dec 7, 2019

Bug report

Array item appending to typed property is not type checked.

Code snippet that reproduces the problem

https://phpstan.org/r/82a63ef2-cce6-4936-a3d0-37fefc92d524

also when the property is boolean there is "no error" https://phpstan.org/r/b0d411ba-c345-41a5-8a76-f2cea151aa64

Expected output

sth like https://phpstan.org/r/6fca031f-be60-4ff7-855a-af488c5d64b7

@adaamz adaamz changed the title FN: Append item to array is not checked FN: Append item to property is not checked Dec 7, 2019
@ondrejmirtes
Copy link
Member

It's something specific to callables. Feel free to check out what CallableType does. Same for BooleanType.

@adaamz
Copy link
Contributor Author

adaamz commented Dec 7, 2019

I think it is for all types, for example if i want to append sth to int property
https://phpstan.org/r/0d1fe327-fe89-4f93-b0ec-1f1d6a2c50bf

@ondrejmirtes
Copy link
Member

It's not for all the types. See: https://phpstan.org/r/f704bd9e-4ca4-498d-b9f6-0fe8f9a9ab6f

@ondrejmirtes
Copy link
Member

The reason is defiinitely this:

trait MaybeOffsetAccessibleTypeTrait
{

	public function isOffsetAccessible(): TrinaryLogic
	{
		return TrinaryLogic::createMaybe();
	}

	public function hasOffsetValueType(Type $offsetType): TrinaryLogic
	{
		return TrinaryLogic::createMaybe();
	}

	public function getOffsetValueType(Type $offsetType): Type
	{
		return new MixedType();
	}

	public function setOffsetValueType(?Type $offsetType, Type $valueType): Type
	{
		return $this;
	}

}

@ondrejmirtes
Copy link
Member

It should complain that hasOffsetValueType is only maybe but array assignment is weird, it's used for creating new offset.

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 29, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants