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

PHP 7.4 support #383

Closed
SteveDesmond-ca opened this issue Jan 1, 2020 · 8 comments
Closed

PHP 7.4 support #383

SteveDesmond-ca opened this issue Jan 1, 2020 · 8 comments

Comments

@SteveDesmond-ca
Copy link

As of right now, ANet's PHP SDK cannot run on PHP 7.4, as it throws errors about invalid code in the various model types, e.g.

    <h4>A PHP Error was encountered</h4>

    <p>Severity: 8192</p>
    <p>Message: Cannot use "parent" when current class scope has no parent</p>
    <p>Filename: v1/MessagesType.php</p>
    <p>Line Number: 134</p>

I believe this is due to the new JIT compiler seeing things like

    return array_merge(parent::jsonSerialize(), $values);

on classes that don't actually have parents.

PR #382 already exists and appears to fix this, but even just some news that an in-house solution is in the works would be helpful.

@Nix-id
Copy link

Nix-id commented Jul 15, 2020

I also have same problem.

Deprecated: Cannot use "parent" when current class scope has no parent in /var/www/html/vendor/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/OrderType.php on line 532

Deprecated: Cannot use "parent" when current class scope has no parent in /var/www/html/vendor/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/NameAndAddressType.php on line 262

Deprecated: Cannot use "parent" when current class scope has no parent in /var/www/html/vendor/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/CustomerDataType.php on line 181

Deprecated: Cannot use "parent" when current class scope has no parent in /var/www/html/vendor/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/TransactionRequestType.php on line 1122

Deprecated: Cannot use "parent" when current class scope has no parent in /var/www/html/vendor/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/ANetApiRequestType.php on line 129

Deprecated: Cannot use "parent" when current class scope has no parent in /var/www/html/vendor/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/ANetApiResponseType.php on line 127

Deprecated: Cannot use "parent" when current class scope has no parent in /var/www/html/vendor/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/TransactionResponseType.php on line 889

Deprecated: Cannot use "parent" when current class scope has no parent in /var/www/html/vendor/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/MessagesType.php on line 134

Deprecated: Cannot use "parent" when current class scope has no parent in /var/www/html/vendor/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/MessagesType/MessageAType.php on line 97

@witchblade32
Copy link

Also having the same issue with 7.4 and Deprecated: Cannot use "parent" when current class scope has no parent

@mihaijoldis
Copy link

Same issue on PHP 7.4.10
Cannot use "parent" when current class scope has no parent

@aetikon
Copy link

aetikon commented Sep 24, 2020

Also having this exact same issue on PHP 7.4.

@JeffUssing
Copy link

Same thing here.

@FactoryAidan
Copy link

FactoryAidan commented Oct 9, 2020

✅ I've been able to modify my clone of the codebase to work with PHP ^7.4 . It has been working well.

It's the same thing this guy did 👉 Forked Repo working with PHP ^7.4 resulting in this PR mentioned in the first comment of this issue.

I know it's ultimately Authorize.net's responsibility to fix this but it's been 🦗💤 from them and I've been reaching out for a long time. I don't know when they're going to accept accountability for this, step up to the plate, and fix it.

⚠️ The issue is that all files in the lib/net/authorize/api/contract/v1 directory are autogenerated by their cross-platform compiler "based on the XML schema" of Authorize.net's API. This means a human didn't actually spend time making sure the bugged classes made logical sense in the PHP language.

🙇 Unfortunately, without possibly getting sued, I'm not allowed to distribute the fixed code to all of you due to the license agreement of their codebase unless Authorize.net gives me permission to do so, which they have not yet. But you can use the repo I mentioned above 👆. But hopefully this feedback will give you all 'some' control of your own success if Authorize.net isn't able to reconsider the decision to rely on a cross-platform compiler before PHP 7.3 reaches end of support on 6 Dec 2021.

📖 This explains the manual effort to fix all files in the lib/net/authorize/api/contract/v1 directory to work with PHP ^7.4:

  • Any class that extends another class and does not define its own method jsonSerialize(), I added that method with the same content as its parent. (Because it definitely has a parent. However, copy the method from the parent right now because we're about to change the parent's method definition in the next step)
  • Any class that does not extend another class can never have a parent. So I removed the last if(){} block in jsonSerialize() that checks for a parent class and simply return $values; always.

FYI (no changes to):

  • Any class that extends another class and also defines its own method jsonSerialize(), I left as is; no changes. (Because it definitely has a parent).

ℹ️ I experimented with doing this an 'easier' way that involves less manual file editing and instead inheritance of a wiser jsonSerialize() method in the base classes. Ultimately things didn't behave properly in my experiment and I went down a rabbit's-hole that ultimately didn't pan-out. So I bit the bullet and just stuck to the original plan of updating all the files.

@rekliner
Copy link

rekliner commented Jan 14, 2021

Just want to link to issue 397 from here since it is discussing the same problem and suggests the dev branch "dev-master#ef297d3e2d7c1092ddabd2c376eb485aac1aa66c" as an alternative to user repos. Nobody from authorize.net is coming to the rescue. This repo appears abandoned.

@SteveDesmond-ca
Copy link
Author

Per #407, v2.0.2 supports PHP 7.4+

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

8 participants