Skip to content

Modernize the codebase for PHP 8.1+ and PHPUnit 11–13.#48

Open
josbeir wants to merge 5 commits into
Antidot-be:masterfrom
josbeir:chore/modernize-phpunit11-cs-fixer
Open

Modernize the codebase for PHP 8.1+ and PHPUnit 11–13.#48
josbeir wants to merge 5 commits into
Antidot-be:masterfrom
josbeir:chore/modernize-phpunit11-cs-fixer

Conversation

@josbeir

@josbeir josbeir commented Jun 2, 2026

Copy link
Copy Markdown

Summary

Modernize the codebase for PHP 8.1+ and PHPUnit 11–13.

Changes

Dependencies

  • PHP constraint: >=5.3.0>=8.1
  • phpunit/phpunit: ^5^11.1|| ^12.0 || ^13.0
  • friendsofphp/php-cs-fixer: =3.9.5^3.9

Source fixes — Implicit nullable parameter deprecations across ~20 files

Test migration — PHPUnit 5 → 11/12/13

  • @expectedException$this->expectException()
  • @dataProvider#[DataProvider] attribute
  • assertInternalType()assertIsArray()
  • assertContains()assertStringContainsString()
  • Made data providers and helpers static

Code style — Ran php-cs-fixer (62 files): constant visibility, PSR-12 abstract ordering, import cleanup

CI — Matrix with PHP 8.1–8.4 (highest deps) + PHP 8.4 (prefer-lowest), plus a separate php-cs-fixer dry-run job

If your're happy with this PR i recommend a new major as the current major is already a bit dated...

josbeir added 4 commits June 2, 2026 16:40
- Update composer.json: php >=8.1, phpunit ^11.1, php-cs-fixer ^3.9
- Fix implicit nullable parameter deprecations (src exceptions, ApiCaller, Box types, Geo6/Day)
- Migrate phpunit.xml.dist to PHPUnit 11 schema
- Replace @ExpectedException annotations with ->expectException()
- Replace @dataProvider annotations with #[DataProvider] attribute
- Fix removed methods: assertInternalType -> assertIsArray, assertContains -> assertStringContainsString
- Make data providers static for PHPUnit 11 compatibility
- Fix DOMElement::createElement null parameter deprecation in CustomsInfoTest
- Run php-cs-fixer: add public visibility to consts, fix abstract ordering, cleanup imports
- Use shivammathur/setup-php with PHP 8.1 + Composer v2
- Use ramsey/composer-install for dependency caching
- Uncomment php-cs-fixer dry-run step (now compatible with PHP 8.1+)
- Replace php-actions/phpunit with direct vendor/bin/phpunit call (PHPUnit 11)
- Update actions/checkout to v4
- Broaden phpunit constraint to ^11.1 || ^12.0 || ^13.0
- Split CI into php-cs-fixer and tests jobs
- Test matrix: PHP 8.1, 8.2, 8.3, 8.4 (highest deps) + PHP 8.4 (lowest deps)
@josbeir josbeir marked this pull request as ready for review June 2, 2026 15:28
Copilot AI review requested due to automatic review settings June 2, 2026 15:28

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Modernizes the library for PHP 8.1+ and updates the test/tooling stack (PHPUnit, CI workflow, phpunit.xml) while applying widespread typing/constant visibility cleanups.

Changes:

  • Bumps minimum PHP to 8.1 and migrates PHPUnit tests to PHPUnit\Framework\TestCase + modern assertions/attributes.
  • Updates CI to run php-cs-fixer and PHPUnit across a PHP version matrix.
  • Refactors various core classes (public constants, nullable params, minor typing/docblock updates).

Reviewed changes

