Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ branches:

before_script:
- composer install --prefer-source
- ./vendor/bin/parallel-lint --exclude vendor .
- vendor/bin/parallel-lint --exclude vendor .
- vendor/bin/php-cs-fixer fix --dry-run --level psr2 .

after_script:
- php vendor/bin/coveralls -v
Expand Down
10 changes: 9 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ efforts. Here are a few general guidelines to follow:
will need to write new test cases; if you're updating existing code, you will
need to make sure the methods you're updating are still completely covered.

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

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

* 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).

## Ensuring PSR-2 coding style compliance

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:

$ vendor/bin/php-cs-fixer fix --level psr2 .

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.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"require-dev" : {
"guzzle/guzzle": "~3.8",
"satooshi/php-coveralls": "0.6.*@dev",
"jakub-onderka/php-parallel-lint": "0.*"
"jakub-onderka/php-parallel-lint": "0.*",
"fabpot/php-cs-fixer": "1.0.*@dev"
}
}
1 change: 0 additions & 1 deletion lib/OpenCloud/Autoscale/Resource/LaunchConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
*/
class LaunchConfiguration extends AbstractResource
{

public $type;
public $args;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ public function parseResponseBody($body)

return $parsed;
}
}
}
2 changes: 1 addition & 1 deletion lib/OpenCloud/CloudMonitoring/Resource/Agent.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,4 @@ public function getAgentHost()
{
return $this->getService()->resource('AgentHost', null, $this);
}
}
}
2 changes: 1 addition & 1 deletion lib/OpenCloud/CloudMonitoring/Resource/AgentHost.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ public function info($type)
'resourceClass' => 'AgentHostInfo'
));
}
}
}
1 change: 0 additions & 1 deletion lib/OpenCloud/CloudMonitoring/Resource/AgentTarget.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
*/
class AgentTarget extends ReadOnlyResource
{

private $type = 'agent.filesystem';

protected static $json_name = 'targets';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
*/
class ReadOnlyResource extends AbstractResource
{

public function create($params = array())
{
return $this->noCreate();
Expand Down
11 changes: 0 additions & 11 deletions lib/OpenCloud/Common/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ protected function setProperty($property, $value)
if (method_exists($this, $setter)) {
return call_user_func(array($this, $setter), $value);
} elseif (false !== ($propertyVal = $this->propertyExists($property))) {

// Are we setting a public or private property?
if ($this->isAccessible($propertyVal)) {
$this->$propertyVal = $value;
Expand All @@ -120,7 +119,6 @@ protected function setProperty($property, $value)

return $this;
} else {

$this->getLogger()->warning(
'Attempted to set {property} with value {value}, but the'
. ' property has not been defined. Please define first.',
Expand Down Expand Up @@ -284,15 +282,11 @@ public function url($path = null, array $query = array())
public function populate($info, $setObjects = true)
{
if (is_string($info) || is_integer($info)) {

$this->setProperty($this->primaryKeyField(), $info);
$this->refresh($info);
} elseif (is_object($info) || is_array($info)) {

foreach ($info as $key => $value) {

if ($key == 'metadata' || $key == 'meta') {

// Try retrieving existing value
if (null === ($metadata = $this->getProperty($key))) {
// If none exists, create new object
Expand All @@ -305,21 +299,17 @@ public function populate($info, $setObjects = true)
// Set object property
$this->setProperty($key, $metadata);
} elseif (!empty($this->associatedResources[$key]) && $setObjects === true) {

// Associated resource
try {

$resource = $this->getService()->resource($this->associatedResources[$key], $value);
$resource->setParent($this);

$this->setProperty($key, $resource);
} catch (Exception\ServiceException $e) {
}
} elseif (!empty($this->associatedCollections[$key]) && $setObjects === true) {

// Associated collection
try {

$className = $this->associatedCollections[$key];
$options = $this->makeResourceIteratorOptions($className);
$iterator = ResourceIterator::factory($this, $options, $value);
Expand All @@ -328,7 +318,6 @@ public function populate($info, $setObjects = true)
} catch (Exception\ServiceException $e) {
}
} elseif (!empty($this->aliases[$key])) {

// Sometimes we might want to preserve camelCase
// or covert `rax-bandwidth:bandwidth` to `raxBandwidth`
$this->setProperty($this->aliases[$key], $value);
Expand Down
1 change: 0 additions & 1 deletion lib/OpenCloud/Common/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/
class Collection extends Base
{

private $service;
private $itemClass;
private $itemList = array();
Expand Down
1 change: 0 additions & 1 deletion lib/OpenCloud/Common/Collection/PaginatedIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,6 @@ public function extractNextLink($body)
public function constructNextUrl()
{
if (!$url = $this->nextUrl) {

$url = clone $this->getOption('baseUrl');
$query = $url->getQuery();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,4 @@

class ResourceBucketException extends \Exception
{

}
1 change: 0 additions & 1 deletion lib/OpenCloud/Common/Http/Message/Formatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

class Formatter
{

public static function decode(Response $response)
{
if (strpos($response->getHeader(Header::CONTENT_TYPE), Mime::JSON) !== false) {
Expand Down
1 change: 0 additions & 1 deletion lib/OpenCloud/Common/Lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

class Lang
{

public static function translate($word = null)
{
return $word;
Expand Down
3 changes: 1 addition & 2 deletions lib/OpenCloud/Common/Log/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ private function dispatch($message, $context)
// Output to file
file_put_contents($file, $this->formatFileLine($output), FILE_APPEND);
} else {

echo $output;
}
}
Expand All @@ -246,4 +245,4 @@ public function deprecated($method, $new)

return $this->warning($string);
}
}
}
1 change: 0 additions & 1 deletion lib/OpenCloud/Common/Resource/BaseResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ public function getMetadata()
public function getUrl($path = null, array $query = array())
{
if (!$url = $this->findLink('self')) {

// ...otherwise construct a URL from parent and this resource's
// "URL name". If no name is set, resourceName() throws an error.
$url = $this->getParent()->getUrl($this->resourceName());
Expand Down
1 change: 0 additions & 1 deletion lib/OpenCloud/Common/Resource/PersistentResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ public function waitFor($state = null, $timeout = null, $callback = null, $inter
$states = array('ERROR', $state);

while (true) {

$this->refresh($this->getProperty($this->primaryKeyField()));

if ($callback) {
Expand Down
1 change: 0 additions & 1 deletion lib/OpenCloud/Common/Service/NovaService.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
*/
abstract class NovaService extends CatalogService
{

/**
* Returns a flavor from the service
*
Expand Down
1 change: 0 additions & 1 deletion lib/OpenCloud/Common/Service/ServiceBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
*/
class ServiceBuilder
{

/**
* Simple factory method for creating services.
*
Expand Down
1 change: 0 additions & 1 deletion lib/OpenCloud/Compute/Resource/Flavor.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
*/
class Flavor extends PersistentObject
{

public $status;
public $updated;
public $vcpus;
Expand Down
2 changes: 0 additions & 2 deletions lib/OpenCloud/Compute/Resource/Network.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
*/
class Network extends PersistentObject
{

public $id;
public $label;
public $cidr;
Expand Down Expand Up @@ -128,7 +127,6 @@ protected function createJson()
public function getUrl($path = null, array $query = array())
{
if (!$url = $this->findLink('self')) {

$url = $this->getParent()->getUrl($this->getResourcePath());

if (null !== ($primaryKey = $this->getProperty($this->primaryKeyField()))) {
Expand Down
3 changes: 0 additions & 3 deletions lib/OpenCloud/Compute/Resource/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,6 @@ protected function createJson()

// Boot from volume
if ($this->volume instanceof Volume) {

$this->checkExtension('os-block-device-mapping-v2-boot');

$server->block_device_mapping_v2 = array();
Expand All @@ -675,12 +674,10 @@ protected function createJson()
'boot_index' => 0,
'delete_on_termination' => (boolean) $this->volumeDeleteOnTermination
);

}

// Networks
if (is_array($this->networks) && count($this->networks)) {

$server->networks = array();

foreach ($this->networks as $network) {
Expand Down
1 change: 0 additions & 1 deletion lib/OpenCloud/Compute/Resource/ServerMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ public function __construct(Server $parent, $key = null)

// set the URL according to whether or not we have a key
if ($this->getParent()->getId()) {

$this->url = $this->getParent()->url('metadata');
$this->key = $key;

Expand Down
1 change: 0 additions & 1 deletion lib/OpenCloud/Compute/Resource/VolumeAttachment.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
*/
class VolumeAttachment extends PersistentObject
{

public $id;
public $device;
public $serverId;
Expand Down
1 change: 0 additions & 1 deletion lib/OpenCloud/DNS/Resource/AsyncResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ public function waitFor($state = null, $timeout = null, $callback = null, $inter
$states = array('ERROR', $state);

while ($continue) {

$body = $this->getClient()->get($jobUrl)->send()->json();

if ($callback) {
Expand Down
2 changes: 0 additions & 2 deletions lib/OpenCloud/DNS/Resource/Domain.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ protected function createJson()

// add records, if any
if (count($this->records)) {

$recordsObject = (object) array('records' => array());

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

// add subdomains, if any
if (count($this->subdomains)) {

$subdomainsObject = (object) array('domains' => array());

foreach ($this->subdomains as $subdomain) {
Expand Down
2 changes: 1 addition & 1 deletion lib/OpenCloud/Database/Resource/Datastore.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Datastore extends PersistentResource
protected static $url_resource = 'datastores';

protected $associatedCollections = array(
'version' => 'DatastoreVersion'
'version' => 'DatastoreVersion'
);

/**
Expand Down
1 change: 0 additions & 1 deletion lib/OpenCloud/Identity/Constants/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

class User
{

const MODE_NAME = 'name';
const MODE_EMAIL = 'email';
const MODE_ID = 'id';
Expand Down
1 change: 0 additions & 1 deletion lib/OpenCloud/Identity/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
*/
class Service extends AbstractService
{

/**
* Factory method which allows for easy service creation
*
Expand Down
1 change: 0 additions & 1 deletion lib/OpenCloud/Image/Resource/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ public function update(array $params, Schema $schema = null)
$document = new JsonDocument();

foreach ($params as $propertyName => $value) {

// find property object
if (!($property = $schema->getProperty($propertyName))) {
// check whether additional properties are found
Expand Down
2 changes: 1 addition & 1 deletion lib/OpenCloud/Image/Resource/JsonPatch/Operation.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public static function factory(Schema $schema, Property $property, $operationTyp
*/
public function setType($type)
{
$this->type = $type;
$this->type = $type;
}

/**
Expand Down
1 change: 0 additions & 1 deletion lib/OpenCloud/ObjectStore/Resource/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,6 @@ public function uploadObjects(array $files, array $commonHeaders = array())
$requests = $entities = array();

foreach ($files as $entity) {

if (empty($entity['name'])) {
throw new Exceptions\InvalidArgumentError('You must provide a name.');
}
Expand Down
2 changes: 0 additions & 2 deletions lib/OpenCloud/ObjectStore/Upload/ConcurrentTransfer.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,11 @@ public function transfer()
$parts = $this->collectParts($workers);

while ($this->transferState->count() < $totalParts) {

$completedParts = $this->transferState->count();
$requests = array();

// Iterate over number of workers until total completed parts is what we need it to be
for ($i = 0; $i < $workers && ($completedParts + $i) < $totalParts; $i++) {

// Offset is the current pointer multiplied by the standard chunk length
$offset = ($completedParts + $i) * $this->partSize;
$parts[$i]->setOffset($offset);
Expand Down
2 changes: 0 additions & 2 deletions lib/OpenCloud/ObjectStore/Upload/ConsecutiveTransfer.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,9 @@
*/
class ConsecutiveTransfer extends AbstractTransfer
{

public function transfer()
{
while (!$this->entityBody->isConsumed()) {

if ($this->entityBody->getContentLength() && $this->entityBody->isSeekable()) {
// Stream directly from the data
$body = new ReadLimitEntityBody($this->entityBody, $this->partSize, $this->entityBody->ftell());
Expand Down
Loading