cocart-headless / cocart-core

This is the core of CoCart that provides support for managing the user session and decouples WooCommerce.
Other
3 stars 1 forks source link

Fix critical bugs #5

Closed szepeviktor closed 1 year ago

szepeviktor commented 1 year ago

Description

The clone of that fruitful PR in the packaging repository. https://github.com/co-cart/co-cart/pull/388

Types of changes

Contains critical bug fixes, and the type fixes leading up to finding those bugs during static analysis.

Checklist:

I hope you take fancy to run PHPStan as there are sure benefits.

seb86 commented 1 year ago

@szepeviktor Thanks again for submitting this PR. Does PHPStan automatically apply these corrections or only notifies you on what needs to be fixed? Also are any changes related to a specific WordPress version for compatibility?

szepeviktor commented 1 year ago

Does PHPStan automatically apply these corrections?

No. PHPStan has a learning curve. Basically this is the rule of thumb: You write code PHPStan understands ✔️ PHPStan shows a false positive 👉🏻 Write code PHPStan understands!

Also are any changes related to a specific WordPress version for compatibility?

No, these are generic fixes. This is PHPStan level 0.

szepeviktor commented 1 year ago

I want you to be a PHPStan fan.

seb86 commented 1 year ago

@szepeviktor Have I done the configuration wrong or am I missing something? image

szepeviktor commented 1 year ago

phpstan.neon

# composer require php-stubs/woocommerce-stubs php-stubs/wp-cli-stubs szepeviktor/phpstan-wordpress --dev

includes:
    - vendor/szepeviktor/phpstan-wordpress/extension.neon
parameters:
    paths:
        - includes/
        - uninstall.php
    excludePaths:
        - includes/cocart-deprecated-functions.php
    bootstrapFiles:
        - vendor/php-stubs/woocommerce-stubs/woocommerce-stubs.php
    scanFiles:
        - vendor/php-stubs/wp-cli-stubs/wp-cli-stubs.php
        - includes/cocart-deprecated-functions.php
        # For analyzing cocart-core only
        - packages/admin/includes/class-cocart-admin-notices.php
        - packages/products-api/includes/class-cocart-datetime.php
    level: 0

If you bump into errors try debugging: vendor/bin/phpstan analyze --debug

seb86 commented 1 year ago

Thanks. Got it working. Crazy how much memory it needs to work.

szepeviktor commented 1 year ago

PHPStan has 100 developers built in!

👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻 👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻 👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻 👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻 👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻 👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻 👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻 👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻 👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻 👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