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

Please introduce PHPStan in CI #243

Closed
szepeviktor opened this issue Feb 4, 2020 · 1 comment · Fixed by #560
Closed

Please introduce PHPStan in CI #243

szepeviktor opened this issue Feb 4, 2020 · 1 comment · Fixed by #560
Milestone

Comments

@szepeviktor
Copy link
Contributor

szepeviktor commented Feb 4, 2020

composer require --dev szepeviktor/phpstan-wordpress
vendor/bin/phpstan analyze

I've cleaned up the codebase up to Level 4.
Robust code starts at Level 5!

Here is the config: phpstan.neon.dist

includes:
    - vendor/szepeviktor/phpstan-wordpress/extension.neon
parameters:
    level: 4
#    level: max
    inferPrivatePropertyTypeFromConstructor: true
    paths:
        - integrations/
        - wp-admin/
        - wp-includes/
    autoload_files:
        - tests/phpstan/bootstrap.php
        - integrations/functions.php
        - wp-includes/class-wp-web-app-manifest.php
        - wp-includes/class-wp-https-detection.php
        - wp-includes/class-wp-https-ui.php
        - wp-includes/interface-wp-service-worker-registry.php
        - wp-includes/interface-wp-service-worker-registry-aware.php
        - wp-includes/class-wp-service-workers.php
        - wp-includes/class-wp-service-worker-scripts.php
        - wp-includes/components/interface-wp-service-worker-component.php
        - wp-includes/components/class-wp-service-worker-configuration-component.php
        - wp-includes/components/class-wp-service-worker-navigation-routing-component.php
        - wp-includes/components/class-wp-service-worker-precaching-routes-component.php
        - wp-includes/components/class-wp-service-worker-precaching-routes.php
        - wp-includes/components/class-wp-service-worker-caching-routes-component.php
        - wp-includes/components/class-wp-service-worker-caching-routes.php
        - wp-includes/service-workers.php
        - wp-includes/default-filters.php
        - wp-includes/query.php
        - wp-includes/template.php
        - wp-includes/general-template.php
        - wp-includes/post-template.php
        - wp-includes/template-loader.php
        - wp-includes/class-wp.php
        - wp-includes/class-wp-query.php
        - wp-admin/admin.php
    autoload_directories:
        - integrations/
    dynamicConstantNames:
        - SCRIPT_DEBUG
    ignoreErrors:
        # Uses func_get_args()
        - '#^Function apply_filters(_ref_array)? invoked with [34567] parameters, 2 required\.$#'
        # Dynamically generated
        - '#^Access to an undefined property WP_Query::\$(is_offline|is_500)\.$#'

:)

@szepeviktor
Copy link
Contributor Author

ooops, the bootstrap file: tests/phpstan/bootstrap.php

<?php

define( 'PWA_VERSION', '0.0.0' );
define( 'PWA_PLUGIN_FILE', dirname( __DIR__, 2 ) . '/pwa.php' );
define( 'PWA_PLUGIN_DIR', dirname( __DIR__, 2 ) );
define( 'PWA_PLUGIN_URL', '' );


define( 'WPINC', '' );
define( 'TEMPLATEPATH', '' );
define( 'STYLESHEETPATH', '' );
define( 'SCRIPT_DEBUG', true );

// Should use core function instead.
define( 'WP_CONTENT_DIR', '' );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants