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

Deprecate the define method #22

Merged
merged 5 commits into from
Mar 5, 2025
Merged
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
90 changes: 0 additions & 90 deletions bin/baseline.neon
Original file line number Diff line number Diff line change
@@ -48,12 +48,6 @@ parameters:
count: 2
path: ../includes/acf-field-functions.php

-
message: '#^Constant ACF_PATH not found\.$#'
identifier: constant.notFound
count: 1
path: ../includes/acf-helper-functions.php

-
message: '#^Function acf_set_filters\(\) should return array but return statement is missing\.$#'
identifier: return.missing
@@ -126,24 +120,12 @@ parameters:
count: 1
path: ../includes/acf-user-functions.php

-
message: '#^Constant ACF_PATH not found\.$#'
identifier: constant.notFound
count: 1
path: ../includes/acf-utility-functions.php

-
message: '#^Action callback returns string but should not return anything\.$#'
identifier: return.void
count: 1
path: ../includes/admin/admin-internal-post-type-list.php

-
message: '#^Constant ACF_PATH not found\.$#'
identifier: constant.notFound
count: 1
path: ../includes/admin/admin-internal-post-type-list.php

-
message: '#^Action callback returns string but should not return anything\.$#'
identifier: return.void
@@ -168,12 +150,6 @@ parameters:
count: 2
path: ../includes/admin/admin-upgrade.php

-
message: '#^Constant ACF_UPGRADE_VERSION not found\.$#'
identifier: constant.notFound
count: 1
path: ../includes/admin/admin-upgrade.php

-
message: '#^Action callback returns string but should not return anything\.$#'
identifier: return.void
@@ -288,12 +264,6 @@ parameters:
count: 1
path: ../includes/admin/views/tools/tools.php

-
message: '#^Constant ACF_VERSION not found\.$#'
identifier: constant.notFound
count: 2
path: ../includes/admin/views/upgrade/network.php

-
message: '#^Variable \$button_text might not be defined\.$#'
identifier: variable.undefined
@@ -312,12 +282,6 @@ parameters:
count: 1
path: ../includes/admin/views/upgrade/notice.php

-
message: '#^Constant ACF_VERSION not found\.$#'
identifier: constant.notFound
count: 1
path: ../includes/admin/views/upgrade/upgrade.php

-
message: '#^Function remove_filter invoked with 4 parameters, 2\-3 required\.$#'
identifier: arguments.count
@@ -360,12 +324,6 @@ parameters:
count: 1
path: ../includes/api/api-term.php

-
message: '#^Constant ACF_VERSION not found\.$#'
identifier: constant.notFound
count: 3
path: ../includes/blocks.php

-
message: '#^Access to an undefined property ACF_Data\:\:\$site_aliases\.$#'
identifier: property.notFound
@@ -618,24 +576,6 @@ parameters:
count: 1
path: ../includes/revisions.php

-
message: '#^Constant ACF_VERSION not found\.$#'
identifier: constant.notFound
count: 1
path: ../includes/third-party.php

-
message: '#^Constant ACF_UPGRADE_VERSION not found\.$#'
identifier: constant.notFound
count: 2
path: ../includes/upgrades.php

-
message: '#^Constant ACF_VERSION not found\.$#'
identifier: constant.notFound
count: 3
path: ../includes/upgrades.php

-
message: '#^Access to an undefined property acf_validation\:\:\$errors\.$#'
identifier: property.notFound
@@ -648,36 +588,6 @@ parameters:
count: 1
path: ../includes/wpml.php

-
message: '#^Constant ACF_BASENAME not found\.$#'
identifier: constant.notFound
count: 2
path: ../secure-custom-fields.php

-
message: '#^Constant ACF_FIELD_API_VERSION not found\.$#'
identifier: constant.notFound
count: 3
path: ../secure-custom-fields.php

-
message: '#^Constant ACF_MAJOR_VERSION not found\.$#'
identifier: constant.notFound
count: 4
path: ../secure-custom-fields.php

-
message: '#^Constant ACF_PATH not found\.$#'
identifier: constant.notFound
count: 2
path: ../secure-custom-fields.php

-
message: '#^Constant ACF_VERSION not found\.$#'
identifier: constant.notFound
count: 2
path: ../secure-custom-fields.php

-
message: '#^One or more @param tags has an invalid name or invalid syntax\.$#'
identifier: phpDoc.parseError
13 changes: 13 additions & 0 deletions bin/phpstan-bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
/**
* Bootstrap the plugin for PHPStan.
*
* Loads the plugin file as the entry point for PHPStan.
*
* @package WordPress/Secure-Custom-Fields
*/

/**
* Main plugin file. Will always be loaded.
*/
require_once __DIR__ . '/../secure-custom-fields.php';
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -71,6 +71,7 @@
"@test:phpstan"
],
"test:php": "phpunit",
"test:phpstan": "phpstan analyze --memory-limit=2G"
"test:phpstan": "phpstan analyze --memory-limit=2G",
"test:phpstan:baseline": "phpstan analyze --memory-limit=2G --generate-baseline=bin/baseline.neon"
}
}
2 changes: 2 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -11,3 +11,5 @@ parameters:
- docs
- lang
- wordpress
bootstrapFiles:
- bin/phpstan-bootstrap.php
21 changes: 10 additions & 11 deletions secure-custom-fields.php
Original file line number Diff line number Diff line change
@@ -28,8 +28,6 @@
*/
#[AllowDynamicProperties]
class ACF {


/**
* The plugin version number.
*
@@ -77,14 +75,14 @@ public function __construct() {
public function initialize() {

// Define constants.
$this->define( 'ACF', true );
$this->define( 'ACF_PATH', plugin_dir_path( __FILE__ ) );
$this->define( 'ACF_BASENAME', plugin_basename( __FILE__ ) );
$this->define( 'ACF_VERSION', $this->version );
$this->define( 'ACF_MAJOR_VERSION', 6 );
$this->define( 'ACF_FIELD_API_VERSION', 5 );
$this->define( 'ACF_UPGRADE_VERSION', '5.5.0' ); // Highest version with an upgrade routine. See upgrades.php.
$this->define( 'ACF_PRO', true );
defined( 'ACF' ) || define( 'ACF', true );
defined( 'ACF_PATH' ) || define( 'ACF_PATH', plugin_dir_path( __FILE__ ) );
defined( 'ACF_BASENAME' ) || define( 'ACF_BASENAME', plugin_basename( __FILE__ ) );
defined( 'ACF_VERSION' ) || define( 'ACF_VERSION', $this->version );
defined( 'ACF_MAJOR_VERSION' ) || define( 'ACF_MAJOR_VERSION', 6 );
defined( 'ACF_FIELD_API_VERSION' ) || define( 'ACF_FIELD_API_VERSION', 5 );
defined( 'ACF_UPGRADE_VERSION' ) || define( 'ACF_UPGRADE_VERSION', '5.5.0' ); // Highest version with an upgrade routine. See upgrades.php.
defined( 'ACF_PRO' ) || define( 'ACF_PRO', true );

// Register activation hook.
register_activation_hook( __FILE__, array( $this, 'acf_plugin_activated' ) );
@@ -585,14 +583,15 @@ public function posts_where( $where, $wp_query ) {
/**
* Defines a constant if doesnt already exist.
*
* @date 3/5/17
* @since ACF 5.5.13
* @deprecated 6.5.0 -- Use vanilla PHP defined() || define() instead.
*
* @param string $name The constant name.
* @param mixed $value The constant value.
* @return void
*/
public function define( $name, $value = true ) {
_deprecated_function( __METHOD__, '6.5.0', 'defined() || define()' );
if ( ! defined( $name ) ) {
define( $name, $value );
}