Skip to content

Commit 7cf0896

Browse files
committed
phpstan fixes
1 parent a750c71 commit 7cf0896

29 files changed

+516
-283
lines changed

Diff for: .github/workflows/cs.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121

2222
steps:
2323
- name: Checkout code
24-
uses: actions/checkout@v3
24+
uses: actions/checkout@v4
2525

2626
- name: Install PHP
2727
uses: shivammathur/setup-php@v2

Diff for: .github/workflows/unit-tests.yml

+15-16
Original file line numberDiff line numberDiff line change
@@ -23,31 +23,28 @@ jobs:
2323
matrix:
2424
# Notes regarding supported versions in WP:
2525
# The base matrix only contains the PHP versions which are supported on all supported WP versions.
26-
php: ['7.2', '7.3', '7.4','8.0']
26+
php: ['8.0', '8.1', '7.4']
2727
wp: ['latest']
2828
experimental: [false]
2929

3030
include:
3131
# Complement the builds run via the matrix with high/low WP builds for PHP 7.4 and 8.0.
3232
# PHP 8.0 is sort of supported since WP 5.6.
3333
# PHP 7.4 is supported since WP 5.3.
34-
- php: '8.1'
34+
- php: '8.3'
3535
wp: 'latest'
3636
experimental: true
3737
- php: '8.2'
3838
wp: 'latest'
3939
experimental: true
40-
- php: '8.0'
41-
wp: '5.6'
42-
experimental: true
43-
- php: '7.4'
44-
wp: '5.5'
40+
- php: '8.2'
41+
wp: '6.3'
4542
experimental: true
46-
- php: '7.4'
47-
wp: 'nightly'
43+
- php: '8.0'
44+
wp: '5.9'
4845
experimental: true
4946

50-
name: 'PHP ${{ matrix.php }} - WP ${{ matrix.wp }}'
47+
name: "PHP ${{ matrix.php }} - WP ${{ matrix.wp }}"
5148

5249
continue-on-error: ${{ matrix.experimental }}
5350

@@ -68,7 +65,7 @@ jobs:
6865

6966
steps:
7067
- name: Checkout code
71-
uses: actions/checkout@v3
68+
uses: actions/checkout@v4
7269

7370
- name: Install PHP
7471
uses: shivammathur/setup-php@v2
@@ -88,24 +85,26 @@ jobs:
8885
id: set_phpunit
8986
run: |
9087
if [[ "${{ matrix.php }}" > "8.1" ]]; then
91-
echo '::set-output name=PHPUNIT::10.*'
88+
echo "PHPUNIT=10.*" >> $GITHUB_ENV
9289
else
93-
echo '::set-output name=PHPUNIT::5.7.*||6.*||7.5.*'
90+
echo "PHPUNIT=5.7.*||6.*||7.5.*||8.5.*" >> $GITHUB_ENV
9491
fi
9592
9693
- name: 'Composer: set up PHPUnit'
97-
run: composer require --no-update phpunit/phpunit:"${{ steps.set_phpunit.outputs.PHPUNIT }}"
94+
env:
95+
PHPUNIT: ${{ env.PHPUNIT }}
96+
run: composer require --no-update phpunit/phpunit:"${{ env.PHPUNIT }}"
9897

9998
# Install dependencies and handle caching in one go.
10099
# @link https://github.com/marketplace/actions/install-composer-dependencies
101100
- name: Install Composer dependencies for PHP < 8.0
102101
if: ${{ matrix.php < 8.0 }}
103-
uses: 'ramsey/composer-install@v2'
102+
uses: "ramsey/composer-install@v2"
104103

105104
# For the PHP 8.0 and above, we need to install with ignore platform reqs as not all dependencies allow it yet.
106105
- name: Install Composer dependencies for PHP >= 8.0
107106
if: ${{ matrix.php >= 8.0 }}
108-
uses: 'ramsey/composer-install@v2'
107+
uses: "ramsey/composer-install@v2"
109108
with:
110109
composer-options: --ignore-platform-reqs
111110

