Skip to content

Commit fb00b42

Browse files
committed
Merge pull request googleapis#604 from localheinz/feature/phpcs
Enhancement: Run phpcs on Travis
2 parents d93ae67 + 8718f88 commit fb00b42

File tree

17 files changed

+62
-67
lines changed

17 files changed

+62
-67
lines changed

.travis.yml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,17 @@ cache:
1414
directories:
1515
- $HOME/.composer/cache
1616

17-
php:
18-
# Can't test against 5.2; openssl is not available:
19-
# http://docs.travis-ci.com/user/languages/php/#PHP-installation
20-
- 5.3
21-
- 5.4
22-
- 5.5
23-
- 5.6
24-
- hhvm
17+
matrix:
18+
fast_finish: true
19+
include:
20+
# Can't test against 5.2; openssl is not available:
21+
# http://docs.travis-ci.com/user/languages/php/#PHP-installation
22+
- php: 5.3
23+
- php: 5.4
24+
- php: 5.5
25+
- php: 5.6
26+
env: PHPCS=true
27+
- php: hhvm
2528

2629
install:
2730
- composer install
@@ -34,3 +37,4 @@ before_script:
3437

3538
script:
3639
- vendor/bin/phpunit
40+
- if [[ "$PHPCS" == "true" ]]; then vendor/bin/phpcs src --standard=style/ruleset.xml -np; fi

README.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,18 +84,22 @@ $opt_params = array(
8484

8585
The library strips out nulls from the objects sent to the Google APIs as its the default value of all of the uninitialised properties. To work around this, set the field you want to null to Google_Model::NULL_VALUE. This is a placeholder that will be replaced with a true null when sent over the wire.
8686

87-
## Notes For Distributors ##
88-
89-
To avoid clashes with the autoloader, its best to update the function inside autoload.php to `google_api_php_client_autoload_MyProject`.
90-
9187
## Code Quality ##
9288

9389
Run the PHPUnit tests with PHPUnit. You can configure an API key and token in BaseTest.php to run all calls, but this will require some setup on the Google Developer Console.
9490

9591
phpunit tests/
9692

97-
Copy the ruleset.xml in style/ into a new directory named GAPI/ in your
98-
/usr/share/php/PHP/CodeSniffer/Standards (or appropriate equivalent directory),
99-
and run code sniffs with:
93+
### Coding Style
94+
95+
To check for coding style violations, run
10096

101-
phpcs --standard=GAPI src/
97+
```
98+
vendor/bin/phpcs src --standard=style/ruleset.xml -np
99+
```
100+
101+
To automatically fix (fixable) coding style violations, run
102+
103+
```
104+
vendor/bin/phpcbf src --standard=style/ruleset.xml
105+
```

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"php": ">=5.2.1"
1010
},
1111
"require-dev": {
12-
"phpunit/phpunit": "3.7.*"
12+
"phpunit/phpunit": "3.7.*",
13+
"squizlabs/php_codesniffer": "~2.3"
1314
},
1415
"autoload": {
1516
"classmap": [

src/Google/Auth/OAuth2.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public function authenticate($code, $crossClient = false)
9595
'client_secret' => $this->client->getClassConfig($this, 'client_secret')
9696
);
9797

98-
if($crossClient !== true) {
98+
if ($crossClient !== true) {
9999
$arguments['redirect_uri'] = $this->client->getClassConfig($this, 'redirect_uri');
100100
}
101101

src/Google/Client.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,10 @@ public function authenticate($code, $crossClient = false)
129129
}
130130

131131
/**
132-
* Loads a service account key and parameters from a JSON
132+
* Loads a service account key and parameters from a JSON
133133
* file from the Google Developer Console. Uses that and the
134-
* given array of scopes to return an assertion credential for
135-
* use with refreshTokenWithAssertionCredential.
134+
* given array of scopes to return an assertion credential for
135+
* use with refreshTokenWithAssertionCredential.
136136
*
137137
* @param string $jsonLocation File location of the project-key.json.
138138
* @param array $scopes The scopes to assert.

src/Google/Collection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function count()
5656
return count($this->modelData[$this->collection_key]);
5757
}
5858

59-
public function offsetExists ($offset)
59+
public function offsetExists($offset)
6060
{
6161
if (!is_numeric($offset)) {
6262
return parent::offsetExists($offset);

src/Google/Config.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,8 +380,8 @@ public function setDeveloperKey($key)
380380
/**
381381
* Set the hd (hosted domain) parameter streamlines the login process for
382382
* Google Apps hosted accounts. By including the domain of the user, you
383-
* restrict sign-in to accounts at that domain.
384-
*
383+
* restrict sign-in to accounts at that domain.
384+
*
385385
* This should not be used to ensure security on your application - check
386386
* the hd values within an id token (@see Google_Auth_LoginTicket) after sign
387387
* in to ensure that the user is from the domain you were expecting.

src/Google/Http/MediaFileUpload.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ private function getResumeUri()
287287
}
288288
$message = $code;
289289
$body = @json_decode($response->getResponseBody());
290-
if (!empty( $body->error->errors ) ) {
290+
if (!empty($body->error->errors) ) {
291291
$message .= ': ';
292292
foreach ($body->error->errors as $error) {
293293
$message .= "{$error->domain}, {$error->message};";

src/Google/Http/Request.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public function getQueryParams()
130130
return $this->queryParams;
131131
}
132132

133-
/**
133+
/**
134134
* Set a new query parameter.
135135
* @param $key - string to set, does not need to be URL encoded
136136
* @param $value - string to set, does not need to be URL encoded
@@ -441,7 +441,7 @@ public function toBatchString($id)
441441

442442
/**
443443
* Our own version of parse_str that allows for multiple variables
444-
* with the same name.
444+
* with the same name.
445445
* @param $string - the query string to parse
446446
*/
447447
private function parseQuery($string)
@@ -465,7 +465,7 @@ private function parseQuery($string)
465465

466466
/**
467467
* A version of build query that allows for multiple
468-
* duplicate keys.
468+
* duplicate keys.
469469
* @param $parts array of key value pairs
470470
*/
471471
private function buildQuery($parts)
@@ -483,7 +483,7 @@ private function buildQuery($parts)
483483
return implode('&', $return);
484484
}
485485

486-
/**
486+
/**
487487
* If we're POSTing and have no body to send, we can send the query
488488
* parameters in there, which avoids length issues with longer query
489489
* params.

src/Google/Model.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class Google_Model implements ArrayAccess
2525
{
2626
/**
2727
* If you need to specify a NULL JSON value, use Google_Model::NULL_VALUE
28-
* instead - it will be replaced when converting to JSON with a real null.
28+
* instead - it will be replaced when converting to JSON with a real null.
2929
*/
3030
const NULL_VALUE = "{}gapi-php-null";
3131
protected $internal_gapi_mappings = array();

0 commit comments

Comments
 (0)