glorpen / kimai-duration-plugin

Enables setting duration rounding option (same as global one) to override rounding for any Customer, Project or Activity.
GNU General Public License v3.0
3 stars 3 forks source link

PHP Fatal error: Incompatible Declaration #3

Closed terdinatore closed 1 year ago

terdinatore commented 1 year ago

Hi there, thanks for the plugin! Just wanted to let you know that there is an issue when I try to reload the cache after the plugin has been cloned.

I have created a PR #4 with an untested fix. It would be great if you gave it a glance whenever possible.

PHP Fatal error:  Declaration of KimaiPlugin\GlorpenDurationBundle\Timesheet\Rounding\OverriddenDurationRounding::roundBegin(App\Entity\Timesheet $record, int $minutes): void must be compatible with App\Timesheet\Rounding\RoundingInterface::roundBegin(App\Entity\Timesheet $record, $minutes) in /opt/kimai/var/plugins/GlorpenDurationBundle/Timesheet/Rounding/OverriddenDurationRounding.php on line 72
[2023-05-07 20:41:09] php.CRITICAL: Fatal Compile Error: Declaration of KimaiPlugin\GlorpenDurationBundle\Timesheet\Rounding\OverriddenDurationRounding::roundBegin(App\Entity\Timesheet $record, int $minutes): void must be compatible with App\Timesheet\Rounding\RoundingInterface::roundBegin(App\Entity\Timesheet $record, $minutes) {"exception":"[object] (Symfony\\Component\\ErrorHandler\\Error\\FatalError(code: 0): Compile Error: Declaration of KimaiPlugin\\GlorpenDurationBundle\\Timesheet\\Rounding\\OverriddenDurationRounding::roundBegin(App\\Entity\\Timesheet $record, int $minutes): void must be compatible with App\\Timesheet\\Rounding\\RoundingInterface::roundBegin(App\\Entity\\Timesheet $record, $minutes) at /opt/kimai/var/plugins/GlorpenDurationBundle/Timesheet/Rounding/OverriddenDurationRounding.php:72)"} []

In OverriddenDurationRounding.php line 72:

  [Symfony\Component\ErrorHandler\Error\FatalError]
  Compile Error: Declaration of KimaiPlugin\GlorpenDurationBundle\Timesheet\Rounding\OverriddenDurationRounding::roundBegin(
  App\Entity\Timesheet $record, int $minutes): void must be compatible with App\Timesheet\Rounding\RoundingInterface::roundB
  egin(App\Entity\Timesheet $record, $minutes)

Exception trace:
  at /opt/kimai/var/plugins/GlorpenDurationBundle/Timesheet/Rounding/OverriddenDurationRounding.php:72
glorpen commented 1 year ago

int / void type was introduced in Kimai v2.0.0, could it be that you installed glorpen-duration-plugin in version 2.0 on Kimai v1.x? If it is the case, try with https://github.com/glorpen/kimai-duration-plugin/tree/v1.0.2 instead - same functionality but for Kimai 1.x.

terdinatore commented 1 year ago

I am pretty sure that I am using the latest kimai/kimai2:apache docker image. Could it be that the types have been removed again in the upstream?

glorpen commented 1 year ago

Well, using kimai/kimai2:apache would explain it, seems that not all of their images with "latest" tags are v2:

docker run --rm -it --entrypoint '' kimai/kimai2:apache cat /opt/kimai/version.txt
1.30.11
docker run --rm -it --entrypoint '' kimai/kimai2:apache-2.0.10-prod cat /opt/kimai/version.txt
2.0.10
terdinatore commented 1 year ago

Okay, thank you for this clarification. I wasn't aware that there is something weird going on with the versions (see https://github.com/tobybatch/kimai2/issues/503#issuecomment-1508526542)