-
Notifications
You must be signed in to change notification settings - Fork 8
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
Php storm flags unwrap method as unreachble statement #16
Comments
Yeah I can see why that would happen.. I don't know what's kosher here, to me it seems it should say that it returns @Lctrs can you shed some light here? I'm out of the loop with PHP, haven't been in the ecosystem since 2018 basically, but happy to help in any way I can. |
Arguably, I would say that Given that |
Wouldn't letting None say it's returning T work as well? |
Yeah, I was talking about the current state of the lib. |
Yeah as you implied, PHP can't infer stuff. I guess Psalm would be able to if it was advanced enough. What I don't understand is how phpStorm finds the The Rust impl looks like this: pub const fn unwrap(self) -> T {
match self {
Some(val) => val,
None => panic("called `Option::unwrap()` on a `None` value"),
}
} If phpStorm indeed does read the types in |
* remove handling of `$pass` properties, as this is not the role of `Option`'s subclasses to pass them around. * simplify phpdoc types, making `Option` the only source of truth for most methods * added some static analysis assert for `Option#isSome()` and `Option#isNone()` (closes prewk#16) * added `Option#inspect()` and `Option#filter()` from their Rust counterparts * migrating from phpspec to PHPUnit * added a Makefile to help during development * added a coding standard via `easy-coding-standard` * added mutation testing coverage via `infection` * added some static analysis tests * modernize github actions setup * added dependabot config * upgrading all dependencies
* dropping support for `PHP < 8.1.0` * remove handling of `$pass` properties, as this is not the role of `Option`'s subclasses to pass them around. * simplify phpdoc types, making `Option` the only source of truth for most methods * added some static analysis assert for `Option#isSome()` and `Option#isNone()` (closes prewk#16) * added `Option#inspect()` and `Option#filter()` from their Rust counterparts * migrating from phpspec to PHPUnit * added a Makefile to help during development * added a coding standard via `easy-coding-standard` * added mutation testing coverage via `infection` * added some static analysis tests * modernize github actions setup * added dependabot config * upgrading all dependencies
* dropping support for `PHP < 8.1.0` * remove handling of `$pass` properties, as this is not the role of `Option`'s subclasses to pass them around. * simplify phpdoc types, making `Option` the only source of truth for most methods * added some static analysis assert for `Option#isSome()` and `Option#isNone()` (closes prewk#16) * added `Option#inspect()` and `Option#filter()` from their Rust counterparts * migrating from phpspec to PHPUnit * added a Makefile to help during development * added a coding standard via `easy-coding-standard` * added mutation testing coverage via `infection` * added some static analysis tests * modernize github actions setup * added dependabot config * upgrading all dependencies
* dropping support for `PHP < 8.1.0` * remove handling of `$pass` properties, as this is not the role of `Option`'s subclasses to pass them around. * simplify phpdoc types, making `Option` the only source of truth for most methods * added some static analysis assert for `Option#isSome()` and `Option#isNone()` (closes prewk#16) * added `Option#inspect()` and `Option#filter()` from their Rust counterparts * migrating from phpspec to PHPUnit * added a Makefile to help during development * added a coding standard via `easy-coding-standard` * added mutation testing coverage via `infection` * added some static analysis tests * modernize github actions setup * added dependabot config * upgrading all dependencies
* dropping support for `PHP < 8.1.0` * simplify phpdoc types, making `Option` the only source of truth for most methods * added some static analysis assert for `Option#isSome()` and `Option#isNone()` (closes prewk#16) * added `Option#inspect()` and `Option#filter()` from their Rust counterparts * migrating from phpspec to PHPUnit * added a Makefile to help during development * added a coding standard via `easy-coding-standard` * added mutation testing coverage via `infection` * added some static analysis tests * modernize github actions setup * added dependabot config * upgrading all dependencies
* dropping support for `PHP < 8.1.0` * simplify phpdoc types, making `Option` the only source of truth for most methods * added some static analysis assert for `Option#isSome()` and `Option#isNone()` (closes #16) * added `Option#inspect()` and `Option#filter()` from their Rust counterparts * migrating from phpspec to PHPUnit * added a Makefile to help during development * added a coding standard via `easy-coding-standard` * added mutation testing coverage via `infection` * added some static analysis tests * modernize github actions setup * added dependabot config * upgrading all dependencies
The
@psalm-return never-return
annotation for the unwrap() in classNone
, flags any proceeding code as unreachable when using Option as a reutrn type.Using the native php
never
return type (from 8.1) instead of the annotation seems to solve my issue.Maybe you have an idea? or perhaps i should return union type Some|None instead?
The text was updated successfully, but these errors were encountered: