Skip to content

Commit

Permalink
Fix finfo constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Jun 8, 2020
1 parent 61f7a97 commit c2135cb
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Reflection/SignatureMap/functionMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -2983,6 +2983,7 @@
'FilterIterator::rewind' => ['void'],
'FilterIterator::valid' => ['bool'],
'finfo::__construct' => ['void', 'options='=>'int', 'magic_file='=>'string'],
'finfo::finfo' => ['void', 'options='=>'int', 'magic_file='=>'string'],
'finfo::buffer' => ['string|false', 'string'=>'string', 'options='=>'int', 'context='=>'resource'],
'finfo::file' => ['string|false', 'file_name'=>'string', 'options='=>'int', 'context='=>'resource'],
'finfo::set_flags' => ['bool', 'options'=>'int'],
Expand Down
10 changes: 10 additions & 0 deletions tests/PHPStan/Rules/Classes/InstantiationRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,14 @@ public function testClassExists(): void
$this->analyse([__DIR__ . '/data/instantiation-class-exists.php'], []);
}

public function testBug3404(): void
{
$this->analyse([__DIR__ . '/data/bug-3404.php'], [
[
'Class finfo constructor invoked with 3 parameters, 0-2 required.',
7,
],
]);
}

}
7 changes: 7 additions & 0 deletions tests/PHPStan/Rules/Classes/data/bug-3404.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace Bug3404;

new \finfo();
new \finfo(FILEINFO_MIME_TYPE);
new \finfo(0, 'foo', 'bar');

0 comments on commit c2135cb

Please sign in to comment.