Skip to content

Commit acf43d1

Browse files
committed
Update contributors guide and readme
1 parent 5069193 commit acf43d1

File tree

3 files changed

+52
-35
lines changed

3 files changed

+52
-35
lines changed

.php-cs-fixer.dist.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
// php-cs-fixer 3.0 distributed config file
4+
5+
$config = new PhpCsFixer\Config();
6+
$config
7+
->setRules([
8+
'@PSR2' => true,
9+
'concat_space' => ['spacing' => 'one'],
10+
'no_unused_imports' => true,
11+
'whitespace_after_comma_in_array' => true,
12+
'method_argument_space' => [
13+
'keep_multiple_spaces_after_comma' => true,
14+
'on_multiline' => 'ignore'
15+
],
16+
'return_type_declaration' => [
17+
'space_before' => 'none'
18+
],
19+
// only converts simple strings in double quotes to single quotes
20+
// ignores strings using variables, escape characters or single quotes inside
21+
'single_quote' => true,
22+
// there should be a single space b/w the cast and it's operand
23+
'cast_spaces' => ['space' => 'single'],
24+
// there shouldn't be any trailing whitespace at the end of a non-blank line
25+
'no_trailing_whitespace' => true,
26+
// there shouldn't be any trailing whitespace at the end of a blank line
27+
'no_whitespace_in_blank_line' => true,
28+
// there should be a space around binary operators like (=, => etc)
29+
'binary_operator_spaces' => ['default' => 'single_space'],
30+
// deals with rogue empty blank lines
31+
'no_extra_blank_lines' => ['tokens' => ['extra']],
32+
// reduces multi blank lines b/w phpdoc description and @param to a single line
33+
// NOTE: Doesn't add a blank line if none exist
34+
'phpdoc_trim_consecutive_blank_line_separation' => true,
35+
])
36+
->setFinder(
37+
PhpCsFixer\Finder::create()
38+
->in(__DIR__)
39+
)
40+
;
41+
42+
return $config;

CONTRIBUTING.md

Lines changed: 8 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,8 @@ Write samples according to the [sample style guide](https://googlecloudplatform.
4242
To run the tests in a samples directory, you will need to install
4343
[Composer](http://getcomposer.org/doc/00-intro.md).
4444

45-
First install the testing dependencies which are shared across all samples:
46-
47-
```
48-
composer install -d testing/
49-
```
50-
51-
Next, install the dependencies for the individual sample you're testing:
52-
53-
```
54-
SAMPLES_DIRECTORY=translate
55-
cd $SAMPLES_DIRECTORY
56-
composer install
57-
```
45+
First install dependencies as described in the
46+
[README.md](google-analytics-data/README.md).
5847

5948
### Environment variables
6049
Some tests require specific environment variables to run. PHPUnit will skip the tests
@@ -64,27 +53,17 @@ to run against any sample project as follows:
6453

6554
```
6655
export GOOGLE_PROJECT_ID=YOUR_PROJECT_ID
67-
export GOOGLE_STORAGE_BUCKET=YOUR_BUCKET
56+
export GA_TEST_PROPERTY_ID=YOUR_GA4_PROPERTY_ID
6857
```
6958

70-
If you have access to the Google Cloud Kokoro project, decrypt the
71-
`.kokoro/secrets.sh.enc` file and load those environment variables. Follow
72-
the instructions in [.kokoro/secrets-example.sh](.kokoro/secrets-example.sh).
73-
74-
If your tests require new environment variables, you can set them up in
75-
`.kokoro/secrets.sh.enc` so they pass on Kokoro. For instructions on managing those
76-
variables, view [.kokoro/secrets-example.sh](.kokoro/secrets-example.sh) for more
77-
information.
78-
7959
### Run the tests
8060

8161
Once the dependencies are installed and the environment variables set, you can run the
8262
tests in a samples directory.
8363
```
84-
cd $SAMPLES_DIRECTORY
64+
cd google-analytics-data
8565
# Execute the "phpunit" installed for the shared dependencies
86-
PATH_TO_REPO=/path/to/php-docs-samples
87-
$PATH_TO_REPO/testing/vendor/bin/phpunit
66+
./vendor/bin/phpunit
8867
```
8968

9069
Use `phpunit -v` to get a more detailed output if there are errors.
@@ -102,18 +81,16 @@ recommendations. This is enforced using [PHP CS Fixer][php-cs-fixer], using the
10281
Install that by running
10382

10483
```
105-
composer global require friendsofphp/php-cs-fixer
84+
RUN composer require --dev friendsofphp/php-cs-fixer
10685
```
10786

10887
Then to fix your directory or file run
10988

11089
```
111-
php-cs-fixer fix . --config .php-cs-fixer.dist.php
112-
php-cs-fixer fix path/to/file --config .php-cs-fixer.dist.php
90+
./vendor/bin/php-cs-fixer fix --config .php-cs-fixer.dist.php .
91+
./vendor/bin/php-cs-fixer fix --config .php-cs-fixer.dist.php path/to/file
11392
```
11493

115-
The [DLP snippets](https://github.com/GoogleCloudPlatform/php-docs-samples/tree/main/dlp) are an example of snippets following the latest style guidelines.
116-
11794
[psr2]: http://www.php-fig.org/psr/psr-2/
11895
[psr4]: http://www.php-fig.org/psr/psr-4/
11996
[php-cs-fixer]: https://github.com/FriendsOfPHP/PHP-CS-Fixer

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22

33
PHP samples for [Google Analytics APIs][ga].
44

5-
Check out the `README.md` in one of the following directories to get started:
6-
7-
- Admin API: [README.md](google-analytics-admin/README.md)
8-
- Data API: [README.md](google-analytics-data/README.md)
5+
Check out the [`README.md`](google-analytics-data/README.md) in the
6+
`google-analytics-data` directory to get started.
97

108
## Contributing
119

0 commit comments

Comments
 (0)