Skip to content

Commit

Permalink
Fix #4017 - allow float defaults in namespaced classes
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed Aug 18, 2020
1 parent ebe3739 commit 45d9ab1
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/Psalm/Internal/Type/TypeTokenizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,7 @@ public static function getFullyQualifiedTokens(

if ($string_type_token[0][0] === '"'
|| $string_type_token[0][0] === '\''
|| $string_type_token[0] === '0'
|| preg_match('/[1-9]/', $string_type_token[0][0])
|| preg_match('/[0-9]/', $string_type_token[0][0])
) {
continue;
}
Expand Down
26 changes: 26 additions & 0 deletions tests/MagicMethodAnnotationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,32 @@ public function __construct(\IteratorAggregate $foos)
}
}'
],
'parseFloatInDefault' => [
'<?php
namespace Foo {
/**
* @method int randomInt()
* @method void takesFloat($a = 0.1)
*/
class G
{
/**
* @param string $method
* @param array $attributes
*
* @return mixed
*/
public function __call($method, $attributes)
{
return null;
}
}
}
namespace Bar {
(new \Foo\G)->randomInt();
}'
],
];
}

Expand Down

0 comments on commit 45d9ab1

Please sign in to comment.