Skip to content

PHPStan level 9 #286

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@
"wp-cli/db-command": "^1.3 || ^2",
"wp-cli/entity-command": "^1.3 || ^2",
"wp-cli/extension-command": "^1.2 || ^2",
"wp-cli/wp-cli-tests": "^4"
"wp-cli/wp-cli-tests": "dev-main"
},
"config": {
"process-timeout": 7200,
"sort-packages": true,
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true,
"johnpbloch/wordpress-core-installer": true
"johnpbloch/wordpress-core-installer": true,
"phpstan/extension-installer": true
},
"lock": false
},
Expand Down Expand Up @@ -64,12 +65,14 @@
"behat-rerun": "rerun-behat-tests",
"lint": "run-linter-tests",
"phpcs": "run-phpcs-tests",
"phpstan": "run-phpstan-tests",
"phpcbf": "run-phpcbf-cleanup",
"phpunit": "run-php-unit-tests",
"prepare-tests": "install-package-tests",
"test": [
"@lint",
"@phpcs",
"@phstan",
"@phpunit",
"@behat"
]
Expand Down
71 changes: 18 additions & 53 deletions features/core-update.feature
Original file line number Diff line number Diff line change
@@ -1,77 +1,42 @@
Feature: Update WordPress core

# This test downgrades to an older WordPress version, but the SQLite plugin requires 6.0+
# This test downgrades to an older WordPress version, but the SQLite plugin requires 6.4+
@require-mysql
Scenario: Update from a ZIP file
Given a WP install
And I try `wp theme install twentytwenty --activate`

When I run `wp core download --version=3.9 --force`
When I run `wp core download --version=6.2 --force`
Then STDOUT should not be empty

When I run `wp eval 'echo $GLOBALS["wp_version"];'`
When I try `wp eval 'echo $GLOBALS["wp_version"];'`
Then STDOUT should be:
"""
3.9
6.2
"""

When I run `wget http://wordpress.org/wordpress-4.0.zip --quiet`
And I run `wp core update wordpress-4.0.zip`
When I run `wget http://wordpress.org/wordpress-6.2.zip --quiet`
And I run `wp core update wordpress-6.2.zip`
Then STDOUT should be:
"""
Starting update...
Unpacking the update...
Cleaning up files...
No files found that need cleaning up.
Success: WordPress updated successfully.
"""

When I run `wp eval 'echo $GLOBALS["wp_version"];'`
Then STDOUT should be:
"""
4.0
"""

# PHP 7.1 needs WP 3.9 (due to wp_check_php_mysql_versions(), see trac changeset [27257]),
# and travis doesn't install mysql extension by default for PHP 7.0.
@less-than-php-7
Scenario: Update to the latest minor release
Given a WP install
And I try `wp theme install twentytwenty --activate`

When I run `wp core download --version=4.1 --force`
Then STDOUT should not be empty

# WP core throws notice for PHP 8+.
When I try `wp core update --minor`
Then STDOUT should contain:
"""
Updating to version {WP_VERSION-4.1-latest}
"""
And STDOUT should contain:
"""
Success: WordPress updated successfully.
"""

When I run `wp core update --minor`
Then STDOUT should be:
"""
Success: WordPress is at the latest minor release.
"""

When I run `wp core version`
When I try `wp eval 'echo $GLOBALS["wp_version"];'`
Then STDOUT should be:
"""
{WP_VERSION-4.1-latest}
6.2
"""

# This test downgrades to an older WordPress version, but the SQLite plugin requires 6.0+
# This test downgrades to an older WordPress version, but the SQLite plugin requires 6.4+
@require-mysql
Scenario: Update to the latest minor release (PHP 7.1 compatible with WP >= 3.9)
Scenario: Update to the latest minor release (PHP 7.2 compatible with WP >= 4.9)
Given a WP install
And I try `wp theme install twentytwenty --activate`

When I run `wp core download --version=4.1.30 --force`
When I run `wp core download --version=6.2.5 --force`
Then STDOUT should contain:
"""
Success: WordPress downloaded.
Expand All @@ -81,7 +46,7 @@ Feature: Update WordPress core
When I try `wp core update --minor`
Then STDOUT should contain:
"""
Updating to version {WP_VERSION-4.1-latest}
Updating to version {WP_VERSION-6.2-latest}
"""
And STDOUT should contain:
"""
Expand All @@ -98,17 +63,17 @@ Feature: Update WordPress core
When I run `wp core version`
Then STDOUT should be:
"""
{WP_VERSION-4.1-latest}
{WP_VERSION-6.2-latest}
"""

# This test downgrades to an older WordPress version, but the SQLite plugin requires 6.0+
# This test downgrades to an older WordPress version, but the SQLite plugin requires 6.4+
@require-mysql
Scenario: Core update from cache
Given a WP install
And I try `wp theme install twentytwenty --activate`
And an empty cache

When I run `wp core update --version=3.9.1 --force`
When I run `wp core update --version=6.2.5 --force`
Then STDOUT should not contain:
"""
Using cached file
Expand All @@ -118,13 +83,13 @@ Feature: Update WordPress core
Downloading
"""

When I run `wp core update --version=4.0 --force`
When I run `wp core update --version=6.0 --force`
Then STDOUT should not be empty

When I run `wp core update --version=3.9.1 --force`
When I run `wp core update --version=6.2.5 --force`
Then STDOUT should contain:
"""
Using cached file '{SUITE_CACHE_DIR}/core/wordpress-3.9.1-en_US.zip'...
Using cached file '{SUITE_CACHE_DIR}/core/wordpress-6.2.5-en_US.zip'...
"""
And STDOUT should not contain:
"""
Expand Down
19 changes: 19 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
parameters:
level: 9
paths:
- src
- core-command.php
scanDirectories:
- vendor/wp-cli/wp-cli/php
- vendor/wp-cli/wp-cli-tests
scanFiles:
- vendor/php-stubs/wordpress-stubs/wordpress-stubs.php
treatPhpDocTypesAsCertain: false
dynamicConstantNames:
- WP_DEBUG
- WP_DEBUG_LOG
- WP_DEBUG_DISPLAY
ignoreErrors:
- identifier: missingType.iterableValue
- identifier: missingType.parameter
- identifier: missingType.return
Loading