diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 697910d1..a9f738e8 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -22,7 +22,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 # User PHP 7.4 here for compatibility with the WordPress codesniffer rules. - name: Setup PHP @@ -32,32 +32,41 @@ jobs: coverage: none tools: composer, cs2pr - - uses: technote-space/get-diff-action@v6 + - uses: technote-space/get-diff-action@v6 # repo is archived. with: SUFFIX_FILTER: .php - name: Get Composer cache directory id: composer-cache run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - if: "!! env.GIT_DIFF" - name: Cache Composer vendor directory - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ${{ steps.composer-cache.outputs.dir }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} restore-keys: | ${{ runner.os }}-composer- - if: "!! env.GIT_DIFF" - name: Validate composer.json and composer.lock run: composer validate - if: "!! env.GIT_DIFF" - name: Install dependencies run: composer install --no-progress --optimize-autoloader --prefer-dist - if: "!! env.GIT_DIFF" + + - name: Fix auto-fixable PHP Code Standards Violations + continue-on-error: true + run: vendor/bin/phpcbf --standard=phpcs.xml + + - name: Commit PHPCBF changes on main + if: ${{ github.ref == 'refs/heads/main' }} # only commit on main + uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_message: "🤖 PHPCBF" + commit_options: "" + env: + GITHUB_TOKEN: "${{ github.token }}" - name: Detecting PHP Code Standards Violations - run: vendor/bin/phpcs --standard=phpcs.xml -s ${{ env.GIT_DIFF }} + run: vendor/bin/phpcs --standard=phpcs.xml -s ${{ env.GIT_DIFF }} --report=checkstyle | cs2pr if: "!! env.GIT_DIFF" diff --git a/.github/workflows/codecoverage-main.yml b/.github/workflows/unit-tests-and-coverage-report.yml similarity index 68% rename from .github/workflows/codecoverage-main.yml rename to .github/workflows/unit-tests-and-coverage-report.yml index 49a12c0b..ef254c01 100644 --- a/.github/workflows/codecoverage-main.yml +++ b/.github/workflows/unit-tests-and-coverage-report.yml @@ -1,4 +1,4 @@ -name: Codecoverage-Main +name: Unit tests + Code coverage report # Runs PHPUnit unit and Codeception wp-browser wpunit tests, merges the code coverage, commits the html report to # GitHub Pages, generates a README badge with the coverage percentage. @@ -7,6 +7,11 @@ on: push: branches: - main + pull_request: + types: [ opened, reopened, ready_for_review, synchronize ] + branches: + - main + workflow_dispatch: jobs: @@ -25,31 +30,36 @@ jobs: strategy: matrix: - php: [ '7.4' ] + php: [ '7.3', '7.4', '8.0', '8.1', '8.2', '8.3' ] steps: - name: Checkout uses: actions/checkout@v3 - - - name: Check does gh-pages branch need to be created - run: | - if [[ $(git branch -l gh-pages) == "" ]]; then - gh_pages_branch_needed=true - else - gh_pages_branch_needed=false - fi - echo "GH_PAGES_BRANCH_NEEDED=$gh_pages_branch_needed" >> $GITHUB_ENV; - mkdir gh-pages - - - name: Maybe create gh-pages branch - if: ${{ env.GH_PAGES_BRANCH_NEEDED }} - uses: peaceiris/actions-gh-pages@v4 with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./gh-pages - force_orphan: true - allow_empty_commit: true - commit_message: "🤖 Creating gh-pages branch" + fetch-depth: 0 # attempting to get all branch names. + +# - name: Check does gh-pages branch need to be created +# run: | +# git branch -l; +# if [[ $(git branch -l gh-pages) == "" ]]; then +# gh_pages_branch_needed=true; +# echo "gh-pages branch is needed"; +# else +# gh_pages_branch_needed=false +# echo "gh-pages branch already exists"; +# fi +# echo "GH_PAGES_BRANCH_NEEDED=$gh_pages_branch_needed" >> $GITHUB_ENV; +# mkdir gh-pages +# +# - name: Maybe create gh-pages branch +# if: ${{ env.GH_PAGES_BRANCH_NEEDED }} +# uses: peaceiris/actions-gh-pages@v4 +# with: +# github_token: ${{ secrets.GITHUB_TOKEN }} +# publish_dir: ./gh-pages +# force_orphan: true +# allow_empty_commit: true +# commit_message: "🤖 Creating gh-pages branch" - name: Checkout GitHub Pages branch for code coverage report uses: actions/checkout@v3 @@ -102,6 +112,7 @@ jobs: run: php-coverage-badger gh-pages/phpunit/clover.xml gh-pages/phpunit/coverage.svg - name: Commit code coverage to gh-pages + if: ${{ github.ref == 'refs/heads/main' && matrix.php-version == '7.3' }} # only commit on main, on the PHP version we're using in production. uses: stefanzweifel/git-auto-commit-action@v5 with: repository: gh-pages diff --git a/includes/Event.php b/includes/Event.php index c435b8a8..082f492b 100644 --- a/includes/Event.php +++ b/includes/Event.php @@ -90,7 +90,5 @@ public function __construct( $category = 'Admin', $key = '', $data = array() ) { 'role' => ( ! empty( $user->roles[0] ) ) ? $user->roles[0] : '', 'locale' => get_user_locale(), ); - } - } diff --git a/includes/EventQueue/EventQueue.php b/includes/EventQueue/EventQueue.php index 05ef3f42..7a629c92 100644 --- a/includes/EventQueue/EventQueue.php +++ b/includes/EventQueue/EventQueue.php @@ -36,16 +36,16 @@ public static function getInstance() { /** * Constructor * - * @param Container $container + * @param Container $container */ private function __construct() { global $wpdb; $container = new Container( - [ + array( 'table' => "{$wpdb->prefix}nfd_data_event_queue", - ] + ) ); $container->set( @@ -86,5 +86,4 @@ public function container() { public function queue() { return $this->container->get( 'queue' ); } - } diff --git a/includes/EventQueue/Queryable.php b/includes/EventQueue/Queryable.php index 573cb3e2..9d8a8b8a 100644 --- a/includes/EventQueue/Queryable.php +++ b/includes/EventQueue/Queryable.php @@ -26,8 +26,8 @@ protected function table() { * Bulk inserts records into a table using WPDB. All rows must contain the same keys. * Returns number of affected (inserted) rows. * - * @param string $table - * @param non-empty-array $rows + * @param string $table + * @param non-empty-array $rows * * @return bool|int */ @@ -63,5 +63,4 @@ protected function bulkInsert( string $table, array $rows ) { // Run the query. Returns number of affected rows. return $wpdb->query( $wpdb->prepare( $sql, $data ) ); } - } diff --git a/includes/EventQueue/Queues/BatchQueue.php b/includes/EventQueue/Queues/BatchQueue.php index 2e2b45b9..f27d690a 100644 --- a/includes/EventQueue/Queues/BatchQueue.php +++ b/includes/EventQueue/Queues/BatchQueue.php @@ -20,7 +20,7 @@ class BatchQueue implements BatchQueueInterface { /** * Constructor * - * @param Container $container + * @param Container $container */ public function __construct( Container $container ) { $this->container = $container; @@ -29,7 +29,7 @@ public function __construct( Container $container ) { /** * Push events onto the queue * - * @param non-empty-array $events + * @param non-empty-array $events * * @return bool */ @@ -37,13 +37,13 @@ public function push( array $events ) { $time = current_time( 'mysql' ); - $inserts = []; + $inserts = array(); foreach ( $events as $event ) { - $inserts[] = [ + $inserts[] = array( 'event' => serialize( $event ), 'available_at' => current_time( 'mysql' ), 'created_at' => $time, - ]; + ); } return (bool) $this->bulkInsert( $this->table(), $inserts ); @@ -56,7 +56,7 @@ public function push( array $events ) { */ public function pull( int $count ) { - $events = []; + $events = array(); $rawEvents = $this ->query() @@ -84,7 +84,7 @@ public function pull( int $count ) { /** * Remove events from the queue * - * @param int[] $ids + * @param int[] $ids * * @return bool */ @@ -99,7 +99,7 @@ public function remove( array $ids ) { /** * Reserve events in the queue * - * @param int[] $ids + * @param int[] $ids * * @return bool */ @@ -108,13 +108,13 @@ public function reserve( array $ids ) { ->query() ->table( $this->table(), false ) ->whereIn( 'id', $ids ) - ->update( [ 'reserved_at' => current_time( 'mysql' ) ] ); + ->update( array( 'reserved_at' => current_time( 'mysql' ) ) ); } /** * Release events back onto the queue * - * @param int[] $ids + * @param int[] $ids * * @return bool */ @@ -123,7 +123,7 @@ public function release( array $ids ) { ->query() ->table( $this->table(), false ) ->whereIn( 'id', $ids ) - ->update( [ 'reserved_at' => null ] ); + ->update( array( 'reserved_at' => null ) ); } /** diff --git a/includes/EventQueue/Queues/BatchQueueInterface.php b/includes/EventQueue/Queues/BatchQueueInterface.php index 4f9726b3..f2b4912c 100644 --- a/includes/EventQueue/Queues/BatchQueueInterface.php +++ b/includes/EventQueue/Queues/BatchQueueInterface.php @@ -9,7 +9,7 @@ interface BatchQueueInterface { /** * Push one or more events onto the queue * - * @param Event[] $events + * @param Event[] $events * * @return bool */ @@ -25,7 +25,7 @@ public function pull( int $count ); /** * Remove one or more events from the queue * - * @param Event[] $events + * @param Event[] $events * * @return bool */ @@ -34,7 +34,7 @@ public function remove( array $events ); /** * Reserve one or more events in the queue * - * @param Event[] $events + * @param Event[] $events * * @return bool */ @@ -43,7 +43,7 @@ public function reserve( array $events ); /** * Release one or more events back onto the queue * - * @param Event[] $events + * @param Event[] $events * * @return bool */ @@ -55,5 +55,4 @@ public function release( array $events ); * @return int */ public function count(); - } diff --git a/includes/Helpers/SiteHealth.php b/includes/Helpers/SiteHealth.php index d57f6a83..6117ae30 100644 --- a/includes/Helpers/SiteHealth.php +++ b/includes/Helpers/SiteHealth.php @@ -122,7 +122,7 @@ public static function calculate_score( $results ) { $total_tests = array_reduce( $results, - function( $total, $item ) { + function ( $total, $item ) { return $total += (int) $item; } ); @@ -134,5 +134,4 @@ function( $total, $item ) { return round( (int) $results['good'] / $total_tests * 100 ); } - } diff --git a/includes/Listeners/Content.php b/includes/Listeners/Content.php index 3aab99b1..6e16d223 100644 --- a/includes/Listeners/Content.php +++ b/includes/Listeners/Content.php @@ -25,8 +25,8 @@ public function register_hooks() { /** * Post status transition * - * @param string $new_status The new post status - * @param string $old_status The old post status + * @param string $new_status The new post status + * @param string $old_status The old post status * @param \WP_Post $post Post object * * @return void @@ -94,8 +94,8 @@ public function count_posts() { /** * Comment status transition * - * @param string $new_status The new comment status - * @param string $old_status The new comment status + * @param string $new_status The new comment status + * @param string $old_status The new comment status * @param WP_Comment $comment Comment object * * @return void diff --git a/includes/Listeners/Listener.php b/includes/Listeners/Listener.php index a65ad392..82561c76 100644 --- a/includes/Listeners/Listener.php +++ b/includes/Listeners/Listener.php @@ -55,5 +55,4 @@ protected function get_class_name() { return substr( $class, $position + 1 ); } - } diff --git a/includes/Listeners/SiteHealth.php b/includes/Listeners/SiteHealth.php index 2299bc41..4f283172 100644 --- a/includes/Listeners/SiteHealth.php +++ b/includes/Listeners/SiteHealth.php @@ -33,8 +33,8 @@ public function tests_run( $value ) { $this->push( 'site_health_score', array( - 'label_key' => 'score', - 'score' => SiteHealthHelper::calculate_score( $value ), + 'label_key' => 'score', + 'score' => SiteHealthHelper::calculate_score( $value ), ) ); $this->push( diff --git a/includes/Listeners/Theme.php b/includes/Listeners/Theme.php index 2764b1a4..afe9daeb 100644 --- a/includes/Listeners/Theme.php +++ b/includes/Listeners/Theme.php @@ -54,7 +54,13 @@ public function theme_changed( $new_option, $old_option ) { public function mojo_preview() { global $theme; if ( isset( $_GET['page'] ) && 'mojo-theme-preview' === $_GET['page'] && ! is_wp_error( $theme ) ) { - $this->push( 'mojo_theme_preview', array( 'label_key' => 'theme', 'theme' => $theme ) ); + $this->push( + 'mojo_theme_preview', + array( + 'label_key' => 'theme', + 'theme' => $theme, + ) + ); } } @@ -65,6 +71,12 @@ public function mojo_preview() { */ public function browse_wporg_themes() { $category = ( isset( $_GET['browse'] ) ) ? esc_attr( $_GET['browse'] ) : 'featured'; - $this->push( 'browse_wporg_themes', array( 'label_key' => 'category', 'category' => $category ) ); + $this->push( + 'browse_wporg_themes', + array( + 'label_key' => 'category', + 'category' => $category, + ) + ); } } diff --git a/includes/Listeners/WonderCart.php b/includes/Listeners/WonderCart.php index 7be3efc3..7b844150 100644 --- a/includes/Listeners/WonderCart.php +++ b/includes/Listeners/WonderCart.php @@ -83,7 +83,7 @@ public function create_campaign_modal_open( $args, $event ) { public function campaign_selected( $args, $event ) { $data = array( 'label_key' => 'campaign_slug', - 'type' => $args['type'], + 'type' => $args['type'], 'campaign_slug' => $args['type'], ); @@ -105,7 +105,7 @@ public function campaign_selected( $args, $event ) { public function campaign_abandoned( $args, $event ) { $data = array( 'label_key' => 'campaign_slug', - 'type' => $args['type'], + 'type' => $args['type'], 'campaign_slug' => $args['type'] . '-' . $args['id'], ); @@ -155,7 +155,7 @@ public function checkout_campaigns_used() { if ( count( $campaigns ) > 0 ) { $data = array( 'label_key' => 'type', - 'type' => array_unique( $campaigns ), + 'type' => array_unique( $campaigns ), 'campaign_count' => count( $campaigns ), 'campaign_total' => '$' . $campaign_total, ); diff --git a/includes/Listeners/Yoast.php b/includes/Listeners/Yoast.php index fb69c8f9..097ab78e 100644 --- a/includes/Listeners/Yoast.php +++ b/includes/Listeners/Yoast.php @@ -7,23 +7,23 @@ */ class Yoast extends Listener { // We don't want to track these fields - private $site_representation_skip_fields = [ 'company_logo_id', 'person_logo_id', 'description' ]; + private $site_representation_skip_fields = array( 'company_logo_id', 'person_logo_id', 'description' ); // The names used for Hiive events tracking are different from the names used for the Yoast options - private $site_representation_map = [ + private $site_representation_map = array( 'company_or_person' => 'site_representation', 'company_name' => 'organization_name', 'company_logo' => 'organization_logo', 'person_logo' => 'logo', 'company_or_person_user_id' => 'name', 'website_name' => 'website_name', - ]; + ); - private $social_profiles_map = [ + private $social_profiles_map = array( 'facebook_site' => 'facebook_profile', 'twitter_site' => 'twitter_profile', 'other_social_urls' => 'other_profiles', - ]; + ); /** * Register the hooks for the listener @@ -32,9 +32,9 @@ class Yoast extends Listener { */ public function register_hooks() { // First time configuration - add_action('wpseo_ftc_post_update_site_representation', array( $this, 'site_representation_updated' ), 10, 3 ); - add_action('wpseo_ftc_post_update_social_profiles', array( $this, 'social_profiles_updated' ), 10, 3 ); - add_action('wpseo_ftc_post_update_enable_tracking', array( $this, 'tracking_updated' ), 10, 3 ); + add_action( 'wpseo_ftc_post_update_site_representation', array( $this, 'site_representation_updated' ), 10, 3 ); + add_action( 'wpseo_ftc_post_update_social_profiles', array( $this, 'social_profiles_updated' ), 10, 3 ); + add_action( 'wpseo_ftc_post_update_enable_tracking', array( $this, 'tracking_updated' ), 10, 3 ); } /** @@ -56,7 +56,7 @@ public function site_representation_updated( $new_values, $old_values, $failures $mapped_old_values = $this->map_params_names_to_hiive_names( $old_values, $this->site_representation_map, $this->site_representation_skip_fields ); $mapped_failures = $this->map_failures_to_hiive_names( $failures, $this->site_representation_map, $this->site_representation_skip_fields ); - foreach ($mapped_new_values as $key => $value) { + foreach ( $mapped_new_values as $key => $value ) { $this->maybe_push_site_representation_event( $key, $value, $mapped_old_values[ $key ], \in_array( $key, $mapped_failures ) ); } } @@ -72,8 +72,8 @@ public function site_representation_updated( $new_values, $old_values, $failures */ public function social_profiles_updated( $new_values, $old_values, $failures ) { // Yoast stores only twitter username, and $new_values stores the pre-processed values - if ( strpos( $new_values[ 'twitter_site' ], 'twitter.com/' ) !== false ) { - $new_values[ 'twitter_site' ] = (explode( 'twitter.com/', $new_values[ 'twitter_site' ])[ 1 ] ); + if ( strpos( $new_values['twitter_site'], 'twitter.com/' ) !== false ) { + $new_values['twitter_site'] = ( explode( 'twitter.com/', $new_values['twitter_site'] )[1] ); } // All the options are unchanged, opt out @@ -88,10 +88,10 @@ public function social_profiles_updated( $new_values, $old_values, $failures ) { $mapped_old_values = $this->map_params_names_to_hiive_names( $old_values, $this->social_profiles_map ); $mapped_failures = $this->map_failures_to_hiive_names( $cleaned_failures, $this->social_profiles_map ); - foreach ($mapped_values as $key => $value) { + foreach ( $mapped_values as $key => $value ) { // The option update failed if ( \in_array( $key, $mapped_failures ) ) { - $this->push( "failed_$key", [ 'category' => 'ftc_personal_profiles' ] ); + $this->push( "failed_$key", array( 'category' => 'ftc_personal_profiles' ) ); return; } @@ -116,7 +116,7 @@ public function tracking_updated( $new_value, $old_value, $failed ) { return; } - $failed ? $this->push( "failed_usage_tracking", [ 'category' => 'ftc_tracking' ] ) : $this->push( "changed_usage_tracking", [ 'category' => 'ftc_tracking' ] ); + $failed ? $this->push( 'failed_usage_tracking', array( 'category' => 'ftc_tracking' ) ) : $this->push( 'changed_usage_tracking', array( 'category' => 'ftc_tracking' ) ); } /** @@ -134,7 +134,7 @@ private function maybe_push_site_representation_event( $key, $value, $old_value, // The option update failed if ( $failure ) { - $this->push( "failed_$key", [ 'category' => $category] ); + $this->push( "failed_$key", array( 'category' => $category ) ); return; } @@ -154,8 +154,8 @@ private function maybe_push_site_representation_event( $key, $value, $old_value, // switched from organisation to person, and then the person id is being set. // Once the name is assigned an integer > 0, it can never go back to 0, even if the user switches back to organisation // ( it "caches" the last user id that was set) - if ( ( $this->is_param_empty( $old_value) ) || ( $key === 'name' && $old_value === 0 ) ){ - $this->push( "set_$key", [ 'category' => $category] ); + if ( ( $this->is_param_empty( $old_value ) ) || ( $key === 'name' && $old_value === 0 ) ) { + $this->push( "set_$key", array( 'category' => $category ) ); return; } @@ -164,7 +164,7 @@ private function maybe_push_site_representation_event( $key, $value, $old_value, 'category' => $category, 'data' => array( 'label_key' => $key, - 'new_value' => $value + 'new_value' => $value, ), ); @@ -190,7 +190,7 @@ private function maybe_push_social_profiles_event( $key, $value, $old_value, $fa // The option update failed if ( $failure ) { - $this->push( "failed_$key", [ 'category' => $category] ); + $this->push( "failed_$key", array( 'category' => $category ) ); return; } @@ -202,13 +202,13 @@ private function maybe_push_social_profiles_event( $key, $value, $old_value, $fa } // The option was set for the first time - if ( $this->is_param_empty( $old_value) ){ - $this->push( "set_$key", [ 'category' => $category] ); + if ( $this->is_param_empty( $old_value ) ) { + $this->push( "set_$key", array( 'category' => $category ) ); return; } // The option was updated - $this->push( "changed_$key", [ 'category' => $category ] ); + $this->push( "changed_$key", array( 'category' => $category ) ); } } @@ -225,13 +225,13 @@ private function maybe_push_social_profiles_event( $key, $value, $old_value, $fa */ private function push_other_social_profiles( $key, $new_value, $old_value, $category ) { // The option was set for the first time - if ( $this->is_param_empty( $old_value) ){ - $this->push( "set_$key", [ 'category' => $category] ); + if ( $this->is_param_empty( $old_value ) ) { + $this->push( "set_$key", array( 'category' => $category ) ); return; } $changed_profiles = \array_map( - function( $value ) { + function ( $value ) { return $this->get_base_url( \wp_unslash( $value ) ); }, $new_value @@ -242,11 +242,11 @@ function( $value ) { 'category' => $category, 'data' => array( 'label_key' => $key, - 'new_value' => $changed_profiles - ), - ); - - $this->push( "changed_other_profiles", $data ); + 'new_value' => $changed_profiles, + ), + ); + + $this->push( 'changed_other_profiles', $data ); } /** @@ -258,8 +258,8 @@ function( $value ) { * * @return array The mapped params. */ - private function map_params_names_to_hiive_names( $params, $map, $skip_fields=[] ) { - $mapped_params = []; + private function map_params_names_to_hiive_names( $params, $map, $skip_fields = array() ) { + $mapped_params = array(); foreach ( $params as $param_name => $param_value ) { if ( in_array( $param_name, $skip_fields, true ) ) { @@ -282,10 +282,10 @@ private function map_params_names_to_hiive_names( $params, $map, $skip_fields=[] * * @return array The mapped params names. */ - private function map_failures_to_hiive_names( $failures, $map, $skip_fields=[] ) { - $mapped_failures = []; + private function map_failures_to_hiive_names( $failures, $map, $skip_fields = array() ) { + $mapped_failures = array(); - foreach ( $failures as $failed_field_name) { + foreach ( $failures as $failed_field_name ) { if ( in_array( $failed_field_name, $skip_fields, true ) ) { continue; } @@ -331,8 +331,8 @@ private function get_base_url( $url ) { * * @return array The cleaned failures array */ - private function clean_social_profiles_failures ( $failures ) { - $cleaned_failures = []; + private function clean_social_profiles_failures( $failures ) { + $cleaned_failures = array(); $other_social_profiles_failed = false; foreach ( $failures as $failure ) { @@ -349,4 +349,4 @@ private function clean_social_profiles_failures ( $failures ) { return $cleaned_failures; } -} \ No newline at end of file +} diff --git a/includes/Logger.php b/includes/Logger.php index e8dcb9c1..28d05d66 100644 --- a/includes/Logger.php +++ b/includes/Logger.php @@ -18,7 +18,7 @@ public function notify( $events ) { return; } $log = wp_json_encode( $event, JSON_UNESCAPED_SLASHES ) . "\n"; - file_put_contents( dirname( dirname( __FILE__ ) ) . '/debug.log', $log, FILE_APPEND ); + file_put_contents( dirname( __DIR__ ) . '/debug.log', $log, FILE_APPEND ); } } } diff --git a/includes/SiteClassification/PrimaryType.php b/includes/SiteClassification/PrimaryType.php index 26e42613..2f9b0800 100644 --- a/includes/SiteClassification/PrimaryType.php +++ b/includes/SiteClassification/PrimaryType.php @@ -61,7 +61,7 @@ public static function instantiate_from_option() { return false; } - $instance = new static( $data['refers'], $data['value'] ); + $instance = new self( $data['refers'], $data['value'] ); if ( ! $instance->validate() ) { delete_option( self::$primary_option_name ); return false; diff --git a/includes/SiteClassification/SecondaryType.php b/includes/SiteClassification/SecondaryType.php index 7ddbb7fd..429c3bea 100644 --- a/includes/SiteClassification/SecondaryType.php +++ b/includes/SiteClassification/SecondaryType.php @@ -68,7 +68,7 @@ public static function instantiate_from_option() { return false; } - $instance = new static( $data['refers'], $data['value'] ); + $instance = new self( $data['refers'], $data['value'] ); if ( ! $instance->validate() ) { delete_option( self::$secondary_option_name ); return false; diff --git a/includes/SiteClassification/SiteClassification.php b/includes/SiteClassification/SiteClassification.php index 6270a093..d0ee617d 100644 --- a/includes/SiteClassification/SiteClassification.php +++ b/includes/SiteClassification/SiteClassification.php @@ -115,6 +115,5 @@ public static function fetch_from_static_file( $locale = 'en-US' ) { } return $data; - } } diff --git a/includes/SiteClassification/Types.php b/includes/SiteClassification/Types.php index 269a3c20..4be63758 100644 --- a/includes/SiteClassification/Types.php +++ b/includes/SiteClassification/Types.php @@ -71,7 +71,6 @@ public function save() { } update_option( $this->option_name, $this->to_array() ); return true; - } /** @@ -92,5 +91,4 @@ public function to_array() { * @return boolean */ abstract public function validate(); - } diff --git a/phpcs.xml b/phpcs.xml index b0747441..1c6f8e23 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -3,8 +3,8 @@ - - ./includes - ./upgrades + + includes + upgrades diff --git a/tests/phpunit/includes/HiiveConnectionTest.php b/tests/phpunit/includes/HiiveConnectionTest.php index 4c0265f6..d1bfaa5f 100644 --- a/tests/phpunit/includes/HiiveConnectionTest.php +++ b/tests/phpunit/includes/HiiveConnectionTest.php @@ -179,7 +179,7 @@ function ( $request_response ) { * * @see https://github.com/10up/wp_mock/pull/246 */ - WP_Mock::userFunction( 'NewfoldLabs\WP\Module\Data\remove_filter' ) + WP_Mock::userFunction( 'remove_filter' ) ->once() ->with( 'http_headers_useragent', array( $sut, 'add_plugin_name_version_to_user_agent' ) ); @@ -343,7 +343,7 @@ function ( string $constant_name ) use ( $temp_dir ) { * * @see https://github.com/10up/wp_mock/pull/246 */ - WP_Mock::userFunction( 'NewfoldLabs\WP\Module\Data\remove_filter' ) + WP_Mock::userFunction( 'remove_filter' ) ->twice() ->with( 'http_headers_useragent', array( $sut, 'add_plugin_name_version_to_user_agent' ) );