Raistlfiren/garmin-csv-plan

PHP 8 support

Silver-Saucepan opened this issue · 9 comments

Hello! Please could garmin-csv-plan be updated to run on PHP 8?

I'm on the current LTS version of Ubuntu and composer install gives:
Root composer.json requires php ^7.2.5 but your php version (8.1.2) does not satisfy that requirement.

Simply editing composer.json to allow PHP 8 doesn't seem to be enough, because I then get:

[Symfony\Component\DependencyInjection\Exception\RuntimeException] Cannot autowire service "App\Command\WorkoutCommand": argument "$name" of method "__construct()" is type-hinte d "string", you should configure its value explicitly.

Thanks in anticipation
Paul

Hey @Silver-Saucepan,

Thank you for reporting the issue. I definitely will look into this and try to get this addressed soon. There shouldn't be too many changes to update PHP to 8.1, but I need to test functionality and make sure I don't break anything in the process. Sadly, I probably won't be able to update and test the code right now since I will be out for 4-5 days. I would recommend using the Docker files to use it with PHP 7.

In the meantime, have a great run! Sorry for the inconvenience. :)

@Silver-Saucepan - I have created a new branch for PHP 8.1 compatibility. Please try using that for now. It isn't perfect, but I will be working through some kinks and testing things this week and next.

@Raistlfiren - many thanks for looking into this.

I have a csv file which works well using a raspberry pi with PHP 7.4, but with 8.1 using the new branch on my desktop machine I get this:

paul@neon-user:garmin-csv-plan$ ./bin/console garmin:workout ~/file.csv schedule -s '2023-01-19' -x -r 'BPHM:'

Starting workout import/export command
======================================

Validating and accessing - /home/paul/file.csv
----------------------------------------------

[critical] Error thrown while running command "garmin:workout '/home/paul/file.csv' schedule -s 2023-01-19 -x -r 'BPHM:'". Message: "Invalid file. Please make sure the file exists."

In Parser.php line 38:
                                                   
  Invalid file. Please make sure the file exists.  
                                                   

garmin:workout [-m|--email EMAIL] [-p|--password PASSWORD] [-x|--delete] [-X|--delete-only] [--dry-run] [-r|--prefix [PREFIX]] [--pool-size [POOL-SIZE]] [-s|--start START] [-d|--end END] [--] <csv> [<type>]

2023-01-31T13:35:54+00:00 [info] User Deprecated: Method "Symfony\Component\EventDispatcher\EventSubscriberInterface::getSubscribedEvents()" might add "array" as a native return type declaration in the future. Do the same in implementation "App\Subscriber\WorkoutCommandSubscriber" now to avoid errors or add an explicit @return annotation to suppress this message.

file.csv

@Silver-Saucepan - I tried the test file and I was able to run it without a problem. Can you double-check the file path, please? I have updated the repository, but it is mostly to get rid of deprecation messages.

@Raistlfiren - the error was thrown if I specified the file path as ~/file.csv or /home/paul/file.csv, but not if I used ../../file.csv, or if I copied the file to the source directory just file.csv was OK

After doing a git pull I now get this:

In ArrayNode.php line 322:
                                                                                                                                                    
  Unrecognized option "handle_all_throwables" under "framework". Available options are "annotations", "assets", "cache", "csrf_protection", "defau  
  lt_locale", "disallow_search_engine_index", "enabled_locales", "error_controller", "esi", "exceptions", "form", "fragments", "http_cache", "http  
  _client", "http_method_override", "ide", "lock", "mailer", "messenger", "notifier", "php_errors", "profiler", "property_access", "property_info"  
  , "rate_limiter", "request", "router", "secret", "secrets", "serializer", "session", "set_content_language_from_locale", "set_locale_from_accept  
  _language", "ssi", "test", "translator", "trusted_headers", "trusted_hosts", "trusted_proxies", "uid", "validation", "web_link", "workflows".     

@Silver-Saucepan - Thank you for the update. The error is probably because I updated Symfony to 6.2. Please do a composer update to install the latest version of Symfony.

@Raistlfiren - composer update fixed the ArrayNode.php error. The path problem persists (~/file.csv and /home/paul/file.csv but OK with ../../file.csv). I'm happy to work with that thanks :-)

Excellent! I should probably include that in the documentation to specify a relative path than an absolute path. I will update the README and merge the changes into the master branch when I get time.

Take care @Silver-Saucepan. Happy running! :)