Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b9f5f12

Browse files
VincentLangletondrejmirtes
authored andcommitted
Allow to cast resource to float
1 parent 07a010f commit b9f5f12

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

‎src/Type/ResourceType.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function toInteger(): Type
7272

7373
public function toFloat(): Type
7474
{
75-
return new ErrorType();
75+
return new FloatType();
7676
}
7777

7878
public function toArray(): Type

‎tests/PHPStan/Rules/Cast/InvalidCastRuleTest.php‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ public function testRule(): void
4343
],
4444
[
4545
'Cannot cast object to string.',
46-
35,
46+
36,
4747
],
4848
[
4949
'Cannot cast Test\\Foo to string.',
50-
41,
50+
42,
5151
],
5252
[
5353
'Cannot cast array|float|int to string.',
54-
48,
54+
49,
5555
],
5656
]);
5757
}

‎tests/PHPStan/Rules/Cast/data/invalid-cast.php‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ function (
2525

2626
(string) fopen('php://memory', 'r');
2727
(int) fopen('php://memory', 'r');
28+
(float) fopen('php://memory', 'r');
2829
};
2930

3031
function (

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /