Skip to content

Commit ed22aa6

Browse files
committed
Merge pull request #435 from rackspace/working
Merging working -> master in preparation for minor release
2 parents 0b95f51 + 7b88926 commit ed22aa6

File tree

159 files changed

+169
-275
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

159 files changed

+169
-275
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ branches:
1717

1818
before_script:
1919
- composer install --prefer-source
20+
- vendor/bin/parallel-lint --exclude vendor .
21+
- vendor/bin/php-cs-fixer fix --dry-run --level psr2 .
2022

2123
after_script:
2224
- php vendor/bin/coveralls -v

CONTRIBUTING.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ efforts. Here are a few general guidelines to follow:
1111
will need to write new test cases; if you're updating existing code, you will
1212
need to make sure the methods you're updating are still completely covered.
1313

14-
3. Please abide by PSR code styling.
14+
3. Please abide by [PSR-2 code styling](#ensuring-psr-2-coding-style-compliance).
1515

1616
4. Explaining your pull requests is appreciated. Unless you're fixing a
1717
minor typographical error, create a description which explains your changes
@@ -44,3 +44,11 @@ phpunit
4444
* Methods that create a new resource, say `Foo`, should be named `createFoo`. For example, [`createEntity`](/lib/OpenCloud/CloudMonitoring/Service.php#L105).
4545

4646
* When validating arguments to a method, please throw `\InvalidArgumentException` when an invalid argument is found. For example, see [here](/lib/OpenCloud/LoadBalancer/Resource/LoadBalancer.php#L212-L215).
47+
48+
## Ensuring PSR-2 coding style compliance
49+
50+
The code in this library is compliant with the [PSR-2 Coding Style Guide](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md). To ensure that any code you contribute is also PSR-2 compliant, please run the following command from the base directory of this project _before_ submitting your contribution:
51+
52+
$ vendor/bin/php-cs-fixer fix --level psr2 .
53+
54+
Running this command will _change_ your code to become PSR-2 compliant. You will need to _commit_ these changes and make them part of your pull request.

composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
},
2828
"require-dev" : {
2929
"guzzle/guzzle": "~3.8",
30-
"satooshi/php-coveralls": "0.6.*@dev"
30+
"satooshi/php-coveralls": "0.6.*@dev",
31+
"jakub-onderka/php-parallel-lint": "0.*",
32+
"fabpot/php-cs-fixer": "1.0.*@dev"
3133
}
3234
}

lib/OpenCloud/Autoscale/Resource/LaunchConfiguration.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
*/
3939
class LaunchConfiguration extends AbstractResource
4040
{
41-
4241
public $type;
4342
public $args;
4443

lib/OpenCloud/CloudMonitoring/Collection/MonitoringIterator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ public function parseResponseBody($body)
3232

3333
return $parsed;
3434
}
35-
}
35+
}

lib/OpenCloud/CloudMonitoring/Resource/Agent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,4 @@ public function getAgentHost()
8989
{
9090
return $this->getService()->resource('AgentHost', null, $this);
9191
}
92-
}
92+
}

lib/OpenCloud/CloudMonitoring/Resource/AgentHost.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,4 @@ public function info($type)
5757
'resourceClass' => 'AgentHostInfo'
5858
));
5959
}
60-
}
60+
}

lib/OpenCloud/CloudMonitoring/Resource/AgentTarget.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
*/
2525
class AgentTarget extends ReadOnlyResource
2626
{
27-
2827
private $type = 'agent.filesystem';
2928

3029
protected static $json_name = 'targets';

lib/OpenCloud/CloudMonitoring/Resource/ReadOnlyResource.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
*/
2525
class ReadOnlyResource extends AbstractResource
2626
{
27-
2827
public function create($params = array())
2928
{
3029
return $this->noCreate();

lib/OpenCloud/Common/Base.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ protected function setProperty($property, $value)
110110
if (method_exists($this, $setter)) {
111111
return call_user_func(array($this, $setter), $value);
112112
} elseif (false !== ($propertyVal = $this->propertyExists($property))) {
113-
114113
// Are we setting a public or private property?
115114
if ($this->isAccessible($propertyVal)) {
116115
$this->$propertyVal = $value;
@@ -120,7 +119,6 @@ protected function setProperty($property, $value)
120119

121120
return $this;
122121
} else {
123-
124122
$this->getLogger()->warning(
125123
'Attempted to set {property} with value {value}, but the'
126124
. ' property has not been defined. Please define first.',
@@ -284,15 +282,11 @@ public function url($path = null, array $query = array())
284282
public function populate($info, $setObjects = true)
285283
{
286284
if (is_string($info) || is_integer($info)) {
287-
288285
$this->setProperty($this->primaryKeyField(), $info);
289286
$this->refresh($info);
290287
} elseif (is_object($info) || is_array($info)) {
291-
292288
foreach ($info as $key => $value) {
293-
294289
if ($key == 'metadata' || $key == 'meta') {
295-
296290
// Try retrieving existing value
297291
if (null === ($metadata = $this->getProperty($key))) {
298292
// If none exists, create new object
@@ -305,21 +299,17 @@ public function populate($info, $setObjects = true)
305299
// Set object property
306300
$this->setProperty($key, $metadata);
307301
} elseif (!empty($this->associatedResources[$key]) && $setObjects === true) {
308-
309302
// Associated resource
310303
try {
311-
312304
$resource = $this->getService()->resource($this->associatedResources[$key], $value);
313305
$resource->setParent($this);
314306

315307
$this->setProperty($key, $resource);
316308
} catch (Exception\ServiceException $e) {
317309
}
318310
} elseif (!empty($this->associatedCollections[$key]) && $setObjects === true) {
319-
320311
// Associated collection
321312
try {
322-
323313
$className = $this->associatedCollections[$key];
324314
$options = $this->makeResourceIteratorOptions($className);
325315
$iterator = ResourceIterator::factory($this, $options, $value);
@@ -328,7 +318,6 @@ public function populate($info, $setObjects = true)
328318
} catch (Exception\ServiceException $e) {
329319
}
330320
} elseif (!empty($this->aliases[$key])) {
331-
332321
// Sometimes we might want to preserve camelCase
333322
// or covert `rax-bandwidth:bandwidth` to `raxBandwidth`
334323
$this->setProperty($this->aliases[$key], $value);

lib/OpenCloud/Common/Collection.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
*/
2424
class Collection extends Base
2525
{
26-
2726
private $service;
2827
private $itemClass;
2928
private $itemList = array();

lib/OpenCloud/Common/Collection/PaginatedIterator.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,6 @@ public function extractNextLink($body)
265265
public function constructNextUrl()
266266
{
267267
if (!$url = $this->nextUrl) {
268-
269268
$url = clone $this->getOption('baseUrl');
270269
$query = $url->getQuery();
271270

lib/OpenCloud/Common/Exceptions/ResourceBucketException.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,4 @@
1919

2020
class ResourceBucketException extends \Exception
2121
{
22-
2322
}

lib/OpenCloud/Common/Http/Message/Formatter.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525
class Formatter
2626
{
27-
2827
public static function decode(Response $response)
2928
{
3029
if (strpos($response->getHeader(Header::CONTENT_TYPE), Mime::JSON) !== false) {

lib/OpenCloud/Common/Lang.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
class Lang
2121
{
22-
2322
public static function translate($word = null)
2423
{
2524
return $word;

lib/OpenCloud/Common/Log/Logger.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,6 @@ private function dispatch($message, $context)
235235
// Output to file
236236
file_put_contents($file, $this->formatFileLine($output), FILE_APPEND);
237237
} else {
238-
239238
echo $output;
240239
}
241240
}
@@ -246,4 +245,4 @@ public function deprecated($method, $new)
246245

247246
return $this->warning($string);
248247
}
249-
}
248+
}

lib/OpenCloud/Common/Resource/BaseResource.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ public function getMetadata()
148148
public function getUrl($path = null, array $query = array())
149149
{
150150
if (!$url = $this->findLink('self')) {
151-
152151
// ...otherwise construct a URL from parent and this resource's
153152
// "URL name". If no name is set, resourceName() throws an error.
154153
$url = $this->getParent()->getUrl($this->resourceName());

lib/OpenCloud/Common/Resource/PersistentResource.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@ public function waitFor($state = null, $timeout = null, $callback = null, $inter
184184
$states = array('ERROR', $state);
185185

186186
while (true) {
187-
188187
$this->refresh($this->getProperty($this->primaryKeyField()));
189188

190189
if ($callback) {

lib/OpenCloud/Common/Service/NovaService.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
*/
2525
abstract class NovaService extends CatalogService
2626
{
27-
2827
/**
2928
* Returns a flavor from the service
3029
*

lib/OpenCloud/Common/Service/ServiceBuilder.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
*/
2626
class ServiceBuilder
2727
{
28-
2928
/**
3029
* Simple factory method for creating services.
3130
*

lib/OpenCloud/Compute/Resource/Flavor.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
*/
2626
class Flavor extends PersistentObject
2727
{
28-
2928
public $status;
3029
public $updated;
3130
public $vcpus;

lib/OpenCloud/Compute/Resource/Network.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
*/
2929
class Network extends PersistentObject
3030
{
31-
3231
public $id;
3332
public $label;
3433
public $cidr;
@@ -128,7 +127,6 @@ protected function createJson()
128127
public function getUrl($path = null, array $query = array())
129128
{
130129
if (!$url = $this->findLink('self')) {
131-
132130
$url = $this->getParent()->getUrl($this->getResourcePath());
133131

134132
if (null !== ($primaryKey = $this->getProperty($this->primaryKeyField()))) {

lib/OpenCloud/Compute/Resource/Server.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,6 @@ protected function createJson()
664664

665665
// Boot from volume
666666
if ($this->volume instanceof Volume) {
667-
668667
$this->checkExtension('os-block-device-mapping-v2-boot');
669668

670669
$server->block_device_mapping_v2 = array();
@@ -675,12 +674,10 @@ protected function createJson()
675674
'boot_index' => 0,
676675
'delete_on_termination' => (boolean) $this->volumeDeleteOnTermination
677676
);
678-
679677
}
680678

681679
// Networks
682680
if (is_array($this->networks) && count($this->networks)) {
683-
684681
$server->networks = array();
685682

686683
foreach ($this->networks as $network) {

lib/OpenCloud/Compute/Resource/ServerMetadata.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ public function __construct(Server $parent, $key = null)
5151

5252
// set the URL according to whether or not we have a key
5353
if ($this->getParent()->getId()) {
54-
5554
$this->url = $this->getParent()->url('metadata');
5655
$this->key = $key;
5756

lib/OpenCloud/Compute/Resource/VolumeAttachment.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
*/
2727
class VolumeAttachment extends PersistentObject
2828
{
29-
3029
public $id;
3130
public $device;
3231
public $serverId;

lib/OpenCloud/DNS/Resource/AsyncResponse.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ public function waitFor($state = null, $timeout = null, $callback = null, $inter
118118
$states = array('ERROR', $state);
119119

120120
while ($continue) {
121-
122121
$body = $this->getClient()->get($jobUrl)->send()->json();
123122

124123
if ($callback) {

lib/OpenCloud/DNS/Resource/Domain.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,6 @@ protected function createJson()
224224

225225
// add records, if any
226226
if (count($this->records)) {
227-
228227
$recordsObject = (object) array('records' => array());
229228

230229
foreach ($this->records as $record) {
@@ -241,7 +240,6 @@ protected function createJson()
241240

242241
// add subdomains, if any
243242
if (count($this->subdomains)) {
244-
245243
$subdomainsObject = (object) array('domains' => array());
246244

247245
foreach ($this->subdomains as $subdomain) {

lib/OpenCloud/Database/Resource/Datastore.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class Datastore extends PersistentResource
3636
protected static $url_resource = 'datastores';
3737

3838
protected $associatedCollections = array(
39-
'version' => 'DatastoreVersion'
39+
'version' => 'DatastoreVersion'
4040
);
4141

4242
/**

lib/OpenCloud/Identity/Constants/User.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
class User
2121
{
22-
2322
const MODE_NAME = 'name';
2423
const MODE_EMAIL = 'email';
2524
const MODE_ID = 'id';

lib/OpenCloud/Identity/Service.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
*/
3232
class Service extends AbstractService
3333
{
34-
3534
/**
3635
* Factory method which allows for easy service creation
3736
*

lib/OpenCloud/Image/Resource/Image.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ public function update(array $params, Schema $schema = null)
5050
$document = new JsonDocument();
5151

5252
foreach ($params as $propertyName => $value) {
53-
5453
// find property object
5554
if (!($property = $schema->getProperty($propertyName))) {
5655
// check whether additional properties are found

lib/OpenCloud/Image/Resource/JsonPatch/Operation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public static function factory(Schema $schema, Property $property, $operationTyp
7575
*/
7676
public function setType($type)
7777
{
78-
$this->type = $type;
78+
$this->type = $type;
7979
}
8080

8181
/**

lib/OpenCloud/ObjectStore/Resource/Container.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,6 @@ public function uploadObjects(array $files, array $commonHeaders = array())
441441
$requests = $entities = array();
442442

443443
foreach ($files as $entity) {
444-
445444
if (empty($entity['name'])) {
446445
throw new Exceptions\InvalidArgumentError('You must provide a name.');
447446
}

lib/OpenCloud/ObjectStore/Upload/ConcurrentTransfer.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,11 @@ public function transfer()
3636
$parts = $this->collectParts($workers);
3737

3838
while ($this->transferState->count() < $totalParts) {
39-
4039
$completedParts = $this->transferState->count();
4140
$requests = array();
4241

4342
// Iterate over number of workers until total completed parts is what we need it to be
4443
for ($i = 0; $i < $workers && ($completedParts + $i) < $totalParts; $i++) {
45-
4644
// Offset is the current pointer multiplied by the standard chunk length
4745
$offset = ($completedParts + $i) * $this->partSize;
4846
$parts[$i]->setOffset($offset);

lib/OpenCloud/ObjectStore/Upload/ConsecutiveTransfer.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,9 @@
2929
*/
3030
class ConsecutiveTransfer extends AbstractTransfer
3131
{
32-
3332
public function transfer()
3433
{
3534
while (!$this->entityBody->isConsumed()) {
36-
3735
if ($this->entityBody->getContentLength() && $this->entityBody->isSeekable()) {
3836
// Stream directly from the data
3937
$body = new ReadLimitEntityBody($this->entityBody, $this->partSize, $this->entityBody->ftell());

0 commit comments

Comments
 (0)