diff --git a/composer.json b/composer.json
index bad35996..1c1f934f 100644
--- a/composer.json
+++ b/composer.json
@@ -146,7 +146,7 @@
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.2",
"roave/security-advisories": "dev-latest",
"squizlabs/php_codesniffer": "^3.6.2",
- "wp-coding-standards/wpcs": "^2.3"
+ "wp-coding-standards/wpcs": "dev-develop"
},
"config": {
"optimize-autoloader": true,
@@ -210,6 +210,9 @@
"MitComposerScripts::multidev_clone_syntax",
"MitComposerScripts::multidev_search_replace_syntax"
],
+ "phpcs": [
+ "phpcs"
+ ],
"pre-install-cmd": [
"php -v"
],
diff --git a/composer.lock b/composer.lock
index 3f66d64e..a76d50d0 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "e3d2bc1e3910478f39e0fb5d118920d2",
+ "content-hash": "349a297b373f3c2eee291440e9e89541",
"packages": [
{
"name": "ConnectThink/WP-SCSS",
@@ -3426,6 +3426,143 @@
},
"time": "2022-02-04T12:51:07+00:00"
},
+ {
+ "name": "phpcsstandards/phpcsextra",
+ "version": "1.0.3",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/PHPCSStandards/PHPCSExtra.git",
+ "reference": "7029c051cd310e2e17c6caea3429bfbe290c41ae"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/PHPCSStandards/PHPCSExtra/zipball/7029c051cd310e2e17c6caea3429bfbe290c41ae",
+ "reference": "7029c051cd310e2e17c6caea3429bfbe290c41ae",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.4",
+ "phpcsstandards/phpcsutils": "^1.0",
+ "squizlabs/php_codesniffer": "^3.7.1"
+ },
+ "require-dev": {
+ "php-parallel-lint/php-console-highlighter": "^1.0",
+ "php-parallel-lint/php-parallel-lint": "^1.3.2",
+ "phpcsstandards/phpcsdevcs": "^1.1.5",
+ "phpcsstandards/phpcsdevtools": "^1.2.0",
+ "phpunit/phpunit": "^4.5 || ^5.0 || ^6.0 || ^7.0"
+ },
+ "type": "phpcodesniffer-standard",
+ "extra": {
+ "branch-alias": {
+ "dev-stable": "1.x-dev",
+ "dev-develop": "1.x-dev"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "LGPL-3.0-or-later"
+ ],
+ "authors": [
+ {
+ "name": "Juliette Reinders Folmer",
+ "homepage": "https://github.com/jrfnl",
+ "role": "lead"
+ },
+ {
+ "name": "Contributors",
+ "homepage": "https://github.com/PHPCSStandards/PHPCSExtra/graphs/contributors"
+ }
+ ],
+ "description": "A collection of sniffs and standards for use with PHP_CodeSniffer.",
+ "keywords": [
+ "PHP_CodeSniffer",
+ "phpcbf",
+ "phpcodesniffer-standard",
+ "phpcs",
+ "standards",
+ "static analysis"
+ ],
+ "support": {
+ "issues": "https://github.com/PHPCSStandards/PHPCSExtra/issues",
+ "source": "https://github.com/PHPCSStandards/PHPCSExtra"
+ },
+ "time": "2023-03-28T17:48:27+00:00"
+ },
+ {
+ "name": "phpcsstandards/phpcsutils",
+ "version": "1.0.5",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/PHPCSStandards/PHPCSUtils.git",
+ "reference": "0cfef5193e68e8ff179333d8ae937db62939b656"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/PHPCSStandards/PHPCSUtils/zipball/0cfef5193e68e8ff179333d8ae937db62939b656",
+ "reference": "0cfef5193e68e8ff179333d8ae937db62939b656",
+ "shasum": ""
+ },
+ "require": {
+ "dealerdirect/phpcodesniffer-composer-installer": "^0.4.1 || ^0.5 || ^0.6.2 || ^0.7 || ^1.0",
+ "php": ">=5.4",
+ "squizlabs/php_codesniffer": "^3.7.1 || 4.0.x-dev@dev"
+ },
+ "require-dev": {
+ "ext-filter": "*",
+ "php-parallel-lint/php-console-highlighter": "^1.0",
+ "php-parallel-lint/php-parallel-lint": "^1.3.2",
+ "phpcsstandards/phpcsdevcs": "^1.1.3",
+ "phpunit/phpunit": "^4.8.36 || ^5.7.21 || ^6.0 || ^7.0 || ^8.0 || ^9.3",
+ "yoast/phpunit-polyfills": "^1.0.1"
+ },
+ "type": "phpcodesniffer-standard",
+ "extra": {
+ "branch-alias": {
+ "dev-stable": "1.x-dev",
+ "dev-develop": "1.x-dev"
+ }
+ },
+ "autoload": {
+ "classmap": [
+ "PHPCSUtils/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "LGPL-3.0-or-later"
+ ],
+ "authors": [
+ {
+ "name": "Juliette Reinders Folmer",
+ "homepage": "https://github.com/jrfnl",
+ "role": "lead"
+ },
+ {
+ "name": "Contributors",
+ "homepage": "https://github.com/PHPCSStandards/PHPCSUtils/graphs/contributors"
+ }
+ ],
+ "description": "A suite of utility functions for use with PHP_CodeSniffer",
+ "homepage": "https://phpcsutils.com/",
+ "keywords": [
+ "PHP_CodeSniffer",
+ "phpcbf",
+ "phpcodesniffer-standard",
+ "phpcs",
+ "phpcs3",
+ "standards",
+ "static analysis",
+ "tokens",
+ "utility"
+ ],
+ "support": {
+ "docs": "https://phpcsutils.com/",
+ "issues": "https://github.com/PHPCSStandards/PHPCSUtils/issues",
+ "source": "https://github.com/PHPCSStandards/PHPCSUtils"
+ },
+ "time": "2023-04-17T16:27:27+00:00"
+ },
{
"name": "roave/security-advisories",
"version": "dev-latest",
@@ -4091,31 +4228,36 @@
},
{
"name": "wp-coding-standards/wpcs",
- "version": "2.3.0",
+ "version": "dev-develop",
"source": {
"type": "git",
"url": "https://github.com/WordPress/WordPress-Coding-Standards.git",
- "reference": "7da1894633f168fe244afc6de00d141f27517b62"
+ "reference": "fca9d9ef2dcd042658ccb9df16552f5048e7bb04"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/WordPress/WordPress-Coding-Standards/zipball/7da1894633f168fe244afc6de00d141f27517b62",
- "reference": "7da1894633f168fe244afc6de00d141f27517b62",
+ "url": "https://api.github.com/repos/WordPress/WordPress-Coding-Standards/zipball/fca9d9ef2dcd042658ccb9df16552f5048e7bb04",
+ "reference": "fca9d9ef2dcd042658ccb9df16552f5048e7bb04",
"shasum": ""
},
"require": {
+ "ext-filter": "*",
"php": ">=5.4",
- "squizlabs/php_codesniffer": "^3.3.1"
+ "phpcsstandards/phpcsextra": "^1.0",
+ "phpcsstandards/phpcsutils": "^1.0.5",
+ "squizlabs/php_codesniffer": "^3.7.2"
},
"require-dev": {
- "dealerdirect/phpcodesniffer-composer-installer": "^0.5 || ^0.6",
+ "php-parallel-lint/php-console-highlighter": "^1.0.0",
+ "php-parallel-lint/php-parallel-lint": "^1.3.2",
"phpcompatibility/php-compatibility": "^9.0",
- "phpcsstandards/phpcsdevtools": "^1.0",
+ "phpcsstandards/phpcsdevtools": "^1.2.0",
"phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0"
},
"suggest": {
- "dealerdirect/phpcodesniffer-composer-installer": "^0.6 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically."
+ "ext-mbstring": "For improved results"
},
+ "default-branch": true,
"type": "phpcodesniffer-standard",
"notification-url": "https://packagist.org/downloads/",
"license": [
@@ -4131,6 +4273,7 @@
"keywords": [
"phpcs",
"standards",
+ "static analysis",
"wordpress"
],
"support": {
@@ -4138,7 +4281,7 @@
"source": "https://github.com/WordPress/WordPress-Coding-Standards",
"wiki": "https://github.com/WordPress/WordPress-Coding-Standards/wiki"
},
- "time": "2020-05-13T23:57:56+00:00"
+ "time": "2023-05-01T08:34:06+00:00"
}
],
"aliases": [],
@@ -4146,7 +4289,8 @@
"stability-flags": {
"connectthink/wp-scss": 10,
"pantheon-upstreams/upstream-configuration": 20,
- "roave/security-advisories": 20
+ "roave/security-advisories": 20,
+ "wp-coding-standards/wpcs": 20
},
"prefer-stable": true,
"prefer-lowest": false,
diff --git a/docs/howto/normalize-code-formating.md b/docs/howto/normalize-code-formating.md
new file mode 100644
index 00000000..943832bf
--- /dev/null
+++ b/docs/howto/normalize-code-formating.md
@@ -0,0 +1,34 @@
+# How to normalize code formating
+
+This respostory uses `phpcs` to scan for both security and formating preferences. It follows the WordPress Coding
+Standards as well as other PHP standards where they don't conflict.
+
+## CodeClimate runs on all Pull Requests
+
+We have configure CodeClimate to check for PHPCS violations using the rules we have defined in `phpcs.xml` on every
+pull request. When possible, issues flagged in this way should be resolved prior to asking for a Code Review. If you do
+no feel it is important to resolve a particular issue, it would be best to note that to the code reviewer when requsting
+a code review and why.
+
+## Security checks run in GitHub Actions
+
+We run a subset of phpcs rules automatically in GitHub Actions. Failure on these checks will fail the build. If there is
+a good reason to not resolve something found in this check, you will need to:
+
+- use the phpcs:disable/enable syntax for the specific rule to be skipped around the code in violation
+- inform the code reviewer clearly why this is being skipped and not resolved at this time
+
+## Running checks locally
+
+It is often better to run checks locally rather than rely on CodeClimate or GitHub Actions to determine if you have
+resolved all issues in a pull reqeust.
+
+You can run `composer security` to run the security checks on the whole repository. This should always be expected to
+output no concerns.
+
+You can run our full checks on a specific file via `composer phpcs FILENAME` (you can run it on the whole repository
+but there are a lot of legacy rule violations so you should focus only on files you are working directly with as part
+of your pull request).
+
+You can enable your code editor to work for you. In VSCode, the extension `PHP Sniffer & Beatifier` does solid job
+autofixing or flagging errors when you save the file depending on your configuration.
diff --git a/phpcs.security.xml b/phpcs.security.xml
index 39b27f1b..02c0586c 100644
--- a/phpcs.security.xml
+++ b/phpcs.security.xml
@@ -10,7 +10,7 @@
-
+
@@ -20,5 +20,7 @@
+
+
diff --git a/web/app/plugins/mitlib-pull-hours/src/class-display-widget-slim.php b/web/app/plugins/mitlib-pull-hours/src/class-display-widget-slim.php
index f72edd49..8ef7e66d 100644
--- a/web/app/plugins/mitlib-pull-hours/src/class-display-widget-slim.php
+++ b/web/app/plugins/mitlib-pull-hours/src/class-display-widget-slim.php
@@ -124,7 +124,7 @@ public function widget( $args, $instance ) {
// Render markup.
echo wp_kses( $args['before_widget'], $allowed );
- $template = file_get_contents( dirname( __FILE__ ) . '/../templates/display-widget-slim.html' );
+ $template = file_get_contents( __DIR__ . '/../templates/display-widget-slim.html' );
echo wp_kses( sprintf( $template, $instance['location_label'], $instance['title'] ), $allowed );
echo wp_kses( $args['after_widget'], $allowed );
}