Upgrading arrays to 5.4 short syntax
Change-Id: I1a238996a3a8ab56fa0282cddc51c06f5c9bd139
This commit is contained in:
@@ -7,12 +7,12 @@ Autoloader::useAutoloader();
|
|||||||
Bootstrap::useStreamWrappers();
|
Bootstrap::useStreamWrappers();
|
||||||
|
|
||||||
$ini = parse_ini_file(getenv('HOME') . '/.OpenStack.ini');
|
$ini = parse_ini_file(getenv('HOME') . '/.OpenStack.ini');
|
||||||
$settings = array(
|
$settings = [
|
||||||
'account' => $ini['account'],
|
'account' => $ini['account'],
|
||||||
'key' => $ini['secret'],
|
'key' => $ini['secret'],
|
||||||
'tenantid' => $ini['tenantId'],
|
'tenantid' => $ini['tenantId'],
|
||||||
'endpoint' => $ini['url'],
|
'endpoint' => $ini['url'],
|
||||||
);
|
];
|
||||||
Bootstrap::setConfiguration($settings);
|
Bootstrap::setConfiguration($settings);
|
||||||
|
|
||||||
// Create a new file and write it to the object store.
|
// Create a new file and write it to the object store.
|
||||||
@@ -29,13 +29,13 @@ if (file_exists('swift://Example/my_file.txt')) {
|
|||||||
$file = file_get_contents('swift://Example/my_file.txt');
|
$file = file_get_contents('swift://Example/my_file.txt');
|
||||||
print 'File: ' . $file . PHP_EOL;
|
print 'File: ' . $file . PHP_EOL;
|
||||||
|
|
||||||
$cxt = stream_context_create(array(
|
$cxt = stream_context_create([
|
||||||
'swift' => array(
|
'swift' => [
|
||||||
'account' => $ini['account'],
|
'account' => $ini['account'],
|
||||||
'key' => $ini['secret'],
|
'key' => $ini['secret'],
|
||||||
'tenantid' => $ini['tenantId'],
|
'tenantid' => $ini['tenantId'],
|
||||||
'endpoint' => $ini['url'],
|
'endpoint' => $ini['url'],
|
||||||
),
|
],
|
||||||
));
|
]);
|
||||||
|
|
||||||
print file_get_contents('swift://Example/my_file.txt', FALSE, $cxt);
|
print file_get_contents('swift://Example/my_file.txt', FALSE, $cxt);
|
||||||
|
|||||||
@@ -85,10 +85,10 @@ class Bootstrap
|
|||||||
{
|
{
|
||||||
const VERSION = '0.0.1';
|
const VERSION = '0.0.1';
|
||||||
|
|
||||||
public static $config = array(
|
public static $config = [
|
||||||
// The transport implementation. By default, we use the Guzzle Client
|
// The transport implementation. By default, we use the Guzzle Client
|
||||||
'transport' => 'OpenStack\Common\Transport\Guzzle\GuzzleAdapter',
|
'transport' => 'OpenStack\Common\Transport\Guzzle\GuzzleAdapter',
|
||||||
);
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \OpenStack\Identity\v2\IdentityService An identity services object
|
* @var \OpenStack\Identity\v2\IdentityService An identity services object
|
||||||
|
|||||||
@@ -169,7 +169,7 @@ class IdentityService
|
|||||||
/**
|
/**
|
||||||
* The service catalog.
|
* The service catalog.
|
||||||
*/
|
*/
|
||||||
protected $catalog = array();
|
protected $catalog = [];
|
||||||
|
|
||||||
protected $userDetails;
|
protected $userDetails;
|
||||||
|
|
||||||
@@ -272,9 +272,9 @@ class IdentityService
|
|||||||
public function authenticate(array $ops)
|
public function authenticate(array $ops)
|
||||||
{
|
{
|
||||||
$url = $this->url() . '/tokens';
|
$url = $this->url() . '/tokens';
|
||||||
$envelope = array(
|
$envelope = [
|
||||||
'auth' => $ops,
|
'auth' => $ops,
|
||||||
);
|
];
|
||||||
|
|
||||||
$body = json_encode($envelope);
|
$body = json_encode($envelope);
|
||||||
|
|
||||||
@@ -323,12 +323,12 @@ class IdentityService
|
|||||||
*/
|
*/
|
||||||
public function authenticateAsUser($username, $password, $tenantId = null, $tenantName = null)
|
public function authenticateAsUser($username, $password, $tenantId = null, $tenantName = null)
|
||||||
{
|
{
|
||||||
$ops = array(
|
$ops = [
|
||||||
'passwordCredentials' => array(
|
'passwordCredentials' => [
|
||||||
'username' => $username,
|
'username' => $username,
|
||||||
'password' => $password,
|
'password' => $password,
|
||||||
)
|
]
|
||||||
);
|
];
|
||||||
|
|
||||||
// If a tenant ID is provided, added it to the auth array.
|
// If a tenant ID is provided, added it to the auth array.
|
||||||
if (!empty($tenantId)) {
|
if (!empty($tenantId)) {
|
||||||
@@ -518,7 +518,7 @@ class IdentityService
|
|||||||
return $this->serviceCatalog;
|
return $this->serviceCatalog;
|
||||||
}
|
}
|
||||||
|
|
||||||
$list = array();
|
$list = [];
|
||||||
foreach ($this->serviceCatalog as $entry) {
|
foreach ($this->serviceCatalog as $entry) {
|
||||||
if ($entry['type'] == $type) {
|
if ($entry['type'] == $type) {
|
||||||
$list[] = $entry;
|
$list[] = $entry;
|
||||||
|
|||||||
@@ -233,7 +233,7 @@ class ObjectStorage
|
|||||||
$response = $this->client->get($url, ['headers' => $headers]);
|
$response = $this->client->get($url, ['headers' => $headers]);
|
||||||
$containers = $response->json();
|
$containers = $response->json();
|
||||||
|
|
||||||
$containerList = array();
|
$containerList = [];
|
||||||
foreach ($containers as $container) {
|
foreach ($containers as $container) {
|
||||||
$cname = $container['name'];
|
$cname = $container['name'];
|
||||||
$containerList[$cname] = Container::newFromJSON($container, $this->token(), $this->url(), $this->client);
|
$containerList[$cname] = Container::newFromJSON($container, $this->token(), $this->url(), $this->client);
|
||||||
@@ -354,7 +354,7 @@ class ObjectStorage
|
|||||||
* @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.
|
* was not created because it already exists.
|
||||||
*/
|
*/
|
||||||
public function createContainer($name, ACL $acl = null, $metadata = array())
|
public function createContainer($name, ACL $acl = null, $metadata = [])
|
||||||
{
|
{
|
||||||
$url = $this->url() . '/' . rawurlencode($name);
|
$url = $this->url() . '/' . rawurlencode($name);
|
||||||
$headers = ['X-Auth-Token' => $this->token()];
|
$headers = ['X-Auth-Token' => $this->token()];
|
||||||
@@ -391,7 +391,7 @@ class ObjectStorage
|
|||||||
* you are encouraged to use this alias in cases where you clearly intend
|
* you are encouraged to use this alias in cases where you clearly intend
|
||||||
* to update an existing container.
|
* to update an existing container.
|
||||||
*/
|
*/
|
||||||
public function updateContainer($name, ACL $acl = null, $metadata = array())
|
public function updateContainer($name, ACL $acl = null, $metadata = [])
|
||||||
{
|
{
|
||||||
return $this->createContainer($name, $acl, $metadata);
|
return $this->createContainer($name, $acl, $metadata);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ class ACL
|
|||||||
*/
|
*/
|
||||||
const HEADER_WRITE = 'X-Container-Write';
|
const HEADER_WRITE = 'X-Container-Write';
|
||||||
|
|
||||||
protected $rules = array();
|
protected $rules = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allow READ access to the public.
|
* Allow READ access to the public.
|
||||||
@@ -190,7 +190,7 @@ class ACL
|
|||||||
$acl = new ACL();
|
$acl = new ACL();
|
||||||
|
|
||||||
// READ rules.
|
// READ rules.
|
||||||
$rules = array();
|
$rules = [];
|
||||||
if (!empty($headers[self::HEADER_READ])) {
|
if (!empty($headers[self::HEADER_READ])) {
|
||||||
$read = $headers[self::HEADER_READ];
|
$read = $headers[self::HEADER_READ];
|
||||||
$rules = explode(',', $read);
|
$rules = explode(',', $read);
|
||||||
@@ -203,7 +203,7 @@ class ACL
|
|||||||
}
|
}
|
||||||
|
|
||||||
// WRITE rules.
|
// WRITE rules.
|
||||||
$rules = array();
|
$rules = [];
|
||||||
if (!empty($headers[self::HEADER_WRITE])) {
|
if (!empty($headers[self::HEADER_WRITE])) {
|
||||||
$write = $headers[self::HEADER_WRITE];
|
$write = $headers[self::HEADER_WRITE];
|
||||||
$rules = explode(',', $write);
|
$rules = explode(',', $write);
|
||||||
@@ -245,10 +245,10 @@ class ACL
|
|||||||
// );
|
// );
|
||||||
$exp = '/^\s*(.r:([a-zA-Z0-9\*\-\.]+)|\.(rlistings)|([a-zA-Z0-9]+)(\:([a-zA-Z0-9]+))?)\s*$/';
|
$exp = '/^\s*(.r:([a-zA-Z0-9\*\-\.]+)|\.(rlistings)|([a-zA-Z0-9]+)(\:([a-zA-Z0-9]+))?)\s*$/';
|
||||||
|
|
||||||
$matches = array();
|
$matches = [];
|
||||||
preg_match($exp, $rule, $matches);
|
preg_match($exp, $rule, $matches);
|
||||||
|
|
||||||
$entry = array('mask' => $perm);
|
$entry = ['mask' => $perm];
|
||||||
if (!empty($matches[2])) {
|
if (!empty($matches[2])) {
|
||||||
$entry['host'] = $matches[2];
|
$entry['host'] = $matches[2];
|
||||||
} elseif (!empty($matches[3])) {
|
} elseif (!empty($matches[3])) {
|
||||||
@@ -307,7 +307,7 @@ class ACL
|
|||||||
*/
|
*/
|
||||||
public function addAccount($perm, $account, $user = null)
|
public function addAccount($perm, $account, $user = null)
|
||||||
{
|
{
|
||||||
$rule = array('account' => $account);
|
$rule = ['account' => $account];
|
||||||
|
|
||||||
if (!empty($user)) {
|
if (!empty($user)) {
|
||||||
$rule['user'] = $user;
|
$rule['user'] = $user;
|
||||||
@@ -343,7 +343,7 @@ class ACL
|
|||||||
*/
|
*/
|
||||||
public function addReferrer($perm, $host = '*')
|
public function addReferrer($perm, $host = '*')
|
||||||
{
|
{
|
||||||
$this->addRule($perm, array('host' => $host));
|
$this->addRule($perm, ['host' => $host]);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@@ -382,10 +382,10 @@ class ACL
|
|||||||
*/
|
*/
|
||||||
public function allowListings()
|
public function allowListings()
|
||||||
{
|
{
|
||||||
$this->rules[] = array(
|
$this->rules[] = [
|
||||||
'mask' => self::READ,
|
'mask' => self::READ,
|
||||||
'rlistings' => true,
|
'rlistings' => true,
|
||||||
);
|
];
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@@ -410,9 +410,9 @@ class ACL
|
|||||||
*/
|
*/
|
||||||
public function headers()
|
public function headers()
|
||||||
{
|
{
|
||||||
$headers = array();
|
$headers = [];
|
||||||
$readers = array();
|
$readers = [];
|
||||||
$writers = array();
|
$writers = [];
|
||||||
|
|
||||||
// Create the rule strings. We need two copies, one for READ and
|
// Create the rule strings. We need two copies, one for READ and
|
||||||
// one for WRITE.
|
// one for WRITE.
|
||||||
@@ -477,7 +477,7 @@ class ACL
|
|||||||
|
|
||||||
// Account + multiple users.
|
// Account + multiple users.
|
||||||
elseif (is_array($rule['user'])) {
|
elseif (is_array($rule['user'])) {
|
||||||
$buffer = array();
|
$buffer = [];
|
||||||
foreach ($rule['user'] as $user) {
|
foreach ($rule['user'] as $user) {
|
||||||
$buffer[] = $rule['account'] . ':' . $user;
|
$buffer[] = $rule['account'] . ':' . $user;
|
||||||
}
|
}
|
||||||
@@ -557,7 +557,7 @@ class ACL
|
|||||||
{
|
{
|
||||||
$headers = $this->headers();
|
$headers = $this->headers();
|
||||||
|
|
||||||
$buffer = array();
|
$buffer = [];
|
||||||
foreach ($headers as $k => $v) {
|
foreach ($headers as $k => $v) {
|
||||||
$buffer[] = $k . ': ' . $v;
|
$buffer[] = $k . ': ' . $v;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ class Container implements \Countable, \IteratorAggregate
|
|||||||
if (empty($prefix)) {
|
if (empty($prefix)) {
|
||||||
$prefix = Container::METADATA_HEADER_PREFIX;
|
$prefix = Container::METADATA_HEADER_PREFIX;
|
||||||
}
|
}
|
||||||
$headers = array();
|
$headers = [];
|
||||||
foreach ($metadata as $key => $val) {
|
foreach ($metadata as $key => $val) {
|
||||||
$headers[$prefix . $key] = $val;
|
$headers[$prefix . $key] = $val;
|
||||||
}
|
}
|
||||||
@@ -150,7 +150,7 @@ class Container implements \Countable, \IteratorAggregate
|
|||||||
}
|
}
|
||||||
|
|
||||||
$oParts = explode('/', $oname);
|
$oParts = explode('/', $oname);
|
||||||
$buffer = array();
|
$buffer = [];
|
||||||
foreach ($oParts as $part) {
|
foreach ($oParts as $part) {
|
||||||
$buffer[] = rawurlencode($part);
|
$buffer[] = rawurlencode($part);
|
||||||
}
|
}
|
||||||
@@ -182,7 +182,7 @@ class Container implements \Countable, \IteratorAggregate
|
|||||||
if (empty($prefix)) {
|
if (empty($prefix)) {
|
||||||
$prefix = Container::METADATA_HEADER_PREFIX;
|
$prefix = Container::METADATA_HEADER_PREFIX;
|
||||||
}
|
}
|
||||||
$attributes = array();
|
$attributes = [];
|
||||||
$offset = strlen($prefix);
|
$offset = strlen($prefix);
|
||||||
foreach ($headers as $header => $value) {
|
foreach ($headers as $header => $value) {
|
||||||
|
|
||||||
@@ -465,7 +465,7 @@ class Container implements \Countable, \IteratorAggregate
|
|||||||
$url = self::objectUrl($this->url, $obj->name());
|
$url = self::objectUrl($this->url, $obj->name());
|
||||||
|
|
||||||
// See if we have any metadata.
|
// See if we have any metadata.
|
||||||
$headers = array();
|
$headers = [];
|
||||||
$md = $obj->metadata();
|
$md = $obj->metadata();
|
||||||
if (!empty($md)) {
|
if (!empty($md)) {
|
||||||
$headers = self::generateMetadataHeaders($md, Container::METADATA_HEADER_PREFIX);
|
$headers = self::generateMetadataHeaders($md, Container::METADATA_HEADER_PREFIX);
|
||||||
@@ -943,7 +943,7 @@ class Container implements \Countable, \IteratorAggregate
|
|||||||
* Perform the HTTP query for a list of objects and de-serialize the
|
* Perform the HTTP query for a list of objects and de-serialize the
|
||||||
* results.
|
* results.
|
||||||
*/
|
*/
|
||||||
protected function objectQuery($params = array(), $limit = null, $marker = null)
|
protected function objectQuery($params = [], $limit = null, $marker = null)
|
||||||
{
|
{
|
||||||
if (isset($limit)) {
|
if (isset($limit)) {
|
||||||
$params['limit'] = (int) $limit;
|
$params['limit'] = (int) $limit;
|
||||||
@@ -972,7 +972,7 @@ class Container implements \Countable, \IteratorAggregate
|
|||||||
$json = $response->json();
|
$json = $response->json();
|
||||||
|
|
||||||
// Turn the array into a list of RemoteObject instances.
|
// Turn the array into a list of RemoteObject instances.
|
||||||
$list = array();
|
$list = [];
|
||||||
foreach ($json as $item) {
|
foreach ($json as $item) {
|
||||||
if (!empty($item['subdir'])) {
|
if (!empty($item['subdir'])) {
|
||||||
$list[] = new Subdir($item['subdir'], $params['delimiter']);
|
$list[] = new Subdir($item['subdir'], $params['delimiter']);
|
||||||
@@ -1029,9 +1029,9 @@ class Container implements \Countable, \IteratorAggregate
|
|||||||
public function delete($name)
|
public function delete($name)
|
||||||
{
|
{
|
||||||
$url = self::objectUrl($this->url, $name);
|
$url = self::objectUrl($this->url, $name);
|
||||||
$headers = array(
|
$headers = [
|
||||||
'X-Auth-Token' => $this->token,
|
'X-Auth-Token' => $this->token,
|
||||||
);
|
];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$response = $this->client->delete($url, ['headers' => $headers]);
|
$response = $this->client->delete($url, ['headers' => $headers]);
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ class Object
|
|||||||
/**
|
/**
|
||||||
* Associative array of stored metadata.
|
* Associative array of stored metadata.
|
||||||
*/
|
*/
|
||||||
protected $metadata = array();
|
protected $metadata = [];
|
||||||
|
|
||||||
protected $contentEncoding;
|
protected $contentEncoding;
|
||||||
protected $contentDisposition;
|
protected $contentDisposition;
|
||||||
@@ -85,7 +85,7 @@ class Object
|
|||||||
/**
|
/**
|
||||||
* Extension mechanism for new headers.
|
* Extension mechanism for new headers.
|
||||||
*/
|
*/
|
||||||
protected $additionalHeaders = array();
|
protected $additionalHeaders = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new object for storage.
|
* Construct a new object for storage.
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ class RemoteObject extends Object
|
|||||||
* serve as a good indicator that the object does not have all
|
* serve as a good indicator that the object does not have all
|
||||||
* attributes set.
|
* attributes set.
|
||||||
*/
|
*/
|
||||||
protected $allHeaders = array();
|
protected $allHeaders = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The HTTP Client
|
* The HTTP Client
|
||||||
@@ -232,7 +232,7 @@ class RemoteObject extends Object
|
|||||||
*/
|
*/
|
||||||
public function setHeaders($headers)
|
public function setHeaders($headers)
|
||||||
{
|
{
|
||||||
$this->allHeaders = array();
|
$this->allHeaders = [];
|
||||||
|
|
||||||
foreach ($headers as $name => $value) {
|
foreach ($headers as $name => $value) {
|
||||||
if (strpos($name, Container::METADATA_HEADER_PREFIX) !== 0) {
|
if (strpos($name, Container::METADATA_HEADER_PREFIX) !== 0) {
|
||||||
@@ -274,12 +274,12 @@ class RemoteObject extends Object
|
|||||||
return $additionalHeaders;
|
return $additionalHeaders;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected $reservedHeaders = array(
|
protected $reservedHeaders = [
|
||||||
'etag' => true, 'content-length' => true,
|
'etag' => true, 'content-length' => true,
|
||||||
'x-auth-token' => true,
|
'x-auth-token' => true,
|
||||||
'transfer-encoding' => true,
|
'transfer-encoding' => true,
|
||||||
'x-trans-id' => true,
|
'x-trans-id' => true,
|
||||||
);
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter the headers.
|
* Filter the headers.
|
||||||
@@ -289,7 +289,7 @@ class RemoteObject extends Object
|
|||||||
*/
|
*/
|
||||||
public function filterHeaders(&$headers)
|
public function filterHeaders(&$headers)
|
||||||
{
|
{
|
||||||
$unset = array();
|
$unset = [];
|
||||||
foreach ($headers as $name => $value) {
|
foreach ($headers as $name => $value) {
|
||||||
$lower = strtolower($name);
|
$lower = strtolower($name);
|
||||||
if (isset($this->reservedHeaders[$lower])) {
|
if (isset($this->reservedHeaders[$lower])) {
|
||||||
|
|||||||
@@ -252,7 +252,7 @@ class StreamWrapper
|
|||||||
* course of a request. Caching the catalog can prevent numerous calls
|
* course of a request. Caching the catalog can prevent numerous calls
|
||||||
* to identity services.
|
* to identity services.
|
||||||
*/
|
*/
|
||||||
protected static $serviceCatalogCache = array();
|
protected static $serviceCatalogCache = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The stream context.
|
* The stream context.
|
||||||
@@ -261,7 +261,7 @@ class StreamWrapper
|
|||||||
* PHP. Note that it is not set through a constructor.
|
* PHP. Note that it is not set through a constructor.
|
||||||
*/
|
*/
|
||||||
public $context;
|
public $context;
|
||||||
protected $contextArray = array();
|
protected $contextArray = [];
|
||||||
|
|
||||||
protected $schemeName = self::DEFAULT_SCHEME;
|
protected $schemeName = self::DEFAULT_SCHEME;
|
||||||
protected $authToken;
|
protected $authToken;
|
||||||
@@ -317,7 +317,7 @@ class StreamWrapper
|
|||||||
*
|
*
|
||||||
* Used for directory methods.
|
* Used for directory methods.
|
||||||
*/
|
*/
|
||||||
protected $dirListing = array();
|
protected $dirListing = [];
|
||||||
protected $dirIndex = 0;
|
protected $dirIndex = 0;
|
||||||
protected $dirPrefix = '';
|
protected $dirPrefix = '';
|
||||||
|
|
||||||
@@ -345,7 +345,7 @@ class StreamWrapper
|
|||||||
public function dir_closedir()
|
public function dir_closedir()
|
||||||
{
|
{
|
||||||
$this->dirIndex = 0;
|
$this->dirIndex = 0;
|
||||||
$this->dirListing = array();
|
$this->dirListing = [];
|
||||||
|
|
||||||
//syslog(LOG_WARNING, "CLOSEDIR called.");
|
//syslog(LOG_WARNING, "CLOSEDIR called.");
|
||||||
return true;
|
return true;
|
||||||
@@ -1215,7 +1215,7 @@ class StreamWrapper
|
|||||||
} else {
|
} else {
|
||||||
$modTime = 0;
|
$modTime = 0;
|
||||||
}
|
}
|
||||||
$values = array(
|
$values = [
|
||||||
'dev' => 0,
|
'dev' => 0,
|
||||||
'ino' => 0,
|
'ino' => 0,
|
||||||
'mode' => $mode,
|
'mode' => $mode,
|
||||||
@@ -1229,7 +1229,7 @@ class StreamWrapper
|
|||||||
'ctime' => $modTime,
|
'ctime' => $modTime,
|
||||||
'blksize' => -1,
|
'blksize' => -1,
|
||||||
'blocks' => -1,
|
'blocks' => -1,
|
||||||
);
|
];
|
||||||
|
|
||||||
$final = array_values($values) + $values;
|
$final = array_values($values) + $values;
|
||||||
|
|
||||||
|
|||||||
@@ -191,7 +191,7 @@ class StreamWrapperFS extends StreamWrapper
|
|||||||
// Fake world-readible
|
// Fake world-readible
|
||||||
$mode = $type + $this->cxt('swiftfs_fake_stat_mode', 0777);
|
$mode = $type + $this->cxt('swiftfs_fake_stat_mode', 0777);
|
||||||
|
|
||||||
$values = array(
|
$values = [
|
||||||
'dev' => 0,
|
'dev' => 0,
|
||||||
'ino' => 0,
|
'ino' => 0,
|
||||||
'mode' => $mode,
|
'mode' => $mode,
|
||||||
@@ -205,7 +205,7 @@ class StreamWrapperFS extends StreamWrapper
|
|||||||
'ctime' => $request_time,
|
'ctime' => $request_time,
|
||||||
'blksize' => -1,
|
'blksize' => -1,
|
||||||
'blocks' => -1,
|
'blocks' => -1,
|
||||||
);
|
];
|
||||||
|
|
||||||
$final = array_values($values) + $values;
|
$final = array_values($values) + $values;
|
||||||
|
|
||||||
|
|||||||
@@ -26,12 +26,12 @@ require_once $base . '/vendor/autoloader.php';
|
|||||||
use \OpenStack\ObjectStore\v1\ObjectStorage;
|
use \OpenStack\ObjectStore\v1\ObjectStorage;
|
||||||
use \OpenStack\Identity\v2\IdentityService;
|
use \OpenStack\Identity\v2\IdentityService;
|
||||||
|
|
||||||
$config = array(
|
$config = [
|
||||||
'transport' => 'OpenStack\Common\Transport\Guzzle\GuzzleAdapter',
|
'transport' => 'OpenStack\Common\Transport\Guzzle\GuzzleAdapter',
|
||||||
'transport.timeout' => 240,
|
'transport.timeout' => 240,
|
||||||
//'transport.debug' => 1,
|
//'transport.debug' => 1,
|
||||||
'transport.ssl.verify' => 0,
|
'transport.ssl.verify' => 0,
|
||||||
);
|
];
|
||||||
|
|
||||||
\OpenStack\Autoloader::useAutoloader();
|
\OpenStack\Autoloader::useAutoloader();
|
||||||
\OpenStack\Bootstrap::setConfiguration($config);
|
\OpenStack\Bootstrap::setConfiguration($config);
|
||||||
|
|||||||
@@ -57,34 +57,34 @@ class IdentityServicesTest extends \OpenStack\Tests\TestCase
|
|||||||
public function testAuthenticate($service)
|
public function testAuthenticate($service)
|
||||||
{
|
{
|
||||||
// Canary: Make sure all the required params are declared.
|
// Canary: Make sure all the required params are declared.
|
||||||
$settings = array(
|
$settings = [
|
||||||
'openstack.identity.username',
|
'openstack.identity.username',
|
||||||
'openstack.identity.password',
|
'openstack.identity.password',
|
||||||
'openstack.identity.tenantId',
|
'openstack.identity.tenantId',
|
||||||
);
|
];
|
||||||
foreach ($settings as $setting) {
|
foreach ($settings as $setting) {
|
||||||
$this->assertNotEmpty(self::conf($setting), "Required param: " . $setting);
|
$this->assertNotEmpty(self::conf($setting), "Required param: " . $setting);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test username/password auth.
|
// Test username/password auth.
|
||||||
$auth = array(
|
$auth = [
|
||||||
'passwordCredentials' => array(
|
'passwordCredentials' => [
|
||||||
'username' => self::conf('openstack.identity.username'),
|
'username' => self::conf('openstack.identity.username'),
|
||||||
'password' => self::conf('openstack.identity.password'),
|
'password' => self::conf('openstack.identity.password'),
|
||||||
),
|
],
|
||||||
'tenantId' => self::conf('openstack.identity.tenantId'),
|
'tenantId' => self::conf('openstack.identity.tenantId'),
|
||||||
);
|
];
|
||||||
$tok = $service->authenticate($auth);
|
$tok = $service->authenticate($auth);
|
||||||
$this->assertNotEmpty($tok);
|
$this->assertNotEmpty($tok);
|
||||||
|
|
||||||
// Again with no tenant ID.
|
// Again with no tenant ID.
|
||||||
$auth = array(
|
$auth = [
|
||||||
'passwordCredentials' => array(
|
'passwordCredentials' => [
|
||||||
'username' => self::conf('openstack.identity.username'),
|
'username' => self::conf('openstack.identity.username'),
|
||||||
'password' => self::conf('openstack.identity.password'),
|
'password' => self::conf('openstack.identity.password'),
|
||||||
),
|
],
|
||||||
//'tenantId' => self::conf('openstack.identity.tenantId'),
|
//'tenantId' => self::conf('openstack.identity.tenantId'),
|
||||||
);
|
];
|
||||||
$tok = $service->authenticate($auth);
|
$tok = $service->authenticate($auth);
|
||||||
$this->assertNotEmpty($tok);
|
$this->assertNotEmpty($tok);
|
||||||
}
|
}
|
||||||
@@ -385,7 +385,7 @@ class IdentityServicesTest extends \OpenStack\Tests\TestCase
|
|||||||
$reset = Bootstrap::$config;
|
$reset = Bootstrap::$config;
|
||||||
|
|
||||||
// Test authenticating as a user.
|
// Test authenticating as a user.
|
||||||
$settings = array(
|
$settings = [
|
||||||
'username' => self::conf('openstack.identity.username'),
|
'username' => self::conf('openstack.identity.username'),
|
||||||
'password' => self::conf('openstack.identity.password'),
|
'password' => self::conf('openstack.identity.password'),
|
||||||
'endpoint' => self::conf('openstack.identity.url'),
|
'endpoint' => self::conf('openstack.identity.url'),
|
||||||
@@ -393,7 +393,7 @@ class IdentityServicesTest extends \OpenStack\Tests\TestCase
|
|||||||
'transport' => self::conf('transport'),
|
'transport' => self::conf('transport'),
|
||||||
'transport.debug' => self::conf('transport.debug', false),
|
'transport.debug' => self::conf('transport.debug', false),
|
||||||
'transport.ssl_verify' => self::conf('transport.ssl', true),
|
'transport.ssl_verify' => self::conf('transport.ssl', true),
|
||||||
);
|
];
|
||||||
if (self::conf('transport.timeout')) {
|
if (self::conf('transport.timeout')) {
|
||||||
$setting['transport.timeout'] = self::conf('transport.timeout');
|
$setting['transport.timeout'] = self::conf('transport.timeout');
|
||||||
}
|
}
|
||||||
@@ -416,7 +416,7 @@ class IdentityServicesTest extends \OpenStack\Tests\TestCase
|
|||||||
Bootstrap::$config = $reset;
|
Bootstrap::$config = $reset;
|
||||||
|
|
||||||
// Test with tenant name
|
// Test with tenant name
|
||||||
$settings = array(
|
$settings = [
|
||||||
'username' => self::conf('openstack.identity.username'),
|
'username' => self::conf('openstack.identity.username'),
|
||||||
'password' => self::conf('openstack.identity.password'),
|
'password' => self::conf('openstack.identity.password'),
|
||||||
'endpoint' => self::conf('openstack.identity.url'),
|
'endpoint' => self::conf('openstack.identity.url'),
|
||||||
@@ -424,7 +424,7 @@ class IdentityServicesTest extends \OpenStack\Tests\TestCase
|
|||||||
'transport' => self::conf('transport'),
|
'transport' => self::conf('transport'),
|
||||||
'transport.debug' => self::conf('transport.debug', false),
|
'transport.debug' => self::conf('transport.debug', false),
|
||||||
'transport.ssl_verify' => self::conf('transport.ssl', true),
|
'transport.ssl_verify' => self::conf('transport.ssl', true),
|
||||||
);
|
];
|
||||||
if (self::conf('transport.timeout')) {
|
if (self::conf('transport.timeout')) {
|
||||||
$setting['transport.timeout'] = self::conf('transport.timeout');
|
$setting['transport.timeout'] = self::conf('transport.timeout');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ class ObjectStorageTest extends \OpenStack\Tests\TestCase
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$md = array('Foo' => 1234);
|
$md = ['Foo' => 1234];
|
||||||
|
|
||||||
$ret = $store->createContainer($testCollection, null, $md);
|
$ret = $store->createContainer($testCollection, null, $md);
|
||||||
$this->assertTrue($ret, "Create container");
|
$this->assertTrue($ret, "Create container");
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ class ACLTest extends \OpenStack\Tests\TestCase
|
|||||||
|
|
||||||
// Test with multiple users:
|
// Test with multiple users:
|
||||||
$acl = new ACL();
|
$acl = new ACL();
|
||||||
$acl->addAccount(ACL::WRITE, 'admin', array('earnie', 'bert'));
|
$acl->addAccount(ACL::WRITE, 'admin', ['earnie', 'bert']);
|
||||||
$rules = $acl->rules();
|
$rules = $acl->rules();
|
||||||
$rule = array_shift($rules);
|
$rule = array_shift($rules);
|
||||||
|
|
||||||
@@ -147,10 +147,10 @@ class ACLTest extends \OpenStack\Tests\TestCase
|
|||||||
|
|
||||||
public function testNewFromHeaders()
|
public function testNewFromHeaders()
|
||||||
{
|
{
|
||||||
$headers = array(
|
$headers = [
|
||||||
ACL::HEADER_READ => '.r:.example.com,.rlistings,.r:-*.evil.net',
|
ACL::HEADER_READ => '.r:.example.com,.rlistings,.r:-*.evil.net',
|
||||||
ACL::HEADER_WRITE => 'testact2, testact3:earnie, .rlistings ',
|
ACL::HEADER_WRITE => 'testact2, testact3:earnie, .rlistings ',
|
||||||
);
|
];
|
||||||
|
|
||||||
$acl = ACL::newFromHeaders($headers);
|
$acl = ACL::newFromHeaders($headers);
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,8 @@ class ContainerTest extends TestCase
|
|||||||
public function testCountable()
|
public function testCountable()
|
||||||
{
|
{
|
||||||
// Verify that the interface Countable is properly implemented.
|
// Verify that the interface Countable is properly implemented.
|
||||||
$mockJSON = array('count' => 5, 'bytes' => 128, 'name' => 'foo');
|
|
||||||
|
$mockJSON = ['count' => 5, 'bytes' => 128, 'name' => 'foo'];
|
||||||
$container = Container::newFromJSON($mockJSON, 'fake', 'fake');
|
$container = Container::newFromJSON($mockJSON, 'fake', 'fake');
|
||||||
$this->assertCount(5, $container);
|
$this->assertCount(5, $container);
|
||||||
}
|
}
|
||||||
@@ -64,7 +65,7 @@ class ContainerTest extends TestCase
|
|||||||
$container = $this->containerFixture();
|
$container = $this->containerFixture();
|
||||||
|
|
||||||
$object = new Object(self::FNAME, self::FCONTENT, self::FTYPE);
|
$object = new Object(self::FNAME, self::FCONTENT, self::FTYPE);
|
||||||
$object->setMetadata(array('foo' => '1234'));
|
$object->setMetadata(['foo' => '1234']);
|
||||||
|
|
||||||
$this->assertEquals(self::FCONTENT, $object->content());
|
$this->assertEquals(self::FCONTENT, $object->content());
|
||||||
|
|
||||||
|
|||||||
@@ -110,12 +110,12 @@ class ObjectTest extends \OpenStack\Tests\TestCase
|
|||||||
|
|
||||||
public function testMetadata()
|
public function testMetadata()
|
||||||
{
|
{
|
||||||
$md = array(
|
$md = [
|
||||||
'Immanuel' => 'Kant',
|
'Immanuel' => 'Kant',
|
||||||
'David' => 'Hume',
|
'David' => 'Hume',
|
||||||
'Gottfried' => 'Leibniz',
|
'Gottfried' => 'Leibniz',
|
||||||
'Jean-Jaques' => 'Rousseau',
|
'Jean-Jaques' => 'Rousseau',
|
||||||
);
|
];
|
||||||
|
|
||||||
$o = $this->basicObjectFixture();
|
$o = $this->basicObjectFixture();
|
||||||
$o->setMetadata($md);
|
$o->setMetadata($md);
|
||||||
@@ -132,17 +132,17 @@ class ObjectTest extends \OpenStack\Tests\TestCase
|
|||||||
{
|
{
|
||||||
$o = $this->basicObjectFixture();
|
$o = $this->basicObjectFixture();
|
||||||
|
|
||||||
$extra = array(
|
$extra = [
|
||||||
'a' => 'b',
|
'a' => 'b',
|
||||||
'aaa' => 'bbb',
|
'aaa' => 'bbb',
|
||||||
'ccc' => 'bbb',
|
'ccc' => 'bbb',
|
||||||
);
|
];
|
||||||
$o->setAdditionalHeaders($extra);
|
$o->setAdditionalHeaders($extra);
|
||||||
|
|
||||||
$got = $o->additionalHeaders();
|
$got = $o->additionalHeaders();
|
||||||
$this->assertEquals(3, count($got));
|
$this->assertEquals(3, count($got));
|
||||||
|
|
||||||
$o->removeHeaders(array('ccc'));
|
$o->removeHeaders(['ccc']);
|
||||||
|
|
||||||
$got = $o->additionalHeaders();
|
$got = $o->additionalHeaders();
|
||||||
$this->assertEquals(2, count($got));
|
$this->assertEquals(2, count($got));
|
||||||
|
|||||||
@@ -41,13 +41,13 @@ class RemoteObjectTest extends \OpenStack\Tests\TestCase
|
|||||||
$container = $this->containerFixture();
|
$container = $this->containerFixture();
|
||||||
|
|
||||||
$object = new Object(self::FNAME, self::FCONTENT, self::FTYPE);
|
$object = new Object(self::FNAME, self::FCONTENT, self::FTYPE);
|
||||||
$object->setMetadata(array(self::FMETA_NAME => self::FMETA_VALUE));
|
$object->setMetadata([self::FMETA_NAME => self::FMETA_VALUE]);
|
||||||
$object->setDisposition(self::FDISPOSITION);
|
$object->setDisposition(self::FDISPOSITION);
|
||||||
$object->setEncoding(self::FENCODING);
|
$object->setEncoding(self::FENCODING);
|
||||||
$object->setAdditionalHeaders(array(
|
$object->setAdditionalHeaders([
|
||||||
'Access-Control-Allow-Origin' => 'http://example.com',
|
'Access-Control-Allow-Origin' => 'http://example.com',
|
||||||
'Access-control-allow-origin' => 'http://example.com',
|
'Access-control-allow-origin' => 'http://example.com',
|
||||||
));
|
]);
|
||||||
|
|
||||||
// Need some headers that Swift actually stores and returns. This
|
// Need some headers that Swift actually stores and returns. This
|
||||||
// one does not seem to be returned ever.
|
// one does not seem to be returned ever.
|
||||||
@@ -154,7 +154,7 @@ class RemoteObjectTest extends \OpenStack\Tests\TestCase
|
|||||||
|
|
||||||
$this->assertNotEmpty($headers['Date']);
|
$this->assertNotEmpty($headers['Date']);
|
||||||
|
|
||||||
$obj->removeHeaders(array('Date'));
|
$obj->removeHeaders(['Date']);
|
||||||
|
|
||||||
$headers = $obj->headers();
|
$headers = $obj->headers();
|
||||||
$this->assertFalse(isset($headers['Date']));
|
$this->assertFalse(isset($headers['Date']));
|
||||||
|
|||||||
@@ -18,6 +18,6 @@
|
|||||||
* Helpers for testing using the CurlTransport.
|
* Helpers for testing using the CurlTransport.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$bootstrap_settings = array(
|
$bootstrap_settings = [
|
||||||
'transport' => '\OpenStack\Transport\CURLTransport',
|
'transport' => '\OpenStack\Transport\CURLTransport',
|
||||||
);
|
];
|
||||||
|
|||||||
@@ -18,6 +18,6 @@
|
|||||||
* Helpers for testing using the CurlTransport.
|
* Helpers for testing using the CurlTransport.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$bootstrap_settings = array(
|
$bootstrap_settings = [
|
||||||
'transport' => '\OpenStack\Transport\PHPStreamTransport',
|
'transport' => '\OpenStack\Transport\PHPStreamTransport',
|
||||||
);
|
];
|
||||||
|
|||||||
Reference in New Issue
Block a user