Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SplFileInfo::getSize returns int instead of int|false #8642

Closed
neclimdul opened this issue Nov 1, 2022 · 1 comment · Fixed by #8644
Closed

SplFileInfo::getSize returns int instead of int|false #8642

neclimdul opened this issue Nov 1, 2022 · 1 comment · Fixed by #8644

Comments

@neclimdul
Copy link
Contributor

At least, I think there's something wrong with the stub for this method. The documentation says int or null on failure but trying to handle the failure condition results in a warning from psalm.

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/bdaae2f851
<?php declare(strict_types = 1);

class HelloWorld
{
	public function __construct(private \SplFileObject $file) {}
	public function sayHello(): ?int
	{
		$size = $this->file->getSize();
		if ($size !== false) {
			return $size;
		}
		// so some other things.
		return null;		
	}
}
Psalm output (using commit 7c83878):

ERROR: RedundantCondition - 9:7 - int can never contain false

neclimdul added a commit to neclimdul/psalm that referenced this issue Nov 1, 2022
Update SplFileInfo method signatures and related classes.

Fixes vimeo#8642
neclimdul added a commit to neclimdul/psalm that referenced this issue Nov 1, 2022
Update SplFileInfo method signatures and related classes.

Fixes vimeo#8642
orklah pushed a commit to neclimdul/psalm that referenced this issue Nov 4, 2022
Update SplFileInfo method signatures and related classes.

Fixes vimeo#8642
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant