[Pkg-owncloud-commits] [php-sabredav] 08/34: CS fixer for examples

David Prévot taffit at moszumanska.debian.org
Wed May 27 13:57:07 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to tag 3.0.0-beta1
in repository php-sabredav.

commit 7d13e61c935034fd1e308b8968eed455adf84871
Author: Evert Pot <me at evertpot.com>
Date:   Tue May 19 21:59:16 2015 +0300

    CS fixer for examples
---
 examples/addressbookserver.php        |  6 ++--
 examples/calendarserver.php           |  6 ++--
 examples/fileserver.php               |  2 +-
 examples/groupwareserver.php          |  6 ++--
 examples/simplefsserver.php           |  8 ++---
 lib/DAV/CorePlugin.php                | 55 +++++++++++++++++------------------
 lib/DAV/TemporaryFileFilterPlugin.php |  6 ++--
 7 files changed, 44 insertions(+), 45 deletions(-)

diff --git a/examples/addressbookserver.php b/examples/addressbookserver.php
index 4ae78f7..befd9f1 100644
--- a/examples/addressbookserver.php
+++ b/examples/addressbookserver.php
@@ -17,10 +17,10 @@ $baseUri = '/';
 
 /* Database */
 $pdo = new PDO('sqlite:data/db.sqlite');
-$pdo->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
+$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
 
 //Mapping PHP errors to exceptions