Diff for: .github/workflows/zipitup.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@ jobs:
2222
runs-on: ubuntu-latest
2323
steps:
2424
- name: Checkout code
25-
uses: actions/checkout@v2
25+
uses: actions/checkout@v4
2626
- name: Build project
2727
run: |
2828
mkdir build
2929
- name: Create artifact
3030
uses: montudor/action-zip@v1
3131
with:
32-
args: zip -X -r build/add-to-all.zip . -x *.git* node_modules/\* .* "*/\.*" CODE_OF_CONDUCT.md CONTRIBUTING.md ISSUE_TEMPLATE.md PULL_REQUEST_TEMPLATE.md *.dist *.yml composer.* dev-helpers** build** wporg-assets** phpunit**
32+
args: zip -X -r build/add-to-all.zip . -x *.git* node_modules/\* .* "*/\.*" CODE_OF_CONDUCT.md CONTRIBUTING.md ISSUE_TEMPLATE.md PULL_REQUEST_TEMPLATE.md *.dist *.yml *.neon composer.* package.json dev-helpers** build** wporg-assets** phpunit**
3333
- name: Upload artifact
34-
uses: actions/upload-artifact@v3
34+
uses: actions/upload-artifact@v4
3535
with:
3636
name: add-to-all
3737
path: build/add-to-all.zip

Diff for: add-to-all.php

+38-41
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
* @author Ajay D'Souza
1111
* @license GPL-2.0+
1212
* @link https://webberzone.com
13-
* @copyright 2012-2023 Ajay D'Souza
13+
* @copyright 2012-2025 Ajay D'Souza
1414
*
1515
* @wordpress-plugin
1616
* Plugin Name: WebberZone Snippetz
17-
* Version: 2.0.1
17+
* Version: 2.1.0-beta1
1818
* Plugin URI: https://webberzone.com/plugins/add-to-all/
1919
* Description: A simple yet powerful plugin that allows you to insert any code snippet or script into WordPress.
2020
* Author: Ajay D'Souza
@@ -31,62 +31,59 @@
3131
exit;
3232
}
3333

34-
/**
35-
* Holds the version of WebberZone Snippetz.
36-
*
37-
* @since 1.8.0
38-
*
39-
* @var string WebberZone Snippetz version.
40-
*/
4134
if ( ! defined( 'WZ_SNIPPETZ_VERSION' ) ) {
42-
define( 'WZ_SNIPPETZ_VERSION', '2.0.0' );
35+
/**
36+
* Holds the version of WebberZone Snippetz.
37+
*
38+
* @since 1.8.0
39+
*
40+
* @var string $WZ_SNIPPETZ_VERSION WebberZone Snippetz version.
41+
*/
42+
define( 'WZ_SNIPPETZ_VERSION', '2.1.0' );
4343
}
4444

4545

46-
/**
47-
* Holds the plugin file path
48-
*
49-
* @since 1.2.0
50-
*
51-
* @var string Plugin Root File
52-
*/
5346
if ( ! defined( 'WZ_SNIPPETZ_FILE' ) ) {
47+
/**
48+
* Holds the plugin file path
49+
*
50+
* @since 1.2.0
51+
*
52+
* @var string $WZ_SNIPPETZ_FILE Plugin Root File
53+
*/
5454
define( 'WZ_SNIPPETZ_FILE', __FILE__ );
5555
}
5656

57-
58-
/**
59-
* Holds the filesystem directory path (with trailing slash)
60-
*
61-
* @since 1.2.0
62-
*
63-
* @var string Plugin folder path
64-
*/
6557
if ( ! defined( 'WZ_SNIPPETZ_DIR' ) ) {
58+
/**
59+
* Holds the filesystem directory path (with trailing slash)
60+
*
61+
* @since 1.2.0
62+
*
63+
* @var string $WZ_SNIPPETZ_DIR Plugin folder path
64+
*/
6665
define( 'WZ_SNIPPETZ_DIR', plugin_dir_path( WZ_SNIPPETZ_FILE ) );
6766
}
6867

