azuyalabs / yasumi

The easy PHP Library for calculating holidays
https://www.yasumi.dev
Other
1.05k stars 155 forks source link

Fix BC break add missing method `ProviderInterface::getHolidays` #277

Closed ghost closed 2 years ago

ghost commented 2 years ago

In the previous version Yasumi\Yasumi::create was returning Yasumi\Provider\AbstractProvider now its return Yasumi\ProviderInterface without method getHolidays . Even tests expects that ProviderInterface::getHolidays exists for example Yasumi\tests\Base\YasumiTest::testRemoveHoliday

stelgenhof commented 2 years ago

@jwojtyra-aterian Thank you very much for the PR. Could give me an example of how this would break things? All tests are successful (Unless the tests missed something :) )

ghost commented 2 years ago

Sure, an example from this repo, I run phpstan with current configuration but for some tests ./vendor/bin/phpstan analyse tests/Base here is part of the output. For the same reason I cannot upgrade yasumi in my project


 ------ -------------------------------------------------------------------------- 
  Line   YasumiTest.php                                                            
 ------ -------------------------------------------------------------------------- 
  138    Call to an undefined method Yasumi\ProviderInterface::count().            
  139    Call to an undefined method Yasumi\ProviderInterface::count().            
  140    Call to an undefined method Yasumi\ProviderInterface::count().            
  183    Call to an undefined method Yasumi\ProviderInterface::next().             
  199    Call to an undefined method Yasumi\ProviderInterface::next().             
  220    Call to an undefined method Yasumi\ProviderInterface::previous().         
  237    Call to an undefined method Yasumi\ProviderInterface::previous().         
  248    Call to an undefined method Yasumi\ProviderInterface::getHolidayNames().  
  264    Call to an undefined method Yasumi\ProviderInterface::whenIs().           
  280    Call to an undefined method Yasumi\ProviderInterface::whenIs().           
  305    Call to an undefined method Yasumi\ProviderInterface::whatWeekDayIs().    
  321    Call to an undefined method Yasumi\ProviderInterface::whatWeekDayIs().    
  380    Call to an undefined method Yasumi\ProviderInterface::isHoliday().        
  385    Call to an undefined method Yasumi\ProviderInterface::isHoliday().        
  410    Call to an undefined method Yasumi\ProviderInterface::isHoliday().        
  415    Call to an undefined method Yasumi\ProviderInterface::isHoliday().    

  490    Call to an undefined method Yasumi\ProviderInterface::getHolidays().    

  508    Call to an undefined method Yasumi\ProviderInterface::removeHoliday().    
  509    Call to an undefined method Yasumi\ProviderInterface::removeHoliday().    
  510    Call to an undefined method Yasumi\ProviderInterface::removeHoliday().    
  512    Call to an undefined method Yasumi\ProviderInterface::getHolidays().      
  578    Call to an undefined method Yasumi\ProviderInterface::getHolidayNames().  
  581    Call to an undefined method Yasumi\ProviderInterface::addHoliday().       
  582    Call to an undefined method Yasumi\ProviderInterface::getHolidayNames().  
  583    Call to an undefined method Yasumi\ProviderInterface::getHolidayNames().  
  588    Call to an undefined method Yasumi\ProviderInterface::addHoliday().       
  589    Call to an undefined method Yasumi\ProviderInterface::getHolidayNames().  
  590    Call to an undefined method Yasumi\ProviderInterface::getHolidayNames().  
  591    Call to an undefined method Yasumi\ProviderInterface::getHolidayNames().  
  592    Call to an undefined method Yasumi\ProviderInterface::getHolidayNames().  
  593    Call to an undefined method Yasumi\ProviderInterface::getHolidayNames().  
 ------ -------------------------------------------------------------------------- 
stelgenhof commented 2 years ago

@jwojtyra-aterian Indeed, the test classes are not yet following the checks as the base code (src) does. You should run phpstan with the provided phpstan config (phpstan.neon.dist) or use the included composer script composer phpstan.

Not sure I understand why you can't upgrade Yasumi in your project. PHPStan does not look at vendor packages when you use Yasumi as a composer package.

ghost commented 2 years ago

Yes but just like wrote at the beginning, I use method getHolidays and previously Yasumi::create returns AbstractProvider that have this method, now it returns ProviderInterface without this method. And PHPStan finds those errors in the codebase.

stelgenhof commented 2 years ago

Ah, you mean when using PHPStan for your own project?

ghost commented 2 years ago

yes

stelgenhof commented 2 years ago

I see, Sorry it wasn't immediately clear to me from your description. I'll make a fix for this.