Skip to content
Permalink
Browse files

@voku’s fixes for issues found by their callmap update

  • Loading branch information...
muglug committed Apr 11, 2019
1 parent da163e9 commit 97f53a64864cedeec2027e7567ae76460d91ee30
@@ -204,16 +204,31 @@ private static function writeToFile(
) {
$baselineDoc = new \DOMDocument('1.0', 'UTF-8');
$filesNode = $baselineDoc->createElement('files');
if (!$filesNode) {
return;
}
foreach ($groupedIssues as $file => $issueTypes) {
$fileNode = $baselineDoc->createElement('file');
if (!$fileNode) {
continue;
}
$fileNode->setAttribute('src', $file);
foreach ($issueTypes as $issueType => $existingIssueType) {
$issueNode = $baselineDoc->createElement($issueType);
if (!$issueNode) {
continue;
}
$issueNode->setAttribute('occurrences', (string)$existingIssueType['o']);
foreach ($existingIssueType['s'] as $selection) {
$codeNode = $baselineDoc->createElement('code');
if (!$codeNode) {
continue;
}
$codeNode->textContent = $selection;
$issueNode->appendChild($codeNode);
}
@@ -82,16 +82,22 @@ public function addPlugin(string $plugin_class)
$plugins_elements = $psalm_root->getElementsByTagName('plugins');
if (!$plugins_elements->length) {
$plugins_element = $config_xml->createElement('plugins');
$psalm_root->appendChild($plugins_element);
if ($plugins_element) {
$psalm_root->appendChild($plugins_element);
}
} else {
/** @var \DomElement */
$plugins_element = $plugins_elements->item(0);
}
$plugin_class_element = $config_xml->createElement('pluginClass');
$plugin_class_element->setAttribute('xmlns', self::NS);
$plugin_class_element->setAttribute('class', $plugin_class);
$plugins_element->appendChild($plugin_class_element);
if ($plugin_class_element) {
$plugin_class_element->setAttribute('xmlns', self::NS);
$plugin_class_element->setAttribute('class', $plugin_class);
if ($plugins_element) {
$plugins_element->appendChild($plugin_class_element);
}
}
$this->saveXml($config_xml);
}
@@ -1263,7 +1263,7 @@ function foo(string $s) : void {
'<?php
$a = microtime(true);
$b = microtime();
/** @psalm-suppress InvalidScalarArgument */
/** @psalm-suppress InvalidArgument */
$c = microtime(1);
$d = microtime(false);',
'assertions' => [
@@ -1577,7 +1577,7 @@ function getOrderings(array $arr): int {
'<?php
$a = hrtime(true);
$b = hrtime();
/** @psalm-suppress InvalidScalarArgument */
/** @psalm-suppress InvalidArgument */
$c = hrtime(1);
$d = hrtime(false);',
'assertions' => [
@@ -78,7 +78,7 @@ final class MyDate extends DateTimeImmutable {}
$b = (new DateTimeImmutable())->modify("+3 hours");',
'assertions' => [
'$yesterday' => 'MyDate',
'$yesterday' => 'false|MyDate',
'$b' => 'DateTimeImmutable',
],
],
@@ -133,8 +133,10 @@ public function __invoke(string $p): void {}
'<?php
$doc = new DOMDocument("1.0");
$node = $doc->createElement("foo");
$newnode = $doc->appendChild($node);
$newnode->setAttribute("bar", "baz");',
if ($node instanceof DOMElement) {
$newnode = $doc->appendChild($node);
$newnode->setAttribute("bar", "baz");
}',
],
'nonStaticSelfCall' => [
'<?php
@@ -158,7 +160,7 @@ public function method() : self {
$b = $xml->asXML("foo.xml");',
'assertions' => [
'$a' => 'string|false',
'$b' => 'string|bool',
'$b' => 'bool',
],
],
'datetimeformatNotFalse' => [
@@ -886,27 +886,47 @@ public function testValidCallMapType()
continue;
}
\Psalm\Type::parseString($return_type);
try {
\Psalm\Type::parseString($return_type);
} catch (\Psalm\Exception\TypeParseTreeException $e) {
self::assertTrue(false, $e . ' | ' . print_r($signature, true));
}
}
if ($param_type_1 && $param_type_1 !== 'mixed') {
if (stripos($param_type_1, 'oci-') !== false) {
continue;
}
\Psalm\Type::parseString($param_type_1);
try {
\Psalm\Type::parseString($param_type_1);
} catch (\Psalm\Exception\TypeParseTreeException $e) {
self::assertTrue(false, $e . ' | ' . print_r($signature, true));
}
}
if ($param_type_2 && $param_type_2 !== 'mixed') {
\Psalm\Type::parseString($param_type_2);
try {
\Psalm\Type::parseString($param_type_2);
} catch (\Psalm\Exception\TypeParseTreeException $e) {
self::assertTrue(false, $e . ' | ' . print_r($signature, true));
}
}
if ($param_type_3 && $param_type_3 !== 'mixed') {
\Psalm\Type::parseString($param_type_3);
try {
\Psalm\Type::parseString($param_type_3);
} catch (\Psalm\Exception\TypeParseTreeException $e) {
self::assertTrue(false, $e . ' | ' . print_r($signature, true));
}
}
if ($param_type_4 && $param_type_4 !== 'mixed') {
\Psalm\Type::parseString($param_type_4);
try {
\Psalm\Type::parseString($param_type_4);
} catch (\Psalm\Exception\TypeParseTreeException $e) {
self::assertTrue(false, $e . ' | ' . print_r($signature, true));
}
}
}
}

0 comments on commit 97f53a6

Please sign in to comment.
You can’t perform that action at this time.