69-
/**
70-
* Holds the URL directory path (with trailing slash)
71-
*
72-
* @since 1.2.0
73-
*
74-
* @var string Plugin folder URL
75-
*/
7668
if ( ! defined( 'WZ_SNIPPETZ_URL' ) ) {
69+
/**
70+
* Holds the URL directory path (with trailing slash)
71+
*
72+
* @since 1.2.0
73+
*
74+
* @var string $WZ_SNIPPETZ_URL Plugin folder URL
75+
*/
7776
define( 'WZ_SNIPPETZ_URL', plugin_dir_url( WZ_SNIPPETZ_FILE ) );
7877
}
7978

8079
// Load the autoloader.
81-
require_once WZ_SNIPPETZ_DIR . 'includes/autoloader.php';
80+
require_once plugin_dir_path( __FILE__ ) . 'includes/autoloader.php';
8281

8382
/**
8483
* The main function responsible for returning the one true WebberZone Snippetz instance to functions everywhere.
85-
*
86-
* @return Add_To_All The one true WebberZone Snippetz instance.
8784
*/
8885
function load_wz_snippetz() {
89-
return \WebberZone\Snippetz\Main::get_instance();
86+
\WebberZone\Snippetz\Main::get_instance();
9087
}
9188
add_action( 'plugins_loaded', __NAMESPACE__ . '\load_wz_snippetz' );
9289

@@ -95,13 +92,13 @@ function load_wz_snippetz() {
9592
* Include files
9693
*----------------------------------------------------------------------------
9794
*/
98-
require_once WZ_SNIPPETZ_DIR . 'includes/options-api.php';
95+
require_once plugin_dir_path( __FILE__ ) . 'includes/options-api.php';
9996

10097
/**
101-
* Declare $ata_settings global so that it can be accessed in every function
98+
* Declare $wz_snippetz_settings global so that it can be accessed in every function
10299
*
103100
* @since 1.0
104-
* @var $ata_settings WebberZone Snippetz settings array.
101+
* @var $wz_snippetz_settings WebberZone Snippetz settings array.
105102
*/
106-
global $ata_settings;
107-
$ata_settings = ata_get_settings();
103+
global $wz_snippetz_settings;
104+
$wz_snippetz_settings = ata_get_settings();

Diff for: composer.json

+31-11
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,45 @@
11
{
22
"name": "webberzone/add-to-all",
3-
"description": "The ultimate snippet manager for WordPress to create and manage custom HTML, CSS or JS code snippets.",
3+
"description": "WebberZone Snippetz lets you add custom text or HTML to your WordPress header, footer, sidebar, content or feed.",
4+
"version": "2.1.0",
45
"type": "wordpress-plugin",
56
"keywords": [
6-
"webberzone",
7-
"snippetz",
8-
"add-to-all",
7+
"snippets",
98
"header",
109
"footer",
11-
"feed",
12-
"snippets",
13-
"code snippets"
10+
"sidebar",
11+
"content",
12+
"feed"
1413
],
15-
"license": "gpl-2.0-or-later",
14+
"license": "GPL-2.0-or-later",
1615
"authors": [
1716
{
1817
"name": "WebberZone",
1918
"role": "Developer"
2019
}
2120
],
22-
"requires": {
23-
"php": ">=7.3"
21+
"require": {
22+
"php": ">=7.4"
23+
},
24+
"require-dev": {
25+
"php-stubs/wordpress-stubs": "^6",
26+
"wp-coding-standards/wpcs": "^3",
27+
"dealerdirect/phpcodesniffer-composer-installer": "^1",
28+
"phpcompatibility/phpcompatibility-wp": "^2",
29+
"yoast/phpunit-polyfills": "^3",
30+
"phpunit/phpunit": "^5.7.21 || ^6.5 || ^7.5 || ^8",
31+
"szepeviktor/phpstan-wordpress": "^1.3",
32+
"phpstan/phpstan": "^1.12",
33+
"phpstan/extension-installer": "^1.4"
34+
},
35+
"config": {
36+
"allow-plugins": {
37+
"phpstan/extension-installer": true,
38+
"dealerdirect/phpcodesniffer-composer-installer": true
39+
}
40+
},
41+
"scripts": {
42+
"phpstan": "vendor/bin/phpstan analyse --memory-limit=2048M",
43+
"phpstan-baseline": "vendor/bin/phpstan analyse --generate-baseline --memory-limit=2048M"
2444
}
25-
}
45+
}

0 commit comments

Comments
 (0)