Skip to content

chore: setup PHPStan - #746

Merged
kidunot89 merged 27 commits into
wp-graphql:developfrom
justlevine:chore/configure-phpstan
Jun 13, 2023
Merged

kidunot89 merged 27 commits into
wp-graphql:developfrom
justlevine:chore/configure-phpstan

Conversation

@justlevine

Copy link
Copy Markdown
Contributor

Your checklist for this pull request

Thanks for sending a pull request! Please make sure you click the link above to view the contribution guidelines, then fill out the blanks below.

🚨Please review the guidelines for contributing to this repository.

  • Make sure you are making a pull request against the develop branch (left side). Also you should start your branch off our develop.
  • Make sure you are requesting to pull request from a topic/feature/bugfix/devops branch (right side). Don't pull request from your master!
  • Have you ensured/updated that CLI tests to extend coverage to any new logic. Learn how to modify the tests here.

What does this implement/fix? Explain your changes.

This PR implements PHPStan static analysis for the plugin.

Incidentally, the platform req in composer.json has been set to PHP 7.3 to ensure Composer deps are built against the same WordPress version.

To run (following the convention of the other composer script commands)

composer stan

Does this close any currently open issues?

…

Any relevant logs, error output, GraphiQL screenshots, etc?

(If it’s long, please paste to https://ghostbin.com/ and insert the link here.)

Any other comments?

  • This intentionally does not include a GH workflow, since itl just add extra noise until we address some of the smells.
  • To get issues shown in VSCode's Problems panel, you must install the dev dependences and then reload the window.

Where has this been tested?

  • WooGraphQL Version: 0.12.5
  • WPGraphQL Version: 1.14.3
  • **WordPress Version:**6.2
  • **WooCommerce Version:**7.6.1

@kidunot89 kidunot89 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@justlevine Thanks for the quick work, bro 🚀 .

@qlty-cloud-legacy

Copy link
Copy Markdown

Code Climate has analyzed commit bb5cdcc and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 31.5% (50% is the threshold).

This pull request will bring the total coverage in the repository to 82.3% (0.0% change).

View more on Code Climate.

@justlevine justlevine left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Okay I flagged any possible changes in behavior I noticed, but best would be to see what the GraphQL error is that we're getting from the tests

public function get_node_by_id( $id ) {
$post = get_post( $id );
if ( empty( $post ) || is_wp_error( $post ) ) {
if ( empty( $post ) ) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is possibly a change in behavior.


// Set sub tax query relation.
if ( 1 > count( $sub_tax_query ) ) {
if ( 1 > count( $sub_tax_query ) && ! empty( $relation ) ) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this is possibly a change in behavior

if ( ! empty( $input['keys'] ) && ! isset( $items ) ) {
$items = [];

if ( ! empty( $input['keys'] ) && ! empty( $items ) ) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This change means that if WC()->cart->get_cart() returns empty, the foreach loop will no longer run.

If that's not intentional, then initialize $items to null, and then change this to && null !== $items

'description' => __( 'Identify a resource by the URI.', 'wp-graphql-woocommerce' ),
];
case 'id':
default:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

the lack of a 'default' case is a possibl change in behavior

]
);

if ( ! WooCommerce_Filters::is_session_handler_disabled() ) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this is a change in behavior

@kidunot89
kidunot89 force-pushed the chore/configure-phpstan branch from caf471b to bb01736 Compare June 7, 2023 00:03
@justlevine

Copy link
Copy Markdown
Contributor Author

@kidunot89 after my latest commit, the last two level-4 errors are:

@kidunot89 kidunot89 added the dev-ops PR resolves an issue or implements a feature related to the development process label Jun 12, 2023
@kidunot89
kidunot89 merged commit 4ef46ac into wp-graphql:develop Jun 13, 2023
@justlevine
justlevine deleted the chore/configure-phpstan branch July 19, 2023 21:44
@justlevine
justlevine restored the chore/configure-phpstan branch July 19, 2023 21:44
@justlevine
justlevine deleted the chore/configure-phpstan branch July 19, 2023 21:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dev-ops PR resolves an issue or implements a feature related to the development process

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants