In PHP 7 the correct code should be
function foo(?string $bar): void
Having `= null` marks the parameter as optional with the default being `null`. Using `?string` means there is no default and you can pass in either a string or null.