1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

Fix #2114 - make builtin constructors mutation free

This commit is contained in:
Matthew Brown 2019-09-21 21:07:27 -04:00
parent fdbea45534
commit ae46c9e132
2 changed files with 12 additions and 0 deletions

View File

@ -243,6 +243,7 @@ class Reflection
$storage->is_static = $method->isStatic();
$storage->abstract = $method->isAbstract();
$storage->mutation_free = $storage->external_mutation_free = $method_name === '__construct';
$declaring_method_id = $declaring_class->name . '::' . strtolower((string)$method->getName());

View File

@ -155,6 +155,17 @@ class PureAnnotationTest extends TestCase
return \array_map(function(string $s) { return $s;}, $arr);
}'
],
'pureBuiltinCall' => [
'<?php
final class Date
{
/** @psalm-pure */
public static function timeZone(string $tzString) : DateTimeZone
{
return new \DateTimeZone($tzString);
}
}',
],
];
}