Skip to content

Commit

Permalink
Merge pull request #641 from 10up/feature/update-phpcs
Browse files Browse the repository at this point in the history
Update `10up/phpcs-composer` to version 3 and fix all newly flagged issues
  • Loading branch information
dkotter authored Jan 8, 2024
2 parents 064add6 + ef74f13 commit cfed77f
Show file tree
Hide file tree
Showing 44 changed files with 387 additions and 210 deletions.
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

0 comments on commit cfed77f

Please sign in to comment.