chronos icon indicating copy to clipboard operation
chronos copied to clipboard

Move property docblocks from Chronos and Date to ChronosInterface

Open votemike opened this issue 7 years ago • 5 comments

I am using PHPStan on my code. I am calling ->year and ->month on an object that is typehinted with ChronosInterface which is causing PHPStan to complain with the error "Access to an undefined property Cake\Chronos\ChronosInterface::$month." Should the docblocks for these shared properties be moved down to ChronosInterface?

votemike avatar Sep 05 '17 09:09 votemike

Should the docblocks for these shared properties be moved down to ChronosInterface?

The properties aren't part of the interface, so I'm not sure they should be moved down.

markstory avatar Sep 05 '17 17:09 markstory

Hmmm. I see your point. They come from the PHP base DateTimeImmutable don't they? Is there any way we could tidy this up? Or not?

votemike avatar Sep 05 '17 17:09 votemike

Those properties come from the __get implementation in the MagicPropertyTrait.

markstory avatar Sep 06 '17 01:09 markstory

Do we expect users to typehint with ChronosInterface for both Date and Chronos objects?

othercorey avatar Nov 14 '19 03:11 othercorey

I think users should be able to do what they like.

votemike avatar Nov 14 '19 08:11 votemike

I think this should be closed. The interface (for obvious reasons) doesn't have these properties so if an implementing class is accessing them the annotation needs to be on that class.

MGatner avatar Sep 05 '22 16:09 MGatner