Skip to content

Fix linter errors for ./includes/fbproductfeed.php#3396

Closed
ajello-meta wants to merge 1 commit intomainfrom
phpcs-fbproductfeed
Closed

Fix linter errors for ./includes/fbproductfeed.php#3396
ajello-meta wants to merge 1 commit intomainfrom
phpcs-fbproductfeed

Conversation

@ajello-meta
Copy link
Copy Markdown
Contributor

Description

This PR fixes phpcs issues in ./includes/fbproductfeed.php. Comments were also added for several functions. The fixes were made manually (in conjunction with ./vendor/bin/phpcbf) to ensure that the logic remains the same. Running ./vendor/bin/phpcs:

FILE: /Users/angeloou/Local Sites/test-site-i/app/public/wp-content/plugins/facebook-for-woocommerce/includes/fbproductfeed.php
--------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 48 ERRORS AND 22 WARNINGS AFFECTING 50 LINES
--------------------------------------------------------------------------------------------------------------------------------------------------
  34 | ERROR   | [ ] Missing member variable doc comment (Squiz.Commenting.VariableComment.Missing)
  35 | ERROR   | [ ] Missing member variable doc comment (Squiz.Commenting.VariableComment.Missing)
  77 | ERROR   | [x] Expected 1 spaces after opening parenthesis; 0 found (PEAR.Functions.FunctionCallSignature.SpaceAfterOpenBracket)
  77 | ERROR   | [x] Expected 1 spaces before closing parenthesis; 0 found (PEAR.Functions.FunctionCallSignature.SpaceBeforeCloseBracket)
 212 | ERROR   | [ ] Comment missing for @throws tag in function comment (Squiz.Commenting.FunctionComment.EmptyThrows)
 253 | WARNING | [ ] Variable assignment found within a condition. Did you mean to do a comparison ?
     |         |     (Generic.CodeAnalysis.AssignmentInCondition.Found)
 253 | ERROR   | [ ] Assignments must be the first block of code on a line (Squiz.PHP.DisallowMultipleAssignments.FoundInControlStructure)
 253 | WARNING | [ ] Silencing errors is strongly discouraged. Use proper error checking instead. Found: @fopen( trailingslashit(...
     |         |     (WordPress.PHP.NoSilencedErrors.Discouraged)
 253 | WARNING | [ ] File operations should use WP_Filesystem methods instead of direct PHP filesystem calls. Found: fopen().
     |         |     (WordPress.WP.AlternativeFunctions.file_system_operations_fopen)
 255 | WARNING | [ ] File operations should use WP_Filesystem methods instead of direct PHP filesystem calls. Found: fwrite().
     |         |     (WordPress.WP.AlternativeFunctions.file_system_operations_fwrite)
 256 | WARNING | [ ] File operations should use WP_Filesystem methods instead of direct PHP filesystem calls. Found: fclose().
     |         |     (WordPress.WP.AlternativeFunctions.file_system_operations_fclose)
 303 | WARNING | [ ] File operations should use WP_Filesystem methods instead of direct PHP filesystem calls. Found: fclose().
     |         |     (WordPress.WP.AlternativeFunctions.file_system_operations_fclose)
 309 | WARNING | [ ] unlink() is discouraged. Use wp_delete_file() to delete a file. (WordPress.WP.AlternativeFunctions.unlink_unlink)
 326 | WARNING | [ ] Silencing errors is strongly discouraged. Use proper error checking instead. Found: @fopen( $temp_file_path,...
     |         |     (WordPress.PHP.NoSilencedErrors.Discouraged)
 326 | WARNING | [ ] File operations should use WP_Filesystem methods instead of direct PHP filesystem calls. Found: fopen().
     |         |     (WordPress.WP.AlternativeFunctions.file_system_operations_fopen)
 329 | WARNING | [ ] File operations should use WP_Filesystem methods instead of direct PHP filesystem calls. Found: is_writable().
     |         |     (WordPress.WP.AlternativeFunctions.file_system_operations_is_writable)
 336 | WARNING | [ ] File operations should use WP_Filesystem methods instead of direct PHP filesystem calls. Found: is_writable().
     |         |     (WordPress.WP.AlternativeFunctions.file_system_operations_is_writable)
 340 | WARNING | [ ] File operations should use WP_Filesystem methods instead of direct PHP filesystem calls. Found: fwrite().
     |         |     (WordPress.WP.AlternativeFunctions.file_system_operations_fwrite)
 344 | ERROR   | [ ] Doc comment for parameter "$wp_ids" missing (Squiz.Commenting.FunctionComment.MissingParamTag)
 344 | ERROR   | [ ] Doc comment for parameter "$temp_feed_file" missing (Squiz.Commenting.FunctionComment.MissingParamTag)
 356 | WARNING | [x] Equals sign not aligned with surrounding assignments; expected 11 spaces but found 1 space
     |         |     (Generic.Formatting.MultipleStatementAlignment.NotSameWarning)
 383 | WARNING | [ ] File operations should use WP_Filesystem methods instead of direct PHP filesystem calls. Found: fwrite().
     |         |     (WordPress.WP.AlternativeFunctions.file_system_operations_fwrite)
 390 | WARNING | [ ] File operations should use WP_Filesystem methods instead of direct PHP filesystem calls. Found: fclose().
     |         |     (WordPress.WP.AlternativeFunctions.file_system_operations_fclose)
 401 | ERROR   | [ ] Missing @throws tag in function comment (Squiz.Commenting.FunctionCommentThrowTag.Missing)
 407 | WARNING | [ ] rename() is discouraged. Use WP_Filesystem::move() to rename a file. (WordPress.WP.AlternativeFunctions.rename_rename)
 419 | ERROR   | [x] Concat operator must be surrounded by a single space (Squiz.Strings.ConcatenationSpacing.PaddingFound)
 420 | ERROR   | [x] Concat operator must be surrounded by a single space (Squiz.Strings.ConcatenationSpacing.PaddingFound)
 421 | ERROR   | [x] Concat operator must be surrounded by a single space (Squiz.Strings.ConcatenationSpacing.PaddingFound)
 421 | ERROR   | [x] Space found before semicolon; expected "PHP_EOL;" but found "PHP_EOL ;" (Squiz.WhiteSpace.SemicolonSpacing.Incorrect)
 507 | WARNING | [x] Loose comparisons are not allowed. Expected: "==="; Found: "==" (Universal.Operators.StrictComparisons.LooseEqual)
 511 | WARNING | [x] Stand-alone post-increment statement found. Use pre-increment instead: ++$this->has_default_product_count.
     |         |     (Universal.Operators.DisallowStandalonePostIncrementDecrement.PostIncrementFound)
 513 | WARNING | [x] Stand-alone post-increment statement found. Use pre-increment instead: ++$this->no_default_product_count.
     |         |     (Universal.Operators.DisallowStandalonePostIncrementDecrement.PostIncrementFound)
 520 | WARNING | [x] Stand-alone post-increment statement found. Use pre-increment instead: ++$this->no_default_product_count.
     |         |     (Universal.Operators.DisallowStandalonePostIncrementDecrement.PostIncrementFound)
 551 | ERROR   | [x] Opening parenthesis of a multi-line function call must be the last content on the line
     |         |     (PEAR.Functions.FunctionCallSignature.ContentAfterOpenBracket)
 554 | ERROR   | [x] Closing parenthesis of a multi-line function call must be on a line by itself
     |         |     (PEAR.Functions.FunctionCallSignature.CloseBracketLine)
 561 | ERROR   | [ ] String concat is not required here; use a single string instead (Generic.Strings.UnnecessaryStringConcat.Found)
 562 | ERROR   | [x] Expected 1 spaces before closing parenthesis; 0 found (PEAR.Functions.FunctionCallSignature.SpaceBeforeCloseBracket)
 563 | ERROR   | [x] Expected 1 spaces before closing parenthesis; 0 found (PEAR.Functions.FunctionCallSignature.SpaceBeforeCloseBracket)
 564 | ERROR   | [x] Expected 1 spaces before closing parenthesis; 0 found (PEAR.Functions.FunctionCallSignature.SpaceBeforeCloseBracket)
 565 | ERROR   | [x] Expected 1 spaces before closing parenthesis; 0 found (PEAR.Functions.FunctionCallSignature.SpaceBeforeCloseBracket)
 566 | ERROR   | [x] Expected 1 spaces before closing parenthesis; 0 found (PEAR.Functions.FunctionCallSignature.SpaceBeforeCloseBracket)
 567 | ERROR   | [x] Expected 1 spaces before closing parenthesis; 0 found (PEAR.Functions.FunctionCallSignature.SpaceBeforeCloseBracket)
 568 | ERROR   | [x] Expected 1 spaces before closing parenthesis; 0 found (PEAR.Functions.FunctionCallSignature.SpaceBeforeCloseBracket)
 569 | ERROR   | [x] Expected 1 spaces before closing parenthesis; 0 found (PEAR.Functions.FunctionCallSignature.SpaceBeforeCloseBracket)
 570 | ERROR   | [x] Expected 1 spaces before closing parenthesis; 0 found (PEAR.Functions.FunctionCallSignature.SpaceBeforeCloseBracket)
 571 | ERROR   | [x] Expected 1 spaces before closing parenthesis; 0 found (PEAR.Functions.FunctionCallSignature.SpaceBeforeCloseBracket)
 576 | ERROR   | [x] Expected 1 spaces after opening parenthesis; 0 found (PEAR.Functions.FunctionCallSignature.SpaceAfterOpenBracket)
 576 | ERROR   | [x] Expected 1 spaces before closing parenthesis; 0 found (PEAR.Functions.FunctionCallSignature.SpaceBeforeCloseBracket)
 576 | ERROR   | [x] Concat operator must be surrounded by a single space (Squiz.Strings.ConcatenationSpacing.PaddingFound)
 576 | ERROR   | [x] Space found before semicolon; expected "PHP_EOL;" but found "PHP_EOL ;" (Squiz.WhiteSpace.SemicolonSpacing.Incorrect)
 603 | ERROR   | [x] Opening parenthesis of a multi-line function call must be the last content on the line
     |         |     (PEAR.Functions.FunctionCallSignature.ContentAfterOpenBracket)
 603 | ERROR   | [x] Expected 1 space after FUNCTION keyword; 0 found (Squiz.Functions.MultiLineFunctionDeclaration.SpaceAfterFunction)
 603 | ERROR   | [x] Expected 1 spaces after opening parenthesis; 0 found (Squiz.Functions.FunctionDeclarationArgumentSpacing.SpacingAfterOpen)
 603 | ERROR   | [x] Expected 1 spaces before closing parenthesis; 0 found
     |         |     (Squiz.Functions.FunctionDeclarationArgumentSpacing.SpacingBeforeClose)
 604 | ERROR   | [x] Expected 1 spaces after opening parenthesis; 0 found (PEAR.Functions.FunctionCallSignature.SpaceAfterOpenBracket)
 604 | ERROR   | [x] Expected 1 spaces before closing parenthesis; 0 found (PEAR.Functions.FunctionCallSignature.SpaceBeforeCloseBracket)
 605 | ERROR   | [x] Space found before comma in argument list (Generic.Functions.FunctionCallArgumentSpacing.SpaceBeforeComma)
 605 | ERROR   | [x] Only one argument is allowed per line in a multi-line function call (PEAR.Functions.FunctionCallSignature.MultipleArguments)
 605 | ERROR   | [x] Closing parenthesis of a multi-line function call must be on a line by itself
     |         |     (PEAR.Functions.FunctionCallSignature.CloseBracketLine)
 606 | ERROR   | [x] Expected 1 spaces after opening parenthesis; 0 found (PEAR.Functions.FunctionCallSignature.SpaceAfterOpenBracket)
 606 | ERROR   | [x] String "[%s]" does not require double quotes; use single quotes instead (Squiz.Strings.DoubleQuoteUsage.NotRequired)
 606 | ERROR   | [x] Expected 1 spaces before closing parenthesis; 0 found (PEAR.Functions.FunctionCallSignature.SpaceBeforeCloseBracket)
 614 | ERROR   | [x] Multi-line function declaration not indented correctly; expected 8 spaces but found 4
     |         |     (Squiz.Functions.MultiLineFunctionDeclaration.Indent)
 615 | ERROR   | [x] Multi-line function declaration not indented correctly; expected 8 spaces but found 4
     |         |     (Squiz.Functions.MultiLineFunctionDeclaration.Indent)
 616 | ERROR   | [x] Multi-line function declaration not indented correctly; expected 8 spaces but found 4
     |         |     (Squiz.Functions.MultiLineFunctionDeclaration.Indent)
 617 | ERROR   | [x] Multi-line function declaration not indented correctly; expected 8 spaces but found 4
     |         |     (Squiz.Functions.MultiLineFunctionDeclaration.Indent)
 617 | ERROR   | [x] The closing parenthesis of a multi-line function declaration must be on a new line
     |         |     (Squiz.Functions.MultiLineFunctionDeclaration.CloseBracketLine)
 669 | WARNING | [x] Equals sign not aligned with surrounding assignments; expected 15 spaces but found 1 space
     |         |     (Generic.Formatting.MultipleStatementAlignment.NotSameWarning)
 683 | ERROR   | [ ] You must use "/**" style comments for a function comment (Squiz.Commenting.FunctionComment.WrongStyle)
 683 | WARNING | [ ] It is recommended not to use reserved keyword "object" as function parameter name. Found: $object
     |         |     (Universal.NamingConventions.NoReservedKeywordParameterNames.objectFound)
--------------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 45 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------------------------------------------------------------

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Syntax change (non-breaking change which fixes code modularity, linting or phpcs issues)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected

Test Plan

  1. Run ./vendor/bin/phpcs, you should get:
FILE: /Users/angeloou/Local Sites/test-site-i/app/public/wp-content/plugins/facebook-for-woocommerce/includes/fbproductfeed.php
--------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 12 WARNINGS AFFECTING 10 LINES
--------------------------------------------------------------------------------------------------------------------------------------------------
 253 | WARNING | Silencing errors is strongly discouraged. Use proper error checking instead. Found: @fopen( trailingslashit(...
     |         | (WordPress.PHP.NoSilencedErrors.Discouraged)
 253 | WARNING | File operations should use WP_Filesystem methods instead of direct PHP filesystem calls. Found: fopen().
     |         | (WordPress.WP.AlternativeFunctions.file_system_operations_fopen)
 255 | WARNING | File operations should use WP_Filesystem methods instead of direct PHP filesystem calls. Found: fwrite().
     |         | (WordPress.WP.AlternativeFunctions.file_system_operations_fwrite)
 256 | WARNING | File operations should use WP_Filesystem methods instead of direct PHP filesystem calls. Found: fclose().
     |         | (WordPress.WP.AlternativeFunctions.file_system_operations_fclose)
 303 | WARNING | File operations should use WP_Filesystem methods instead of direct PHP filesystem calls. Found: fclose().
     |         | (WordPress.WP.AlternativeFunctions.file_system_operations_fclose)
 326 | WARNING | Silencing errors is strongly discouraged. Use proper error checking instead. Found: @fopen( $temp_file_path,...
     |         | (WordPress.PHP.NoSilencedErrors.Discouraged)
 326 | WARNING | File operations should use WP_Filesystem methods instead of direct PHP filesystem calls. Found: fopen().
     |         | (WordPress.WP.AlternativeFunctions.file_system_operations_fopen)
 329 | WARNING | File operations should use WP_Filesystem methods instead of direct PHP filesystem calls. Found: is_writable().
     |         | (WordPress.WP.AlternativeFunctions.file_system_operations_is_writable)
 336 | WARNING | File operations should use WP_Filesystem methods instead of direct PHP filesystem calls. Found: is_writable().
     |         | (WordPress.WP.AlternativeFunctions.file_system_operations_is_writable)
 340 | WARNING | File operations should use WP_Filesystem methods instead of direct PHP filesystem calls. Found: fwrite().
     |         | (WordPress.WP.AlternativeFunctions.file_system_operations_fwrite)
 385 | WARNING | File operations should use WP_Filesystem methods instead of direct PHP filesystem calls. Found: fwrite().
     |         | (WordPress.WP.AlternativeFunctions.file_system_operations_fwrite)
 392 | WARNING | File operations should use WP_Filesystem methods instead of direct PHP filesystem calls. Found: fclose().
     |         | (WordPress.WP.AlternativeFunctions.file_system_operations_fclose)
--------------------------------------------------------------------------------------------------------------------------------------------------
  1. Run extension and test the basic functionality to ensure everything still works as intended.

@github-actions
Copy link
Copy Markdown
Contributor

📦 Latest Plugin Build

Built at: 2025-06-16T11:33:25.999Z
Commit: cf12ed3
Size: 1.1M

Download: Click here to download the plugin

To download: Click the link above → Scroll to bottom → Download "facebook-for-woocommerce" artifact

@facebook-github-bot
Copy link
Copy Markdown
Contributor

@ajello-meta has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Copy Markdown
Contributor

@ajello-meta merged this pull request in 1ae81d8.

@vahidkay-meta vahidkay-meta mentioned this pull request Jun 20, 2025
facebook-github-bot pushed a commit that referenced this pull request Jun 24, 2025
Summary:
*   Tweak - Add comprehensive unit tests for Locale class by sol-loup in #3362
*   Tweak - Add unit tests for Idempotent_Request trait by sol-loup in #3380
*   Tweak - Add comprehensive unit tests for MetaLog Response by sol-loup in #3376
*   Tweak - Add comprehensive unit tests for ProductSets Delete Response class by sol-loup in #3398
*   Fix - Since tags by sol-loup in #3397
*   Tweak - Add comprehensive unit tests for Pages Read Response by sol-loup in #3378
*   Tweak - Add comprehensive unit tests for User Response to improve code coverage by sol-loup in #3377
*   Fix - Linter errors for ./includes/fbproductfeed.php by ajello-meta in #3396
*   Tweak - Add unit tests for Events AAMSettings class by sol-loup in #3369
*   Tweak - Improve CAPI event handling & add logging for Purchase events by iodic in #3360
*   Fix - Adding links to the updated banner by SayanPandey in #3388
*   Fix - Removing deprecated tag from Product Sync tab by SayanPandey in #3387
*   Fix - Transmit opted_out_woo_all_products timestamp by vinkmeta in #3386
*   Tweak - Product sync tab deprecation using Rollout Switches by SayanPandey in #3364
*   Tweak - Excluded categories and tags from Rollout Switches by SayanPandey in #3382
*   Tweak - Add unit tests for ProductExcludedException and ProductInvalidException by sol-loup in #3357
*   Tweak - Global sync check for Rollout Switches by SayanPandey in #3367
*   Fix - Limiting BatchLogHandler processing for performance reasons by vinkmeta in #3381
*   Tweak - Add unit tests for Framework Api Exception class by sol-loup in #3370
*   Tweak - Add unit tests for Framework Plugin Exception class by sol-loup in #3371
*   Fix - Updated since tags across a few files by sol-loup in #3374
*   Fix - Deprecated the concept of tip info by vinkmeta in #3373
*   Fix - Removed instance of deprecated logger by vinkmeta in #3372
*   Fix - the process to share ExternalVersionUpdate with Meta by vinkmeta in #3365
*   Fix - Failing tests by vinkmeta in #3366
*   Fix - Deprecated legacy logging apis by vinkmeta in #3351
*   Fix - Issue with productSetSyncTest causing warnings during PHPUnit by sol-loup in #3355
*   Tweak - Add comprehensive unit tests for Events\Normalizer class by sol-loup in #3359
*   Tweak - Add unit tests for API Response classes to improve code coverage by sol-loup in #3358
*   Fix - Deprecated the concept of fblog by vinkmeta in #3354
*   Fix - Deprecated tool tip event concepts by vinkmeta in #3349
*   Fix - Removed unnecessary logs being sent to Meta servers by vinkmeta in #3347
*   Fix - Clean up info Banner releated class and components by vinkmeta in #3348
*   Fix - Sending backgroung syncing jobs action logs to Meta by vinkmeta in #3346
*   Fix - Tracking error messages being displayed to Admins by vinkmeta in #3345
*   Tweak - Workflow for Releasing Plugin by tzahgr in #3309
*   Fix - Deleted wp_ajax_ajax_sync_all_fb_products action by vinkmeta in #3343
*   Fix - Deprecated log_with_debug_mode_enabled by vinkmeta in #3342
*   Fix - Removed unnecessary logs by vinkmeta in #3341
*   Fix - removing duplicate logging by vinkmeta in #3337
*   Fix - Updated exception logs to centralized logger by vinkmeta in #3338
*   Fix - Migrated Feed Logger by vinkmeta in #3340
*   Fix - Deprecated log_to_meta functionality by vinkmeta in #3336
*   Fix - Enabled fbproduct for code sniffing in #3328
*   Fix - Enabled phpcs for plugin banners by vinkmeta in #3332
*   Fix - Updated loggers for Feeds by vinkmeta in #3335
*   Fix - Updated loggers for checkout flow by vinkmeta in #3334
*   Fix - Logging background product syncing debug logs by vinkmeta in #3329
*   Fix - Enabled Pixel Normalizer for CS by vinkmeta in #3333
*   Fix - Update to Feed Loggers by vinkmeta in #3330
*   Fix - Debug logs for background product syncing by vinkmeta in #3327
*   Add - Sync all products if user has opted-in for Woo All Products by SayanPandey in #3281
*   Fix - PHPUnit warnings by renaming test files to match their class names by sol-loup in #3311
*   Tweak - Removing exclusion of sync of excluded categories and tags by SayanPandey in #3244
*   Fix - Lints and phpcs issues with fbproduct by vinkmeta in #3324
*   Fix - Code sniffing fixes for fbproduct by vinkmeta in #3323
*   Fix - Migrated Product Feed Progress Logging Mechanism by vinkmeta in #3321
*   Fix - Added critical log when user attempting non-permissible actions by vinkmeta in #3322
*   Fix - Handling edge case with BatchLogHandler in #3320
*   Fix - Product Group Logging by vinkmeta in #3317
*   Fix - PHPCBF for fbproduct by vinkmeta in #3319
*   Fix - Linting for WC_Facebookcommerce_Background_Process by vinkmeta in #3318
*   Tweak - Adding tags on excluded categories and tags by SayanPandey in #3308
*   Tweak - Removing unnecessary modal for excluded categories by SayanPandey in #3307
*   Tweak - Removing delete on stock check by SayanPandey in #3306
*   Add - Showing a banner to the user about the changes by SayanPandey in #3256
*   Fix - Updated location for Product Feeds by vinkmeta in #3316
*   Tweak - Removing internal wiki links by vinkmeta in #3315
*   Add - Introducing a centralized logger by vinkmeta in #3313
*   Fix - Update ratings and reviews query logic and fix tests by nrostrow-meta in #3312
*   Fix - Restoring the product sync tagging with integers by SayanPandey in #3305
*   Tweak - Removing Enable Sync checkbox by SayanPandey in #3241
*   Fix - Flush rewrite rules to ensure /fb-checkout endpoint is working correctly by ajello-meta in #3301
*   Tweak - Deprecating Product Sync tab by SayanPandey in #3273
*   Tweak - Updated GitHub PR template by vinkmeta in #3304
*   Fix - Changed json_encode to wp_json_encode to avoid phpcs issues by vinkmeta in #3303
*   Fix - Replaced json_encode with wp_json_encode by vinkmeta in #3276
*   Fix - Linting issues resolved for includes/ProductSets/Sync.phpby sol-loup in #3188
*   Fix - Linting issues resolved for includes/Utilities/Background_Remove_Duplicate_Visibility_Meta.php by sol-loup in #3187
*   Fix - Linting issues resolved for includes/Events/Event.php by sol-loup in #3189
*   Tweak - Enable Video sync at Variable Product Level by gurtejrehal in #3291
*   Fix - Revert #3295 by vinkmeta in #3299

Pull Request resolved: #3444

Reviewed By: tzahgr

Differential Revision: D77219857

Pulled By: vahidkay-meta

fbshipit-source-id: 52148818ea2d6c1b937f3caa78e6071a258d17f3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants