lcobucci/clock

Update from PHP 8.1 to PHP 8.3

Closed this issue ยท 5 comments

Hi, I am using lcobucci/clock:3.0.0 with PHP 8.1. Now I'm trying to upgrade to PHP 8.3 and I'm getting the problem

composer why-not php ^8.3
Package "php" could not be found with constraint "^8.3", results below will most likely be incomplete.
lcobucci/clock 3.0.0 requires php (~8.1.0 || ~8.2.0) 

Do I understand correctly, given the PHP dependencies https://github.com/lcobucci/clock/blob/3.0.x/composer.json#L13 I need to upgrade to PHP 8.2. Then upgrade lcobucci/clock to version 3.2.0 because it supports PHP 8.2 and 8.3 https://github.com/lcobucci/clock/blob/3.2.x/composer.json#L13. And thereafter I can upgrade to PHP 8.3.

I don't see any critical code changes that would forbid me from using version 3.0.0 with PHP 8.3
3.0.x...3.3.x

I think it would be great if version 3.0.0 (or 3.0.1) depended on php >= 8.1

Hi @pmlkvch, AFAIK that shouldn't happen but it might depend on the version constraint you have on your composer.json file.

We won't follow up on your suggestion because the support of a new php version isn't a bug fix, therefore it gets a minor release not a patch. Even though the changes are minimal, PHP has BC-breaks in minor releases and this is the way we guarantee compatibility.

What version constraint are you using for lcobucci/clock?

If this package is the only one blocking your upgrade, you may bump php and lcobucci/clock together (composer require php:^8.3 lcobucci/jwt:^3.2).

My version constraint are as follows:
php: ^8.1
lcobucci/clock: ^3.0

I need the code to work with both PHP 8.1 and PHP 8.3. Therefore, the composer require php:^8.3 suggestion does not work.

I'm following this upgrade plan:

  • update the code that is considered incompatible or deprecated in PHP 8.2 and 8.3
  • update the code on production
  • update PHP version to 8.3 on each server

Perhaps you have suggestions on how to do this with the current limitations.

Hi @pmlkvch

You can use https://github.com/okvpn/clock-lts

composer require okvpn/clock-lts

Also you may fork this package and update composer.json with replace

{
    "name": "acme/clock",
    "require": {
        "php": ">=7.2",
        "psr/clock": "^1.0"
    },
    "replace": {
        "lcobucci/clock": "*"
    },
   ....

@pmlkvch I now understand your constraints and you indeed won't be able to have a single lock file that will be usable for both php 8.1 and 8.3 using this library.

The policy I follow for PHP version support in my libs don't accommodate for what you need.

You can:

  1. Compromise: ignore php requirements when installing dependencies in either php versions (composer install --ignore-platform-req=php) or use different lock files for the different php versions
  2. Rely on PSR-20 and temporarily (or not ๐Ÿ˜…) any other implementation (the one @vtsykun shared or incubate one in your project, instructing composer to consider it a replacement of lcobucci/clock). When you're on php 8.3 only you may pin to v3.2 and move forward.

I hope that helps your migration ๐Ÿ‘

@vtsykun, @lcobucci thank you for your advice. I used composer.json with replace, it works.