1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-21 21:31:13 +01:00

return types (#4311)

* return types

* remove willReturn for void methods
This commit is contained in:
orklah 2020-10-12 21:02:52 +02:00 committed by Daniil Gentili
parent bb42c12d7b
commit 6e3546d900
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
99 changed files with 166 additions and 551 deletions

View File

@ -15,15 +15,13 @@ class TemplateScanner extends Psalm\Internal\Scanner\FileScanner
/**
* @param bool $storage_from_cache
*
* @return void
*/
public function scan(
Codebase $codebase,
FileStorage $file_storage,
$storage_from_cache = false,
?Progress $progress = null
) {
): void {
$stmts = $codebase->statements_provider->getStatementsForFile(
$file_storage->file_path,
'7.4',

View File

@ -11,8 +11,6 @@ class ClassUnqualifier implements AfterClassLikeExistenceCheckInterface
{
/**
* @param FileManipulation[] $file_replacements
*
* @return void
*/
public static function afterClassLikeExistenceCheck(
string $fq_class_name,
@ -20,7 +18,7 @@ class ClassUnqualifier implements AfterClassLikeExistenceCheckInterface
StatementsSource $statements_source,
Codebase $codebase,
array &$file_replacements = []
) {
): void {
$candidate_type = $code_location->getSelectedText();
$aliases = $statements_source->getAliasedClassesFlipped();

View File

@ -25,8 +25,6 @@ class FunctionCasingChecker implements AfterFunctionCallAnalysisInterface, After
/**
* @param MethodCall|StaticCall $expr
* @param FileManipulation[] $file_replacements
*
* @return void
*/
public static function afterMethodCallAnalysis(
Expr $expr,
@ -38,7 +36,7 @@ class FunctionCasingChecker implements AfterFunctionCallAnalysisInterface, After
Codebase $codebase,
array &$file_replacements = [],
Union &$return_type_candidate = null
) {
): void {
if (!$expr->name instanceof PhpParser\Node\Identifier) {
return;
}
@ -74,8 +72,6 @@ class FunctionCasingChecker implements AfterFunctionCallAnalysisInterface, After
/**
* @param non-empty-string $function_id
* @param FileManipulation[] $file_replacements
*
* @return void
*/
public static function afterFunctionCallAnalysis(
FuncCall $expr,
@ -85,7 +81,7 @@ class FunctionCasingChecker implements AfterFunctionCallAnalysisInterface, After
Codebase $codebase,
Union $return_type_candidate,
array &$file_replacements
) {
): void {
if ($expr->name instanceof PhpParser\Node\Expr) {
return;
}

View File

@ -26,7 +26,7 @@ class EchoChecker implements AfterStatementAnalysisInterface
StatementsSource $statements_source,
Codebase $codebase,
array &$file_replacements = []
) {
): ?bool {
if ($stmt instanceof PhpParser\Node\Stmt\Echo_) {
foreach ($stmt->exprs as $expr) {
$expr_type = $statements_source->getNodeTypeProvider()->getType($expr);
@ -67,5 +67,7 @@ class EchoChecker implements AfterStatementAnalysisInterface
}
}
}
return null;
}
}

View File

@ -6,8 +6,7 @@ use SimpleXMLElement;
class PluginEntryPoint implements Plugin\PluginEntryPointInterface
{
/** @return void */
public function __invoke(Plugin\RegistrationInterface $registration, ?SimpleXMLElement $config = null)
public function __invoke(Plugin\RegistrationInterface $registration, ?SimpleXMLElement $config = null): void
{
require_once __DIR__ . '/EchoChecker.php';
$registration->registerHooksFromClass(EchoChecker::class);

View File

@ -138,10 +138,8 @@ class CodeLocation
/**
* @psalm-suppress MixedArrayAccess
*
* @return void
*/
private function calculateRealLocation()
private function calculateRealLocation(): void
{
if ($this->have_recalculated) {
return;

View File

@ -873,10 +873,7 @@ class Codebase
return $this->methods->getCasedMethodId(Internal\MethodIdentifier::wrap($method_id));
}
/**
* @return void
*/
public function invalidateInformationForFile(string $file_path)
public function invalidateInformationForFile(string $file_path): void
{
$this->scanner->removeFile($file_path);
@ -968,10 +965,7 @@ class Codebase
}
}
/**
* @return ?CodeLocation
*/
public function getSymbolLocation(string $file_path, string $symbol)
public function getSymbolLocation(string $file_path, string $symbol): ?CodeLocation
{
if (\is_numeric($symbol[0])) {
$symbol = \preg_replace('/:.*/', '', $symbol);

View File

@ -377,9 +377,6 @@ class Context
$this->parent_context = null;
}
/**
* @return void
*/
public function __clone()
{
foreach ($this->clauses as &$clause) {
@ -635,15 +632,12 @@ class Context
}
}
/**
* @return void
*/
public function removeDescendents(
string $remove_var_id,
?Union $existing_type = null,
?Union $new_type = null,
?StatementsAnalyzer $statements_analyzer = null
) {
): void {
if (!$existing_type && isset($this->vars_in_scope[$remove_var_id])) {
$existing_type = $this->vars_in_scope[$remove_var_id];
}
@ -668,10 +662,7 @@ class Context
}
}
/**
* @return void
*/
public function removeAllObjectVars()
public function removeAllObjectVars(): void
{
$vars_to_remove = [];

View File

@ -30,10 +30,8 @@ class FileBasedPluginAdapter implements Plugin\PluginEntryPointInterface
/**
* @psalm-suppress PossiblyUnusedParam
*
* @return void
*/
public function __invoke(Plugin\RegistrationInterface $registration, ?SimpleXMLElement $config = null)
public function __invoke(Plugin\RegistrationInterface $registration, ?SimpleXMLElement $config = null): void
{
$fq_class_name = $this->getPluginClassForPath($this->path);

View File

@ -28,8 +28,6 @@ class AlgebraAnalyzer
* @param array<int, Clause> $formula_1
* @param array<int, Clause> $formula_2
* @param array<string, bool> $new_assigned_var_ids
*
* @return void
*/
public static function checkForParadox(
array $formula_1,
@ -37,7 +35,7 @@ class AlgebraAnalyzer
StatementsAnalyzer $statements_analyzer,
PhpParser\Node $stmt,
array $new_assigned_var_ids
) {
): void {
try {
$negated_formula2 = Algebra::negateFormula($formula_2);
} catch (\Psalm\Exception\ComplicatedExpressionException $e) {

View File

@ -1135,9 +1135,6 @@ class ClassAnalyzer extends ClassLikeAnalyzer
}
}
/**
* @return void
*/
private function checkPropertyInitialization(
Codebase $codebase,
Config $config,
@ -1145,7 +1142,7 @@ class ClassAnalyzer extends ClassLikeAnalyzer
Context $class_context,
?Context $global_context = null,
?MethodAnalyzer $constructor_analyzer = null
) {
): void {
if (!$config->reportIssueInFile('PropertyNotSetInConstructor', $this->getFilePath())) {
return;
}
@ -1607,14 +1604,11 @@ class ClassAnalyzer extends ClassLikeAnalyzer
return null;
}
/**
* @return void
*/
private function checkForMissingPropertyType(
StatementsSource $source,
PhpParser\Node\Stmt\Property $stmt,
Context $context
) {
): void {
$fq_class_name = $source->getFQCLN();
$property_name = $stmt->props[0]->name->name;

View File

@ -768,13 +768,12 @@ class CommentAnalyzer
/**
* @param array<int, string> $return_specials
* @return void
*/
private static function extractReturnType(
PhpParser\Comment\Doc $comment,
array $return_specials,
FunctionDocblockComment $info
) {
): void {
foreach ($return_specials as $offset => $return_block) {
$return_lines = explode("\n", $return_block);

View File

@ -323,10 +323,7 @@ class FileAnalyzer extends SourceAnalyzer implements StatementsSource
return $leftover_stmts;
}
/**
* @return void
*/
private function populateClassLikeAnalyzers(PhpParser\Node\Stmt\ClassLike $stmt)
private function populateClassLikeAnalyzers(PhpParser\Node\Stmt\ClassLike $stmt): void
{
if ($stmt instanceof PhpParser\Node\Stmt\Class_) {
if (!$stmt->name) {
@ -372,14 +369,11 @@ class FileAnalyzer extends SourceAnalyzer implements StatementsSource
$this->interface_analyzers_to_analyze[strtolower($fq_class_name)] = $interface_analyzer;
}
/**
* @return void
*/
public function getMethodMutations(
\Psalm\Internal\MethodIdentifier $method_id,
Context $this_context,
bool $from_project_analyzer = false
) {
): void {
$fq_class_name = $method_id->fq_class_name;
$method_name = $method_id->method_name;
$fq_class_name_lc = strtolower($fq_class_name);
@ -515,10 +509,7 @@ class FileAnalyzer extends SourceAnalyzer implements StatementsSource
return $this->root_file_path ?: $this->file_path;
}
/**
* @return void
*/
public function setRootFilePath(string $file_path, string $file_name)
public function setRootFilePath(string $file_path, string $file_name): void
{
$this->root_file_name = $file_name;
$this->root_file_path = $file_path;
@ -575,10 +566,8 @@ class FileAnalyzer extends SourceAnalyzer implements StatementsSource
/**
* @param array<int, string> $new_issues
*
* @return void
*/
public function addSuppressedIssues(array $new_issues)
public function addSuppressedIssues(array $new_issues): void
{
if (isset($new_issues[0])) {
$new_issues = \array_combine($new_issues, $new_issues);
@ -589,10 +578,8 @@ class FileAnalyzer extends SourceAnalyzer implements StatementsSource
/**
* @param array<int, string> $new_issues
*
* @return void
*/
public function removeSuppressedIssues(array $new_issues)
public function removeSuppressedIssues(array $new_issues): void
{
if (isset($new_issues[0])) {
$new_issues = \array_combine($new_issues, $new_issues);

View File

@ -258,7 +258,7 @@ class ReturnTypeCollector
protected static function getYieldTypeFromExpression(
PhpParser\Node\Expr $stmt,
\Psalm\Internal\Provider\NodeDataProvider $nodes
) {
): array {
if ($stmt instanceof PhpParser\Node\Expr\Yield_) {
$key_type = null;

View File

@ -1857,10 +1857,8 @@ abstract class FunctionLikeAnalyzer extends SourceAnalyzer
/**
* @param array<int, string> $new_issues
*
* @return void
*/
public function addSuppressedIssues(array $new_issues)
public function addSuppressedIssues(array $new_issues): void
{
if (isset($new_issues[0])) {
$new_issues = \array_combine($new_issues, $new_issues);
@ -1871,10 +1869,8 @@ abstract class FunctionLikeAnalyzer extends SourceAnalyzer
/**
* @param array<int, string> $new_issues
*
* @return void
*/
public function removeSuppressedIssues(array $new_issues)
public function removeSuppressedIssues(array $new_issues): void
{
if (isset($new_issues[0])) {
$new_issues = \array_combine($new_issues, $new_issues);

View File

@ -18,10 +18,7 @@ class InterfaceAnalyzer extends ClassLikeAnalyzer
parent::__construct($interface, $source, $fq_interface_name);
}
/**
* @return void
*/
public function analyze()
public function analyze(): void
{
if (!$this->class instanceof PhpParser\Node\Stmt\Interface_) {
throw new \LogicException('Something went badly wrong');

View File

@ -495,8 +495,7 @@ class ProjectAnalyzer
$reader = new ProtocolStreamReader($socket);
$reader->on(
'close',
/** @return void */
function () {
function (): void {
fwrite(STDOUT, "Connection closed\n");
}
);
@ -1345,15 +1344,12 @@ class ProjectAnalyzer
return $file_analyzer;
}
/**
* @return void
*/
public function getMethodMutations(
\Psalm\Internal\MethodIdentifier $original_method_id,
Context $this_context,
string $root_file_path,
string $root_file_name
) {
): void {
$fq_class_name = $original_method_id->fq_class_name;
$appearing_method_id = $this->codebase->methods->getAppearingMethodId($original_method_id);

View File

@ -82,7 +82,7 @@ class ScopeAnalyzer
array $exit_functions,
array $break_types = [],
$return_is_exit = true
) {
): array {
if (empty($stmts)) {
return [self::ACTION_NONE];
}

View File

@ -77,10 +77,7 @@ abstract class SourceAnalyzer implements StatementsSource
return $this->source->getRootFilePath();
}
/**
* @return void
*/
public function setRootFilePath(string $file_path, string $file_name)
public function setRootFilePath(string $file_path, string $file_name): void
{
$this->source->setRootFilePath($file_path, $file_name);
}
@ -120,20 +117,16 @@ abstract class SourceAnalyzer implements StatementsSource
/**
* @param array<int, string> $new_issues
*
* @return void
*/
public function addSuppressedIssues(array $new_issues)
public function addSuppressedIssues(array $new_issues): void
{
$this->source->addSuppressedIssues($new_issues);
}
/**
* @param array<int, string> $new_issues
*
* @return void
*/
public function removeSuppressedIssues(array $new_issues)
public function removeSuppressedIssues(array $new_issues): void
{
$this->source->removeSuppressedIssues($new_issues);
}

View File

@ -692,9 +692,6 @@ class ForeachAnalyzer
return null;
}
/**
* @return void
*/
public static function handleIterable(
StatementsAnalyzer $statements_analyzer,
Type\Atomic\TNamedObject $iterator_atomic_type,
@ -704,7 +701,7 @@ class ForeachAnalyzer
?Type\Union &$key_type,
?Type\Union &$value_type,
bool &$has_valid_iterator
) {
): void {
if ($iterator_atomic_type->extra_types) {
$iterator_atomic_type_copy = clone $iterator_atomic_type;
$iterator_atomic_type_copy->extra_types = [];
@ -954,15 +951,12 @@ class ForeachAnalyzer
}
}
/**
* @return void
*/
public static function getKeyValueParamsForTraversableObject(
Type\Atomic $iterator_atomic_type,
Codebase $codebase,
?Type\Union &$key_type,
?Type\Union &$value_type
) {
): void {
if ($iterator_atomic_type instanceof Type\Atomic\TIterable
|| ($iterator_atomic_type instanceof Type\Atomic\TGenericObject
&& strtolower($iterator_atomic_type->value) === 'traversable')

View File

@ -1693,11 +1693,8 @@ class IfAnalyzer
/**
* Returns statements that are definitely evaluated before any statements after the end of the
* if/elseif/else blocks
*
*
* @return PhpParser\Node\Expr|null
*/
private static function getDefinitelyEvaluatedExpressionAfterIf(PhpParser\Node\Expr $stmt)
private static function getDefinitelyEvaluatedExpressionAfterIf(PhpParser\Node\Expr $stmt): ?PhpParser\Node\Expr
{
if ($stmt instanceof PhpParser\Node\Expr\BinaryOp\Equal
|| $stmt instanceof PhpParser\Node\Expr\BinaryOp\Identical
@ -1740,11 +1737,8 @@ class IfAnalyzer
/**
* Returns statements that are definitely evaluated before any statements inside
* the if block
*
*
* @return PhpParser\Node\Expr|null
*/
private static function getDefinitelyEvaluatedExpressionInsideIf(PhpParser\Node\Expr $stmt)
private static function getDefinitelyEvaluatedExpressionInsideIf(PhpParser\Node\Expr $stmt): ?PhpParser\Node\Expr
{
if ($stmt instanceof PhpParser\Node\Expr\BinaryOp\Equal
|| $stmt instanceof PhpParser\Node\Expr\BinaryOp\Identical

View File

@ -288,8 +288,6 @@ class TryAnalyzer
array_map(
/**
* @param string $fq_catch_class
*
* @return Type\Atomic
*/
function ($fq_catch_class) use ($codebase): Type\Atomic {
$catch_class_type = new TNamedObject($fq_catch_class);

View File

@ -1662,9 +1662,6 @@ class AssignmentAnalyzer
return true;
}
/**
* @return void
*/
public static function assignByRefParam(
StatementsAnalyzer $statements_analyzer,
PhpParser\Node\Expr $stmt,
@ -1673,7 +1670,7 @@ class AssignmentAnalyzer
Context $context,
bool $constrain_type = true,
bool $prevent_null = false
) {
): void {
if ($stmt instanceof PhpParser\Node\Expr\PropertyFetch && $stmt->name instanceof PhpParser\Node\Identifier) {
$prop_name = $stmt->name->name;

View File

@ -61,9 +61,6 @@ class CoalesceAnalyzer
$if_clauses = array_values(
array_map(
/**
* @return \Psalm\Internal\Clause
*/
function (\Psalm\Internal\Clause $c) use ($mixed_var_ids, $stmt_id): \Psalm\Internal\Clause {
$keys = array_keys($c->possibilities);

View File

@ -29,8 +29,6 @@ class ConcatAnalyzer
{
/**
* @param Type\Union|null &$result_type
*
* @return void
*/
public static function analyze(
StatementsAnalyzer $statements_analyzer,
@ -38,7 +36,7 @@ class ConcatAnalyzer
PhpParser\Node\Expr $right,
Context $context,
Type\Union &$result_type = null
) {
): void {
$codebase = $statements_analyzer->getCodebase();
$left_type = $statements_analyzer->node_data->getType($left);

View File

@ -726,8 +726,6 @@ class ArrayFunctionArgumentsAnalyzer
/**
* @param Type\Atomic\TClosure|Type\Atomic\TCallable $closure_type
* @param (TArray|null)[] $array_arg_types
*
* @return void
*/
private static function checkClosureTypeArgs(
StatementsAnalyzer $statements_analyzer,
@ -738,7 +736,7 @@ class ArrayFunctionArgumentsAnalyzer
int $min_closure_param_count,
int $max_closure_param_count,
array $array_arg_types
) {
): void {
$codebase = $statements_analyzer->getCodebase();
$closure_params = $closure_type->params;

View File

@ -669,9 +669,6 @@ class StaticCallAnalyzer extends CallAnalyzer
}
$array_values = array_map(
/**
* @return PhpParser\Node\Expr\ArrayItem
*/
function (PhpParser\Node\Arg $arg): PhpParser\Node\Expr\ArrayItem {
return new PhpParser\Node\Expr\ArrayItem($arg->value);
},

View File

@ -35,14 +35,11 @@ use function array_merge;
*/
class CallAnalyzer
{
/**
* @return void
*/
public static function collectSpecialInformation(
FunctionLikeAnalyzer $source,
string $method_name,
Context $context
) {
): void {
$fq_class_name = (string)$source->getFQCLN();
$project_analyzer = $source->getFileAnalyzer()->project_analyzer;

View File

@ -402,8 +402,7 @@ class Analyzer
// files up among a given number of child processes.
$pool = new \Psalm\Internal\Fork\Pool(
$process_file_paths,
/** @return void */
function () {
function (): void {
$project_analyzer = ProjectAnalyzer::getInstance();
$codebase = $project_analyzer->getCodebase();
@ -1066,10 +1065,7 @@ class Analyzer
$this->mixed_counts[$file_path] = $mixed_counts;
}
/**
* @return void
*/
public function incrementMixedCount(string $file_path)
public function incrementMixedCount(string $file_path): void
{
if (!$this->count_mixed) {
return;
@ -1082,10 +1078,7 @@ class Analyzer
++$this->mixed_counts[$file_path][0];
}
/**
* @return void
*/
public function decrementMixedCount(string $file_path)
public function decrementMixedCount(string $file_path): void
{
if (!$this->count_mixed) {
return;
@ -1098,10 +1091,7 @@ class Analyzer
--$this->mixed_counts[$file_path][0];
}
/**
* @return void
*/
public function incrementNonMixedCount(string $file_path)
public function incrementNonMixedCount(string $file_path): void
{
if (!$this->count_mixed) {
return;
@ -1298,10 +1288,7 @@ class Analyzer
$this->count_mixed = true;
}
/**
* @return void
*/
public function updateFile(string $file_path, bool $dry_run)
public function updateFile(string $file_path, bool $dry_run): void
{
FileManipulationBuffer::add(
$file_path,

View File

@ -767,10 +767,7 @@ class ClassLikes
$manipulator->makeImmutable();
}
/**
* @return void
*/
public function moveMethods(Methods $methods, ?Progress $progress = null)
public function moveMethods(Methods $methods, ?Progress $progress = null): void
{
if ($progress === null) {
$progress = new VoidProgress();
@ -851,10 +848,7 @@ class ClassLikes
FileManipulationBuffer::addCodeMigrations($code_migrations);
}
/**
* @return void
*/
public function moveProperties(Properties $properties, ?Progress $progress = null)
public function moveProperties(Properties $properties, ?Progress $progress = null): void
{
if ($progress === null) {
$progress = new VoidProgress();
@ -952,10 +946,7 @@ class ClassLikes
FileManipulationBuffer::addCodeMigrations($code_migrations);
}
/**
* @return void
*/
public function moveClassConstants(?Progress $progress = null)
public function moveClassConstants(?Progress $progress = null): void
{
if ($progress === null) {
$progress = new VoidProgress();

View File

@ -211,7 +211,7 @@ class Functions
*
* @return non-empty-string
*/
public function getFullyQualifiedFunctionNameFromString(string $function_name, StatementsSource $source)
public function getFullyQualifiedFunctionNameFromString(string $function_name, StatementsSource $source): string
{
if ($function_name[0] === '\\') {
$function_name = substr($function_name, 1);

View File

@ -945,10 +945,7 @@ class Methods
return [];
}
/**
* @return string
*/
public function getCasedMethodId(MethodIdentifier $original_method_id)
public function getCasedMethodId(MethodIdentifier $original_method_id): string
{
$method_id = $this->getDeclaringMethodId($original_method_id);

View File

@ -148,10 +148,7 @@ class Populator
$this->file_storage_provider->populated();
}
/**
* @return void
*/
private function populateClassLikeStorage(ClassLikeStorage $storage, array $dependent_classlikes = [])
private function populateClassLikeStorage(ClassLikeStorage $storage, array $dependent_classlikes = []): void
{
if ($storage->populated) {
return;
@ -478,14 +475,11 @@ class Populator
return new Type\Union($extended_types);
}
/**
* @return void
*/
private function populateDataFromParentClass(
ClassLikeStorage $storage,
ClassLikeStorageProvider $storage_provider,
array $dependent_classlikes
) {
): void {
$parent_storage_class = reset($storage->parent_classes);
$parent_storage_class = strtolower(
@ -871,10 +865,8 @@ class Populator
/**
* @param array<string, bool> $dependent_file_paths
*
* @return void
*/
private function populateFileStorage(FileStorage $storage, array $dependent_file_paths = [])
private function populateFileStorage(FileStorage $storage, array $dependent_file_paths = []): void
{
if ($storage->populated) {
return;

View File

@ -41,10 +41,7 @@ class Reflection
self::$builtin_functions = [];
}
/**
* @return void
*/
public function registerClass(\ReflectionClass $reflected_class)
public function registerClass(\ReflectionClass $reflected_class): void
{
$class_name = $reflected_class->name;
@ -222,10 +219,7 @@ class Reflection
}
}
/**
* @return void
*/
public function extractReflectionMethodInfo(\ReflectionMethod $method)
public function extractReflectionMethodInfo(\ReflectionMethod $method): void
{
$method_name_lc = strtolower($method->getName());

View File

@ -226,18 +226,15 @@ class Scanner
return $this->classlike_files[$fq_classlike_name_lc];
}
/**
/**
* @param array<string, mixed> $phantom_classes
*
* @return void
*/
public function queueClassLikeForScanning(
string $fq_classlike_name,
bool $analyze_too = false,
bool $store_failure = true,
array $phantom_classes = []
) {
): void {
if ($fq_classlike_name[0] === '\\') {
$fq_classlike_name = substr($fq_classlike_name, 1);
}
@ -318,10 +315,7 @@ class Scanner
$files_to_deep_scan = $this->files_to_deep_scan;
$scanner_worker =
/**
* @return void
*/
function (int $_, string $file_path) use ($filetype_scanners, $files_to_deep_scan) {
function (int $_, string $file_path) use ($filetype_scanners, $files_to_deep_scan): void {
$this->scanFile(
$file_path,
$filetype_scanners,

View File

@ -107,10 +107,7 @@ class FileManipulationBuffer
);
}
/**
* @return void
*/
public static function addVarAnnotationToRemove(CodeLocation\DocblockTypeLocation $code_location)
public static function addVarAnnotationToRemove(CodeLocation\DocblockTypeLocation $code_location): void
{
$bounds = $code_location->getSelectionBounds();

View File

@ -45,10 +45,8 @@ class PsalmRestarter extends \Composer\XdebugHandler\XdebugHandler
/**
* @param mixed $command
*
* @return void
*/
protected function restart($command)
protected function restart($command): void
{
if ($this->required && $this->tmpIni) {
$regex = '/^\s*(extension\s*=.*(' . implode('|', $this->disabledExtensions) . ').*)$/mi';

View File

@ -61,10 +61,7 @@ class ClientHandler
$deferred = new Deferred();
$listener =
/**
* @return void
*/
function (Message $msg) use ($id, $deferred, &$listener) {
function (Message $msg) use ($id, $deferred, &$listener): void {
error_log('request handler');
/**
* @psalm-suppress UndefinedPropertyFetch

View File

@ -16,10 +16,8 @@ interface EmitterInterface
{
/**
* Subscribe to an event.
*
* @return void
*/
public function on(string $eventName, callable $callBack, int $priority = 100);
public function on(string $eventName, callable $callBack, int $priority = 100): void;
/**
* Emits an event.

View File

@ -28,10 +28,8 @@ trait EmitterTrait
/**
* Subscribe to an event.
*
* @return void
*/
public function on(string $eventName, callable $callBack, int $priority = 100)
public function on(string $eventName, callable $callBack, int $priority = 100): void
{
if (!isset($this->listeners[$eventName])) {
$this->listeners[$eventName] = [

View File

@ -93,17 +93,13 @@ class LanguageServer extends AdvancedJsonRpc\Dispatcher
$this->protocolReader = $reader;
$this->protocolReader->on(
'close',
/**
* @return void
*/
function () {
function (): void {
$this->shutdown();
$this->exit();
}
);
$this->protocolReader->on(
'message',
/** @return void */
asyncCoroutine(
/**
* @return \Generator<int, \Amp\Promise, mixed, void>
@ -166,8 +162,7 @@ class LanguageServer extends AdvancedJsonRpc\Dispatcher
$this->protocolReader->on(
'readMessageGroup',
/** @return void */
function () {
function (): void {
$this->doAnalysis();
}
);
@ -288,10 +283,7 @@ class LanguageServer extends AdvancedJsonRpc\Dispatcher
$this->onsave_paths_to_analyze[$file_path] = $uri;
}
/**
* @return void
*/
public function doAnalysis()
public function doAnalysis(): void
{
$this->clientStatus('analyzing');
@ -405,7 +397,7 @@ class LanguageServer extends AdvancedJsonRpc\Dispatcher
*
* @psalm-return Promise<null>
*/
public function shutdown()
public function shutdown(): Promise
{
$this->clientStatus('closing');
$this->verboseLog("Shutting down...");

View File

@ -74,8 +74,7 @@ class ProtocolStreamReader implements ProtocolReader
$this->on(
'close',
/** @return void */
static function () use ($input) {
static function () use ($input): void {
$input->close();
}
);
@ -135,10 +134,7 @@ class ProtocolStreamReader implements ProtocolReader
return $emitted_messages;
}
/**
* @return void
*/
private function emitClose()
private function emitClose(): void
{
if ($this->did_emit_close) {
return;

View File

@ -53,10 +53,8 @@ class TextDocument
* document's uri.
*
* @param \LanguageServerProtocol\TextDocumentItem $textDocument the document that was opened
*
* @return void
*/
public function didOpen(TextDocumentItem $textDocument)
public function didOpen(TextDocumentItem $textDocument): void
{
$file_path = LanguageServer::uriToPath($textDocument->uri);
@ -71,10 +69,7 @@ class TextDocument
$this->server->queueFileAnalysis($file_path, $textDocument->uri);
}
/**
* @return void
*/
public function didSave(TextDocumentItem $textDocument)
public function didSave(TextDocumentItem $textDocument): void
{
$file_path = LanguageServer::uriToPath($textDocument->uri);
@ -93,10 +88,8 @@ class TextDocument
* The document change notification is sent from the client to the server to signal changes to a text document.
*
* @param \LanguageServerProtocol\TextDocumentContentChangeEvent[] $contentChanges
*
* @return void
*/
public function didChange(VersionedTextDocumentIdentifier $textDocument, array $contentChanges)
public function didChange(VersionedTextDocumentIdentifier $textDocument, array $contentChanges): void
{
$file_path = \Psalm\Internal\LanguageServer\LanguageServer::uriToPath($textDocument->uri);

View File

@ -1548,14 +1548,11 @@ class ReflectorVisitor extends PhpParser\NodeVisitorAbstract implements PhpParse
return null;
}
/**
* @return void
*/
private function extendTemplatedType(
ClassLikeStorage $storage,
PhpParser\Node\Stmt\ClassLike $node,
string $extended_class_name
) {
): void {
if (trim($extended_class_name) === '') {
$storage->docblock_issues[] = new InvalidDocblock(
'Extended class cannot be empty in docblock for ' . implode('.', $this->fq_classlike_names),
@ -1635,14 +1632,11 @@ class ReflectorVisitor extends PhpParser\NodeVisitorAbstract implements PhpParse
}
}
/**
* @return void
*/
private function implementTemplatedType(
ClassLikeStorage $storage,
PhpParser\Node\Stmt\ClassLike $node,
string $implemented_class_name
) {
): void {
if (trim($implemented_class_name) === '') {
$storage->docblock_issues[] = new InvalidDocblock(
'Extended class cannot be empty in docblock for ' . implode('.', $this->fq_classlike_names),
@ -1724,14 +1718,11 @@ class ReflectorVisitor extends PhpParser\NodeVisitorAbstract implements PhpParse
}
}
/**
* @return void
*/
private function useTemplatedType(
ClassLikeStorage $storage,
PhpParser\Node\Stmt\TraitUse $node,
string $used_class_name
) {
): void {
if (trim($used_class_name) === '') {
$storage->docblock_issues[] = new InvalidDocblock(
'Extended class cannot be empty in docblock for ' . implode('.', $this->fq_classlike_names),
@ -4062,10 +4053,7 @@ class ReflectorVisitor extends PhpParser\NodeVisitorAbstract implements PhpParse
return null;
}
/**
* @return void
*/
public function visitInclude(PhpParser\Node\Expr\Include_ $stmt)
public function visitInclude(PhpParser\Node\Expr\Include_ $stmt): void
{
$config = Config::getInstance();

View File

@ -174,7 +174,7 @@ class SimpleNameResolver extends NodeVisitorAbstract
* @psalm-suppress InvalidReturnType
* @psalm-suppress InvalidReturnStatement
*/
private function resolveType($node)
private function resolveType($node): ?Node
{
if ($node instanceof Node\NullableType) {
/** @psalm-suppress PossiblyInvalidPropertyAssignmentValue */

View File

@ -27,10 +27,7 @@ class DisableCommand extends Command
parent::__construct();
}
/**
* @return void
*/
protected function configure()
protected function configure(): void
{
$this
->setName('disable')

View File

@ -27,10 +27,7 @@ class EnableCommand extends Command
parent::__construct();
}
/**
* @return void
*/
protected function configure()
protected function configure(): void
{
$this
->setName('enable')

View File

@ -28,10 +28,7 @@ class ShowCommand extends Command
parent::__construct();
}
/**
* @return void
*/
protected function configure()
protected function configure(): void
{
$this
->setName('show')

View File

@ -44,8 +44,7 @@ class ConfigFile
return Config::loadFromXMLFile($this->path, $this->current_dir);
}
/** @return void */
public function removePlugin(string $plugin_class)
public function removePlugin(string $plugin_class): void
{
$config_xml = $this->readXml();
/** @var \DomElement */

View File

@ -66,10 +66,7 @@ class ClassLikeStorageCacheProvider
$this->modified_timestamps .= $this->config->hash;
}
/**
* @return void
*/
public function writeToCache(ClassLikeStorage $storage, ?string $file_path, ?string $file_contents)
public function writeToCache(ClassLikeStorage $storage, ?string $file_path, ?string $file_contents): void
{
$fq_classlike_name_lc = strtolower($storage->name);

View File

@ -42,10 +42,7 @@ class FileProvider
return (string)file_get_contents($file_path);
}
/**
* @return void
*/
public function setContents(string $file_path, string $file_contents)
public function setContents(string $file_path, string $file_contents): void
{
if (isset($this->open_files[strtolower($file_path)])) {
$this->open_files[strtolower($file_path)] = $file_contents;

View File

@ -339,10 +339,7 @@ class FileReferenceCacheProvider
return $issues_cache;
}
/**
* @return void
*/
public function setCachedFileReferences(array $file_references)
public function setCachedFileReferences(array $file_references): void
{
$cache_directory = $this->config->getCacheDirectory();
@ -355,10 +352,7 @@ class FileReferenceCacheProvider
file_put_contents($reference_cache_location, serialize($file_references));
}
/**
* @return void
*/
public function setCachedClassLikeFiles(array $file_references)
public function setCachedClassLikeFiles(array $file_references): void
{
$cache_directory = $this->config->getCacheDirectory();
@ -371,10 +365,7 @@ class FileReferenceCacheProvider
file_put_contents($reference_cache_location, serialize($file_references));
}
/**
* @return void
*/
public function setCachedNonMethodClassReferences(array $file_class_references)
public function setCachedNonMethodClassReferences(array $file_class_references): void
{
$cache_directory = $this->config->getCacheDirectory();
@ -387,10 +378,7 @@ class FileReferenceCacheProvider
file_put_contents($reference_cache_location, serialize($file_class_references));
}
/**
* @return void
*/
public function setCachedMethodClassReferences(array $method_class_references)
public function setCachedMethodClassReferences(array $method_class_references): void
{
$cache_directory = $this->config->getCacheDirectory();
@ -403,10 +391,7 @@ class FileReferenceCacheProvider
file_put_contents($reference_cache_location, serialize($method_class_references));
}
/**
* @return void
*/
public function setCachedMethodMemberReferences(array $member_references)
public function setCachedMethodMemberReferences(array $member_references): void
{
$cache_directory = $this->config->getCacheDirectory();
@ -419,10 +404,7 @@ class FileReferenceCacheProvider
file_put_contents($member_cache_location, serialize($member_references));
}
/**
* @return void
*/
public function setCachedMethodMissingMemberReferences(array $member_references)
public function setCachedMethodMissingMemberReferences(array $member_references): void
{
$cache_directory = $this->config->getCacheDirectory();
@ -435,10 +417,7 @@ class FileReferenceCacheProvider
file_put_contents($member_cache_location, serialize($member_references));
}
/**
* @return void
*/
public function setCachedFileMemberReferences(array $member_references)
public function setCachedFileMemberReferences(array $member_references): void
{
$cache_directory = $this->config->getCacheDirectory();
@ -451,10 +430,7 @@ class FileReferenceCacheProvider
file_put_contents($member_cache_location, serialize($member_references));
}
/**
* @return void
*/
public function setCachedFileMissingMemberReferences(array $member_references)
public function setCachedFileMissingMemberReferences(array $member_references): void
{
$cache_directory = $this->config->getCacheDirectory();
@ -467,10 +443,7 @@ class FileReferenceCacheProvider
file_put_contents($member_cache_location, serialize($member_references));
}
/**
* @return void
*/
public function setCachedMixedMemberNameReferences(array $references)
public function setCachedMixedMemberNameReferences(array $references): void
{
$cache_directory = $this->config->getCacheDirectory();
@ -483,10 +456,7 @@ class FileReferenceCacheProvider
file_put_contents($cache_location, serialize($references));
}
/**
* @return void
*/
public function setCachedMethodParamUses(array $uses)
public function setCachedMethodParamUses(array $uses): void
{
$cache_directory = $this->config->getCacheDirectory();
@ -499,10 +469,7 @@ class FileReferenceCacheProvider
file_put_contents($cache_location, serialize($uses));
}
/**
* @return void
*/
public function setCachedIssues(array $issues)
public function setCachedIssues(array $issues): void
{
$cache_directory = $this->config->getCacheDirectory();
@ -536,10 +503,8 @@ class FileReferenceCacheProvider
/**
* @param array<string, array<string, int>> $analyzed_methods
*
* @return void
*/
public function setAnalyzedMethodCache(array $analyzed_methods)
public function setAnalyzedMethodCache(array $analyzed_methods): void
{
$cache_directory = Config::getInstance()->getCacheDirectory();
@ -580,10 +545,8 @@ class FileReferenceCacheProvider
/**
* @param array<string, FileMapType> $file_maps
*
* @return void
*/
public function setFileMapCache(array $file_maps)
public function setFileMapCache(array $file_maps): void
{
$cache_directory = Config::getInstance()->getCacheDirectory();
@ -620,10 +583,8 @@ class FileReferenceCacheProvider
/**
* @param array<string, array{int, int}> $mixed_counts
*
* @return void
*/
public function setTypeCoverage(array $mixed_counts)
public function setTypeCoverage(array $mixed_counts): void
{
$cache_directory = Config::getInstance()->getCacheDirectory();

View File

@ -925,10 +925,7 @@ class FileReferenceProvider
unset(self::$file_maps[$file_path]);
}
/**
* @return void
*/
public function addIssue(string $file_path, IssueData $issue)
public function addIssue(string $file_path, IssueData $issue): void
{
// dont save parse errors ever, as they're not responsive to AST diffing
if ($issue->type === 'ParseError') {

View File

@ -67,10 +67,7 @@ class FileStorageCacheProvider
$this->modified_timestamps .= $this->config->hash;
}
/**
* @return void
*/
public function writeToCache(FileStorage $storage, string $file_contents)
public function writeToCache(FileStorage $storage, string $file_contents): void
{
$file_path = strtolower($storage->file_path);
$cache_location = $this->getCacheLocationForPath($file_path, true);
@ -106,10 +103,7 @@ class FileStorageCacheProvider
return $cached_value;
}
/**
* @return void
*/
public function removeCacheForFile(string $file_path)
public function removeCacheForFile(string $file_path): void
{
$cache_path = $this->getCacheLocationForPath($file_path);

View File

@ -348,12 +348,7 @@ class ParserCacheProvider
return $removed_count;
}
/**
* @param float $start_time
*
* @return void
*/
public function processSuccessfulRun()
public function processSuccessfulRun(): void
{
$cache_directory = Config::getInstance()->getCacheDirectory();
@ -380,10 +375,8 @@ class ParserCacheProvider
/**
* @param array<string> $file_names
*
* @return void
*/
public function touchParserCaches(array $file_names, int $min_time)
public function touchParserCaches(array $file_names, int $min_time): void
{
$cache_directory = Config::getInstance()->getCacheDirectory();

View File

@ -40,10 +40,7 @@ class ProjectCacheProvider
return $cache_directory && file_exists($cache_directory . DIRECTORY_SEPARATOR . self::GOOD_RUN_NAME);
}
/**
* @return void
*/
public function processSuccessfulRun(float $start_time)
public function processSuccessfulRun(float $start_time): void
{
$cache_directory = Config::getInstance()->getCacheDirectory();

View File

@ -38,15 +38,12 @@ class FileScanner implements FileSource
$this->will_analyze = $will_analyze;
}
/**
* @return void
*/
public function scan(
Codebase $codebase,
FileStorage $file_storage,
bool $storage_from_cache = false,
?Progress $progress = null
) {
): void {
if ($progress === null) {
$progress = new VoidProgress();
}

View File

@ -19,9 +19,8 @@ class PhpStormMetaScanner
{
/**
* @param array<PhpParser\Node\Arg> $args
* @return void
*/
public static function handleOverride(array $args, Codebase $codebase)
public static function handleOverride(array $args, Codebase $codebase): void
{
$identifier = $args[0]->value;

View File

@ -6,6 +6,7 @@ use Psalm\Internal\Analyzer\StatementsAnalyzer;
use Psalm\Codebase;
use Psalm\Internal\Codebase\InternalCallMapHandler;
use Psalm\Type;
use Psalm\Type\Atomic;
use Psalm\Type\Atomic\TKeyedArray;
use Psalm\Type\Atomic\TArray;
use Psalm\Type\Atomic\TCallable;
@ -224,7 +225,7 @@ class CallableTypeComparator
Type\Atomic $input_type_part,
?TCallable $container_type_part = null,
?StatementsAnalyzer $statements_analyzer = null
) {
): ?Atomic {
if ($input_type_part instanceof TCallable || $input_type_part instanceof TClosure) {
return $input_type_part;
}

View File

@ -1,6 +1,7 @@
<?php
namespace Psalm\Internal\Type;
use Psalm\Type\TypeNode;
use function array_keys;
use function array_map;
use function array_shift;
@ -115,7 +116,7 @@ class TypeParser
?array $php_version = null,
array $template_type_map = [],
array $type_aliases = []
) {
): TypeNode {
if ($parse_tree instanceof ParseTree\GenericTree) {
$generic_type = $parse_tree->value;

View File

@ -20,8 +20,6 @@ class TypeScanner extends NodeVisitor
/**
* @param array<string, mixed> $phantom_classes
*
* @return void
*/
public function __construct(
Scanner $scanner,

View File

@ -821,10 +821,7 @@ class IssueBuffer
return $recorded_issues;
}
/**
* @return void
*/
public static function bubbleUp(CodeIssue $e)
public static function bubbleUp(CodeIssue $e): void
{
if (self::$recording_level === 0) {
self::add($e);

View File

@ -11,13 +11,11 @@ interface AfterAnalysisInterface
* Called after analysis is complete
*
* @param array<string, list<IssueData>> $issues
*
* @return void
*/
public static function afterAnalysis(
Codebase $codebase,
array $issues,
array $build_info,
?SourceControlInfo $source_control_info = null
);
): void;
}

View File

@ -10,8 +10,6 @@ interface AfterClassLikeExistenceCheckInterface
{
/**
* @param FileManipulation[] $file_replacements
*
* @return void
*/
public static function afterClassLikeExistenceCheck(
string $fq_class_name,
@ -19,5 +17,5 @@ interface AfterClassLikeExistenceCheckInterface
StatementsSource $statements_source,
Codebase $codebase,
array &$file_replacements = []
);
): void;
}

View File

@ -10,13 +10,11 @@ interface AfterFileAnalysisInterface
{
/**
* Called after a file has been checked
*
* @return void
*/
public static function afterAnalyzeFile(
StatementsSource $statements_source,
Context $file_context,
FileStorage $file_storage,
Codebase $codebase
);
): void;
}

View File

@ -13,8 +13,6 @@ interface AfterFunctionCallAnalysisInterface
/**
* @param non-empty-string $function_id
* @param FileManipulation[] $file_replacements
*
* @return void
*/
public static function afterFunctionCallAnalysis(
FuncCall $expr,
@ -24,5 +22,5 @@ interface AfterFunctionCallAnalysisInterface
Codebase $codebase,
Union $return_type_candidate,
array &$file_replacements
);
): void;
}

View File

@ -15,8 +15,6 @@ interface AfterMethodCallAnalysisInterface
/**
* @param MethodCall|StaticCall $expr
* @param FileManipulation[] $file_replacements
*
* @return void
*/
public static function afterMethodCallAnalysis(
Expr $expr,
@ -28,5 +26,5 @@ interface AfterMethodCallAnalysisInterface
Codebase $codebase,
array &$file_replacements = [],
Union &$return_type_candidate = null
);
): void;
}

View File

@ -22,5 +22,5 @@ interface AfterStatementAnalysisInterface
StatementsSource $statements_source,
Codebase $codebase,
array &$file_replacements = []
);
): ?bool;
}

View File

@ -10,13 +10,11 @@ interface BeforeFileAnalysisInterface
{
/**
* Called before a file has been checked
*
* @return void
*/
public static function beforeAnalyzeFile(
StatementsSource $statements_source,
Context $file_context,
FileStorage $file_storage,
Codebase $codebase
);
): void;
}

View File

@ -20,8 +20,6 @@ interface FunctionReturnTypeProviderInterface
* if something should be returned, but can't be more specific.
*
* @param array<PhpParser\Node\Arg> $call_args
*
* @return ?Type\Union
*/
public static function getFunctionReturnType(
StatementsSource $statements_source,
@ -29,5 +27,5 @@ interface FunctionReturnTypeProviderInterface
array $call_args,
Context $context,
CodeLocation $code_location
);
): ?Type\Union;
}

View File

@ -5,6 +5,5 @@ use SimpleXMLElement;
interface PluginEntryPointInterface
{
/** @return void */
public function __invoke(RegistrationInterface $registration, ?SimpleXMLElement $config = null);
public function __invoke(RegistrationInterface $registration, ?SimpleXMLElement $config = null): void;
}

View File

@ -3,11 +3,7 @@ namespace Psalm\Plugin;
interface RegistrationInterface
{
/** @return void */
public function addStubFile(string $file_name);
public function addStubFile(string $file_name): void;
/**
* @return void
*/
public function registerHooksFromClass(string $handler);
public function registerHooksFromClass(string $handler): void;
}

View File

@ -33,15 +33,13 @@ class Shepherd implements \Psalm\Plugin\Hook\AfterAnalysisInterface
* Called after analysis is complete
*
* @param array<string, list<IssueData>> $issues
*
* @return void
*/
public static function afterAnalysis(
Codebase $codebase,
array $issues,
array $build_info,
?SourceControlInfo $source_control_info = null
) {
): void {
if (!function_exists('curl_init')) {
fwrite(STDERR, 'No curl found, cannot send data to ' . $codebase->config->shepherd_host . PHP_EOL);

View File

@ -23,16 +23,12 @@ class PluginRegistrationSocket implements RegistrationInterface
$this->codebase = $codebase;
}
/** @return void */
public function addStubFile(string $file_name)
public function addStubFile(string $file_name): void
{
$this->config->addStubFile($file_name);
}
/**
* @return void
*/
public function registerHooksFromClass(string $handler)
public function registerHooksFromClass(string $handler): void
{
if (!class_exists($handler, false)) {
throw new \InvalidArgumentException('Plugins must be loaded before registration');

View File

@ -26,10 +26,7 @@ interface StatementsSource extends FileSource
*/
public function getTemplateTypeMap(): ?array;
/**
* @return void
*/
public function setRootFilePath(string $file_path, string $file_name);
public function setRootFilePath(string $file_path, string $file_name): void;
public function hasParentFilePath(string $file_path): bool;
@ -52,17 +49,13 @@ interface StatementsSource extends FileSource
/**
* @param array<int, string> $new_issues
*
* @return void
*/
public function addSuppressedIssues(array $new_issues);
public function addSuppressedIssues(array $new_issues): void;
/**
* @param array<int, string> $new_issues
*
* @return void
*/
public function removeSuppressedIssues(array $new_issues);
public function removeSuppressedIssues(array $new_issues): void;
public function getNodeTypeProvider() : NodeTypeProvider;
}

View File

@ -86,15 +86,13 @@ abstract class Atomic implements TypeNode
* @param array{int,int}|null $php_version
* @param array<string, array<string, array{Union}>> $template_type_map
* @param array<string, TypeAlias> $type_aliases
*
* @return Atomic
*/
public static function create(
string $value,
?array $php_version = null,
array $template_type_map = [],
array $type_aliases = []
) {
): Atomic {
switch ($value) {
case 'int':
return new TInt();

View File

@ -54,8 +54,6 @@ class TObjectWithProperties extends TObject
/**
* @param string|int $name
* @param Union $type
*
* @return string
*/
function ($name, Union $type): string {
return $name . ($type->possibly_undefined ? '?' : '') . ':' . $type;
@ -95,8 +93,6 @@ class TObjectWithProperties extends TObject
/**
* @param string|int $name
* @param Union $type
*
* @return string
*/
function ($name, Union $type): string {
return $name . ($type->possibly_undefined ? '?' : '') . ':' . $type->getId();
@ -143,8 +139,6 @@ class TObjectWithProperties extends TObject
/**
* @param string|int $name
* @param Union $type
*
* @return string
*/
function (
$name,

View File

@ -887,15 +887,13 @@ class Reconciler
* @param string[] $key_parts
* @param array<string,Type\Union> $existing_types
* @param array<string, bool> $changed_var_ids
*
* @return void
*/
private static function adjustTKeyedArrayType(
array $key_parts,
array &$existing_types,
array &$changed_var_ids,
Type\Union $result_type
) {
): void {
array_pop($key_parts);
$array_key = array_pop($key_parts);
array_pop($key_parts);

View File

@ -952,10 +952,7 @@ class Union implements TypeNode
return isset($this->types['empty']);
}
/**
* @return void
*/
public function substitute(Union $old_type, ?Union $new_type = null)
public function substitute(Union $old_type, ?Union $new_type = null): void
{
if ($this->hasMixed() && !$this->isEmptyMixed()) {
return;

View File

@ -75,10 +75,8 @@ if ($psalm_proxy !== false) {
array_map(
/**
* @param string $arg
*
* @return void
*/
function ($arg) use ($valid_long_options, $valid_short_options) {
function ($arg) use ($valid_long_options, $valid_short_options): void {
if (substr($arg, 0, 2) === '--' && $arg !== '--') {
$arg_name = preg_replace('/=.*$/', '', substr($arg, 2));

View File

@ -62,10 +62,8 @@ $options = getopt(implode('', $valid_short_options), $valid_long_options);
array_map(
/**
* @param string $arg
*
* @return void
*/
function ($arg) use ($valid_long_options, $valid_short_options) {
function ($arg) use ($valid_long_options, $valid_short_options): void {
if (substr($arg, 0, 2) === '--' && $arg !== '--') {
$arg_name = preg_replace('/=.*$/', '', substr($arg, 2));

View File

@ -153,10 +153,8 @@ if (isset($options['refactor'])) {
array_map(
/**
* @param string $arg
*
* @return void
*/
function ($arg) use ($valid_long_options, $valid_short_options) {
function ($arg) use ($valid_long_options, $valid_short_options): void {
if (substr($arg, 0, 2) === '--' && $arg !== '--') {
$arg_name = preg_replace('/=.*$/', '', substr($arg, 2));

View File

@ -82,10 +82,8 @@ $options = getopt(implode('', $valid_short_options), $valid_long_options);
array_map(
/**
* @param string $arg
*
* @return void
*/
function ($arg) use ($valid_long_options, $valid_short_options) {
function ($arg) use ($valid_long_options, $valid_short_options): void {
if (substr($arg, 0, 2) === '--' && $arg !== '--') {
$arg_name = preg_replace('/=.*$/', '', substr($arg, 2));

View File

@ -7,8 +7,7 @@ use SimpleXMLElement;
/** @psalm-suppress UnusedClass */
class AfterAnalysisPlugin implements \Psalm\Plugin\PluginEntryPointInterface
{
/** @return void */
public function __invoke(Plugin\RegistrationInterface $registration, ?SimpleXMLElement $config = null)
public function __invoke(Plugin\RegistrationInterface $registration, ?SimpleXMLElement $config = null): void
{
require_once __DIR__ . '/Hook/AfterAnalysis.php';

View File

@ -7,8 +7,7 @@ use SimpleXMLElement;
/** @psalm-suppress UnusedClass */
class FilePlugin implements \Psalm\Plugin\PluginEntryPointInterface
{
/** @return void */
public function __invoke(Plugin\RegistrationInterface $registration, ?SimpleXMLElement $config = null)
public function __invoke(Plugin\RegistrationInterface $registration, ?SimpleXMLElement $config = null): void
{
require_once __DIR__ . '/Hook/FileProvider.php';

View File

@ -7,8 +7,7 @@ use SimpleXMLElement;
/** @psalm-suppress UnusedClass */
class FunctionPlugin implements \Psalm\Plugin\PluginEntryPointInterface
{
/** @return void */
public function __invoke(Plugin\RegistrationInterface $registration, ?SimpleXMLElement $config = null)
public function __invoke(Plugin\RegistrationInterface $registration, ?SimpleXMLElement $config = null): void
{
require_once __DIR__ . '/Hook/MagicFunctionProvider.php';

View File

@ -15,15 +15,13 @@ class AfterAnalysis implements
* Called after analysis is complete
*
* @param array<string, list<IssueData>> $issues
*
* @return void
*/
public static function afterAnalysis(
Codebase $codebase,
array $issues,
array $build_info,
?SourceControlInfo $source_control_info = null
) {
): void {
if ($source_control_info) {
$source_control_info->toArray();
}

View File

@ -14,30 +14,26 @@ class FileProvider implements
{
/**
* Called before a file has been checked
*
* @return void
*/
public static function beforeAnalyzeFile(
StatementsSource $statements_source,
Context $file_context,
FileStorage $file_storage,
Codebase $codebase
) {
): void {
$file_storage = $codebase->file_storage_provider->get($statements_source->getFilePath());
$file_storage->custom_metadata['before-analysis'] = true;
}
/**
* Called before a file has been checked
*
* @return void
*/
public static function afterAnalyzeFile(
StatementsSource $statements_source,
Context $file_context,
FileStorage $file_storage,
Codebase $codebase
) {
): void {
$file_storage = $codebase->file_storage_provider->get($statements_source->getFilePath());
$file_storage->custom_metadata['after-analysis'] = true;
}

View File

@ -7,8 +7,7 @@ use SimpleXMLElement;
/** @psalm-suppress UnusedClass */
class MethodPlugin implements \Psalm\Plugin\PluginEntryPointInterface
{
/** @return void */
public function __invoke(Plugin\RegistrationInterface $registration, ?SimpleXMLElement $config = null)
public function __invoke(Plugin\RegistrationInterface $registration, ?SimpleXMLElement $config = null): void
{
require_once __DIR__ . '/Hook/FooMethodProvider.php';

View File

@ -7,8 +7,7 @@ use SimpleXMLElement;
/** @psalm-suppress UnusedClass */
class PropertyPlugin implements \Psalm\Plugin\PluginEntryPointInterface
{
/** @return void */
public function __invoke(Plugin\RegistrationInterface $registration, ?SimpleXMLElement $config = null)
public function __invoke(Plugin\RegistrationInterface $registration, ?SimpleXMLElement $config = null): void
{
require_once __DIR__ . '/Hook/FooPropertyProvider.php';

View File

@ -7,8 +7,7 @@ use SimpleXMLElement;
/** @psalm-suppress UnusedClass */
class SqlStringProviderPlugin implements \Psalm\Plugin\PluginEntryPointInterface
{
/** @return void */
public function __invoke(Plugin\RegistrationInterface $registration, ?SimpleXMLElement $config = null)
public function __invoke(Plugin\RegistrationInterface $registration, ?SimpleXMLElement $config = null): void
{
require_once __DIR__ . '/Hook/SqlStringProvider.php';
require_once __DIR__ . '/Hook/StringProvider/TSqlSelectString.php';

View File

@ -137,7 +137,7 @@ class ErrorBaselineTest extends TestCase
return true;
})
)->willReturn(null);
);
ErrorBaseline::create(
$this->fileProvider->reveal(),
@ -341,7 +341,7 @@ class ErrorBaselineTest extends TestCase
</file>
</files>'
);
$this->fileProvider->setContents(Argument::cetera())->willReturn(null);
$this->fileProvider->setContents(Argument::cetera());
$newIssues = [
'sample/sample-file.php' => [

View File

@ -13,10 +13,7 @@ class ClassLikeStorageInstanceCacheProvider extends \Psalm\Internal\Provider\Cla
{
}
/**
* @return void
*/
public function writeToCache(ClassLikeStorage $storage, ?string $file_path, ?string $file_contents)
public function writeToCache(ClassLikeStorage $storage, ?string $file_path, ?string $file_contents): void
{
$fq_classlike_name_lc = strtolower($storage->name);
$this->cache[$fq_classlike_name_lc] = $storage;

View File

@ -35,10 +35,7 @@ class FakeFileProvider extends \Psalm\Internal\Provider\FileProvider
return parent::getContents($file_path);
}
/**
* @return void
*/
public function setContents(string $file_path, string $file_contents)
public function setContents(string $file_path, string $file_contents): void
{
$this->fake_files[$file_path] = $file_contents;
}

View File

@ -115,90 +115,57 @@ class FakeFileReferenceCacheProvider extends \Psalm\Internal\Provider\FileRefere
return $this->cached_issues;
}
/**
* @return void
*/
public function setCachedFileReferences(array $file_references)
public function setCachedFileReferences(array $file_references): void
{
$this->cached_file_references = $file_references;
}
/**
* @return void
*/
public function setCachedClassLikeFiles(array $file_references)
public function setCachedClassLikeFiles(array $file_references): void
{
$this->cached_classlike_files = $file_references;
}
/**
* @return void
*/
public function setCachedMethodClassReferences(array $method_class_references)
public function setCachedMethodClassReferences(array $method_class_references): void
{
$this->cached_method_class_references = $method_class_references;
}
/**
* @return void
*/
public function setCachedNonMethodClassReferences(array $file_class_references)
public function setCachedNonMethodClassReferences(array $file_class_references): void
{
$this->cached_nonmethod_class_references = $file_class_references;
}
/**
* @return void
*/
public function setCachedMethodMemberReferences(array $member_references)
public function setCachedMethodMemberReferences(array $member_references): void
{
$this->cached_method_member_references = $member_references;
}
/**
* @return void
*/
public function setCachedMethodMissingMemberReferences(array $member_references)
public function setCachedMethodMissingMemberReferences(array $member_references): void
{
$this->cached_method_missing_member_references = $member_references;
}
/**
* @return void
*/
public function setCachedFileMemberReferences(array $member_references)
public function setCachedFileMemberReferences(array $member_references): void
{
$this->cached_file_member_references = $member_references;
}
/**
* @return void
*/
public function setCachedFileMissingMemberReferences(array $member_references)
public function setCachedFileMissingMemberReferences(array $member_references): void
{
$this->cached_file_missing_member_references = $member_references;
}
/**
* @return void
*/
public function setCachedMixedMemberNameReferences(array $references)
public function setCachedMixedMemberNameReferences(array $references): void
{
$this->cached_unknown_member_references = $references;
}
/**
* @return void
*/
public function setCachedMethodParamUses(array $uses)
public function setCachedMethodParamUses(array $uses): void
{
$this->cached_method_param_uses = $uses;
}
/**
* @return void
*/
public function setCachedIssues(array $issues)
public function setCachedIssues(array $issues): void
{
$this->cached_issues = $issues;
}
@ -213,10 +180,8 @@ class FakeFileReferenceCacheProvider extends \Psalm\Internal\Provider\FileRefere
/**
* @param array<string, array<string, int>> $analyzed_methods
*
* @return void
*/
public function setAnalyzedMethodCache(array $analyzed_methods)
public function setAnalyzedMethodCache(array $analyzed_methods): void
{
$this->cached_correct_methods = $analyzed_methods;
}
@ -245,20 +210,16 @@ class FakeFileReferenceCacheProvider extends \Psalm\Internal\Provider\FileRefere
* 2: array<int, array{0: int, 1: non-empty-string, 2: int}>
* }
* > $file_maps
*
* @return void
*/
public function setFileMapCache(array $file_maps)
public function setFileMapCache(array $file_maps): void
{
$this->cached_file_maps = $file_maps;
}
/**
* @param array<string, array{int, int}> $mixed_counts
*
* @return void
*/
public function setTypeCoverage(array $mixed_counts)
public function setTypeCoverage(array $mixed_counts): void
{
}
}

View File

@ -13,10 +13,7 @@ class FileStorageInstanceCacheProvider extends \Psalm\Internal\Provider\FileStor
{
}
/**
* @return void
*/
public function writeToCache(FileStorage $storage, string $file_contents)
public function writeToCache(FileStorage $storage, string $file_contents): void
{
$file_path = strtolower($storage->file_path);
$this->cache[$file_path] = $storage;
@ -33,10 +30,7 @@ class FileStorageInstanceCacheProvider extends \Psalm\Internal\Provider\FileStor
return $cached_value;
}
/**
* @return void
*/
public function removeCacheForFile(string $file_path)
public function removeCacheForFile(string $file_path): void
{
unset($this->cache[strtolower($file_path)]);
}

View File

@ -17,10 +17,7 @@ class ProjectCacheProvider extends \Psalm\Internal\Provider\ProjectCacheProvider
return $this->last_run;
}
/**
* @return void
*/
public function processSuccessfulRun(float $start_time)
public function processSuccessfulRun(float $start_time): void
{
$this->last_run = (int) $start_time;
}

View File

@ -10,6 +10,6 @@ class BasePlugin implements Psalm\Plugin\Hook\AfterFunctionCallAnalysisInterface
\Psalm\Codebase $codebase,
\Psalm\Type\Union $return_type_candidate,
array &$file_replacements
) {
): void {
}
}

View File

@ -7,8 +7,7 @@ require_once __DIR__ . '/extending_plugin.php';
class ExtendingPluginRegistration implements PluginEntryPointInterface
{
/** @return void */
public function __invoke(RegistrationInterface $r, ?SimpleXMLElement $config = null)
public function __invoke(RegistrationInterface $r, ?SimpleXMLElement $config = null): void
{
$r->registerHooksFromClass(ExtendingPlugin::class);
}