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

Define determine_locale() only if not already defined #2

Closed
wants to merge 1 commit into from
Closed

Define determine_locale() only if not already defined #2

wants to merge 1 commit into from

Conversation

kingkero
Copy link

@kingkero kingkero commented Jan 10, 2020

Using this library alongside php-stubs/wordpress-stubs will break PHPStan.

composer.json (partially) (php-stubs/wordpress-stubs is a dependency of php-stubs/woocommerce-stubs)

  "scripts": {
    "phpstan": "phpstan analyze"
  },
  "require-dev": {
    "paulthewalton/acf-pro-stubs": "^5.8",
    "php-stubs/woocommerce-stubs": "^3.8",
    "szepeviktor/phpstan-wordpress": "^0.5.0"
  }

phpstan.neon.dist (partially)

includes:
    # @see https://github.com/phpstan/phpstan/blob/master/conf/bleedingEdge.neon
    - phar://phpstan.phar/conf/bleedingEdge.neon
    # Include this extension
    - vendor/szepeviktor/phpstan-wordpress/extension.neon
parameters:
    level: max
    inferPrivatePropertyTypeFromConstructor: true
    autoload_files:
      - %currentWorkingDirectory%/vendor/php-stubs/woocommerce-stubs/woocommerce-stubs.php
      - %currentWorkingDirectory%/vendor/paulthewalton/acf-pro-stubs/acf-pro-stubs.php

Running phpstan analyze will then result in

➜ composer phpstan
> phpstan analyze
Note: Using configuration file .../phpstan.neon.dist.
PHP Fatal error:  Cannot redeclare determine_locale() (previously declared in .../vendor/php-stubs/wordpress-stubs/wordpress-stubs.php:89692) in .../vendor/paulthewalton/acf-pro-stubs/acf-pro-stubs.php on line 16212
Fatal error: Cannot redeclare determine_locale() (previously declared in .../vendor/php-stubs/wordpress-stubs/wordpress-stubs.php:89692) in .../vendor/paulthewalton/acf-pro-stubs/acf-pro-stubs.php on line 16212

This PR will solve this issue.

@kingkero
Copy link
Author

Just realized the file is auto generated. Might look into this in the future.

@kingkero kingkero closed this Jan 29, 2020
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.

None yet

1 participant