mirror of
https://github.com/danog/psalm.git
synced 2024-12-05 21:19:03 +01:00
18 lines
307 B
Markdown
18 lines
307 B
Markdown
# RiskyCast
|
|
|
|
Emitted when attempting to cast an array to int or float
|
|
|
|
```php
|
|
<?php
|
|
|
|
$foo = (int) array( 'hello' );
|
|
```
|
|
|
|
## Why this is bad
|
|
|
|
The value resulting from the cast depends on if the array is empty or not and can easily lead to off-by-one errors
|
|
|
|
## How to fix
|
|
|
|
Don't cast arrays to int or float.
|