diff --git a/src/OpenStack/Bootstrap.php b/src/OpenStack/Bootstrap.php index abf2ec8..2bc25fc 100644 --- a/src/OpenStack/Bootstrap.php +++ b/src/OpenStack/Bootstrap.php @@ -90,12 +90,12 @@ class Bootstrap * @var \OpenStack\Services\IdentityService An identity services object * created from the global settings. */ - public static $identity = NULL; + public static $identity = null; /** * @var \OpenStack\Transport\ClientInterface A transport client for requests. */ - public static $transport = NULL; + public static $transport = null; /** * Register stream wrappers for OpenStack. @@ -115,7 +115,7 @@ class Bootstrap * )); * * // Get the contents of a Swift object. - * $content = file_get_contents('swift://public/notes.txt', 'r', FALSE, $cxt); + * $content = file_get_contents('swift://public/notes.txt', 'r', false, $cxt); */ public static function useStreamWrappers() { @@ -152,7 +152,7 @@ class Bootstrap * the transport layer should wait for an HTTP request. A * transport MAY ignore this parameter, but the ones included * with the library honor it. - * - 'transport.ssl_verify': Set this to FALSE to turn off SSL certificate + * - 'transport.ssl_verify': Set this to false to turn off SSL certificate * verification. This is NOT recommended, but is sometimes necessary for * certain proxy configurations. * - 'transport.proxy': Set the proxy as a string. @@ -176,9 +176,9 @@ class Bootstrap * @param string $name The name of the configuration option to get. * @param mixed $default The default value to return if the name is not found. * - * @return mixed The value, if found; or the default, if set; or NULL. + * @return mixed The value, if found; or the default, if set; or null. */ - public static function config($name = NULL, $default = NULL) + public static function config($name = null, $default = null) { // If no name is specified, return the entire config array. if (empty($name)) { @@ -203,8 +203,8 @@ class Bootstrap * * @param string $name The name of the item to check for. * - * @return boolean TRUE if the named option is set, FALSE otherwise. Note that - * the value may be falsey (FALSE, 0, etc.), but if the value is NULL, this + * @return boolean true if the named option is set, false otherwise. Note that + * the value may be falsey (false, 0, etc.), but if the value is null, this * will return false. */ public static function hasConfig($name) @@ -226,7 +226,7 @@ class Bootstrap * @throws \OpenStack\Exception When the needed configuration to authenticate * is not available. */ - public static function identity($force = FALSE) + public static function identity($force = false) { $transport = self::transport(); @@ -239,14 +239,14 @@ class Bootstrap } // User cannot be an empty string, so we need - // to do more checking than self::hasConfig(), which returns TRUE + // to do more checking than self::hasConfig(), which returns true // if an item exists and is an empty string. - $user = self::config('username', NULL); + $user = self::config('username', null); // Check if we have a username/password if (!empty($user) && self::hasConfig('password')) { $is = new IdentityService(self::config('endpoint'), $transport); - $is->authenticateAsUser($user, self::config('password'), self::config('tenantid', NULL), self::config('tenantname', NULL)); + $is->authenticateAsUser($user, self::config('password'), self::config('tenantid', null), self::config('tenantname', null)); self::$identity = $is; } else { throw new Exception('Unable to authenticate. No user credentials supplied.'); @@ -263,15 +263,15 @@ class Bootstrap * * @return \OpenStack\Transport\ClientInterface A transport client. */ - public static function transport($reset = FALSE) + public static function transport($reset = false) { - if (is_null(self::$transport) || $reset == TRUE) { + if (is_null(self::$transport) || $reset == true) { $options = [ - 'ssl_verify' => self::config('ssl_verify', TRUE), + 'ssl_verify' => self::config('ssl_verify', true), 'timeout' => self::config('timeout', 0), // 0 is no timeout. 'debug' => self::config('debug', 0), ]; - $proxy = self::config('proxy', FALSE); + $proxy = self::config('proxy', false); if ($proxy) { $options['proxy'] = $proxy; } diff --git a/src/OpenStack/Services/IdentityService.php b/src/OpenStack/Services/IdentityService.php index a7781b1..71ec79e 100644 --- a/src/OpenStack/Services/IdentityService.php +++ b/src/OpenStack/Services/IdentityService.php @@ -201,7 +201,7 @@ class IdentityService * * @param \OpenStack\Transport\ClientInterface $client An optional HTTP client to use when making the requests. */ - public function __construct($url, \OpenStack\Transport\ClientInterface $client = NULL) + public function __construct($url, \OpenStack\Transport\ClientInterface $client = null) { $parts = parse_url($url); @@ -319,7 +319,7 @@ class IdentityService * @throws \OpenStack\Exception For abnormal network conditions. The message * will give an indication as to the underlying problem. */ - public function authenticateAsUser($username, $password, $tenantId = NULL, $tenantName = NULL) + public function authenticateAsUser($username, $password, $tenantId = null, $tenantName = null) { $ops = array( 'passwordCredentials' => array( @@ -355,12 +355,12 @@ class IdentityService * Get the tenant ID associated with this token. * * If this token has a tenant ID, the ID will be returned. Otherwise, this - * will return NULL. + * will return null. * * This will not be populated until after an authentication method has been * run. * - * @return string The tenant ID if available, or NULL. + * @return string The tenant ID if available, or null. */ public function tenantId() { @@ -373,12 +373,12 @@ class IdentityService * Get the tenant name associated with this token. * * If this token has a tenant name, the name will be returned. Otherwise, this - * will return NULL. + * will return null. * * This will not be populated until after an authentication method has been * run. * - * @return string The tenant name if available, or NULL. + * @return string The tenant name if available, or null. */ public function tenantName() { @@ -424,16 +424,16 @@ class IdentityService * machine's local timestamp with the server's expiration time stamp. A * mis-configured machine timestamp could give spurious results. * - * @return boolean This will return FALSE if there is a current token and it + * @return boolean This will return false if there is a current token and it * has not yet expired (according to the date info). In all - * other cases it returns TRUE. + * other cases it returns true. */ public function isExpired() { $details = $this->tokenDetails(); if (empty($details['expires'])) { - return TRUE; + return true; } $currentDateTime = new \DateTime('now'); @@ -508,7 +508,7 @@ class IdentityService * * @return array An associative array representing the service catalog. */ - public function serviceCatalog($type = NULL) + public function serviceCatalog($type = null) { // If no type is specified, return the entire // catalog. @@ -573,7 +573,7 @@ class IdentityService * "id" => "395I91234514446", * "name" => "Banking Tenant Services", * "description" => "Banking Tenant Services for TimeWarner", - * "enabled" => TRUE, + * "enabled" => true, * "created" => "2011-11-29T16:59:52.635Z", * "updated" => "2011-11-29T16:59:52.635Z", * ), @@ -589,7 +589,7 @@ class IdentityService * @throws \OpenStack\Exception For abnormal network conditions. The message * will give an indication as to the underlying problem. */ - public function tenants($token = NULL) + public function tenants($token = null) { $url = $this->url() . '/tenants'; diff --git a/src/OpenStack/Storage/ObjectStorage.php b/src/OpenStack/Storage/ObjectStorage.php index 3931455..bfb2a79 100644 --- a/src/OpenStack/Storage/ObjectStorage.php +++ b/src/OpenStack/Storage/ObjectStorage.php @@ -76,11 +76,11 @@ class ObjectStorage /** * The authorization token. */ - protected $token = NULL; + protected $token = null; /** * The URL to the Swift endpoint. */ - protected $url = NULL; + protected $url = null; /** * The HTTP Client @@ -119,7 +119,7 @@ class ObjectStorage * @deprecated Newer versions of OpenStack use Keystone auth instead * of Swift auth. */ - public static function newFromSwiftAuth($account, $key, $url, \OpenStack\Transport\ClientInterface $client = NULL) + public static function newFromSwiftAuth($account, $key, $url, \OpenStack\Transport\ClientInterface $client = null) { $headers = array( 'X-Auth-User' => $account, @@ -160,7 +160,7 @@ class ObjectStorage * * @return \OpenStack\Storage\ObjectStorage A new ObjectStorage instance. */ - public static function newFromIdentity($identity, $region = ObjectStorage::DEFAULT_REGION, \OpenStack\Transport\ClientInterface $client = NULL) + public static function newFromIdentity($identity, $region = ObjectStorage::DEFAULT_REGION, \OpenStack\Transport\ClientInterface $client = null) { $cat = $identity->serviceCatalog(); $tok = $identity->token(); @@ -184,7 +184,7 @@ class ObjectStorage * * @return \OpenStack\Storage\ObjectStorage A new ObjectStorage instance. */ - public static function newFromServiceCatalog($catalog, $authToken, $region = ObjectStorage::DEFAULT_REGION, \OpenStack\Transport\ClientInterface $client = NULL) + public static function newFromServiceCatalog($catalog, $authToken, $region = ObjectStorage::DEFAULT_REGION, \OpenStack\Transport\ClientInterface $client = null) { $c = count($catalog); for ($i = 0; $i < $c; ++$i) { @@ -199,7 +199,7 @@ class ObjectStorage } } - return FALSE; + return false; } @@ -214,7 +214,7 @@ class ObjectStorage * @param string $url The URL to the endpoint. This typically is returned * after authentication. */ - public function __construct($authToken, $url, \OpenStack\Transport\ClientInterface $client = NULL) + public function __construct($authToken, $url, \OpenStack\Transport\ClientInterface $client = null) { $this->token = $authToken; $this->url = $url; @@ -279,7 +279,7 @@ class ObjectStorage * object. Results are ordered in server order (the order that the remote * host puts them in). */ - public function containers($limit = 0, $marker = NULL) + public function containers($limit = 0, $marker = null) { $url = $this->url() . '?format=json'; @@ -315,7 +315,7 @@ class ObjectStorage public function container($name) { $url = $this->url() . '/' . rawurlencode($name); - $data = $this->req($url, 'HEAD', FALSE); + $data = $this->req($url, 'HEAD', false); $status = $data->getStatusCode(); if ($status == 204) { @@ -337,7 +337,7 @@ class ObjectStorage * * @param string $name The name of the container to test. * - * @return boolean TRUE if the container exists, FALSE if it does not. + * @return boolean true if the container exists, false if it does not. * * @throws \OpenStack\Exception If an unexpected network error occurs. */ @@ -346,10 +346,10 @@ class ObjectStorage try { $container = $this->container($name); } catch (\OpenStack\Transport\FileNotFoundException $fnfe) { - return FALSE; + return false; } - return TRUE; + return true; } /** @@ -361,8 +361,8 @@ class ObjectStorage * A boolean is returned when the operation did not generate an error * condition. * - * - TRUE means that the container was created. - * - FALSE means that the container was not created because it already + * - true means that the container was created. + * - false means that the container was not created because it already * exists. * * Any actual error will cause an exception to be thrown. These will @@ -408,10 +408,10 @@ class ObjectStorage * @param array $metadata An associative array of metadata to attach to the * container. * - * @return boolean TRUE if the container was created, FALSE if the container + * @return boolean true if the container was created, false if the container * was not created because it already exists. */ - public function createContainer($name, ACL $acl = NULL, $metadata = array()) + public function createContainer($name, ACL $acl = null, $metadata = array()) { $url = $this->url() . '/' . rawurlencode($name); $headers = array( @@ -429,14 +429,14 @@ class ObjectStorage } $data = $this->client->doRequest($url, 'PUT', $headers); - //syslog(LOG_WARNING, print_r($data, TRUE)); + //syslog(LOG_WARNING, print_r($data, true)); $status = $data->getStatusCode(); if ($status == 201) { - return TRUE; + return true; } elseif ($status == 202) { - return FALSE; + return false; } // According to the OpenStack docs, there are no other return codes. else { @@ -452,7 +452,7 @@ class ObjectStorage * you are encouraged to use this alias in cases where you clearly intend * to update an existing container. */ - public function updateContainer($name, ACL $acl = NULL, $metadata = array()) + public function updateContainer($name, ACL $acl = null, $metadata = array()) { return $this->createContainer($name, $acl, $metadata); } @@ -470,7 +470,7 @@ class ObjectStorage * @param object $acl \OpenStack\Storage\ObjectStorage\ACL An ACL. To make the * container publically readable, use ACL::makePublic(). * - * @return boolean TRUE if the cointainer was created, FALSE otherwise. + * @return boolean true if the cointainer was created, false otherwise. */ public function changeContainerACL($name, ACL $acl) { @@ -491,7 +491,7 @@ class ObjectStorage * * @param string $name The name of the container. * - * @return boolean TRUE if the container was deleted, FALSE if the container + * @return boolean true if the container was deleted, false if the container * was not found (and hence, was not deleted). * * @throws \OpenStack\Storage\ObjectStorage\ContainerNotEmptyException if the container is not empty. @@ -505,9 +505,9 @@ class ObjectStorage $url = $this->url() . '/' . rawurlencode($name); try { - $data = $this->req($url, 'DELETE', FALSE); + $data = $this->req($url, 'DELETE', false); } catch (\OpenStack\Transport\FileNotFoundException $e) { - return FALSE; + return false; } // XXX: I'm not terribly sure about this. Why not just throw the // ConflictException? @@ -519,7 +519,7 @@ class ObjectStorage // 204 indicates that the container has been deleted. if ($status == 204) { - return TRUE; + return true; } // OpenStacks documentation doesn't suggest any other return // codes. @@ -546,7 +546,7 @@ class ObjectStorage public function accountInfo() { $url = $this->url(); - $data = $this->req($url, 'HEAD', FALSE); + $data = $this->req($url, 'HEAD', false); $results = array( 'bytes' => $data->getHeader('X-Account-Bytes-Used', 0), @@ -563,7 +563,7 @@ class ObjectStorage * This is a convenience method that handles the * most common case of Swift requests. */ - protected function get($url, $jsonDecode = TRUE) + protected function get($url, $jsonDecode = true) { return $this->req($url, 'GET', $jsonDecode); } @@ -571,7 +571,7 @@ class ObjectStorage /** * Internal request issuing command. */ - protected function req($url, $method = 'GET', $jsonDecode = TRUE, $body = '') + protected function req($url, $method = 'GET', $jsonDecode = true, $body = '') { $headers = array( 'X-Auth-Token' => $this->token(), diff --git a/src/OpenStack/Storage/ObjectStorage/ACL.php b/src/OpenStack/Storage/ObjectStorage/ACL.php index 2a714c4..ac6ada8 100644 --- a/src/OpenStack/Storage/ObjectStorage/ACL.php +++ b/src/OpenStack/Storage/ObjectStorage/ACL.php @@ -215,7 +215,7 @@ class ACL } } - //throw new \Exception(print_r($acl->rules(), TRUE)); + //throw new \Exception(print_r($acl->rules(), true)); return $acl; } @@ -252,7 +252,7 @@ class ACL if (!empty($matches[2])) { $entry['host'] = $matches[2]; } elseif (!empty($matches[3])) { - $entry['rlistings'] = TRUE; + $entry['rlistings'] = true; } elseif (!empty($matches[4])) { $entry['account'] = $matches[4]; if (!empty($matches[6])) { @@ -305,7 +305,7 @@ class ACL * @return \OpenStack\Storage\ObjectStorage\ACL $this for current object so * the method can be used in chaining. */ - public function addAccount($perm, $account, $user = NULL) + public function addAccount($perm, $account, $user = null) { $rule = array('account' => $account); @@ -384,7 +384,7 @@ class ACL { $this->rules[] = array( 'mask' => self::READ, - 'rlistings' => TRUE, + 'rlistings' => true, ); return $this; @@ -496,10 +496,10 @@ class ACL /** * Check if the ACL marks this private. * - * This returns TRUE only if this ACL does not grant any permissions + * This returns true only if this ACL does not grant any permissions * at all. * - * @return boolean TRUE if this is private (non-public), FALSE if any + * @return boolean true if this is private (non-public), false if any * permissions are granted via this ACL. */ public function isNonPublic() @@ -518,7 +518,7 @@ class ACL /** * Check whether this object allows public reading. * - * This will return TRUE the ACL allows (a) any host to access + * This will return true the ACL allows (a) any host to access * the item, and (b) it allows container listings. * * This checks whether the object allows public reading, @@ -530,14 +530,14 @@ class ACL */ public function isPublic() { - $allowsAllHosts = FALSE; - $allowsRListings = FALSE; + $allowsAllHosts = false; + $allowsRListings = false; foreach ($this->rules as $rule) { if (self::READ & $rule['mask']) { if (!empty($rule['rlistings'])) { - $allowsRListings = TRUE; + $allowsRListings = true; } elseif (!empty($rule['host']) && trim($rule['host']) == '*') { - $allowsAllHosts = TRUE; + $allowsAllHosts = true; } } } diff --git a/src/OpenStack/Storage/ObjectStorage/Container.php b/src/OpenStack/Storage/ObjectStorage/Container.php index 413e2d9..af172c1 100644 --- a/src/OpenStack/Storage/ObjectStorage/Container.php +++ b/src/OpenStack/Storage/ObjectStorage/Container.php @@ -72,12 +72,12 @@ class Container implements \Countable, \IteratorAggregate const CONTAINER_METADATA_HEADER_PREFIX = 'X-Container-Meta-'; //protected $properties = array(); - protected $name = NULL; + protected $name = null; - // These were both changed from 0 to NULL to allow + // These were both changed from 0 to null to allow // lazy loading. - protected $count = NULL; - protected $bytes = NULL; + protected $count = null; + protected $bytes = null; protected $token; protected $url; @@ -106,7 +106,7 @@ class Container implements \Countable, \IteratorAggregate * @see http://docs.openstack.org/bexar/openstack-object-storage/developer/content/ch03s03.html#d5e635 * @see http://docs.openstack.org/bexar/openstack-object-storage/developer/content/ch03s03.html#d5e700 */ - public static function generateMetadataHeaders(array $metadata, $prefix = NULL) + public static function generateMetadataHeaders(array $metadata, $prefix = null) { if (empty($prefix)) { $prefix = Container::METADATA_HEADER_PREFIX; @@ -140,7 +140,7 @@ class Container implements \Countable, \IteratorAggregate */ public static function objectUrl($base, $oname) { - if (strpos($oname, '/') === FALSE) { + if (strpos($oname, '/') === false) { return $base . '/' . rawurlencode($oname); } @@ -172,7 +172,7 @@ class Container implements \Countable, \IteratorAggregate * * @return array An associative array of name/value attribute pairs. */ - public static function extractHeaderAttributes($headers, $prefix = NULL) + public static function extractHeaderAttributes($headers, $prefix = null) { if (empty($prefix)) { $prefix = Container::METADATA_HEADER_PREFIX; @@ -198,7 +198,7 @@ class Container implements \Countable, \IteratorAggregate * fetching containers from ObjectStorage. * * @param array $jsonArray An associative array as returned by - * json_decode($foo, TRUE); + * json_decode($foo, true); * @param string $token The auth token. * @param string $url The base URL. The container name is automatically * appended to this at construction time. @@ -206,9 +206,9 @@ class Container implements \Countable, \IteratorAggregate * * @return \OpenStack\Storage\ObjectStorage\Container A new container object. */ - public static function newFromJSON($jsonArray, $token, $url, \OpenStack\Transport\ClientInterface $client = NULL) + public static function newFromJSON($jsonArray, $token, $url, \OpenStack\Transport\ClientInterface $client = null) { - $container = new Container($jsonArray['name'], NULL, NULL, $client); + $container = new Container($jsonArray['name'], null, null, $client); $container->baseUrl = $url; @@ -226,7 +226,7 @@ class Container implements \Countable, \IteratorAggregate $container->bytes = $jsonArray['bytes']; } - //syslog(LOG_WARNING, print_r($jsonArray, TRUE)); + //syslog(LOG_WARNING, print_r($jsonArray, true)); return $container; } @@ -246,9 +246,9 @@ class Container implements \Countable, \IteratorAggregate * * @return \OpenStack\Storage\ObjectStorage\Container The Container object, initialized and ready for use. */ - public static function newFromResponse($name, $response, $token, $url, \OpenStack\Transport\ClientInterface $client = NULL) + public static function newFromResponse($name, $response, $token, $url, \OpenStack\Transport\ClientInterface $client = null) { - $container = new Container($name, NULL, NULL, $client); + $container = new Container($name, null, null, $client); $container->bytes = $response->getHeader('X-Container-Bytes-Used', 0); $container->count = $response->getHeader('X-Container-Object-Count', 0); $container->baseUrl = $url; @@ -307,7 +307,7 @@ class Container implements \Countable, \IteratorAggregate * @param string $token The auth token. * @param \OpenStack\Transport\ClientInterface $client A HTTP transport client. */ - public function __construct($name , $url = NULL, $token = NULL, \OpenStack\Transport\ClientInterface $client = NULL) + public function __construct($name , $url = null, $token = null, \OpenStack\Transport\ClientInterface $client = null) { $this->name = $name; $this->url = $url; @@ -433,7 +433,7 @@ class Container implements \Countable, \IteratorAggregate * @param resource $file An optional file argument that, if set, will be * treated as the contents of the object. * - * @return boolean TRUE if the object was saved. + * @return boolean true if the object was saved. * * @throws \OpenStack\Transport\LengthRequiredException if the Content-Length could not be determined and * chunked encoding was not enabled. This should not occur @@ -445,7 +445,7 @@ class Container implements \Countable, \IteratorAggregate * @throws \OpenStack\Exception when an unexpected (usually network-related) error * condition arises. */ - public function save(Object $obj, $file = NULL) + public function save(Object $obj, $file = null) { if (empty($this->token)) { throw new \OpenStack\Exception('Container does not have an auth token.'); @@ -530,7 +530,7 @@ class Container implements \Countable, \IteratorAggregate throw new \OpenStack\Exception('An unknown error occurred while saving: ' . $response->status()); } - return TRUE; + return true; } /** @@ -546,7 +546,7 @@ class Container implements \Countable, \IteratorAggregate * * @param object $obj \OpenStack\Storage\ObjectStorage\Object The object to update. * - * @return boolean TRUE if the metadata was updated. + * @return boolean true if the metadata was updated. * * @throws \OpenStack\Transport\FileNotFoundException if the object does not already exist on the object storage. */ @@ -575,7 +575,7 @@ class Container implements \Countable, \IteratorAggregate throw new \OpenStack\Exception('An unknown error occurred while saving: ' . $response->status()); } - return TRUE; + return true; } /** @@ -601,7 +601,7 @@ class Container implements \Countable, \IteratorAggregate * set, the object will be saved into this container. If this is not sent, * the copy will be performed inside of the original container. */ - public function copy(Object $obj, $newName, $container = NULL) + public function copy(Object $obj, $newName, $container = null) { //$sourceUrl = $obj->url(); // This doesn't work with Object; only with RemoteObject. $sourceUrl = self::objectUrl($this->url, $obj->name()); @@ -629,7 +629,7 @@ class Container implements \Countable, \IteratorAggregate throw new \OpenStack\Exception("An unknown condition occurred during copy. " . $response->getStatusCode()); } - return TRUE; + return true; } /** @@ -759,7 +759,7 @@ class Container implements \Countable, \IteratorAggregate * * @return array List of RemoteObject or Subdir instances. */ - public function objects($limit = NULL, $marker = NULL) + public function objects($limit = null, $marker = null) { $params = array(); @@ -819,7 +819,7 @@ class Container implements \Countable, \IteratorAggregate * * @return array List of RemoteObject or Subdir instances. */ - public function objectsWithPrefix($prefix, $delimiter = '/', $limit = NULL, $marker = NULL) + public function objectsWithPrefix($prefix, $delimiter = '/', $limit = null, $marker = null) { $params = array( 'prefix' => $prefix, @@ -863,7 +863,7 @@ class Container implements \Countable, \IteratorAggregate * @param string $marker The name of the object to start with. The query will * begin with the next object AFTER this one. */ - public function objectsByPath($path, $delimiter = '/', $limit = NULL, $marker = NULL) + public function objectsByPath($path, $delimiter = '/', $limit = null, $marker = null) { $params = array( 'path' => $path, @@ -902,7 +902,7 @@ class Container implements \Countable, \IteratorAggregate * * @todo Determine how to get the ACL from JSON data. * - * @return \OpenStack\Storage\ObjectStorage\ACL An ACL, or NULL if the ACL could not be retrieved. + * @return \OpenStack\Storage\ObjectStorage\ACL An ACL, or null if the ACL could not be retrieved. */ public function acl() { @@ -954,7 +954,7 @@ class Container implements \Countable, \IteratorAggregate * Perform the HTTP query for a list of objects and de-serialize the * results. */ - protected function objectQuery($params = array(), $limit = NULL, $marker = NULL) + protected function objectQuery($params = array(), $limit = null, $marker = null) { if (isset($limit)) { $params['limit'] = (int) $limit; @@ -1036,7 +1036,7 @@ class Container implements \Countable, \IteratorAggregate * * @param string $name The name of the object to remove. * - * @return boolean TRUE if the file was deleted, FALSE if no such file is + * @return boolean true if the file was deleted, false if no such file is * found. */ public function delete($name) @@ -1049,14 +1049,14 @@ class Container implements \Countable, \IteratorAggregate try { $response = $this->client->doRequest($url, 'DELETE', $headers); } catch (\OpenStack\Transport\FileNotFoundException $fnfe) { - return FALSE; + return false; } if ($response->getStatusCode() != 204) { throw new \OpenStack\Exception("An unknown exception occured while deleting $name."); } - return TRUE; + return true; } /** diff --git a/src/OpenStack/Storage/ObjectStorage/Object.php b/src/OpenStack/Storage/ObjectStorage/Object.php index 81fd1e4..5843181 100644 --- a/src/OpenStack/Storage/ObjectStorage/Object.php +++ b/src/OpenStack/Storage/ObjectStorage/Object.php @@ -96,7 +96,7 @@ class Object * @param string $type Optional content type for this content. This is the * same as calling setContentType(). */ - public function __construct($name, $content = NULL, $type = NULL) + public function __construct($name, $content = null, $type = null) { $this->name = $name; @@ -266,7 +266,7 @@ class Object * @return \OpenStack\Storage\ObjectStorage\Object $this so the method can be * used in chaining. */ - public function setContent($content, $type = NULL) + public function setContent($content, $type = null) { $this->content = $content; if (!empty($type)) { @@ -411,7 +411,7 @@ class Object * * See setDisposition() for discussion. * - * @return string The disposition string, or NULL if none is set. + * @return string The disposition string, or null if none is set. */ public function disposition() { @@ -507,19 +507,19 @@ class Object * This should be used when (a) the file size is large, or (b) the * exact size of the file is unknown. * - * If this returns TRUE, it does not guarantee that the data + * If this returns true, it does not guarantee that the data * will be transmitted in chunks. But it recommends that the * underlying transport layer use chunked encoding. * * The contentLength() method is not called for chunked transfers. So - * if this returns TRUE, contentLength() is ignored. + * if this returns true, contentLength() is ignored. * - * @return boolean TRUE to recommend chunked transfer, FALSE otherwise. + * @return boolean true to recommend chunked transfer, false otherwise. */ public function isChunked() { // Currently, this value is hard-coded. The default Object // implementation does not get chunked. - return FALSE; + return false; } } diff --git a/src/OpenStack/Storage/ObjectStorage/RemoteObject.php b/src/OpenStack/Storage/ObjectStorage/RemoteObject.php index 214c16a..beb4d89 100644 --- a/src/OpenStack/Storage/ObjectStorage/RemoteObject.php +++ b/src/OpenStack/Storage/ObjectStorage/RemoteObject.php @@ -48,8 +48,8 @@ class RemoteObject extends Object protected $etag = ''; protected $lastModified = 0; - protected $contentVerification = TRUE; - protected $caching = FALSE; + protected $contentVerification = true; + protected $caching = false; /** * All headers received from a remote are stored in this array. @@ -75,7 +75,7 @@ class RemoteObject extends Object * @param $url The URL to the object on the remote server * @param \OpenStack\Transport\ClientInterface $client A HTTP transport client. */ - public static function newFromJSON($data, $token, $url, \OpenStack\Transport\ClientInterface $client = NULL) + public static function newFromJSON($data, $token, $url, \OpenStack\Transport\ClientInterface $client = null) { $object = new RemoteObject($data['name']); $object->setContentType($data['content_type']); @@ -114,14 +114,14 @@ class RemoteObject extends Object * * @return \OpenStack\Storage\ObjectStorage\RemoteObject A new RemoteObject. */ - public static function newFromHeaders($name, $headers, $token, $url, \OpenStack\Transport\ClientInterface $client = NULL) + public static function newFromHeaders($name, $headers, $token, $url, \OpenStack\Transport\ClientInterface $client = null) { $object = new RemoteObject($name); //$object->allHeaders = $headers; $object->setHeaders($headers); - //throw new \Exception(print_r($headers, TRUE)); + //throw new \Exception(print_r($headers, true)); // Fix inconsistant header. if (isset($headers['ETag'])) { @@ -179,7 +179,7 @@ class RemoteObject extends Object * authentication. You can, for example, pass the URL to a browser * user agent. * - If this object has never been saved remotely, then there will be - * no URL, and this will return NULL. + * no URL, and this will return null. */ public function url() { @@ -256,7 +256,7 @@ class RemoteObject extends Object return $this->allHeaders; } - public function additionalHeaders($mergeAll = FALSE) + public function additionalHeaders($mergeAll = false) { // Any additional headers will be set. Note that $this->headers will contain // some headers that are NOT additional. But we do not know which headers are @@ -273,10 +273,10 @@ class RemoteObject extends Object } protected $reservedHeaders = array( - 'etag' => TRUE, 'content-length' => TRUE, - 'x-auth-token' => TRUE, - 'transfer-encoding' => TRUE, - 'x-trans-id' => TRUE, + 'etag' => true, 'content-length' => true, + 'x-auth-token' => true, + 'transfer-encoding' => true, + 'x-trans-id' => true, ); /** @@ -360,7 +360,7 @@ class RemoteObject extends Object } // Get the object, content included. - $response = $this->fetchObject(TRUE); + $response = $this->fetchObject(true); $content = $response->getBody(); @@ -393,7 +393,7 @@ class RemoteObject extends Object * * If there is a local copy of the content, the stream will be read * out of the content as if it were a temp-file backed in-memory - * resource. To ignore the local version, pass in TRUE for the + * resource. To ignore the local version, pass in true for the * $refresh parameter. * * If the content is coming from a remote copy, the stream will be @@ -401,11 +401,11 @@ class RemoteObject extends Object * * Each time stream() is called, a new stream is created. In most * cases, this results in a new HTTP transaction (unless $refresh is - * FALSE and the content is already stored locally). + * false and the content is already stored locally). * * The stream is read-only. * - * @param boolean $refresh If this is set to TRUE, any existing local + * @param boolean $refresh If this is set to true, any existing local * modifications will be ignored and the content will * be refreshed from the server. Any local changes to * the object will be discarded. @@ -413,7 +413,7 @@ class RemoteObject extends Object * @return resource A handle to the stream, which is already opened and * positioned at the beginning of the stream. */ - public function stream($refresh = FALSE) + public function stream($refresh = false) { // If we're working on local content, return that content wrapped in // a fake IO stream. @@ -423,7 +423,7 @@ class RemoteObject extends Object // Otherwise, we fetch a fresh version from the remote server and // return its stream handle. - $response = $this->fetchObject(TRUE); + $response = $this->fetchObject(true); // Write to in-mem handle backed by a temp file. $out = fopen('php://temp', 'rb+'); @@ -463,8 +463,8 @@ class RemoteObject extends Object * existing cached content will not be removed if caching is turned * off. * - * @param boolean $enabled If this is TRUE, caching will be enabled. If this - * is FALSE, caching will be disabled. + * @param boolean $enabled If this is true, caching will be enabled. If this + * is false, caching will be disabled. * * @return \OpenStack\Storage\ObjectStorage\RemoteObject $this so the method can be used in chaining. */ @@ -481,7 +481,7 @@ class RemoteObject extends Object * Importantly, this indicates whether the object will cache * its contents, not whether anything is actually cached. * - * @return boolean TRUE if caching is enabled, FALSE otherwise. + * @return boolean true if caching is enabled, false otherwise. */ public function isCaching() { @@ -506,9 +506,9 @@ class RemoteObject extends Object * also provide a small performance improvement on large files, but at * the expense of security. * - * @param boolean $enabled If this is TRUE, content verification is performed. + * @param boolean $enabled If this is true, content verification is performed. * The content is hashed and checked against a - * server-supplied MD5 hashcode. If this is FALSE, + * server-supplied MD5 hashcode. If this is false, * no checking is done. * * @return \OpenStack\Storage\ObjectStorage\RemoteObject $this so the method can be used in chaining. @@ -528,7 +528,7 @@ class RemoteObject extends Object * returned by the remote server, and comparing that to the server's * supplied ETag hash. * - * @return boolean TRUE if this is verifying, FALSE otherwise. + * @return boolean true if this is verifying, false otherwise. */ public function isVerifyingContent() { @@ -563,17 +563,17 @@ class RemoteObject extends Object { // If there is no content, the object can't be dirty. if (!isset($this->content)) { - return FALSE; + return false; } // Content is dirty iff content is set, and it is // different from the original content. Note that // we are using the etag from the original headers. if ($this->etag != md5($this->content)) { - return TRUE; + return true; } - return FALSE; + return false; } /** @@ -585,13 +585,13 @@ class RemoteObject extends Object * WARNING: This will destroy any unsaved local changes. You can use * isDirty() to determine whether or not a local change has been made. * - * @param boolean $fetchContent If this is TRUE, the content will be + * @param boolean $fetchContent If this is true, the content will be * downloaded as well. * * @return \OpenStack\Storage\ObjectStorage\RemoteObject $this for the current object so it can be used in chaining * methods. */ - public function refresh($fetchContent = FALSE) + public function refresh($fetchContent = false) { // Kill old content. unset($this->content); @@ -609,17 +609,17 @@ class RemoteObject extends Object /** * Helper function for fetching an object. * - * @param boolean $fetchContent If this is set to TRUE, a GET request will be + * @param boolean $fetchContent If this is set to true, a GET request will be * issued, which will cause the remote host to * return the object in the response body. The * response body is not handled, though. If this - * is set to FALSE, a HEAD request is sent, and + * is set to false, a HEAD request is sent, and * no body is returned. * * @return \OpenStack\Transport\Response containing the object metadata and (depending on the $fetchContent flag) * optionally the data. */ - protected function fetchObject($fetchContent = FALSE) + protected function fetchObject($fetchContent = false) { $method = $fetchContent ? 'GET' : 'HEAD'; @@ -653,8 +653,8 @@ class RemoteObject extends Object $this->etag = $response->getHeader('Etag') ? $response->getHeader('Etag') : $this->etag; $this->contentLength = (int) ($response->getHeader('Content-Length') ? $response->getHeader('Content-Length') : 0); - $this->setDisposition($response->getHeader('Content-Disposition', NULL)); - $this->setEncoding($response->getHeader('Content-Encoding', NULL)); + $this->setDisposition($response->getHeader('Content-Disposition', null)); + $this->setEncoding($response->getHeader('Content-Encoding', null)); // Reset the metadata, too: $headers = []; diff --git a/src/OpenStack/Storage/ObjectStorage/StreamWrapper.php b/src/OpenStack/Storage/ObjectStorage/StreamWrapper.php index cd77303..cda96d5 100644 --- a/src/OpenStack/Storage/ObjectStorage/StreamWrapper.php +++ b/src/OpenStack/Storage/ObjectStorage/StreamWrapper.php @@ -108,7 +108,7 @@ use \OpenStack\Storage\ObjectStorage; * ) * ); * // Open the file. - * $handle = fopen('swift://mycontainer/myobject.txt', 'r+', FALSE, $context); + * $handle = fopen('swift://mycontainer/myobject.txt', 'r+', false, $context); * * // You can get the entire file, or use fread() to loop through the file. * $contents = stream_get_contents($handle); @@ -226,7 +226,7 @@ use \OpenStack\Storage\ObjectStorage; * - password: A password. MUST be accompanied by 'username' and 'tenantid' (or 'tenantname'). * - endpoint: The URL to the authentication endpoint. Necessary if you are not * using a 'token' and 'swift_endpoint'. - * - use_swift_auth: If this is set to TRUE, it will force the app to use + * - use_swift_auth: If this is set to true, it will force the app to use * the deprecated swiftAuth instead of IdentityService authentication. * In general, you should avoid using this. * - content_type: This is effective only when writing files. It will @@ -268,30 +268,30 @@ class StreamWrapper protected $authToken; // File flags. These should probably be replaced by O_ const's at some point. - protected $isBinary = FALSE; - protected $isText = TRUE; - protected $isWriting = FALSE; - protected $isReading = FALSE; - protected $isTruncating = FALSE; - protected $isAppending = FALSE; - protected $noOverwrite = FALSE; - protected $createIfNotFound = TRUE; + protected $isBinary = false; + protected $isText = true; + protected $isWriting = false; + protected $isReading = false; + protected $isTruncating = false; + protected $isAppending = false; + protected $noOverwrite = false; + protected $createIfNotFound = true; /** - * If this is TRUE, no data is ever sent to the remote server. + * If this is true, no data is ever sent to the remote server. */ - protected $isNeverDirty = FALSE; + protected $isNeverDirty = false; - protected $triggerErrors = FALSE; + protected $triggerErrors = false; /** * Indicate whether the local differs from remote. * * When the file is modified in such a way that * it needs to be written remotely, the isDirty flag - * is set to TRUE. + * is set to true. */ - protected $isDirty = FALSE; + protected $isDirty = false; /** * Object storage instance. @@ -349,7 +349,7 @@ class StreamWrapper $this->dirListing = array(); //syslog(LOG_WARNING, "CLOSEDIR called."); - return TRUE; + return true; } /** @@ -372,7 +372,7 @@ class StreamWrapper * @param string $path The URL to open. * @param int $options Unused. * - * @return boolean TRUE if the directory is opened, FALSE otherwise. + * @return boolean true if the directory is opened, false otherwise. */ public function dir_opendir($path, $options) { @@ -381,7 +381,7 @@ class StreamWrapper if (empty($url['host'])) { trigger_error('Container name is required.' , E_USER_WARNING); - return FALSE; + return false; } try { @@ -400,10 +400,10 @@ class StreamWrapper } catch (\OpenStack\Exception $e) { trigger_error('Directory could not be opened: ' . $e->getMessage(), E_USER_WARNING); - return FALSE; + return false; } - return TRUE; + return true; } /** @@ -418,21 +418,21 @@ class StreamWrapper * // Get the container as if it were a directory. * $dir = opendir('swift://mycontainer', $cxt); * - * while (($entry = readdir($dir)) !== FALSE) { + * while (($entry = readdir($dir)) !== false) { * print $entry . PHP_EOL; * } * * closedir($dir); * ?> * - * @return string The name of the resource or FALSE when the directory has no + * @return string The name of the resource or false when the directory has no * more entries. */ public function dir_readdir() { - // If we are at the end of the listing, return FALSE. + // If we are at the end of the listing, return false. if (count($this->dirListing) <= $this->dirIndex) { - return FALSE; + return false; } $curr = $this->dirListing[$this->dirIndex]; @@ -464,7 +464,7 @@ class StreamWrapper * // Get the container as if it were a directory. * $dir = opendir('swift://mycontainer', $cxt); * - * while (($entry = readdir($dir)) !== FALSE) { + * while (($entry = readdir($dir)) !== false) { * print $entry . PHP_EOL; * } * @@ -520,7 +520,7 @@ class StreamWrapper * @param string $path_from A swift URL that exists on the remote. * @param string $path_to A swift URL to another path. * - * @return boolean TRUE on success, FALSE otherwise. + * @return boolean true on success, false otherwise. */ public function rename($path_from, $path_to) { @@ -536,7 +536,7 @@ class StreamWrapper || empty($dest['host']) || empty($dest['path'])) { trigger_error('Container and path are required for both source and destination URLs.', E_USER_WARNING); - return FALSE; + return false; } try { @@ -551,7 +551,7 @@ class StreamWrapper } catch (\OpenStack\Exception $e) { trigger_error('Rename was not completed: ' . $e->getMessage(), E_USER_WARNING); - return FALSE; + return false; } } @@ -583,7 +583,7 @@ class StreamWrapper * * // Assuming $cxt has a valid context. * - * $file = fopen('swift://container/file.txt', 'r', FALSE, $cxt); + * $file = fopen('swift://container/file.txt', 'r', false, $cxt); * * fclose($file); * @@ -602,7 +602,7 @@ class StreamWrapper } catch (\OpenStack\Exception $e) { trigger_error('Error while closing: ' . $e->getMessage(), E_USER_NOTICE); - return FALSE; + return false; } // Force-clear the memory hogs. @@ -620,7 +620,7 @@ class StreamWrapper * * @see stream_seek(). * - * @return boolean TRUE if it has reached the end, FALSE otherwise. + * @return boolean true if it has reached the end, false otherwise. */ public function stream_eof() { @@ -643,7 +643,7 @@ class StreamWrapper syslog(LOG_WARNING, $e); trigger_error('Error while flushing: ' . $e->getMessage(), E_USER_NOTICE); - return FALSE; + return false; } } @@ -674,7 +674,7 @@ class StreamWrapper fseek($this->objStream, SEEK_SET, $position); } - $this->isDirty = FALSE; + $this->isDirty = false; } /* @@ -701,7 +701,7 @@ class StreamWrapper * )); * ?> * - * $file = fopen('swift://myContainer/myObject.csv', 'rb', FALSE, $cxt); + * $file = fopen('swift://myContainer/myObject.csv', 'rb', false, $cxt); * while ($bytes = fread($file, 8192)) { * print $bytes; * } @@ -736,7 +736,7 @@ class StreamWrapper // If STREAM_REPORT_ERRORS is set, we are responsible for // all error handling while opening the stream. if (STREAM_REPORT_ERRORS & $options) { - $this->triggerErrors = TRUE; + $this->triggerErrors = true; } // Using the mode string, set the internal mode. @@ -744,14 +744,14 @@ class StreamWrapper // Parse the URL. $url = $this->parseUrl($path); - //syslog(LOG_WARNING, print_r($url, TRUE)); + //syslog(LOG_WARNING, print_r($url, true)); // Container name is required. if (empty($url['host'])) { //if ($this->triggerErrors) { trigger_error('No container name was supplied in ' . $path, E_USER_WARNING); //} - return FALSE; + return false; } // A path to an object is required. @@ -759,7 +759,7 @@ class StreamWrapper //if ($this->triggerErrors) { trigger_error('No object name was supplied in ' . $path, E_USER_WARNING); //} - return FALSE; + return false; } // We set this because it is possible to bind another scheme name, @@ -785,7 +785,7 @@ class StreamWrapper } catch (\OpenStack\Exception $e) { trigger_error('Failed to init object storage: ' . $e->getMessage(), E_USER_WARNING); - return FALSE; + return false; } //syslog(LOG_WARNING, "Container: " . $containerName); @@ -799,7 +799,7 @@ class StreamWrapper } catch (\OpenStack\Transport\FileNotFoundException $e) { trigger_error('Container not found.', E_USER_WARNING); - return FALSE; + return false; } try { @@ -816,7 +816,7 @@ class StreamWrapper //if ($this->triggerErrors) { trigger_error('File exists and cannot be overwritten.', E_USER_WARNING); //} - return FALSE; + return false; } // If we need to write to it, we need a writable @@ -851,12 +851,12 @@ class StreamWrapper if ($this->createIfNotFound) { $this->obj = new Object($objectName); $this->objStream = fopen('php://temp', 'rb+'); - $this->isDirty = TRUE; + $this->isDirty = true; } else { //if ($this->triggerErrors) { trigger_error($nf->getMessage(), E_USER_WARNING); //} - return FALSE; + return false; } } @@ -865,20 +865,20 @@ class StreamWrapper //if ($this->triggerErrors) { trigger_error('Failed to fetch object: ' . $e->getMessage(), E_USER_WARNING); //} - return FALSE; + return false; } // At this point, we have a file that may be read-only. It also may be // reading off of a socket. It will be positioned at the beginning of // the stream. - return TRUE; + return true; } /** * Read N bytes from the stream. * * This will read up to the requested number of bytes. Or, upon - * hitting the end of the file, it will return NULL. + * hitting the end of the file, it will return null. * * @see fread(), fgets(), and so on for examples. * @@ -890,7 +890,7 @@ class StreamWrapper * 'endpoint' => 'https://auth.example.com', * )); * - * $content = file_get_contents('swift://public/myfile.txt', FALSE, $cxt); + * $content = file_get_contents('swift://public/myfile.txt', false, $cxt); * ?> * * @param int $count The number of bytes to read (usually 8192). @@ -917,7 +917,7 @@ class StreamWrapper $ret = fseek($this->objStream, $offset, $whence); // fseek returns 0 for success, -1 for failure. - // We need to return TRUE for success, FALSE for failure. + // We need to return true for success, false for failure. return $ret === 0; } @@ -951,7 +951,7 @@ class StreamWrapper * Perform stat()/lstat() operations. * * * @@ -997,7 +997,7 @@ class StreamWrapper */ public function stream_write($data) { - $this->isDirty = TRUE; + $this->isDirty = true; return fwrite($this->objStream, $data); } @@ -1019,7 +1019,7 @@ class StreamWrapper * * @param string $path The URL. * - * @return boolean TRUE if the file was deleted, FALSE otherwise. + * @return boolean true if the file was deleted, false otherwise. */ public function unlink($path) { @@ -1029,7 +1029,7 @@ class StreamWrapper if (empty($url['host'])) { trigger_error('Container name is required.', E_USER_WARNING); - return FALSE; + return false; } // I suppose we could allow deleting containers, @@ -1038,7 +1038,7 @@ class StreamWrapper if (empty($url['path'])) { trigger_error('Path is required.', E_USER_WARNING); - return FALSE; + return false; } try { @@ -1047,14 +1047,14 @@ class StreamWrapper $name = $url['host']; $token = $this->store->token(); $endpoint_url = $this->store->url() . '/' . rawurlencode($name); - $client = $this->cxt('transport_client', NULL); + $client = $this->cxt('transport_client', null); $container = new \OpenStack\Storage\ObjectStorage\Container($name, $endpoint_url, $token, $client); return $container->delete($url['path']); } catch (\OpenStack\Exception $e) { trigger_error('Error during unlink: ' . $e->getMessage(), E_USER_WARNING); - return FALSE; + return false; } } @@ -1071,7 +1071,7 @@ class StreamWrapper trigger_error('Container name (host) and path are required.', E_USER_WARNING); } - return FALSE; + return false; } try { @@ -1084,7 +1084,7 @@ class StreamWrapper $name = $url['host']; $token = $this->store->token(); $endpoint_url = $this->store->url() . '/' . rawurlencode($name); - $client = $this->cxt('transport_client', NULL); + $client = $this->cxt('transport_client', null); $container = new \OpenStack\Storage\ObjectStorage\Container($name, $endpoint_url, $token, $client); $obj = $container->remoteObject($url['path']); } catch (\OpenStack\Exception $e) { @@ -1092,14 +1092,14 @@ class StreamWrapper //if ($flags & STREAM_URL_STAT_QUIET) { //trigger_error('Could not stat remote file: ' . $e->getMessage(), E_USER_WARNING); //} - return FALSE; + return false; } if ($flags & STREAM_URL_STAT_QUIET) { try { return @$this->generateStat($obj, $container, $obj->contentLength()); } catch (\OpenStack\Exception $e) { - return FALSE; + return false; } } @@ -1261,48 +1261,48 @@ class StreamWrapper // object storage does not distinguish between // text and binary files. Per the PHP recommendation // files are treated as binary. - $this->isBinary = strpos($mode, 'b') !== FALSE; - $this->isText = strpos($mode, 't') !== FALSE; + $this->isBinary = strpos($mode, 'b') !== false; + $this->isText = strpos($mode, 't') !== false; // Rewrite mode to remove b or t: $mode = preg_replace('/[bt]?/', '', $mode); switch ($mode) { case 'r+': - $this->isWriting = TRUE; + $this->isWriting = true; case 'r': - $this->isReading = TRUE; - $this->createIfNotFound = FALSE; + $this->isReading = true; + $this->createIfNotFound = false; break; case 'w+': - $this->isReading = TRUE; + $this->isReading = true; case 'w': - $this->isTruncating = TRUE; - $this->isWriting = TRUE; + $this->isTruncating = true; + $this->isWriting = true; break; case 'a+': - $this->isReading = TRUE; + $this->isReading = true; case 'a': - $this->isAppending = TRUE; - $this->isWriting = TRUE; + $this->isAppending = true; + $this->isWriting = true; break; case 'x+': - $this->isReading = TRUE; + $this->isReading = true; case 'x': - $this->isWriting = TRUE; - $this->noOverwrite = TRUE; + $this->isWriting = true; + $this->noOverwrite = true; break; case 'c+': - $this->isReading = TRUE; + $this->isReading = true; case 'c': - $this->isWriting = TRUE; + $this->isWriting = true; break; // nope mode: Mock read/write support, @@ -1310,16 +1310,16 @@ class StreamWrapper // (This is accomplished by never marking // the stream as dirty.) case 'nope': - $this->isReading = TRUE; - $this->isWriting = TRUE; - $this->isNeverDirty = TRUE; + $this->isReading = true; + $this->isWriting = true; + $this->isNeverDirty = true; break; // Default case is read/write // like c+. default: - $this->isReading = TRUE; - $this->isWriting = TRUE; + $this->isReading = true; + $this->isWriting = true; break; } @@ -1337,10 +1337,10 @@ class StreamWrapper * @param mixed $default The default value to return if no config param was * found. * - * @return mixed The discovered result, or $default if specified, or NULL if + * @return mixed The discovered result, or $default if specified, or null if * no $default is specified. */ - protected function cxt($name, $default = NULL) + protected function cxt($name, $default = null) { // Lazilly populate the context array. if (is_resource($this->context) && empty($this->contextArray)) { @@ -1363,7 +1363,7 @@ class StreamWrapper // Check to see if the value can be gotten from // \OpenStack\Bootstrap. - $val = \OpenStack\Bootstrap::config($name, NULL); + $val = \OpenStack\Bootstrap::config($name, null); if (isset($val)) { return $val; } @@ -1421,7 +1421,7 @@ class StreamWrapper * - password: A password. MUST be accompanied by 'username' and 'tenantname'. * - endpoint: The URL to the authentication endpoint. Necessary if you are not * using a 'token' and 'swift_endpoint'. - * - use_swift_auth: If this is set to TRUE, it will force the app to use + * - use_swift_auth: If this is set to true, it will force the app to use * the deprecated swiftAuth instead of IdentityService authentication. * In general, you should avoid using this. * - transport_client: A transport client for the HTTP requests. @@ -1439,9 +1439,9 @@ class StreamWrapper $tenantName = $this->cxt('tenantname'); $authUrl = $this->cxt('endpoint'); $endpoint = $this->cxt('swift_endpoint'); - $client = $this->cxt('transport_client', NULL); + $client = $this->cxt('transport_client', null); - $serviceCatalog = NULL; + $serviceCatalog = null; if (!empty($token) && isset(self::$serviceCatalogCache[$token])) { $serviceCatalog = self::$serviceCatalogCache[$token]; @@ -1472,7 +1472,7 @@ class StreamWrapper /* $catalog = $ident->serviceCatalog(ObjectStorage::SERVICE_TYPE); if (empty($catalog) || empty($catalog[0]['endpoints'][0]['publicURL'])) { - //throw new \OpenStack\Exception('No object storage services could be found for this tenant ID.' . print_r($catalog, TRUE)); + //throw new \OpenStack\Exception('No object storage services could be found for this tenant ID.' . print_r($catalog, true)); throw new \OpenStack\Exception('No object storage services could be found for this tenant ID.'); } $serviceURL = $catalog[0]['endpoints'][0]['publicURL']; @@ -1494,7 +1494,7 @@ class StreamWrapper $tenantName = $this->cxt('tenantname'); $authUrl = $this->cxt('endpoint'); - $client = $this->cxt('transport_client', NULL); + $client = $this->cxt('transport_client', null); $ident = new \OpenStack\Services\IdentityService($authUrl, $client); diff --git a/src/OpenStack/Storage/ObjectStorage/StreamWrapperFS.php b/src/OpenStack/Storage/ObjectStorage/StreamWrapperFS.php index 5f88b9c..a6278c6 100644 --- a/src/OpenStack/Storage/ObjectStorage/StreamWrapperFS.php +++ b/src/OpenStack/Storage/ObjectStorage/StreamWrapperFS.php @@ -54,8 +54,8 @@ * - swiftfs_fake_isdir_true: Directory functions like mkdir and is_dir (stat) * check to see if there are objects with the the passed in directory as a * prefix to see if it already exists. If you want is_dir to always return - * true even if it is not an existing prefix set this to TRUE. Defaults to - * FALSE. + * true even if it is not an existing prefix set this to true. Defaults to + * false. */ namespace OpenStack\Storage\ObjectStorage; @@ -85,7 +85,7 @@ class StreamWrapperFS extends StreamWrapper */ public function mkdir($uri, $mode, $options) { - return ($this->cxt('swiftfs_fake_isdir_true', FALSE) || !($this->testDirectoryExists($uri))); + return ($this->cxt('swiftfs_fake_isdir_true', false) || !($this->testDirectoryExists($uri))); } @@ -113,15 +113,15 @@ class StreamWrapperFS extends StreamWrapper if ($stat) { return $stat; } - // When FALSE is returned there is no file to stat. So, we attempt to handle + // When false is returned there is no file to stat. So, we attempt to handle // it like a directory. else { - if ($this->cxt('swiftfs_fake_isdir_true', FALSE) || $this->testDirectoryExists($path)) { + if ($this->cxt('swiftfs_fake_isdir_true', false) || $this->testDirectoryExists($path)) { // The directory prefix exists. Fake the directory file permissions. - return $this->fakeStat(TRUE); + return $this->fakeStat(true); } else { // The directory does not exist as a prefix. - return FALSE; + return false; } } } @@ -141,7 +141,7 @@ class StreamWrapperFS extends StreamWrapper * * @param string $path The directory path to test. * - * @return boolean TRUE if the directory prefix exists and FALSE otherwise. + * @return boolean true if the directory prefix exists and false otherwise. */ protected function testDirectoryExists($path) { @@ -150,7 +150,7 @@ class StreamWrapperFS extends StreamWrapper if (empty($url['host'])) { trigger_error('Container name is required.' , E_USER_WARNING); - return FALSE; + return false; } try { @@ -172,7 +172,7 @@ class StreamWrapperFS extends StreamWrapper } catch (\OpenStack\Exception $e) { trigger_error('Path could not be opened: ' . $e->getMessage(), E_USER_WARNING); - return FALSE; + return false; } } @@ -182,7 +182,7 @@ class StreamWrapperFS extends StreamWrapper * Under certain conditions we have to return totally trumped-up * stats. This generates those. */ - protected function fakeStat($dir = FALSE) + protected function fakeStat($dir = false) { $request_time = time(); diff --git a/src/OpenStack/Transport/ClientInterface.php b/src/OpenStack/Transport/ClientInterface.php index 450a030..cb7c47b 100644 --- a/src/OpenStack/Transport/ClientInterface.php +++ b/src/OpenStack/Transport/ClientInterface.php @@ -46,7 +46,7 @@ interface ClientInterface * - timeout (int) The timeout, in seconds, a request should wait before * timing out. * - ssl_verify (bool|string) True, the default, verifies the SSL certificate, - * FALSE disables verification, and a string is the path to a CA to verify + * false disables verification, and a string is the path to a CA to verify * against. */ public function __construct(array $options = []); diff --git a/src/OpenStack/Transport/GuzzleClient.php b/src/OpenStack/Transport/GuzzleClient.php index b1111bc..a169f6e 100644 --- a/src/OpenStack/Transport/GuzzleClient.php +++ b/src/OpenStack/Transport/GuzzleClient.php @@ -41,7 +41,7 @@ class GuzzleClient implements ClientInterface, \Serializable * - timeout (int) The timeout, in seconds, a request should wait before * timing out. * - ssl_verify (bool|string) True, the default, verifies the SSL certificate, - * FALSE disables verification, and a string is the path to a CA to verify + * false disables verification, and a string is the path to a CA to verify * against. * - client (mixed) A guzzle client object to use instead of the default. * This can be either a string to the class or an existing object. If an diff --git a/test/AuthTest.php b/test/AuthTest.php index 460d8b8..0a7f90e 100644 --- a/test/AuthTest.php +++ b/test/AuthTest.php @@ -63,7 +63,7 @@ $user = $argv[1 + $offset]; $password = $argv[2 + $offset]; $uri = $argv[3 + $offset]; -$tenantId = NULL; +$tenantId = null; if (!empty($argv[4 + $offset])) { $tenantId = $argv[4 + $offset]; } diff --git a/test/TestCase.php b/test/TestCase.php index fef8268..b2a085f 100644 --- a/test/TestCase.php +++ b/test/TestCase.php @@ -34,16 +34,16 @@ class TestCase extends \PHPUnit_Framework_TestCase { public static $settings = array(); - public static $ostore = NULL; + public static $ostore = null; /** * The IdentityService instance. */ public static $ident; - public static $httpClient = NULL; + public static $httpClient = null; - //public function __construct(score $score = NULL, locale $locale = NULL, adapter $adapter = NULL) { + //public function __construct(score $score = null, locale $locale = null, adapter $adapter = null) { public static function setUpBeforeClass() { global $bootstrap_settings; @@ -72,7 +72,7 @@ class TestCase extends \PHPUnit_Framework_TestCase * Optionally, specify a default value to be used * if none was found. */ - public static function conf($name, $default = NULL) + public static function conf($name, $default = null) { if (isset(self::$settings[$name])) { return self::$settings[$name]; @@ -81,7 +81,7 @@ class TestCase extends \PHPUnit_Framework_TestCase return $default; } - protected $containerFixture = NULL; + protected $containerFixture = null; /** * @deprecated @@ -107,7 +107,7 @@ class TestCase extends \PHPUnit_Framework_TestCase * $this->identity()->token(); * ?> */ - protected function identity($reset = FALSE) + protected function identity($reset = false) { if ($reset || empty(self::$ident)) { $user = self::conf('openstack.identity.username'); @@ -126,7 +126,7 @@ class TestCase extends \PHPUnit_Framework_TestCase return self::$ident; } - protected function objectStore($reset = FALSE) + protected function objectStore($reset = false) { if ($reset || empty(self::$ostore)) { $ident = $this->identity($reset); diff --git a/test/Tests/ACLTest.php b/test/Tests/ACLTest.php index 49e6ff3..bb5b0c4 100644 --- a/test/Tests/ACLTest.php +++ b/test/Tests/ACLTest.php @@ -117,7 +117,7 @@ class ACLTest extends \OpenStack\Tests\TestCase $acl->addReferrer(ACL::READ_WRITE, '.example.com'); $headers = $acl->headers(); - $this->assertEquals(1, count($headers), print_r($headers, TRUE)); + $this->assertEquals(1, count($headers), print_r($headers, true)); $read = $headers[ACL::HEADER_READ]; $this->assertEquals('.r:.example.com', $read); diff --git a/test/Tests/ContainerTest.php b/test/Tests/ContainerTest.php index 5aeb8e1..9ab3f8b 100644 --- a/test/Tests/ContainerTest.php +++ b/test/Tests/ContainerTest.php @@ -148,10 +148,10 @@ class ContainerTest extends \OpenStack\Tests\TestCase $object->setContent('FOO'); $this->assertEquals('FOO', $object->content()); - $object->refresh(TRUE); + $object->refresh(true); $this->assertEquals($content, (string) $object->content()); - $object->refresh(FALSE); + $object->refresh(false); $this->assertEquals($content, (string) $object->content()); } @@ -306,7 +306,7 @@ class ContainerTest extends \OpenStack\Tests\TestCase // $this->assertEquals(1, count($objects), 'One subdir'); // $objects = $container->objectsByPath('a/'); - // throw new \Exception(print_r($objects, TRUE)); + // throw new \Exception(print_r($objects, true)); // $this->assertEquals(2, count($objects)); // foreach ($objects as $o) { diff --git a/test/Tests/IdentityServicesTest.php b/test/Tests/IdentityServicesTest.php index bb0079c..3eb21c8 100644 --- a/test/Tests/IdentityServicesTest.php +++ b/test/Tests/IdentityServicesTest.php @@ -156,7 +156,7 @@ class IdentityServicesTest extends \OpenStack\Tests\TestCase $this->assertEmpty($service->tenantName()); $service = new IdentityService(self::conf('openstack.identity.url'), $this->getTransportClient()); - $ret = $service->authenticateAsUser($user, $pass, NULL, $tenantName); + $ret = $service->authenticateAsUser($user, $pass, null, $tenantName); $this->assertNotEmpty($service->tenantName()); $service = new IdentityService(self::conf('openstack.identity.url'), $this->getTransportClient()); @@ -231,7 +231,7 @@ class IdentityServicesTest extends \OpenStack\Tests\TestCase $this->assertGreaterThan(0, count($catalog)); - $idService = NULL; + $idService = null; foreach ($catalog as $item) { if ($item['type'] == 'identity') { $idService = $item; @@ -398,8 +398,8 @@ class IdentityServicesTest extends \OpenStack\Tests\TestCase 'endpoint' => self::conf('openstack.identity.url'), 'tenantid' => self::conf('openstack.identity.tenantId'), 'transport' => self::conf('transport'), - 'transport.debug' => self::conf('transport.debug', FALSE), - 'transport.ssl_verify' => self::conf('transport.ssl', TRUE), + 'transport.debug' => self::conf('transport.debug', false), + 'transport.ssl_verify' => self::conf('transport.ssl', true), ); if (self::conf('transport.timeout')) { $setting['transport.timeout'] = self::conf('transport.timeout'); @@ -409,7 +409,7 @@ class IdentityServicesTest extends \OpenStack\Tests\TestCase } Bootstrap::setConfiguration($settings); - $is = Bootstrap::identity(TRUE); + $is = Bootstrap::identity(true); $this->assertInstanceOf('\OpenStack\Services\IdentityService', $is); // Test getting a second instance from the cache. @@ -417,7 +417,7 @@ class IdentityServicesTest extends \OpenStack\Tests\TestCase $this->assertEquals($is, $is2); // Test that forcing a refresh does so. - $is2 = Bootstrap::identity(TRUE); + $is2 = Bootstrap::identity(true); $this->assertNotEquals($is, $is2); Bootstrap::$config = $reset; @@ -429,8 +429,8 @@ class IdentityServicesTest extends \OpenStack\Tests\TestCase 'endpoint' => self::conf('openstack.identity.url'), 'tenantname' => self::conf('openstack.identity.tenantName'), 'transport' => self::conf('transport'), - 'transport.debug' => self::conf('transport.debug', FALSE), - 'transport.ssl_verify' => self::conf('transport.ssl', TRUE), + 'transport.debug' => self::conf('transport.debug', false), + 'transport.ssl_verify' => self::conf('transport.ssl', true), ); if (self::conf('transport.timeout')) { $setting['transport.timeout'] = self::conf('transport.timeout'); @@ -440,7 +440,7 @@ class IdentityServicesTest extends \OpenStack\Tests\TestCase } Bootstrap::setConfiguration($settings); - $is = Bootstrap::identity(TRUE); + $is = Bootstrap::identity(true); $this->assertInstanceOf('\OpenStack\Services\IdentityService', $is); } } diff --git a/test/Tests/ObjectStorageTest.php b/test/Tests/ObjectStorageTest.php index fb9fa0e..8a36463 100644 --- a/test/Tests/ObjectStorageTest.php +++ b/test/Tests/ObjectStorageTest.php @@ -129,7 +129,7 @@ class ObjectStorageTest extends \OpenStack\Tests\TestCase $md = array('Foo' => 1234); - $ret = $store->createContainer($testCollection, NULL, $md); + $ret = $store->createContainer($testCollection, null, $md); $this->assertTrue($ret, "Create container"); } @@ -283,7 +283,7 @@ class ObjectStorageTest extends \OpenStack\Tests\TestCase $this->assertNotEmpty($data, $url); $containers = $store->containers(); - //throw new \Exception(print_r($containers, TRUE)); + //throw new \Exception(print_r($containers, true)); $store->deleteContainer($testCollection); } diff --git a/test/Tests/ObjectTest.php b/test/Tests/ObjectTest.php index 883d6c8..ef7e4d8 100644 --- a/test/Tests/ObjectTest.php +++ b/test/Tests/ObjectTest.php @@ -77,7 +77,7 @@ class ObjectTest extends \OpenStack\Tests\TestCase $this->assertEquals(self::FCONTENT, $o->content()); // Test binary data. - $bin = sha1(self::FCONTENT, TRUE); + $bin = sha1(self::FCONTENT, true); $o->setContent($bin, 'application/octet-stream'); $this->assertEquals($bin, $o->content()); @@ -103,7 +103,7 @@ class ObjectTest extends \OpenStack\Tests\TestCase $this->assertEquals(strlen(self::FCONTENT), $o->contentLength()); // Test on binary data. - $bin = sha1(self::FCONTENT, TRUE); + $bin = sha1(self::FCONTENT, true); $o->setContent($bin); $this->assertFalse($o->contentLength() == 0); diff --git a/test/Tests/RemoteObjectTest.php b/test/Tests/RemoteObjectTest.php index 0b4d87f..61f7cc7 100644 --- a/test/Tests/RemoteObjectTest.php +++ b/test/Tests/RemoteObjectTest.php @@ -152,7 +152,7 @@ class RemoteObjectTest extends \OpenStack\Tests\TestCase $headers = $obj->headers(); $this->assertTrue(count($headers) > 1); - //fwrite(STDOUT, print_r($headers, TRUE)); + //fwrite(STDOUT, print_r($headers, true)); $this->assertNotEmpty($headers['Date']); @@ -210,7 +210,7 @@ class RemoteObjectTest extends \OpenStack\Tests\TestCase // Finally, we redo the first part of the test to make sure that // refreshing gets us a new copy: - $res3 = $obj->stream(TRUE); + $res3 = $obj->stream(true); $res_md = stream_get_meta_data($res3); $this->assertEquals('PHP', $res_md['wrapper_type']); fclose($res3); @@ -253,7 +253,7 @@ class RemoteObjectTest extends \OpenStack\Tests\TestCase fclose($res1); // Enable caching and retest. - $obj->setCaching(TRUE); + $obj->setCaching(true); $this->assertTrue($obj->isCaching()); // This will cache the content. @@ -275,9 +275,9 @@ class RemoteObjectTest extends \OpenStack\Tests\TestCase public function testContentVerification($obj) { $this->assertTrue($obj->isVerifyingContent()); - $obj->setContentVerification(FALSE); - $this->assertFALSE($obj->isVerifyingContent()); - $obj->setContentVerification(TRUE); + $obj->setContentVerification(false); + $this->assertfalse($obj->isVerifyingContent()); + $obj->setContentVerification(true); } /** @@ -291,7 +291,7 @@ class RemoteObjectTest extends \OpenStack\Tests\TestCase // THere is no content. Assert false. $this->assertFalse($obj->isDirty()); - $obj->setCaching(TRUE); + $obj->setCaching(true); $obj->content(); // THere is content, but it is unchanged. @@ -314,14 +314,14 @@ class RemoteObjectTest extends \OpenStack\Tests\TestCase $obj->setContent('foo'); $this->assertTrue($obj->isDirty()); - $obj->refresh(FALSE); + $obj->refresh(false); $this->assertFalse($obj->isDirty()); $this->assertEquals(self::FCONTENT, $obj->content()); $obj->setContent('foo'); $this->assertTrue($obj->isDirty()); - $obj->refresh(TRUE); + $obj->refresh(true); $this->assertFalse($obj->isDirty()); $this->assertEquals(self::FCONTENT, $obj->content()); diff --git a/test/Tests/StreamWrapperFSTest.php b/test/Tests/StreamWrapperFSTest.php index 241bb55..22809ce 100644 --- a/test/Tests/StreamWrapperFSTest.php +++ b/test/Tests/StreamWrapperFSTest.php @@ -94,7 +94,7 @@ class StreamWrapperFSTest extends \OpenStack\Tests\TestCase /** * This assumes auth has already been done. */ - protected function basicSwiftContext($add = array(), $scheme = NULL) + protected function basicSwiftContext($add = array(), $scheme = null) { $cname = self::$settings['openstack.swift.container']; @@ -123,7 +123,7 @@ class StreamWrapperFSTest extends \OpenStack\Tests\TestCase * UPDATE: This now users IdentityService instead of deprecated * swauth. */ - protected function authSwiftContext($add = array(), $scheme = NULL) + protected function authSwiftContext($add = array(), $scheme = null) { $cname = self::$settings['openstack.swift.container']; $username = self::$settings['openstack.identity.username']; @@ -176,7 +176,7 @@ class StreamWrapperFSTest extends \OpenStack\Tests\TestCase { // Clear old values. \OpenStack\Bootstrap::setConfiguration(array( - 'token' => NULL, + 'token' => null, )); $cxt = $this->authSwiftContext(); @@ -229,7 +229,7 @@ class StreamWrapperFSTest extends \OpenStack\Tests\TestCase // Simple write test. $oUrl = $this->newUrl('foo→/test.csv'); - $res = fopen($oUrl, 'nope', FALSE, $this->authSwiftContext()); + $res = fopen($oUrl, 'nope', false, $this->authSwiftContext()); $this->assertTrue(is_resource($res)); @@ -241,7 +241,7 @@ class StreamWrapperFSTest extends \OpenStack\Tests\TestCase // Now we test the same, but re-using the auth token: $cxt = $this->basicSwiftContext(array('token' => $wrapper->token())); - $res = fopen($oUrl, 'nope', FALSE, $cxt); + $res = fopen($oUrl, 'nope', false, $cxt); $this->assertTrue(is_resource($res)); @@ -255,7 +255,7 @@ class StreamWrapperFSTest extends \OpenStack\Tests\TestCase public function testOpenFailureWithRead() { $url = $this->newUrl(__FUNCTION__); - $res = @fopen($url, 'r', FALSE, $this->basicSwiftContext()); + $res = @fopen($url, 'r', false, $this->basicSwiftContext()); $this->assertFalse($res); @@ -269,7 +269,7 @@ class StreamWrapperFSTest extends \OpenStack\Tests\TestCase public function testOpenCreateMode() { $url = $this->newUrl(self::FNAME); - $res = fopen($url, 'c+', FALSE, $this->basicSwiftContext()); + $res = fopen($url, 'c+', false, $this->basicSwiftContext()); $this->assertTrue(is_resource($res)); //fclose($res); return $res; @@ -367,7 +367,7 @@ class StreamWrapperFSTest extends \OpenStack\Tests\TestCase // Grab a copy of the object. $url = $this->newUrl(self::FNAME); - $newObj = fopen($url, 'r', FALSE, $this->basicSwiftContext()); + $newObj = fopen($url, 'r', false, $this->basicSwiftContext()); $stat2 = fstat($newObj); @@ -383,7 +383,7 @@ class StreamWrapperFSTest extends \OpenStack\Tests\TestCase { // Grab a copy of the object. $url = $this->newUrl(self::FNAME); - $newObj = fopen($url, 'r', FALSE, $this->basicSwiftContext()); + $newObj = fopen($url, 'r', false, $this->basicSwiftContext()); $md = stream_get_meta_data($newObj); //throw new \Exception(print_r($md, true)); @@ -410,7 +410,7 @@ class StreamWrapperFSTest extends \OpenStack\Tests\TestCase fclose($res); $url = $this->newUrl(self::FNAME); - $res2 = fopen($url, 'r', FALSE, $this->basicSwiftContext()); + $res2 = fopen($url, 'r', false, $this->basicSwiftContext()); $this->assertTrue(is_resource($res2)); $contents = stream_get_contents($res2); @@ -425,7 +425,7 @@ class StreamWrapperFSTest extends \OpenStack\Tests\TestCase public function testCast() { $url = $this->newUrl(self::FNAME); - $res = fopen($url, 'r', FALSE, $this->basicSwiftContext()); + $res = fopen($url, 'r', false, $this->basicSwiftContext()); $read = array($res); $write = array(); @@ -497,7 +497,7 @@ class StreamWrapperFSTest extends \OpenStack\Tests\TestCase public function testSetOption() { $url = $this->newUrl('fake.foo'); - $fake = fopen($url, 'nope', FALSE, $this->basicSwiftContext()); + $fake = fopen($url, 'nope', false, $this->basicSwiftContext()); $this->assertTrue(stream_set_blocking($fake, 1)); @@ -516,7 +516,7 @@ class StreamWrapperFSTest extends \OpenStack\Tests\TestCase public function testRename() { $url = $this->newUrl('rename.foo'); - $fake = fopen($url, 'w+', FALSE, $this->basicSwiftContext()); + $fake = fopen($url, 'w+', false, $this->basicSwiftContext()); fwrite($fake, 'test'); fclose($fake); @@ -540,7 +540,7 @@ class StreamWrapperFSTest extends \OpenStack\Tests\TestCase $urls = array('test1.txt', 'foo/test2.txt', 'foo/test3.txt', 'bar/test4.txt'); foreach ($urls as $base) { $url = $this->newUrl($base); - $f = fopen($url, 'c+', FALSE, $this->basicSwiftContext()); + $f = fopen($url, 'c+', false, $this->basicSwiftContext()); fwrite($f, 'Test.'); fclose($f); } @@ -563,7 +563,7 @@ class StreamWrapperFSTest extends \OpenStack\Tests\TestCase $expects = array('bar/', 'foo/', 'test1.txt'); $buffer = array(); - while (($entry = readdir($dir)) !== FALSE) { + while (($entry = readdir($dir)) !== false) { $should_be = array_shift($expects); $this->assertEquals($should_be, $entry); } @@ -641,11 +641,11 @@ class StreamWrapperFSTest extends \OpenStack\Tests\TestCase // Object names are pathy. If no object names start with the a path we can // consider mkdir passed. If object names exist we should fail mkdir. $url = $this->newUrl('baz/'); - $this->assertTrue(mkdir($url, 0700, TRUE, $this->basicSwiftContext())); + $this->assertTrue(mkdir($url, 0700, true, $this->basicSwiftContext())); // Test the case for an existing directory. $url = $this->newUrl('foo/'); - $this->assertFalse(mkdir($url, 0700, TRUE, $this->basicSwiftContext())); + $this->assertFalse(mkdir($url, 0700, true, $this->basicSwiftContext())); } /** diff --git a/test/Tests/StreamWrapperTest.php b/test/Tests/StreamWrapperTest.php index 7776fc3..07e4c7d 100644 --- a/test/Tests/StreamWrapperTest.php +++ b/test/Tests/StreamWrapperTest.php @@ -91,7 +91,7 @@ class StreamWrapperTest extends \OpenStack\Tests\TestCase /** * This assumes auth has already been done. */ - protected function basicSwiftContext($add = array(), $scheme = NULL) + protected function basicSwiftContext($add = array(), $scheme = null) { $cname = self::$settings['openstack.swift.container']; @@ -117,7 +117,7 @@ class StreamWrapperTest extends \OpenStack\Tests\TestCase /** * This performs authentication via context. */ - protected function authSwiftContext($add = array(), $scheme = NULL) + protected function authSwiftContext($add = array(), $scheme = null) { $cname = self::$settings['openstack.swift.container']; $username = self::$settings['openstack.identity.username']; @@ -171,7 +171,7 @@ class StreamWrapperTest extends \OpenStack\Tests\TestCase // Reset this in case something else left its // auth token lying around. \OpenStack\Bootstrap::setConfiguration(array( - 'token' => NULL, + 'token' => null, )); $cxt = $this->authSwiftContext(); $array = stream_context_get_options($cxt); @@ -229,7 +229,7 @@ class StreamWrapperTest extends \OpenStack\Tests\TestCase // Simple write test. $oUrl = $this->newUrl('foo→/test.csv'); - $res = fopen($oUrl, 'nope', FALSE, $this->authSwiftContext()); + $res = fopen($oUrl, 'nope', false, $this->authSwiftContext()); $this->assertTrue(is_resource($res)); @@ -240,7 +240,7 @@ class StreamWrapperTest extends \OpenStack\Tests\TestCase // Now we test the same, but re-using the auth token: $cxt = $this->basicSwiftContext(array('token' => $wrapper->token())); - $res = fopen($oUrl, 'nope', FALSE, $cxt); + $res = fopen($oUrl, 'nope', false, $cxt); $this->assertTrue(is_resource($res)); @@ -254,7 +254,7 @@ class StreamWrapperTest extends \OpenStack\Tests\TestCase public function testOpenFailureWithRead() { $url = $this->newUrl(__FUNCTION__); - $res = @fopen($url, 'r', FALSE, $this->basicSwiftContext()); + $res = @fopen($url, 'r', false, $this->basicSwiftContext()); $this->assertFalse($res); @@ -268,7 +268,7 @@ class StreamWrapperTest extends \OpenStack\Tests\TestCase public function testOpenCreateMode() { $url = $this->newUrl(self::FNAME); - $res = fopen($url, 'c+', FALSE, $this->basicSwiftContext()); + $res = fopen($url, 'c+', false, $this->basicSwiftContext()); $this->assertTrue(is_resource($res)); //fclose($res); return $res; @@ -366,7 +366,7 @@ class StreamWrapperTest extends \OpenStack\Tests\TestCase // Grab a copy of the object. $url = $this->newUrl(self::FNAME); - $newObj = fopen($url, 'r', FALSE, $this->basicSwiftContext()); + $newObj = fopen($url, 'r', false, $this->basicSwiftContext()); $stat2 = fstat($newObj); @@ -382,7 +382,7 @@ class StreamWrapperTest extends \OpenStack\Tests\TestCase { // Grab a copy of the object. $url = $this->newUrl(self::FNAME); - $newObj = fopen($url, 'r', FALSE, $this->basicSwiftContext()); + $newObj = fopen($url, 'r', false, $this->basicSwiftContext()); $md = stream_get_meta_data($newObj); //throw new \Exception(print_r($md, true)); @@ -409,7 +409,7 @@ class StreamWrapperTest extends \OpenStack\Tests\TestCase fclose($res); $url = $this->newUrl(self::FNAME); - $res2 = fopen($url, 'r', FALSE, $this->basicSwiftContext()); + $res2 = fopen($url, 'r', false, $this->basicSwiftContext()); $this->assertTrue(is_resource($res2)); $contents = stream_get_contents($res2); @@ -424,7 +424,7 @@ class StreamWrapperTest extends \OpenStack\Tests\TestCase public function testCast() { $url = $this->newUrl(self::FNAME); - $res = fopen($url, 'r', FALSE, $this->basicSwiftContext()); + $res = fopen($url, 'r', false, $this->basicSwiftContext()); $read = array($res); $write = array(); @@ -496,7 +496,7 @@ class StreamWrapperTest extends \OpenStack\Tests\TestCase public function testSetOption() { $url = $this->newUrl('fake.foo'); - $fake = fopen($url, 'nope', FALSE, $this->basicSwiftContext()); + $fake = fopen($url, 'nope', false, $this->basicSwiftContext()); $this->assertTrue(stream_set_blocking($fake, 1)); @@ -515,7 +515,7 @@ class StreamWrapperTest extends \OpenStack\Tests\TestCase public function testRename() { $url = $this->newUrl('rename.foo'); - $fake = fopen($url, 'w+', FALSE, $this->basicSwiftContext()); + $fake = fopen($url, 'w+', false, $this->basicSwiftContext()); fwrite($fake, 'test'); fclose($fake); @@ -539,7 +539,7 @@ class StreamWrapperTest extends \OpenStack\Tests\TestCase $urls = array('test1.txt', 'foo/test2.txt', 'foo/test3.txt', 'bar/test4.txt'); foreach ($urls as $base) { $url = $this->newUrl($base); - $f = fopen($url, 'c+', FALSE, $this->basicSwiftContext()); + $f = fopen($url, 'c+', false, $this->basicSwiftContext()); fwrite($f, 'Test.'); fclose($f); } @@ -562,7 +562,7 @@ class StreamWrapperTest extends \OpenStack\Tests\TestCase $expects = array('bar/', 'foo/', 'test1.txt'); $buffer = array(); - while (($entry = readdir($dir)) !== FALSE) { + while (($entry = readdir($dir)) !== false) { $should_be = array_shift($expects); $this->assertEquals($should_be, $entry); }