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

Merge pull request #6979 from orklah/6975

don't accept unresolved literal string as valid callable-strings
This commit is contained in:
orklah 2021-11-23 21:41:04 +01:00 committed by GitHub
commit fdf3a8dbb8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 0 deletions

View File

@ -582,6 +582,11 @@ class ScalarTypeComparator
}
}
if (!$input_callable) {
//we could not find a callable for the input type, so the input is not contained in the container
return false;
}
return true;
}

View File

@ -1219,6 +1219,18 @@ class CallableTest extends TestCase
}',
'error_message' => 'InvalidScalarArgument',
],
'inexistantCallableinCallableString' => [
'<?php
/**
* @param callable-string $c
*/
function c(string $c): void {
$c();
}
c("hii");',
'error_message' => 'InvalidArgument',
],
];
}
}

View File

@ -973,6 +973,7 @@ class TypeParseTest extends TestCase
}
}
/** @psalm-suppress InvalidArgument Psalm couldn't detect the function exists */
$reflectionFunc = new \ReflectionFunction('Psalm\Tests\someFunction');
$reflectionParams = $reflectionFunc->getParameters();