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

Update 10up/phpcs-composer to version 3 and fix all newly flagged issues #641

Merged
merged 4 commits into from
Jan 8, 2024
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
12 changes: 6 additions & 6 deletions autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,23 +58,23 @@ public function add_namespace( $prefix, $base_dir, $prepend = false ) {
/**
* Loads the class file for a given class name.
*
* @param string $class The fully-qualified class name.
* @param string $classname The fully-qualified class name.
* @return mixed The mapped file name on success, or boolean false on
* failure.
*/
public function load_class( $class ) {
public function load_class( $classname ) {
// the current namespace prefix
$prefix = $class;
$prefix = $classname;

// work backwards through the namespace names of the fully-qualified
// class name to find a mapped file name
while ( false !== $pos = strrpos( $prefix, '\\' ) ) { // phpcs:ignore WordPress.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition
while ( false !== $pos = strrpos( $prefix, '\\' ) ) { // phpcs:ignore Generic.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition, WordPress.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition

// retain the trailing namespace separator in the prefix
$prefix = substr( $class, 0, $pos + 1 );
$prefix = substr( $classname, 0, $pos + 1 );

// the rest is the relative class name
$relative_class = substr( $class, $pos + 1 );
$relative_class = substr( $classname, $pos + 1 );

// try to load a mapped file for the prefix and relative class
$mapped_file = $this->load_mapped_file( $prefix, $relative_class );
Expand Down
2 changes: 1 addition & 1 deletion classifai.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function classifai_site_meets_php_requirements() {
if ( ! classifai_site_meets_php_requirements() ) {
add_action(
'admin_notices',
function() {
function () {
?>
<div class="notice notice-error">
<p>
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
]
},
"require-dev": {
"10up/phpcs-composer": "dev-master",
"10up/phpcs-composer": "^3.0",
"yoast/phpunit-polyfills": "^1.0.0"
},
"scripts": {
"lint": "phpcs . --runtime-set testVersion 7.4-",
"lint": "phpcs -s . --runtime-set testVersion 7.4-",
"lint-fix": "phpcbf ."
},
"minimum-stability": "dev",
Expand Down
Loading
Loading