Hi,

I think it's a valid point of view.

Simple example I can think of is that develop might want to use reuse the
simple implementation that never fails instead of the interface in a
private method/class.
And he knows that it will not fail so it should not be hinted by editor to
handle the exception.

Alex

On Mon, Nov 26, 2018 at 1:51 PM Robbie Averill <rob...@silverstripe.com>
wrote:

> Good afternoon,
>
> It seems to me that your interface says that it throws an exception "if an
> operation fails." If your implementation has no way of failing, then the
> fact that it never throws an exception is not of consequence. In future
> your implementation may change and may fail, in which case you have an
> exception you can throw without breaking the public API definition.
>
> TL;DR: I don't see a problem with your example code.
>
> Regards
> Robbie
>
> On Mon, 26 Nov 2018 at 12:42, Nicholas Ruunu <nicho...@ruu.nu> wrote:
>
>> A lot of people, me included, try not to handle exceptions at all.
>> But if you need to handle them, it's probably a good idea to do so even
>> if the specific implementation doesn't throw.
>> Since otherwise you'd have a problem if you switch to an implementation
>> that do throw in the future.
>>
>> Den måndag 26 november 2018 kl. 12:28:06 UTC+1 skrev Magnar Ovedal
>> Myrtveit:
>>>
>>> According to the current version of PSR-19, PHPDoc is implicitly
>>> inherited, and even when PHPDoc is present in both the subclass and the
>>> superclass, tags that are present in the superclass' PHPDoc but not in the
>>> subclass' PHPDoc are inherited.
>>>
>>> I think this is a very good idea, but I see a potential issue. Consider
>>> the following code.
>>> interface FooInterface {
>>> /**
>>> * @throws RuntimeException If the operation fails.
>>> */
>>> public function foo();
>>> }
>>>
>>> class FooImplementation implements FooInterface {
>>> public function foo() {
>>> // Do something that will never fail.
>>> }
>>> }
>>>
>>> FooImplementation::foo() will never throw an exception, but FooInterface
>>> allows other implementations of FooInterface::foo() to throw exceptions.
>>> For someone depending on FooInterface, they will have to handle any thrown
>>> exceptions. For someone depending on FooImplementation, however, they do
>>> not have to care about FooImplementation::foo() throwing exceptions. But
>>> there seems to be no way to prevent FooImplementation::foo() from
>>> inheriting the @throws tag from FooInterface::foo().
>>>
>>> Do we need a way to specify tags that should not be inherited?
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "PHP Framework Interoperability Group" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to php-fig+unsubscr...@googlegroups.com.
>> To post to this group, send email to php-fig@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/php-fig/b1619215-f3e3-4865-9465-c5f2346a9536%40googlegroups.com
>> <https://groups.google.com/d/msgid/php-fig/b1619215-f3e3-4865-9465-c5f2346a9536%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> --
> Robbie Averill | Senior Developer
> 04 978 7330
> http://silverstripe.com/
>
> --
> You received this message because you are subscribed to the Google Groups
> "PHP Framework Interoperability Group" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to php-fig+unsubscr...@googlegroups.com.
> To post to this group, send email to php-fig@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/php-fig/CANv6TC0PVd0enH6Euey11pd0%2BhGo7m4AkueN5CTVM_gJaoXvCg%40mail.gmail.com
> <https://groups.google.com/d/msgid/php-fig/CANv6TC0PVd0enH6Euey11pd0%2BhGo7m4AkueN5CTVM_gJaoXvCg%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "PHP 
Framework Interoperability Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to php-fig+unsubscr...@googlegroups.com.
To post to this group, send email to php-fig@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/php-fig/CAAwdEzDjkq6_YgTVSGGQnNVi0a%2BsmLWVp9NC1OYPaejjW%2BKhZQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to