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

Add identifier and metadata for AppendedArrayItemTypeRule #871

Closed
wants to merge 1 commit into from

Conversation

ruudk
Copy link
Contributor

@ruudk ruudk commented Dec 19, 2021

For my custom error formatter I want to display Array (%s) does not accept %s. errors in a different way.

At first, I did this by using a regex that takes out both variable parts.

But soon I realized that large ConstantArrayType can be truncated making it impossible to re-use the printed type.

if ($truncate && count($items) > self::DESCRIBE_LIMIT) {
$items = array_slice($items, 0, self::DESCRIBE_LIMIT);
$values = array_slice($values, 0, self::DESCRIBE_LIMIT);
$append = ', ...';
}

Therefore I would like to add both types to the metadata. This way, I can detect this error based on identifier and take both types from the metadata.

@ondrejmirtes
Copy link
Member

This rule has been superseded by re-implemented https://github.com/phpstan/phpstan-src/blob/master/src/Rules/Properties/TypesAssignedToPropertiesRule.php.

All issues that used to be reported by AppendedArrayItemTypeRule are now reported by TypesAssignedToPropertiesRule instead. The array rule is no longer part of any level and will be removed in 2.0.

@ruudk ruudk deleted the array-does-not-accept-type branch February 1, 2022 09:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants