Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compatibility with endroid/qr-code 4 #84

Merged
merged 1 commit into from
Feb 14, 2022
Merged

Fix compatibility with endroid/qr-code 4 #84

merged 1 commit into from
Feb 14, 2022

Conversation

MasterOdin
Copy link
Contributor

@MasterOdin MasterOdin commented Dec 1, 2021

Closes #82

This PR adds compatibility with endroid/qr-code:^4 while maintaining support for older versions.

Test code:

<?php

use RobThree\Auth\Providers\Qr\EndroidQrCodeProvider;
use RobThree\Auth\Providers\Qr\EndroidQrCodeWithLogoProvider;

require_once(__DIR__ . '/vendor/autoload.php');

$filename = method_exists(\Endroid\QrCode\QrCode::class, 'create') ? 'test2.png' : 'test1.png';

$provider = new EndroidQrCodeProvider();
file_put_contents(__DIR__ . '/' . $filename, $provider->getQRCodeImage('foobar', 80));

$provider2 = new EndroidQrCodeWithLogoProvider();
$provider2->setLogo(__DIR__ . '/logo.jpeg', [30, 30]);
file_put_contents(__DIR__ . '/logo-' . $filename, $provider2->getQRCodeImage('foobar', 80));

logo.jpeg:
logo

endroid/qr-code:^3 results:
test1

logo-test1

endroid/qr-code:^4 result:
test2

logo-test2

Copy link
Collaborator

@willpower232 willpower232 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if it works for you then that is great (I don't know endroid enough to test), my only critique would be the unnecessary else before return

@MasterOdin
Copy link
Contributor Author

MasterOdin commented Dec 1, 2021

my only critique would be the unnecessary else before return

replaced.

if it works for you then that is great (I don't know endroid enough to test)

Yeah, that's why I included the test script in the OP to make it easy to verify, along with the generated images from running it. I have used various options to confirm they’ve work as well (setting different colors, image height / width, etc.).

@willpower232
Copy link
Collaborator

Thanks for that.

I'd like the php 8.1 thing to be resolved and then ship a release to fix both unless it takes too long to figure out and you need this fix shipping sooner 😅

I wonder if it is also worth creating another github workflow or two to specifically test against both versions of Endroid, and Bacon for that matter.

@MasterOdin
Copy link
Contributor Author

What is done in other projects I work on is to have a workflow that installs the latest dependencies that work (what's currently happening here) and the lowest dependencies and makes sure the whole range works. A similar thing could be done here, sure.

Though need to also write a test suite for endroid and bacon at the same time.

@MasterOdin
Copy link
Contributor Author

I'd like the php 8.1 thing to be resolved and then ship a release to fix both unless it takes too long to figure out and you need this fix shipping sooner

At this point, ideally a maintainer would be able to add the test I made to #83 and then merge it in relatively quickly, the pieces are all there.

@willpower232
Copy link
Collaborator

@MasterOdin it would be good to get your feedback on #86 as it would be a good way of testing both version 3 and 4 of endroid separately

@RobThree
Copy link
Owner

I'd like the php 8.1 thing to be resolved and then ship a release to fix both unless it takes too long to figure out and you need this fix shipping sooner

At this point, ideally a maintainer would be able to add the test I made to #83 and then merge it in relatively quickly, the pieces are all there.

Is there something I can do? I'm a bit unclear as what needs to still be done.

@willpower232
Copy link
Collaborator

@MasterOdin would you be able to rebase your branch (or merge master into it) and then you can set up a test for both version 3 and 4 as separate workflows?

@MasterOdin
Copy link
Contributor Author

@willpower232 I've rebased the PR on top of the latest master, as well as added a minimal test suite that tests using the provider "works" across a range of PHP / dependency versions.

@willpower232
Copy link
Collaborator

thank you very much, I'll go over it shortly and get a release out

@willpower232 willpower232 merged commit dc681e1 into RobThree:master Feb 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

endroid/qr-code compatibility issue
3 participants