diff --git a/php/README.md b/php/README.md index 0eefb0e4c54..2127dbf9761 100644 --- a/php/README.md +++ b/php/README.md @@ -46,6 +46,23 @@ To install dependencies, run `composer install` (https://getcomposer.org) before Many examples come with a `Runner.php` file to abstract the logic of the example from running the code. From any example directory with a `Runner.php` file, run the example with `php Runner.php`. + +## Linting and formatting +We use [phpcs](https://github.com/PHPCSStandards/PHP_CodeSniffer/) to keep this code consistently formatted and styled. +To contribute PHP code to this project, please refer to the following installation and usage steps. + +### Using PHPCS + +From the `/php` directory, make sure all dependencies are installed at that level with `composer install`. + +Then, the linter can be run with +`vendor/bin/phpcs --standard=../.github/linters/phpcs.xml --extensions=php --ignore=vendor /path/to/lint` + +Replace `/path/to/lint` with the directory you wish to check. + +Simple errors can be automatically fixed using phpcbf: +`vendor/bin/phpcbf --standard=../.github/linters/phpcs.xml --extensions=php --ignore=vendor example_code/dynamodb/` + ## Tests **Note**: Running the tests might result in charges to your AWS account. diff --git a/php/composer.json b/php/composer.json index e82128c77fb..e86ea85ee1f 100644 --- a/php/composer.json +++ b/php/composer.json @@ -6,7 +6,7 @@ "require-dev": { "phpunit/phpunit": "^9.5", "php-mock/php-mock-phpunit": "*", - "squizlabs/php_codesniffer": "3.*" + "squizlabs/php_codesniffer": "*" }, "autoload": { "psr-0": { diff --git a/php/composer.lock b/php/composer.lock index f2647a553ed..defa558549a 100644 --- a/php/composer.lock +++ b/php/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": "e1a484c60c68b2a50dc72bcd038955c2", + "content-hash": "ad58d15c0f671a59f05d36766dc9f28a", "packages": [ { "name": "aws/aws-crt-php", @@ -2793,16 +2793,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "3.7.2", + "version": "3.10.1", "source": { "type": "git", - "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "ed8e00df0a83aa96acf703f8c2979ff33341f879" + "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", + "reference": "8f90f7a53ce271935282967f53d0894f8f1ff877" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/ed8e00df0a83aa96acf703f8c2979ff33341f879", - "reference": "ed8e00df0a83aa96acf703f8c2979ff33341f879", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/8f90f7a53ce271935282967f53d0894f8f1ff877", + "reference": "8f90f7a53ce271935282967f53d0894f8f1ff877", "shasum": "" }, "require": { @@ -2812,11 +2812,11 @@ "php": ">=5.4.0" }, "require-dev": { - "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.3.4" }, "bin": [ - "bin/phpcs", - "bin/phpcbf" + "bin/phpcbf", + "bin/phpcs" ], "type": "library", "extra": { @@ -2831,22 +2831,45 @@ "authors": [ { "name": "Greg Sherwood", - "role": "lead" + "role": "Former lead" + }, + { + "name": "Juliette Reinders Folmer", + "role": "Current lead" + }, + { + "name": "Contributors", + "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer/graphs/contributors" } ], "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", - "homepage": "https://github.com/squizlabs/PHP_CodeSniffer", + "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer", "keywords": [ "phpcs", "standards", "static analysis" ], "support": { - "issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues", - "source": "https://github.com/squizlabs/PHP_CodeSniffer", - "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" + "issues": "https://github.com/PHPCSStandards/PHP_CodeSniffer/issues", + "security": "https://github.com/PHPCSStandards/PHP_CodeSniffer/security/policy", + "source": "https://github.com/PHPCSStandards/PHP_CodeSniffer", + "wiki": "https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki" }, - "time": "2023-02-22T23:07:41+00:00" + "funding": [ + { + "url": "https://github.com/PHPCSStandards", + "type": "github" + }, + { + "url": "https://github.com/jrfnl", + "type": "github" + }, + { + "url": "https://opencollective.com/php_codesniffer", + "type": "open_collective" + } + ], + "time": "2024-05-22T21:24:41+00:00" }, { "name": "theseer/tokenizer",