Skip to content

Fixed PHP 8.5 deprecated code by Knit pay/main#244

Merged
remcotolsma merged 5 commits intomainfrom
knit-pay/main
Feb 27, 2026
Merged

Fixed PHP 8.5 deprecated code by Knit pay/main#244
remcotolsma merged 5 commits intomainfrom
knit-pay/main

Conversation

@remcotolsma
Copy link
Member

knit-pay and others added 4 commits February 24, 2026 01:23
Suggested by Gemini Code Assist

The null coalescing operator ?? in the method body is redundant. Since $price is already nullable, you can directly assign it. This simplifies the code and makes it consistent with set_discount_amount in the same file.
Simplify PaymentMethodsCollection::get by removing the explicit null !== $id check and relying on array_key_exists($id, $this->items) to determine presence. This cleans up the conditional logic; note that if $id is null and the collection has an empty-string key, the method may now return that entry (previously it would have returned null).
@remcotolsma remcotolsma requested a review from Copilot February 27, 2026 11:52
@remcotolsma remcotolsma self-assigned this Feb 27, 2026
@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on enhancing compatibility with PHP 8.0 and later by introducing explicit nullable type hints for parameters that can accept null values. The changes prevent deprecation warnings that arise when parameters with default null values are not explicitly marked as nullable. This ensures the codebase remains robust and aligned with current PHP language specifications.

Highlights

  • PHP 8.0+ Compatibility: Updated method signatures across multiple files to explicitly declare nullable parameters using the ? type hint, addressing deprecation warnings in PHP 8.0 and newer versions.
  • Code Modernization: Ensured adherence to modern PHP type-hinting standards by clarifying parameter nullability, improving code clarity and preventing potential runtime issues.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • src/Address.php
    • Updated set_name method signature to use ?ContactName for the $name parameter.
  • src/Customer.php
    • Updated set_name method signature to use ?ContactName for the $name parameter.
  • src/Payments/Payment.php
    • Updated set_failure_reason method signature to use ?FailureReason for the $failure_reason parameter.
  • src/Payments/PaymentInfo.php
    • Updated set_lines method signature to use ?PaymentLines for the $lines parameter.
    • Updated set_shipping_amount method signature to use ?Money for the $shipping_amount parameter.
  • src/Payments/PaymentLine.php
    • Updated set_unit_price method signature to use ?Money for the $price parameter and simplified its assignment.
    • Updated set_discount_amount method signature to use ?Money for the $discount_amount parameter.
  • src/Payments/PaymentLines.php
    • Updated from_json static method signature to use ?PaymentInfo for the $payment_info parameter.
Activity
  • No activity has been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request correctly addresses a deprecation in PHP 8.5 by adding nullable types to method parameters that have a default value of null. The changes are consistent across multiple files and improve the code's forward-compatibility. The simplification in set_unit_price is also a good improvement. I have one suggestion to improve documentation consistency.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request fixes PHP 8.4+ deprecation warnings related to implicit nullable type hints. In PHP 8.4+, typed parameters that have a default value of null must be explicitly marked as nullable using the ? prefix. The PR updates method signatures across multiple payment-related classes to add the nullable type hint prefix.

Changes:

  • Updated method signatures to use explicit nullable type hints (?Type instead of Type = null)
  • Removed redundant null coalescing operator in PaymentLine::set_unit_price()
  • Applied fixes consistently across Payment, PaymentInfo, PaymentLine, PaymentLines, Customer, and Address classes

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/Payments/PaymentLines.php Added nullable type hint to from_json() method parameter
src/Payments/PaymentLine.php Added nullable type hints to set_unit_price() and set_discount_amount() methods, removed redundant null coalescing
src/Payments/PaymentInfo.php Added nullable type hints to set_lines() and set_shipping_amount() methods
src/Payments/Payment.php Added nullable type hint to set_failure_reason() method
src/Customer.php Added nullable type hint to set_name() method
src/Address.php Added nullable type hint to set_name() method

Update PHPDoc for set_discount_amount to indicate the $discount_amount parameter can be null (Money|null), matching the method signature (?Money $discount_amount = null). This keeps documentation consistent with the code and avoids static analysis/IDE warnings.
@remcotolsma remcotolsma merged commit 1de6b73 into main Feb 27, 2026
16 of 18 checks passed
@remcotolsma remcotolsma deleted the knit-pay/main branch February 27, 2026 11:57
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.

3 participants