slope-it / breadcrumb-bundle

A bundle for generating dynamic breadcrumbs in Symfony applications
Other
10 stars 4 forks source link

Update return types. #4

Closed laurentmuller closed 2 years ago

laurentmuller commented 2 years ago

I have a project that use this bundle with symfony version 5.4. When I run PHP unit tests. Some warning are output:

1x: Method "Symfony\Component\HttpKernel\Bundle\Bundle::getContainerExtension()" might add "?ExtensionInterface" as a native return type declaration in the future. Do the same in child class "SlopeIt\BreadcrumbBundle\SlopeItBreadcrumbBundle" now to avoid errors or add an explicit @return annotation to suppress this message.

1x: Method "Symfony\Component\DependencyInjection\Extension\Extension::getAlias()" might add "string" as a native return type declaration in the future. Do the same in child class "SlopeIt\BreadcrumbBundle\DependencyInjection\SlopeItBreadcrumbExtension" now to avoid errors or add an explicit @return annotation to suppress this message.

1x: Method "Twig\Extension\ExtensionInterface::getFunctions()" might add "array" as a native return type declaration in the future. Do the same in implementation "SlopeIt\BreadcrumbBundle\Twig\BreadcrumbExtension" now to avoid errors or add an explicit @return annotation to suppress this message.

1x: Method "Symfony\Component\Config\Definition\ConfigurationInterface::getConfigTreeBuilder()" might add "TreeBuilder" as a native return type declaration in the future. Do the same in implementation "SlopeIt\BreadcrumbBundle\DependencyInjection\Configuration" now to avoid errors or add an explicit @return annotation to suppress this message.

To stop all this warnings, just modify code to add a return type. For example for SlopeItBreadcrumbBundle warning:

Before:

 /**
   * {@inheritdoc}
   */
  public function getContainerExtension()
  {
      return new SlopeItBreadcrumbExtension();
  }

After:

 /**
   * {@inheritdoc}
   */
  public function getContainerExtension(): ?ExtensionInterface
  {
      return new SlopeItBreadcrumbExtension();
  }

Or

 /**
   * {@inheritdoc}
   * 
   * @return ExtensionInterface|null
   */
  public function getContainerExtension()
  {
      return new SlopeItBreadcrumbExtension();
  }
asprega commented 2 years ago

Hi Laurent! I just opened a pull request to address the issue you reported. I don't know how to have the test suite report warnings like you reported. Do you have any suggestions?

Also, as I wasn't able to reproduce, can you give this PR a try and let me know if it fixes your issue? Thanks!

laurentmuller commented 2 years ago

I have an application that use the Symfony framework, I'm using Windows 10 and simple call the batch file:

\vendor\bin\phpunit.bat

laurentmuller commented 2 years ago

I have tried to use the fix-return-types branch but You changed the composer.json with dependencies to symfony/yaml version 4.0. It is not compatible with version 5.0.

Can You update this dependency? It is just matter of change the following line:

From: "symfony/yaml": "^4.0",

To: "symfony/yaml": "^4.0|^5.0",

asprega commented 2 years ago

sorry, that was unintended :) I updated the branch, can you please check again? Thanks!

laurentmuller commented 2 years ago

Great. No more warning!

Good job and thank You

asprega commented 2 years ago

Thanks for your report. I just tagged a 1.1.1 release so you can install it in your project. Have a good day!