Commit Graph

65 Commits

Author SHA1 Message Date
Néstor Soriano 427b3fbdc2
Make Yoda conditions mandatory again (#34335)
* Make Yoda conditions mandatory again

* Add changelog file
2022-08-29 11:55:23 +02:00
Néstor Soriano 3a76aa4255
Disable the WordPress.PHP.YodaConditions.NotYoda phpcs rule (#34204) 2022-08-05 10:39:55 +02:00
Néstor Soriano a397168a37
Disallow/discourage Yoda comparisons in the WooCommerce codebase (#34185)
- Use the built-in phpcs sniff for "includes" (as warnings)
- Use the slevomat coding standards package for the rest of the code
  (as errors, with the ability to auto-correct)
2022-08-05 09:02:20 +02:00
Roy Ho 14066bdeae
Add phpcs-changed (#33584)
* Add phpcs-changed

* Put report flag value in quotes

* Use phpcs action workflow instead

* Remove no longer used phpcs script

* Remove phpcs ignore rule

* Use proper name for code sniffer step
2022-06-27 11:46:29 -07:00
moon 1a978411eb Add phpcs ignore rules 2022-04-13 16:32:57 -07:00
barryhughes 92a2035896 Update PHPCS ruleset for PHP 7.2. 2022-04-08 16:20:44 -07:00
RJChow ce874e6a75 Temporary PHP lint suppression 2022-04-01 17:29:57 +08:00
Christopher Allford c9f413d297 Created dummy `woocommerce/woocommerce-lib` package to contain dependencies
In order to avoid problems posed by potentially including the unconverted dependencies in the root autoloader, this package will hold all dependencies that require conflict avoidance.
2020-11-18 13:54:20 -08:00
Nestor Soriano 69b32246c1 Remove the PHPCS rule for method names as we'll keep them snake_case. 2020-10-08 09:28:05 +02:00
Christopher Allford eb65252ba8 Merge branch 'master' into feature/container-injection-change 2020-08-07 14:35:44 -07:00
Christopher Allford 081f0d9133 Settled on an injection method of `init`
1. Since our code style dictates that these be `final` methods, we shouldn't be concerned about overlap.
2. There is precedent for `init` methods as requirements before using class instances.
2020-08-07 14:28:29 -07:00
Christopher Allford ea92aedfcd Added a sniff rule for checking the internal injection method 2020-08-06 00:54:29 -07:00
Claudio Sanches a54f0aae19 Ignore file comment and package tag in src 2020-08-05 14:39:28 -03:00
Nestor Soriano 064ae558ab Changes in the overall organization of the dependency injection:
- The `Container` class now implements `Psr\Container\ContainerInterface`
  (and registers itself as such), holding a private instance of the
  real container. This way it's a read-only container from the point
  of view of plugins (which should use their own containers, but
  can still use this to get WooCommerce classes).
- All registrations are now done in the `Container` constructor via
  service providers.
- The container instance is now held in a global variable, set in
  `woocommerce.php`
- Added the `wc_get_container` function for old code.
- Added the `AbstractServiceProvider` class, which inherits with the
  corresponding League's class and adds some utility methods,
  most notably `add/shareWithAutoArguments`.
- Added the `ActionsProxy` and `LegacyProxy` classes, they are
  registered via a dedicated service provider.
- `WC_Queue_Interface` is no longer resolvable via the container
  (which is for classes inside `src` only).
- All the method names in the new classes have the format `fooBarFizz`
  to be PSR4 compliant, so the MethodNameInvalid error has been
  disabled in phpcs.xml for the `src` directory.
- Introduced the `@public` annotation for public API classes
  (classes that plugins can use and whose backwards compatibility
  we guarantee), applied to `ActionsProxy` and to `LegacyProxy` for now.
- Removed the hack for the autoloader as now it doesn't work anyway.
  For the changes in this branch to work, now WP_DEBUG must be false.
2020-07-24 09:23:01 +02:00
Christopher Allford b71ddd35f1 Added sniffs to enforce PSR-4 in the `src` and `tests/php/src` directories 2020-07-15 16:09:00 -07:00
Christopher Allford f72b8db576 Added some exceptions to the PHPCS standards for unit tests
The file comments and @throws tags are unnecessary in unit tests.
2020-07-15 14:29:13 -07:00
Nestor Soriano 2a68bb018d Move testing tools to the tests/Tools directory
The testing tools (only the code hacker at this time) have been moved
from 'src' to 'tests/Tools', since many opcode cache plugins
load the whole src folder in production.

Also, an extra autoloader is set in the tests bootstrap so that
the 'tests/Tools' directory corresponds, using PSR4, to the
'Automattic\WooCommerce\Testing\Tools' namespace.
2020-05-20 09:57:39 +02:00
vedanshujain a74f06f337 Add exception for tests/php for filename sniff because it conflicts with PSR4. 2020-05-05 19:22:21 +05:30
vedanshujain ae68e16070 Add back phpcs for legacy because we still want it tested.
There are lots of tests in legacy folder which we might update from time to time. Its still a good idea to keep phpcs for the folder.
2020-05-05 18:50:54 +05:30
Christopher Allford 857b2231f7 Added a phpcs exclusion to legacy unit tests 2020-04-30 12:43:22 -07:00
Christopher Allford 09df1205de Updated the minimum PHP version to 7.0 2020-04-06 17:07:33 -07:00
Rodrigo Primo 9b73df3bd6 Fix spacing 2019-12-20 12:46:57 -03:00
Rodrigo Primo da139035dd Make phpcs comment more clear 2019-12-20 09:09:14 -03:00
Rodrigo Primo 6734662cbb Improve PHPCS configuration
This commit implements the following changes to PHPCS execution via its configuration file:

- Show progress while it is running
- Improves performance by checking up to 8 files simultaneously
- Display only the relevant bit of filepaths when showing error and warnings
2019-12-18 10:26:36 -03:00
Rodrigo Primo ceaab9fdc0 Bump WP min ver used by PHPCS to match WC current requirement 2019-12-18 10:18:53 -03:00
Claudio Sanches da99bc8ca0 Merge branch 'master' into feature/feature-plugin-packages 2019-07-08 14:33:21 -03:00
Rodrigo Primo 356ad18826
Merge pull request #24003 from woocommerce/remove/apigen
Remove ApiGen
2019-06-28 11:23:36 -03:00
Rodrigo Primo bb78174c33 Remove references to apigen from configuration files
Commit d6bd82865c removed apigen from
WooCommerce core repository as we are moving it to its own repository (https://github.com/woocommerce/woocommerce-api-docs). This
commit removes the apigen from configuration files. In most cases, it is
just removing the apigen directory from the exclude list of things like
PHPCS and Code Climate.
2019-06-28 10:20:30 -03:00
Mike Jolley f8d6b26e2e Add dedicated Packages loader and Autoloader to init functionality 2019-06-25 13:13:04 +01:00
Mike Jolley 06bdfa67fd Include the package autoloader in the main wc file 2019-06-21 13:41:10 +01:00
Gerhard b784de2268 Bump WooCommerce-Sniffs minimum version 2019-06-13 11:47:22 +02:00
Mike Jolley 9d381d456b Remove simplify commerce gateway 2019-01-10 12:01:27 +00:00
Claudio Sanches 9cb219d92b Updated WooCommerce Sniffs to 0.0.3
- Now wp-coding-standards/wpcs and wimg/php-compatibility are dependencies of WooCommerce Sniffs.
- Updated wp-coding-standards/wpcs to 1.1.
- Updated wimg/php-compatibility to 9.0.
2018-11-06 20:58:50 -02:00
Claudio Sanches 61873627a7 Merge branch 'master' into feature/rest-api-v3 2018-09-10 19:16:22 -03:00
Peter Fabian 2f0505a73f Added wc_kses_notice as escaping function to PHPCS. 2018-08-23 14:31:40 +02:00
Claudio Sanches 568f892777 Allow SERVER_REMOTE 2018-07-26 16:31:03 -03:00
Mike Jolley aeb9d3fe65 wc_selected handles escaping 2018-04-24 19:25:20 +01:00
Claudio Sanches 21dc6d28cf
Merge branch 'master' into feature/18477 2018-03-21 14:31:58 -03:00
Claudio Sanches 8a31755b8c Fixed includes/class-wc-session-handler.php PHPCS violations 2018-03-21 00:18:01 -03:00
Claudio Sanches e825f33414 Fixed includes/class-wc-meta-data.php PHPCS violations 2018-03-21 00:11:16 -03:00
Claudio Sanches 47894cc64d Fixed includes/class-wc-checkout.php PHPCS violations 2018-03-16 16:15:08 -03:00
Claudio Sanches 3d4217143e Fixed includes/class-wc-background-emailer.php PHPCS violations 2018-03-15 18:22:12 -03:00
Claudio Sanches 774a54b8ee Deprecated old WC_Geo_IP class 2018-03-15 17:23:40 -03:00
Rodrigo Primo 7b60f55a62 Exclude includes/gateways/simplify-commerce from PHPCS checks
The Simplify Commerce gateway is deprecated since WC 2.6.0 and will be removed in WC 4.0.
2018-03-09 10:48:51 -03:00
Claudio Sanches c7f8e19b0a Ignore legacy directory and deprecated functions 2018-03-07 18:48:56 -03:00
Rodrigo Primo 95b14b3674 Merge branch 'master' into fix/includes-cli-phpcs-violations 2018-03-06 10:32:56 -03:00
Rodrigo Primo 57ae5d8150 WooCommerce CLI commands use anonymous functions
Contrary to the rest of the WC codebase, WC CLI commands require PHP >= 5.5 and use anonymous functions. This commit excludes the PHPCombatibility rule for anonymous functions (PHPCompatibility.PHP.NewClosure.Found) when PHPCS is checking the `includes/cli` directory.
2018-03-06 08:46:28 -03:00
Rodrigo Primo 82f99c4042 Don't check for PHPCompatibility.PHP.NewFunctions.array_columnFound in the includes/cli directory
WooCommerce CLI commands use array_column() which was added in PHP 5.5. Since this was not noticed until now it is probably not worth changing and making the code compatible with PHP < 5.5.
2018-03-06 08:12:37 -03:00
Rodrigo Primo 557e85c1d6 Don't check for PHPCompatibility.PHP.NewLanguageConstructs.t_ns_separatorFound in the includes/cli directory
WooCommerce CLI commands require PHP >= 5.3 so namespace separators can be used in the code.
2018-03-06 08:02:01 -03:00
Claudio Sanches d43cd90cb3 Fixed PHPCS violations on i18n directory 2018-03-05 16:44:56 -03:00