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

Improve PHPDoc types in Cluster #2109

Open
wants to merge 1 commit into
base: 8.x
Choose a base branch
from

Conversation

franmomu
Copy link
Contributor

@franmomu franmomu commented Aug 5, 2022

In order to reach PHPStan level 6, we need to specify iterable types, in this case this is done in the Cluster namespace.

@@ -11,6 +11,26 @@
* @author Ray Ward <[email protected]>
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-health.html
*
* @phpstan-type HealthData = array{
Copy link
Owner

Choose a reason for hiding this comment

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

See my comment in the other PR related to these. The question is likely mostly for my understanding.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Comment on lines 86 to +87
* @return string green, yellow or red
* @phpstan-return HealthStatus
Copy link
Collaborator

Choose a reason for hiding this comment

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

We could use @return 'green'|'yellow'|'red' instead of introducing virtual class ;-)

see: https://phpstan.org/writing-php-code/phpdoc-types#literals-and-constants

@@ -8,6 +8,20 @@
* @author Ray Ward <[email protected]>
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-health.html
*
* @phpstan-import-type HealthStatus from \Elastica\Cluster\Health
* @phpstan-import-type ShardData from Shard
Copy link
Collaborator

Choose a reason for hiding this comment

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

should we prefer a fully-qualified-class name here?

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.

3 participants