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

Update libs with wpcs 3 changes [beta] #373

Merged
merged 22 commits into from
Oct 26, 2023

Conversation

dingo-d
Copy link
Collaborator

@dingo-d dingo-d commented Sep 22, 2023

Description

This PR will:

  • Update coding standards to the latest beta version which should make the libs compatible with PHP 7.4, 8.0, 8.1, 8.2 (and the 8.3 tests seem to be passing)
  • Fix the code so that the tests pass (the latest addition of adding private folders broke a lot of tests (95))
  • Fix existing issues with phpcs and phpstan
    • I've excluded some errors from phpcs reporting, as they are false positives, mainly the exception ones, as the exception messages are escaped in the exception classes
    • Also excluded file creation methods. The WP replacements are not ideal - wp_mkdir_p() will create directories recursively but with 777 permission, and some other WP_Filesystem_* methods are just wrappers with filters added (which is not desired)
  • Fix the deprecated test code:
    • assertions replaced with expectations to avoid breaking change of replacing assertObjectHasAttribute with assertObjectHasProperty in PHPUnit 9 (we could just create a custom assertion, but expectations are cleaner and don't suffer from this issue)
    • Added dynamically created properties to fix the deprecation about dynamically created properties in PHP 8.2+. The only deprecations about this come on versions where the composer was installed with the lowest versions of dependencies - composer update --prefer-lowest --prefer-stable, and that is due to Mockery mocks. On newer versions this issue is fixed, but on older versions, it's not, and any on-the-fly property creation will cause this deprecation, which will fail on PHP9 (all deprecations will become fatal errors then).

Note that some tests do fail but those are allowed failures, and shouldn't matter as it's unlikely people would install the lowest stable packages anyhow.
Regarding the deprecation notices, I can, if you agree, just remove the lowest condition when installing the packages from the integrate.yml (would make the CI checks faster as well, as we would be removing extra checks).

Please review the code and test this code before tagging the v7 beta.

CC: @iruzevic @goranalkovic-infinum

EDIT:

I've realized that the boilerplate will have to be updated with the beta release as well, as the coding standards would block installation (they are still on 1.6, which is locked to 7.4).

Closes #315

8.3 allow failure for non-released version of PHP.
Should prevent failures on PHPUnit <9 where assertObjectHasProperty isn't defined.
This will still be an issue on composer installs with lowest dependencies where dynamic properties isn't allowed/fixed in mockery.
@dingo-d dingo-d marked this pull request as ready for review September 23, 2023 07:22
In real life cases, the sourceItem array will contain list of items in the folder, and the folder as a value, so we need to check that as well. This should probably come up in tests, unless the dataset is not correctly set to mimick how the real life projects are behaving. This needs investigation.
@iruzevic iruzevic changed the base branch from develop to develop-php8 October 26, 2023 06:31
@iruzevic iruzevic merged commit 4c600b7 into infinum:develop-php8 Oct 26, 2023
12 of 16 checks passed
@iruzevic
Copy link
Member

I have created a new branch where we will test and update everything for PHP8, tnx for this major fixes

iruzevic added a commit that referenced this pull request Nov 6, 2023
* Update libs with wpcs 3 changes [beta] (#373)

* Update composer dependencies

* Update phpcs config

* Remove unused ignored error

* Fix deprecation notice

Depth parameter shouldn't be set to 0.

* Fix the tests failures because of inability to check the list of items vs source items

* Remove extra space from init blocks command

* Update readme

* Fix phpcs violation

* Fix deprecations with using traits directly

Added anonymous classes instead.

* Add mocks for the failing tests

* Fix test deprecations

* Update the gh action workflow

* Workflow fix

* Workflow update

8.3 allow failure for non-released version of PHP.

* Minor formatting fix on helpers

* Replace assertions with expectations API

Should prevent failures on PHPUnit <9 where assertObjectHasProperty isn't defined.

* Prevent the dynamic properties deprecation notices in tests

This will still be an issue on composer installs with lowest dependencies where dynamic properties isn't allowed/fixed in mockery.

* Minor grammar typo fix in a test

* Update workflow to allow failures on lowest composer dependencies

* Update moveItem method

* Improve type description in moveItem method

* Improve the moveItems method

In real life cases, the sourceItem array will contain list of items in the folder, and the folder as a value, so we need to check that as well. This should probably come up in tests, unless the dataset is not correctly set to mimick how the real life projects are behaving. This needs investigation.

* changing the commands registration order

* addings fixes for php8

* Update composer.json

Co-authored-by: Denis Žoljom <dingo-d@users.noreply.github.com>

* updating tests

* updating tests

* updating tests

* updating tests

* updating tests

* removing 'Old' function in blocks

* changing config version and name definition

* removing storybook

* fixing missing frontend libs private dir

* fixing wrong block dependeny output

* fixing command examples

* adding new command for changing version name

* fixing import command

* adding better copy for missing attribute

* adding is used method to every enqueu hook

* Update src/Misc/VersionCli.php

Co-authored-by: Ivan Ramljak <22823970+piqusy@users.noreply.github.com>

* adding is used method to every enqueu hook

* adding PR fixes

---------

Co-authored-by: Denis Žoljom <dingo-d@users.noreply.github.com>
Co-authored-by: Ivan Ramljak <22823970+piqusy@users.noreply.github.com>
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.

PHP 8+ support
2 participants