Copilot reviewed 134 out of 138 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/index.php Re-indents commented example calls in the test entry script.
tests/connection-tests/Geo6Test.php Migrates test base class to PHPUnit\Framework\TestCase.
tests/connection-tests/BpostTest.php Migrates test base class to PHPUnit\Framework\TestCase.
tests/connection-tests/Bpack247Test.php Migrates test base class to PHPUnit\Framework\TestCase.
tests/Geo6/ServiceTest.php Migrates test base class to PHPUnit\Framework\TestCase.
tests/Geo6/PoiTest.php Migrates test base class to PHPUnit\Framework\TestCase.
tests/Geo6/DayTest.php Migrates test base class to PHPUnit\Framework\TestCase.
tests/Exception/XmlException/BpostXmlNoUserIdFoundExceptionTest.php Migrates test base class to PHPUnit\Framework\TestCase.
tests/Exception/XmlException/BpostXmlNoReferenceFoundExceptionTest.php Migrates test base class to PHPUnit\Framework\TestCase.
tests/Exception/XmlException/BpostXmlInvalidItemExceptionTest.php Migrates test base class to PHPUnit\Framework\TestCase.
tests/Exception/LogicException/BpostInvalidWeightExceptionTest.php Migrates test base class to PHPUnit\Framework\TestCase.
tests/Exception/LogicException/BpostInvalidValueExceptionTest.php Migrates test base class to PHPUnit\Framework\TestCase.
tests/Exception/LogicException/BpostInvalidPatternExceptionTest.php Migrates test base class to PHPUnit\Framework\TestCase.
tests/Exception/LogicException/BpostInvalidLengthExceptionTest.php Migrates test base class to PHPUnit\Framework\TestCase.
tests/Exception/LogicException/BpostInvalidDayExceptionTest.php Migrates test base class to PHPUnit\Framework\TestCase.
tests/Exception/BpostNotImplementedExceptionTest.php Updates base class + replaces deprecated assertContains with assertStringContainsString.
tests/Exception/ApiResponseException/BpostTaxipostLocatorExceptionTest.php Migrates test base class to PHPUnit\Framework\TestCase.
tests/Exception/ApiResponseException/BpostInvalidXmlResponseExceptionTest.php Migrates test base class to PHPUnit\Framework\TestCase.
tests/Exception/ApiResponseException/BpostInvalidSelectionExceptionTest.php Migrates test base class to PHPUnit\Framework\TestCase.
tests/Exception/ApiResponseException/BpostInvalidResponseExceptionTest.php Migrates test base class to PHPUnit\Framework\TestCase.
tests/Exception/ApiResponseException/BpostCurlExceptionTest.php Migrates test base class to PHPUnit\Framework\TestCase.
tests/Exception/ApiResponseException/BpostApiSystemExceptionTest.php Migrates test base class to PHPUnit\Framework\TestCase.
tests/Exception/ApiResponseException/BpostApiBusinessExceptionTest.php Migrates test base class to PHPUnit\Framework\TestCase.
tests/Common/ValidatedValueTest.php Replaces @expectedException with expectException and updates base class.
tests/Common/ValidatedValue/LabelFormatTest.php Migrates test base class to PHPUnit\Framework\TestCase.
tests/Common/BasicAttributeTest.php Replaces @expectedException with expectException and updates base class.
tests/Common/BasicAttribute/PhoneNumberTest.php Migrates test base class to PHPUnit\Framework\TestCase.
tests/Common/BasicAttribute/LanguageTest.php Migrates test base class to PHPUnit\Framework\TestCase.
tests/Common/BasicAttribute/EmailAddressCharacteristicTest.php Migrates test base class to PHPUnit\Framework\TestCase.
tests/BpostApiExamples/FetchOrder/NationalBoxAtHomeTest.php Updates base class + minor comment formatting.
tests/BpostApiExamples/FetchOrder/NationalBoxAtBpostTest.php Updates base class.
tests/BpostApiExamples/FetchOrder/InternationalPickupTest.php Updates base class.
tests/BpostApiExamples/FetchOrder/AtIntlPugoTest.php Updates base class.
tests/BpostApiExamples/CreateOrder/International/BpackWorldExpressProNoOptionsTest.php Updates base class.
tests/BpostApiExamples/CreateOrder/International/BpackWorldExpressProBasicInsuranceTest.php Updates base class.
tests/BpostApiExamples/CreateOrder/International/BpackWorldExpressProAdditionalInsurance3Test.php Updates base class.
tests/BpostApiExamples/CreateOrder/International/BpackWorldEasyReturnNoOptionsTest.php Updates base class.
tests/BpostApiExamples/CreateOrder/International/BpackWorldBusinessNoOptionsTest.php Updates base class.
tests/BpostApiExamples/CreateOrder/International/BpackWorldBusinessBasicInsuranceTest.php Updates base class.
tests/BpostApiExamples/CreateOrder/International/BpackWorldBusinessAdditionalInsurance3Test.php Updates base class.
tests/BpostApiExamples/CreateOrder/International/BpackEuropeBusinessSecondPresentationAndBasicInsuranceTest.php Updates base class.
tests/BpostApiExamples/CreateOrder/International/BpackEuropeBusinessSecondPresentationAndAdditionalInsurance3Test.php Updates base class.
tests/Bpost/OrderTest.php Updates base class + modernizes exception expectations + uses shorter class refs in assertions.
tests/Bpost/Order/SenderTest.php Updates base class.
tests/Bpost/Order/ReceiverTest.php Updates base class.
tests/Bpost/Order/PugoAddressTest.php Updates base class + replaces @expectedException with expectException.
tests/Bpost/Order/ParcelsDepotAddressTest.php Updates base class + replaces @expectedException with expectException.
tests/Bpost/Order/LineTest.php Updates base class.
tests/Bpost/Order/CustomerTest.php Updates base class.
tests/Bpost/Order/BoxTest.php Updates base class.
tests/Bpost/Order/Box/Option/SignatureTest.php Updates base class.
tests/Bpost/Order/Box/Option/MessagingTest.php Updates base class.
tests/Bpost/Order/Box/Option/InsuranceTest.php Updates base class.
tests/Bpost/Order/Box/Option/CashOnDeliveryTest.php Updates base class.
tests/Bpost/Order/Box/Option/AutomaticSecondPresentationTest.php Updates base class.
tests/Bpost/Order/Box/Openinghour/DayTest.php Updates base class.
tests/Bpost/Order/Box/NationalTest.php Updates base class + fixes docblocks and uses assertIsArray.
tests/Bpost/Order/Box/National/UnregisteredTest.php Updates base class + removes dead return;.
tests/Bpost/Order/Box/National/ShopHandlingInstructionTest.php Updates base class.
tests/Bpost/Order/Box/National/ParcelLockerReducedMobilityZoneTest.php Updates base class.
tests/Bpost/Order/Box/InternationalTest.php Updates base class.
tests/Bpost/Order/Box/International/ParcelContentTest.php Updates base class.
tests/Bpost/Order/Box/CustomsInfo/CustomsInfoTest.php Skips appending XML elements for null values.
tests/Bpost/Order/Box/BpostOnAppointmentTest.php Updates base class + removes dead return; + modernizes exception expectations.
tests/Bpost/Order/Box/AtHomeTest.php Updates base class + modernizes exception expectations.
tests/Bpost/Order/Box/AtBpostTest.php Updates base class.
tests/Bpost/Order/Box/At247Test.php Updates base class.
tests/Bpost/Order/AddressTest.php Updates base class + replaces @expectedException with expectException.
tests/Bpost/LabelsTest.php Updates base class.
tests/Bpost/LabelTest.php Updates base class.
tests/Bpost/Label/BarcodeTest.php Updates base class.
tests/Bpost/HttpRequestBuilder/ModifyOrderTest.php Uses PHPUnit DataProvider attribute; makes provider static; updates base class.
tests/Bpost/HttpRequestBuilder/FetchProductConfigTest.php Uses PHPUnit DataProvider attribute; makes provider static; updates base class.
tests/Bpost/HttpRequestBuilder/FetchOrderTest.php Uses PHPUnit DataProvider attribute; makes provider static; updates base class.
tests/Bpost/HttpRequestBuilder/CreateOrReplaceOrderTest.php Uses PHPUnit DataProvider attribute; makes provider/helpers static; updates base class.
tests/Bpost/HttpRequestBuilder/CreateLabelInBulkForOrdersTest.php Uses PHPUnit DataProvider attribute; makes provider/helpers static; updates base class.
tests/Bpost/HttpRequestBuilder/CreateLabelForOrderTest.php Uses PHPUnit DataProvider attribute; makes provider/helpers static; updates base class.
tests/Bpost/HttpRequestBuilder/CreateLabelForBoxTest.php Uses PHPUnit DataProvider attribute; makes provider/helpers static; updates base class.
tests/Bpack247/CustomerTest.php Updates base class.
tests/Bpack247/CustomerPackStationTest.php Updates base class.
src/Geo6/Day.php Makes constants public; adds safer casting when computing day index.
src/Geo6.php Makes constants public; adds trailing comma in param list (PHP 8+ style).
src/FormHandler.php Re-indents switch comments around parameter validation sections.
src/Exception/XmlException/BpostXmlNoUserIdFoundException.php Allows nullable Exception $previous.
src/Exception/XmlException/BpostXmlNoReferenceFoundException.php Allows nullable Exception $previous.
src/Exception/XmlException/BpostXmlInvalidItemException.php Allows nullable Exception $previous.
src/Exception/BpostNotImplementedException.php Allows nullable Exception $previous.
src/Exception/BpostLogicException/BpostInvalidWeightException.php Allows nullable Exception $previous.
src/Exception/BpostLogicException/BpostInvalidValueException.php Allows nullable Exception $previous.
src/Exception/BpostLogicException/BpostInvalidPatternException.php Allows nullable Exception $previous.
src/Exception/BpostLogicException/BpostInvalidLengthException.php Allows nullable Exception $previous.
src/Exception/BpostLogicException/BpostInvalidDayException.php Allows nullable Exception $previous.
src/Exception/BpostApiResponseException/BpostInvalidXmlResponseException.php Allows nullable Exception $previous.
src/Exception/BpostApiResponseException/BpostInvalidResponseException.php Allows nullable Exception $previous.
src/Common/ValidatedValue/LabelFormat.php Makes constants public.
src/Common/ValidatedValue.php Normalizes abstract method modifier order.
src/Common/BasicAttribute/Language.php Makes constants public.
src/Common/BasicAttribute.php Normalizes abstract method modifier order.
src/Bpost/ProductConfiguration/Visibility.php Makes constants public.
src/Bpost/ProductConfiguration/Product.php Makes constants public.
src/Bpost/ProductConfiguration/Option.php Makes constants public.
src/Bpost/ProductConfiguration/DeliveryMethod.php Makes constants public.
src/Bpost/Order/Sender.php Makes tag constant public.
src/Bpost/Order/Receiver.php Makes tag constant public.
src/Bpost/Order/PugoAddress.php Makes tag constant public.
src/Bpost/Order/ParcelsDepotAddress.php Makes tag constant public.
src/Bpost/Order/Line.php Adjusts toXML signature casing for DOMDocument type.
src/Bpost/Order/Customer.php Makes tag constant public; simplifies docblock types; adjusts toXML signature casing.
src/Bpost/Order/Box/Option/Signed.php Removes unused import; adjusts toXML signature casing.
src/Bpost/Order/Box/Option/SaturdayDelivery.php Fixes docblock DOM type casing.
src/Bpost/Order/Box/Option/Messaging.php Makes constants public; adjusts toXML signature casing.
src/Bpost/Order/Box/Option/Insured.php Makes constants public; adjusts toXML signature casing.
src/Bpost/Order/Box/Option/CashOnDelivery.php Adjusts toXML signature casing.
src/Bpost/Order/Box/Option/AutomaticSecondPresentation.php Removes unused import; adjusts toXML signature casing.
src/Bpost/Order/Box/OpeningHour/Day.php Makes constants public; adjusts toXML signature casing.
src/Bpost/Order/Box/National.php Adjusts toXML signature casing; allows nullable $self in createFromXML.
src/Bpost/Order/Box/International.php Adjusts toXML signature casing; updates docblock return type.
src/Bpost/Order/Box/IBox.php Updates docblock param type; adjusts toXML signature casing.
src/Bpost/Order/Box/CustomsInfo/CustomsInfo.php Makes constants public; fixes docblock DOM type casing.
src/Bpost/Order/Box/BpostOnAppointment.php Fixes docblock DOM type casing; allows nullable $self in createFromXML.
src/Bpost/Order/Box/AtIntlPugo.php Adds missing imports; improves docblocks/type hints; normalizes casts/spacing.
src/Bpost/Order/Box/AtHome.php Simplifies docblock types; allows nullable $self in createFromXML.
src/Bpost/Order/Box/AtBpost.php Simplifies docblock types; allows nullable $self in createFromXML; cleans throws docblock.
src/Bpost/Order/Box/At247.php Simplifies docblock types; allows nullable $self in createFromXML; cleans throws docblock.
src/Bpost/Order/Box.php Makes status constants public; simplifies many docblocks; removes trailing whitespace.
src/Bpost/Order/Address.php Makes tag constant public; adds trailing comma in ctor params; docblock formatting.
src/Bpost/Order.php Improves inline @var annotations in loops.
src/Bpost/Label.php Makes mime-type constants public.
src/Bpost/HttpRequestBuilder/HttpRequestBuilderInterface.php Makes interface constants explicitly public.
src/Bpost.php Makes constants public; reformats conditionals; trailing commas in params.
src/Bpack247/Customer.php Makes constants public.
src/Bpack247.php Makes constants public.
src/ApiCaller/ApiCaller.php Allows nullable injected logger.
phpunit.xml.dist Updates PHPUnit configuration schema (source include/exclude) and removes logging/coverage config.
composer.json Raises minimum PHP to 8.1; widens PHPUnit and php-cs-fixer dev requirements.
.gitignore Ignores PHPUnit result cache file.
.github/workflows/test.yml Splits CI into php-cs-fixer and test matrix jobs; updates actions and PHP setup.
Comments suppressed due to low confidence (1)

tests/Bpost/HttpRequestBuilder/CreateOrReplaceOrderTest.php:1

  • During the refactor to static helpers, the assertion that setBoxes([]) results in an empty box list was removed. That check is still valuable to prevent regressions in Order::setBoxes() semantics. Consider re-adding it using a static assertion (e.g., self::assertCount(...)) or moving the assertion into testResults() so the behavior remains covered.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread phpunit.xml.dist
Comment thread src/Bpost/Order/Box/International.php Outdated
Consistently use uppercase DOMDocument and DOMElement (instead of
mixed DomDocument/DomElement) across all source files in src/.
Also simplify two FQN @var annotations in Order.php.
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.

2 participants