You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Cannot override DirectoryIterator::current() without return typehint in 8.1 #8192
Deprecated: Return type of OverrideValidDirectoryIterator::valid() should either be compatible with DirectoryIterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/S7tkM on line 4
Fatal error: Declaration of OverrideCurrentDirectoryIterator::current() must be compatible with DirectoryIterator::current(): mixed in /in/S7tkM on line 10
Obviously the first here is just a form of the documented 8.1 deprecation of overriding core classes without matching return typehints, but unlike for other methods on DirectoryIterator, overriding current() in this way is a fatal error and not an E_DEPRECATED, and the ReturnTypeWillChange attribute has no effect.
changed the title [-]Cannot override DirectoryIterator::current() in 8.1[/-][+]Cannot override DirectoryIterator::current() without return typehint in 8.1[/+]on Mar 11, 2022
I haven't actually checked but I think that might come down to no return type meaning mixed|void. Since mixed|void is not a subtype of mixed but the other way around, omitting the type here would make the signature incompatible. Although since in PHP void still returns null that doesn't really matter. So allowing this, at least for internal methods, could still make sense.
Edit: But yes you're right in either case this should at most emit a deprecation.
Yeah, I'm not reporting about the incompatibility of mixed and "no hint", but just that in this case it's an error where the documentation indicates it should be a deprecation, as you said in your edit.
Activity
[-]Cannot override DirectoryIterator::current() in 8.1[/-][+]Cannot override DirectoryIterator::current() without return typehint in 8.1[/+]iluuu1994 commentedon Mar 11, 2022
I haven't actually checked but I think that might come down to no return type meaning
mixed|void. Sincemixed|voidis not a subtype ofmixedbut the other way around, omitting the type here would make the signature incompatible. Although since in PHPvoidstill returnsnullthat doesn't really matter. So allowing this, at least for internal methods, could still make sense.Edit: But yes you're right in either case this should at most emit a deprecation.
zerocrates commentedon Mar 12, 2022
Yeah, I'm not reporting about the incompatibility of
mixedand "no hint", but just that in this case it's an error where the documentation indicates it should be a deprecation, as you said in your edit.Make DirectoryIterator current() / key() return types tentative