-function exception_error_handler($errno, $errstr, $errfile, $errline ) {
+function exception_error_handler($errno, $errstr, $errfile, $errline) {
     throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
 }
 set_error_handler("exception_error_handler");
@@ -46,7 +46,7 @@ $server = new Sabre\DAV\Server($nodes);
 $server->setBaseUri($baseUri);
 
 // Plugins
-$server->addPlugin(new Sabre\DAV\Auth\Plugin($authBackend,'SabreDAV'));
+$server->addPlugin(new Sabre\DAV\Auth\Plugin($authBackend, 'SabreDAV'));
 $server->addPlugin(new Sabre\DAV\Browser\Plugin());
 //$server->addPlugin(new Sabre\CalDAV\Plugin());
 $server->addPlugin(new Sabre\CardDAV\Plugin());
diff --git a/examples/calendarserver.php b/examples/calendarserver.php
index de08a10..408a34f 100644
--- a/examples/calendarserver.php
+++ b/examples/calendarserver.php
@@ -17,10 +17,10 @@ date_default_timezone_set('Canada/Eastern');
 
 /* Database */
 $pdo = new PDO('sqlite:data/db.sqlite');
-$pdo->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
+$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
 
 //Mapping PHP errors to exceptions
-function exception_error_handler($errno, $errstr, $errfile, $errline ) {
+function exception_error_handler($errno, $errstr, $errfile, $errline) {
     throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
 }
 set_error_handler("exception_error_handler");
@@ -45,7 +45,7 @@ if (isset($baseUri))
     $server->setBaseUri($baseUri);
 
 /* Server Plugins */
-$authPlugin = new Sabre\DAV\Auth\Plugin($authBackend,'SabreDAV');
+$authPlugin = new Sabre\DAV\Auth\Plugin($authBackend, 'SabreDAV');
 $server->addPlugin($authPlugin);
 
 $aclPlugin = new Sabre\DAVACL\Plugin();
diff --git a/examples/fileserver.php b/examples/fileserver.php
index 952b550..df60a1e 100644
--- a/examples/fileserver.php
+++ b/examples/fileserver.php
@@ -45,7 +45,7 @@ $server->addPlugin(new \Sabre\DAV\Browser\GuessContentType());
 
 // Authentication backend
 $authBackend = new \Sabre\DAV\Auth\Backend\File('.htdigest');
-$auth = new \Sabre\DAV\Auth\Plugin($authBackend,'SabreDAV');
+$auth = new \Sabre\DAV\Auth\Plugin($authBackend, 'SabreDAV');
 $server->addPlugin($auth);
 
 // Temporary file filter
diff --git a/examples/groupwareserver.php b/examples/groupwareserver.php
index 668b92b..6acb6e5 100644
--- a/examples/groupwareserver.php
+++ b/examples/groupwareserver.php
@@ -33,7 +33,7 @@ date_default_timezone_set('UTC');
  * concurrency.
  */
 $pdo = new \PDO('sqlite:data/db.sqlite');
-$pdo->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
+$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
 
 /**
  * Mapping PHP errors to exceptions.
@@ -42,7 +42,7 @@ $pdo->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
  * E_NOTICE or anything appears in your code, this allows SabreDAV to intercept
  * the issue and send a proper response back to the client (HTTP/1.1 500).
  */
-function exception_error_handler($errno, $errstr, $errfile, $errline ) {
+function exception_error_handler($errno, $errstr, $errfile, $errline) {
     throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
 }
 set_error_handler("exception_error_handler");
@@ -81,7 +81,7 @@ $server = new \Sabre\DAV\Server($nodes);
 if (isset($baseUri)) $server->setBaseUri($baseUri);
 
 // Plugins
-$server->addPlugin(new \Sabre\DAV\Auth\Plugin($authBackend,'SabreDAV'));
+$server->addPlugin(new \Sabre\DAV\Auth\Plugin($authBackend, 'SabreDAV'));
 $server->addPlugin(new \Sabre\DAV\Browser\Plugin());
 $server->addPlugin(new \Sabre\CalDAV\Plugin());
 $server->addPlugin(new \Sabre\CardDAV\Plugin());
diff --git a/examples/simplefsserver.php b/examples/simplefsserver.php
index cf64730..ad0679b 100644
--- a/examples/simplefsserver.php
+++ b/examples/simplefsserver.php
@@ -40,10 +40,10 @@ class MyCollection extends Sabre\DAV\Collection {
 
     $children = [];
     // Loop through the directory, and create objects for each node
-    foreach(scandir($this->myPath) as $node) {
+    foreach (scandir($this->myPath) as $node) {
 
       // Ignoring files staring with .
-      if ($node[0]==='.') continue;
+      if ($node[0] === '.') continue;
 
       $children[] = $this->getChild($node);
 
@@ -61,7 +61,7 @@ class MyCollection extends Sabre\DAV\Collection {
         if (!file_exists($this->myPath)) throw new \Sabre\DAV\Exception\NotFound('The file with name: ' . $name . ' could not be found');
         // Some added security
 
-        if ($name[0]=='.')  throw new \Sabre\DAV\Exception\Forbidden('Access denied');
+        if ($name[0] == '.')  throw new \Sabre\DAV\Exception\Forbidden('Access denied');
 
         if (is_dir($path)) {
 
@@ -101,7 +101,7 @@ class MyFile extends \Sabre\DAV\File {
 
   function get() {
 
-    return fopen($this->myPath,'r');
+    return fopen($this->myPath, 'r');
 
   }
 
diff --git a/lib/DAV/CorePlugin.php b/lib/DAV/CorePlugin.php
index e8277d9..5c37400 100644
--- a/lib/DAV/CorePlugin.php
+++ b/lib/DAV/CorePlugin.php
@@ -2,11 +2,10 @@
 
 namespace Sabre\DAV;
 
-use
-    Sabre\DAV\Exception\BadRequest,
-    Sabre\HTTP\RequestInterface,
-    Sabre\HTTP\ResponseInterface,
-    Sabre\Xml\ParseException;
+use Sabre\DAV\Exception\BadRequest;
+use Sabre\HTTP\RequestInterface;
+use Sabre\HTTP\ResponseInterface;
+use Sabre\Xml\ParseException;
 
 /**
  * The core plugin provides all the basic features for a WebDAV server.
@@ -77,7 +76,7 @@ class CorePlugin extends ServerPlugin {
     function httpGet(RequestInterface $request, ResponseInterface $response) {
 
         $path = $request->getPath();
-        $node = $this->server->tree->getNodeForPath($path,0);
+        $node = $this->server->tree->getNodeForPath($path, 0);
 
         if (!$node instanceof IFile) return;
 
@@ -85,8 +84,8 @@ class CorePlugin extends ServerPlugin {
 
         // Converting string into stream, if needed.
         if (is_string($body)) {
-            $stream = fopen('php://temp','r+');
-            fwrite($stream,$body);
+            $stream = fopen('php://temp', 'r+');
+            fwrite($stream, $body);
             rewind($stream);
             $body = $stream;
         }
@@ -136,14 +135,14 @@ class CorePlugin extends ServerPlugin {
                 if (!isset($httpHeaders['Last-Modified'])) $ignoreRangeHeader = true;
                 else {
                     $modified = new \DateTime($httpHeaders['Last-Modified']);
-                    if($modified > $ifRangeDate) $ignoreRangeHeader = true;
+                    if ($modified > $ifRangeDate) $ignoreRangeHeader = true;
                 }
 
             } catch (\Exception $e) {
 
                 // It's an entity. We can do a simple comparison.
                 if (!isset($httpHeaders['ETag'])) $ignoreRangeHeader = true;
-                elseif ($httpHeaders['ETag']!==$ifRange) $ignoreRangeHeader = true;
+                elseif ($httpHeaders['ETag'] !== $ifRange) $ignoreRangeHeader = true;
             }
         }
 
@@ -155,18 +154,18 @@ class CorePlugin extends ServerPlugin {
 
                 $start = $range[0];
                 $end = $range[1] ? $range[1] : $nodeSize - 1;
-                if($start >= $nodeSize)
+                if ($start >= $nodeSize)
                     throw new Exception\RequestedRangeNotSatisfiable('The start offset (' . $range[0] . ') exceeded the size of the entity (' . $nodeSize . ')');
 
-                if($end < $start) throw new Exception\RequestedRangeNotSatisfiable('The end offset (' . $range[1] . ') is lower than the start offset (' . $range[0] . ')');
-                if($end >= $nodeSize) $end = $nodeSize - 1;
+                if ($end < $start) throw new Exception\RequestedRangeNotSatisfiable('The end offset (' . $range[1] . ') is lower than the start offset (' . $range[0] . ')');
+                if ($end >= $nodeSize) $end = $nodeSize - 1;
 
             } else {
 
                 $start = $nodeSize - $range[1];
                 $end  = $nodeSize - 1;
 
-                if ($start<0) $start = 0;
+                if ($start < 0) $start = 0;
 
             }
 
@@ -177,14 +176,14 @@ class CorePlugin extends ServerPlugin {
                 fseek($body, $start, SEEK_SET);
             } else {
                 $consumeBlock = 8192;
-                for($consumed = 0; $start - $consumed > 0; ){
-                    if(feof($body)) throw new Exception\RequestedRangeNotSatisfiable('The start offset (' . $start . ') exceeded the size of the entity (' . $consumed . ')');
+                for ($consumed = 0; $start - $consumed > 0;){
+                    if (feof($body)) throw new Exception\RequestedRangeNotSatisfiable('The start offset (' . $start . ') exceeded the size of the entity (' . $consumed . ')');
                     $consumed += strlen(fread($body, min($start - $consumed, $consumeBlock)));
                 }
             }
 
             $response->setHeader('Content-Length', $end - $start + 1);
-            $response->setHeader('Content-Range','bytes ' . $start . '-' . $end . '/' . $nodeSize);
+            $response->setHeader('Content-Range', 'bytes ' . $start . '-' . $end . '/' . $nodeSize);
             $response->setStatus(206);
             $response->setBody($body);
 
@@ -215,7 +214,7 @@ class CorePlugin extends ServerPlugin {
         $response->setHeader('Allow', strtoupper(implode(', ', $methods)));
         $features = ['1', '3', 'extended-mkcol'];
 
-        foreach($this->server->getPlugins() as $plugin) {
+        foreach ($this->server->getPlugins() as $plugin) {
             $features = array_merge($features, $plugin->getFeatures());
         }
 
@@ -345,10 +344,10 @@ class CorePlugin extends ServerPlugin {
         // iCal seems to also depend on these being set for PROPFIND. Since
         // this is not harmful, we'll add it.
         $features = ['1', '3', 'extended-mkcol'];
-        foreach($this->server->getPlugins() as $plugin) {
+        foreach ($this->server->getPlugins() as $plugin) {
             $features = array_merge($features, $plugin->getFeatures());
         }
-        $response->setHeader('DAV',implode(', ', $features));
+        $response->setHeader('DAV', implode(', ', $features));
 
         $prefer = $this->server->getHTTPPrefer();
         $minimal = $prefer['return-minimal'];
@@ -394,7 +393,7 @@ class CorePlugin extends ServerPlugin {
             // request was succesful, and don't need to return the
             // multi-status.
             $ok = true;
-            foreach($result as $prop=>$code) {
+            foreach ($result as $prop => $code) {
                 if ((int)$code > 299) {
                     $ok = false;
                 }
@@ -415,7 +414,7 @@ class CorePlugin extends ServerPlugin {
 
         // Reorganizing the result for generateMultiStatus
         $multiStatus = [];
-        foreach($result as $propertyName => $code) {
+        foreach ($result as $propertyName => $code) {
             if (isset($multiStatus[$code])) {
                 $multiStatus[$code][$propertyName] = null;
             } else {
@@ -488,14 +487,14 @@ class CorePlugin extends ServerPlugin {
 
             // Only reading first byte
             $firstByte = fread($body, 1);
-            if (strlen($firstByte)!==1) {
+            if (strlen($firstByte) !== 1) {
                 throw new Exception\Forbidden('This server is not compatible with OS/X finder. Consider using a different WebDAV client or webserver.');
             }
 
             // The body needs to stay intact, so we copy everything to a
             // temporary stream.
 
-            $newBody = fopen('php://temp','r+');
+            $newBody = fopen('php://temp', 'r+');
             fwrite($newBody, $firstByte);
             stream_copy_to_stream($body, $newBody);
             rewind($newBody);
@@ -515,7 +514,7 @@ class CorePlugin extends ServerPlugin {
                 return false;
             }
 
-            $response->setHeader('Content-Length','0');
+            $response->setHeader('Content-Length', '0');
             if ($etag) $response->setHeader('ETag', $etag);
             $response->setStatus(204);
 
@@ -558,7 +557,7 @@ class CorePlugin extends ServerPlugin {
         if ($requestBody) {
 
             $contentType = $request->getHeader('Content-Type');
-            if (strpos($contentType, 'application/xml')!==0 && strpos($contentType, 'text/xml')!==0) {
+            if (strpos($contentType, 'application/xml') !== 0 && strpos($contentType, 'text/xml') !== 0) {
 
                 // We must throw 415 for unsupported mkcol bodies
                 throw new Exception\UnsupportedMediaType('The request body for the MKCOL request must have an xml Content-Type');
@@ -811,7 +810,7 @@ class CorePlugin extends ServerPlugin {
 
         $propFind->handle('{DAV:}supported-report-set', function() use ($propFind) {
             $reports = [];
-            foreach($this->server->getPlugins() as $plugin) {
+            foreach ($this->server->getPlugins() as $plugin) {
                 $reports = array_merge($reports, $plugin->getSupportedReportSet($propFind->getPath()));
             }
             return new Xml\Property\SupportedReportSet($reports);
@@ -843,7 +842,7 @@ class CorePlugin extends ServerPlugin {
 
             $nodeProperties = $node->getProperties($propertyNames);
 
-            foreach($nodeProperties as $propertyName=>$value) {
+            foreach ($nodeProperties as $propertyName => $value) {
                 $propFind->set($propertyName, $value, 200);
             }
 
diff --git a/lib/DAV/TemporaryFileFilterPlugin.php b/lib/DAV/TemporaryFileFilterPlugin.php
index 65a900b..41af97a 100644
--- a/lib/DAV/TemporaryFileFilterPlugin.php
+++ b/lib/DAV/TemporaryFileFilterPlugin.php
@@ -267,9 +267,9 @@ class TemporaryFileFilterPlugin extends ServerPlugin {
         $properties = [
             'href' => $request->getPath(),
             200    => [
-                '{DAV:}getlastmodified'             => new Xml\Property\GetLastModified(filemtime($tempLocation)),
-                '{DAV:}getcontentlength'            => filesize($tempLocation),
-                '{DAV:}resourcetype'                => new Xml\Property\ResourceType(null),
+                '{DAV:}getlastmodified'                 => new Xml\Property\GetLastModified(filemtime($tempLocation)),
+                '{DAV:}getcontentlength'                => filesize($tempLocation),
+                '{DAV:}resourcetype'                    => new Xml\Property\ResourceType(null),
                 '{' . Server::NS_SABREDAV . '}tempFile' => true,
 
             ],

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/php-sabredav.git



More information about the Pkg-owncloud-commits mailing list