1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-04 10:38:49 +01:00
psalm/docs/running_psalm/issues/AssignmentToVoid.md
2020-03-21 09:48:35 -04:00

516 B
Raw Blame History

AssignmentToVoid

Emitted when assigning from a function that returns void:

<?php

function foo() : void {}
$a = foo();

Why this is bad

Though void-returning functions are treated by PHP as returning null (so this on its own doesnt lead to runtime errors), void is a concept more broadly in programming languages which is not designed for assignment purposes.

How to fix

You should just be able to remove the assignment entirely:

<?php

function foo() : void {}
foo();