Skip to content
Merged
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
6 changes: 6 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Our standard eslint config reads .gitignore and .eslintignore to determine what to ignore.

# @todo: Files below ignored as part of Automattic/jetpack/pull/25449
# They can be removed here as lint errors are addressed.
/inc/delete-cache-button.js
/inc/preload-notification.js
37 changes: 13 additions & 24 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,24 +1,13 @@
# Automatically generated rules.
/.git* export-ignore

# Package attributes file.
# Files not needed to be distributed in the package.
.gitattributes export-ignore
.github/ export-ignore
package.json export-ignore

# Files to include in the mirror repo, but excluded via gitignore
# Remember to end all directories with `/**` to properly tag every file.
# /src/js/example.min.js production-include

/jetpack_vendor/** production-include
/vendor/autoload.php production-include
/vendor/composer/** production-include
/vendor/automattic/jetpack-device-detection/** production-include

# Files to exclude from the mirror repo, but included in the monorepo.
# Remember to end all directories with `/**` to properly tag every file.
.gitignore production-exclude
.phpcs.dir.xml production-exclude
changelog/** production-exclude
tests/** production-exclude
# Files not needed in the release zip.
/.git* export-ignore
.gitattributes export-ignore
.github/ export-ignore
package.json export-ignore
tests/ export-ignore
.phan/ export-ignore
phpunit.*.xml.dist export-ignore
.phpcs.* export-ignore
.eslintignore export-ignore
eslint.config.mjs export-ignore
changelog/ export-ignore
.w.org-assets/ export-ignore
27 changes: 27 additions & 0 deletions .github/workflows/changelogger.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Changelogger

on:
pull_request:

jobs:
validate:
name: Validate changelog
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
tools: composer
coverage: none
- run: composer install --no-progress
- name: Check for changelog entry
run: |
BASE_SHA=${{ github.event.pull_request.base.sha }}
HEAD_SHA=${{ github.event.pull_request.head.sha }}
CHANGELOG_FILES=$(git diff --name-only "$BASE_SHA" "$HEAD_SHA" -- 'changelog/*')
if [ -z "$CHANGELOG_FILES" ]; then
echo "::warning::No changelog entry found. If this change is user-facing, please add one with: vendor/bin/changelogger add"
fi
21 changes: 0 additions & 21 deletions .github/workflows/e2e-tests.yml

This file was deleted.

20 changes: 20 additions & 0 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Linting

on:
pull_request:
push:
branches: [trunk]

jobs:
phpcs:
name: PHPCS
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
tools: composer
coverage: none
- run: composer install --no-progress
- run: vendor/bin/phpcs
24 changes: 24 additions & 0 deletions .github/workflows/php-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: PHP Tests

on:
pull_request:
push:
branches: [trunk]

jobs:
phpunit:
name: PHPUnit (PHP ${{ matrix.php }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: ['8.2', '8.3', '8.4', '8.5']
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer
coverage: none
- run: composer install --no-progress
- run: composer test-php
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
vendor/
node_modules/
81 changes: 81 additions & 0 deletions .phan/baseline.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?php
/**
* This is an automatically generated baseline for Phan issues.
* When Phan is invoked with --load-baseline=path/to/baseline.php,
* The pre-existing issues listed in this file won't be emitted.
*
* This file can be updated by invoking Phan with --save-baseline=path/to/baseline.php
* (can be combined with --load-baseline)
*/
return [
// # Issue statistics:
// PhanPluginSimplifyExpressionBool : 80+ occurrences
// PhanUndeclaredGlobalVariable : 45+ occurrences
// PhanPossiblyUndeclaredVariable : 20+ occurrences
// PhanUndeclaredVariable : 20+ occurrences
// PhanTypeMismatchArgument : 10+ occurrences
// PhanTypeMismatchArgumentNullableInternal : 10+ occurrences
// PhanTypeMismatchReturn : 10+ occurrences
// PhanTypeNonVarPassByRef : 10+ occurrences
// PhanTypePossiblyInvalidDimOffset : 10+ occurrences
// PhanUndeclaredFunctionInCallable : 10+ occurrences
// PhanTypeMismatchArgumentProbablyReal : 9 occurrences
// PhanUndeclaredFunction : 8 occurrences
// PhanSuspiciousValueComparison : 6 occurrences
// PhanTypeArraySuspiciousNull : 6 occurrences
// PhanTypeInvalidDimOffset : 6 occurrences
// PhanUndeclaredVariableDim : 6 occurrences
// PhanTypeArraySuspiciousNullable : 5 occurrences
// PhanTypeMismatchArgumentInternalProbablyReal : 4 occurrences
// PhanTypeMismatchArgumentInternalReal : 4 occurrences
// PhanPluginDuplicateConditionalNullCoalescing : 3 occurrences
// PhanTypeInvalidLeftOperandOfNumericOp : 3 occurrences
// PhanTypeSuspiciousNonTraversableForeach : 3 occurrences
// PhanUndeclaredClassMethod : 3 occurrences
// PhanPluginDuplicateAdjacentStatement : 2 occurrences
// PhanPluginDuplicateExpressionAssignmentOperation : 2 occurrences
// PhanPluginNeverReturnFunction : 2 occurrences
// PhanPluginUnreachableCode : 2 occurrences
// PhanPossiblyUndeclaredGlobalVariable : 2 occurrences
// PhanTypeMismatchArgumentNullable : 2 occurrences
// PhanTypeSuspiciousStringExpression : 2 occurrences
// PhanCommentParamWithoutRealParam : 1 occurrence
// PhanTypeConversionFromArray : 1 occurrence
// PhanTypeInvalidLeftOperandOfBitwiseOp : 1 occurrence
// PhanTypeInvalidRightOperandOfAdd : 1 occurrence
// PhanTypeInvalidRightOperandOfBitwiseOp : 1 occurrence
// PhanTypeMismatchArgumentInternal : 1 occurrence
// PhanTypeMismatchDimAssignment : 1 occurrence
// PhanTypeMismatchProperty : 1 occurrence
// PhanTypeMissingReturn : 1 occurrence
// PhanUndeclaredConstant : 1 occurrence

// Currently, file_suppressions and directory_suppressions are the only supported suppressions
'file_suppressions' => [
'advanced-cache.php' => ['PhanPluginSimplifyExpressionBool'],
'inc/delete-cache-button.php' => ['PhanPluginNeverReturnFunction', 'PhanTypeMismatchArgument'],
'ossdl-cdn.php' => ['PhanUndeclaredClassMethod'],
'partials/advanced.php' => ['PhanPluginSimplifyExpressionBool', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgument', 'PhanTypeNonVarPassByRef', 'PhanUndeclaredGlobalVariable'],
'partials/debug.php' => ['PhanTypeNonVarPassByRef', 'PhanUndeclaredGlobalVariable'],
'partials/easy.php' => ['PhanPluginSimplifyExpressionBool', 'PhanTypeArraySuspiciousNull', 'PhanTypeInvalidDimOffset', 'PhanTypeMismatchArgumentInternalReal', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredConstant', 'PhanUndeclaredGlobalVariable'],
'partials/lockdown.php' => ['PhanUndeclaredGlobalVariable'],
'partials/preload.php' => ['PhanPluginDuplicateAdjacentStatement', 'PhanPluginSimplifyExpressionBool', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchDimAssignment', 'PhanUndeclaredGlobalVariable'],
'partials/tracking_parameters.php' => ['PhanUndeclaredGlobalVariable'],
'plugins/domain-mapping.php' => ['PhanUndeclaredFunction'],
'plugins/jetpack.php' => ['PhanPluginSimplifyExpressionBool'],
'plugins/wptouch.php' => ['PhanPluginSimplifyExpressionBool', 'PhanUndeclaredFunction'],
'rest/class.wp-super-cache-rest-get-cache.php' => ['PhanPluginSimplifyExpressionBool'],
'rest/class.wp-super-cache-rest-get-settings.php' => ['PhanPluginSimplifyExpressionBool', 'PhanSuspiciousValueComparison', 'PhanTypeMismatchReturn', 'PhanUndeclaredFunctionInCallable', 'PhanUndeclaredVariable'],
'rest/class.wp-super-cache-rest-get-status.php' => ['PhanPluginSimplifyExpressionBool', 'PhanSuspiciousValueComparison', 'PhanTypeNonVarPassByRef', 'PhanUndeclaredVariable'],
'rest/class.wp-super-cache-rest-test-cache.php' => ['PhanPluginSimplifyExpressionBool', 'PhanTypeConversionFromArray', 'PhanTypePossiblyInvalidDimOffset', 'PhanUndeclaredVariableDim'],
'rest/class.wp-super-cache-rest-update-settings.php' => ['PhanCommentParamWithoutRealParam', 'PhanPluginSimplifyExpressionBool', 'PhanTypeMissingReturn'],
'src/device-detection/class-user-agent-info.php' => ['PhanPluginSimplifyExpressionBool', 'PhanTypeMismatchProperty', 'PhanTypeMismatchReturn'],
'tests/e2e/tools/mu-test-helpers.php' => ['PhanTypeMismatchArgument'],
'wp-cache-base.php' => ['PhanTypeMismatchArgumentNullableInternal'],
'wp-cache-phase1.php' => ['PhanTypeNonVarPassByRef'],
'wp-cache-phase2.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanPluginSimplifyExpressionBool', 'PhanPluginUnreachableCode', 'PhanPossiblyUndeclaredVariable', 'PhanSuspiciousValueComparison', 'PhanTypeArraySuspiciousNullable', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentInternalProbablyReal', 'PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchArgumentNullableInternal', 'PhanTypeNonVarPassByRef', 'PhanTypePossiblyInvalidDimOffset', 'PhanTypeSuspiciousNonTraversableForeach', 'PhanTypeSuspiciousStringExpression', 'PhanUndeclaredVariableDim'],
'wp-cache.php' => ['PhanPluginDuplicateAdjacentStatement', 'PhanPluginDuplicateExpressionAssignmentOperation', 'PhanPluginNeverReturnFunction', 'PhanPluginSimplifyExpressionBool', 'PhanPossiblyUndeclaredVariable', 'PhanSuspiciousValueComparison', 'PhanTypeArraySuspiciousNullable', 'PhanTypeInvalidDimOffset', 'PhanTypeInvalidLeftOperandOfBitwiseOp', 'PhanTypeInvalidLeftOperandOfNumericOp', 'PhanTypeInvalidRightOperandOfAdd', 'PhanTypeInvalidRightOperandOfBitwiseOp', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentInternal', 'PhanTypeMismatchArgumentInternalProbablyReal', 'PhanTypeMismatchArgumentInternalReal', 'PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchArgumentNullableInternal', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeNonVarPassByRef', 'PhanTypePossiblyInvalidDimOffset', 'PhanTypeSuspiciousNonTraversableForeach', 'PhanUndeclaredFunction', 'PhanUndeclaredVariable', 'PhanUndeclaredVariableDim'],
],
// 'directory_suppressions' => ['src/directory_name' => ['PhanIssueName1', 'PhanIssueName2']] can be manually added if needed.
// (directory_suppressions will currently be ignored by subsequent calls to --save-baseline, but may be preserved in future Phan releases)
];
49 changes: 49 additions & 0 deletions .phan/config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php
/**
* Phan configuration for WP Super Cache.
*/

return [
'minimum_target_php_version' => '7.2',
'target_php_version' => '8.5',

'backward_compatibility_checks' => false,
'enable_class_alias_support' => false,
'redundant_condition_detection' => true,

'directory_list' => [
'.',
],

'file_list' => [
__DIR__ . '/stubs/amp-stubs.php',
],

'exclude_analysis_directory_list' => [
'vendor/',
'node_modules/',
'tests/e2e/node_modules/',
'jetpack_vendor/',
],

'autoload_internal_extension_signatures' => [],

'stubs' => [
'vendor/php-stubs/wordpress-stubs/wordpress-stubs.php',
'vendor/php-stubs/wp-cli-stubs/wp-cli-stubs.php',
],

'plugins' => [
'AddNeverReturnTypePlugin',
'DuplicateArrayKeyPlugin',
'DuplicateExpressionPlugin',
'LoopVariableReusePlugin',
'PHPUnitNotDeadCodePlugin',
'PregRegexCheckerPlugin',
'RedundantAssignmentPlugin',
'SimplifyExpressionPlugin',
'UnreachableCodePlugin',
'UseReturnValuePlugin',
'UnusedSuppressionPlugin',
],
];
Loading
Loading