THRIFT-4460: Use PSR-2 as php library coding standard
Client: php
This closes #1472
diff --git a/lib/php/lib/ClassLoader/ThriftClassLoader.php b/lib/php/lib/ClassLoader/ThriftClassLoader.php
index 67575ce..4361bd8 100644
--- a/lib/php/lib/ClassLoader/ThriftClassLoader.php
+++ b/lib/php/lib/ClassLoader/ThriftClassLoader.php
@@ -54,7 +54,7 @@
/**
* Set autoloader to use APC cache
* @param boolean $apc
- * @param string $apc_prefix
+ * @param string $apc_prefix
*/
public function __construct($apc = false, $apc_prefix = null)
{
@@ -65,23 +65,23 @@
/**
* Registers a namespace.
*
- * @param string $namespace The namespace
- * @param array|string $paths The location(s) of the namespace
+ * @param string $namespace The namespace
+ * @param array|string $paths The location(s) of the namespace
*/
public function registerNamespace($namespace, $paths)
{
- $this->namespaces[$namespace] = (array) $paths;
+ $this->namespaces[$namespace] = (array)$paths;
}
/**
* Registers a Thrift definition namespace.
*
- * @param string $namespace The definition namespace
- * @param array|string $paths The location(s) of the definition namespace
+ * @param string $namespace The definition namespace
+ * @param array|string $paths The location(s) of the definition namespace
*/
public function registerDefinition($namespace, $paths)
{
- $this->definitions[$namespace] = (array) $paths;
+ $this->definitions[$namespace] = (array)$paths;
}
/**
@@ -101,11 +101,9 @@
*/
public function loadClass($class)
{
- if (
- (true === $this->apc && ($file = $this->findFileInApc($class))) or
+ if ((true === $this->apc && ($file = $this->findFileInApc($class))) or
($file = $this->findFile($class))
- )
- {
+ ) {
require_once $file;
}
}
@@ -117,8 +115,8 @@
*/
protected function findFileInApc($class)
{
- if (false === $file = apc_fetch($this->apc_prefix.$class)) {
- apc_store($this->apc_prefix.$class, $file = $this->findFile($class));
+ if (false === $file = apc_fetch($this->apc_prefix . $class)) {
+ apc_store($this->apc_prefix . $class, $file = $this->findFile($class));
}
return $file;
@@ -150,10 +148,10 @@
foreach ($dirs as $dir) {
$className = substr($class, $pos + 1);
- $file = $dir.DIRECTORY_SEPARATOR.
- str_replace('\\', DIRECTORY_SEPARATOR, $namespace).
- DIRECTORY_SEPARATOR.
- $className.'.php';
+ $file = $dir . DIRECTORY_SEPARATOR .
+ str_replace('\\', DIRECTORY_SEPARATOR, $namespace) .
+ DIRECTORY_SEPARATOR .
+ $className . '.php';
if (file_exists($file)) {
return $file;
@@ -185,20 +183,18 @@
* Available in service: Interface, Client, Processor, Rest
* And every service methods (_.+)
*/
- if(
- 0 === preg_match('#(.+)(if|client|processor|rest)$#i', $class, $n) and
+ if (0 === preg_match('#(.+)(if|client|processor|rest)$#i', $class, $n) and
0 === preg_match('#(.+)_[a-z0-9]+_(args|result)$#i', $class, $n)
- )
- {
+ ) {
$className = 'Types';
} else {
$className = $n[1];
}
- $file = $dir.DIRECTORY_SEPARATOR .
- str_replace('\\', DIRECTORY_SEPARATOR, $namespace) .
- DIRECTORY_SEPARATOR .
- $className . '.php';
+ $file = $dir . DIRECTORY_SEPARATOR .
+ str_replace('\\', DIRECTORY_SEPARATOR, $namespace) .
+ DIRECTORY_SEPARATOR .
+ $className . '.php';
if (file_exists($file)) {
return $file;