ruflin / Elastica

Elastica is a PHP client for elasticsearch
http://elastica.io/
MIT License
2.26k stars 736 forks source link

Use proper types in tests #2081

Closed franmomu closed 2 years ago

franmomu commented 2 years ago

This PR tries to fix some PHPStan findings in level 5, in this case about calling some method with wrong types.

https://github.com/ruflin/Elastica/blob/c0bcdb3b948d9220acb671a0fe130395f6c9b998/src/Aggregation/GapPolicyInterface.php#L15-L35

setGapPolicy expects a string which is one of the policies.

https://github.com/ruflin/Elastica/blob/c0bcdb3b948d9220acb671a0fe130395f6c9b998/src/Document.php#L208

Document:: setDocAsUpsert() expects a bool

https://github.com/ruflin/Elastica/blob/c0bcdb3b948d9220acb671a0fe130395f6c9b998/src/Connection.php#L76-L83

Connection::setPort() expects an int and also the default value (9200) is stored as int, internally it casts the value to int, but IMO we should stick to int since it represents a port.