[Pkg-owncloud-commits] [php-sabredav] 66/275: Added phpcs + lots of cs fixes.

David Prévot taffit at moszumanska.debian.org
Thu Sep 25 14:55:52 UTC 2014


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

taffit pushed a commit to branch master
in repository php-sabredav.

commit 399205b4ccbca3edbc5a1ec42f2a36a2dd5d358d
Author: Evert Pot <me at evertpot.com>
Date:   Wed Jun 25 15:29:17 2014 -0400

    Added phpcs + lots of cs fixes.
---
 .gitignore                                         |   1 +
 .travis.yml                                        |   1 +
 composer.json                                      |   3 +-
 lib/CalDAV/ICSExportPlugin.php                     |   7 +-
 lib/CalDAV/Property/AllowedSharingModes.php        |  10 +-
 lib/CalDAV/Property/Invite.php                     | 176 ++++++++++-----------
 .../Property/SupportedCalendarComponentSet.php     |   8 +-
 lib/CardDAV/Plugin.php                             |   2 +-
 lib/CardDAV/Property/SupportedAddressData.php      |   2 +-
 lib/DAV/Browser/Plugin.php                         |   2 +-
 lib/DAV/Browser/PropFindAll.php                    |   2 +-
 lib/DAV/Browser/assets/openiconic/open-iconic.css  |   1 -
 lib/DAV/PropFind.php                               |   2 +-
 lib/DAV/TemporaryFileFilterPlugin.php              |   4 +-
 lib/DAV/Tree/Filesystem.php                        |   2 +-
 lib/DAV/XMLUtil.php                                |   5 +-
 tests/phpcs/ruleset.xml                            |  57 +++++++
 17 files changed, 176 insertions(+), 109 deletions(-)

diff --git a/.gitignore b/.gitignore
index e9c4ca5..2b0e9e3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -17,6 +17,7 @@ bin/vobject
 bin/generate_vcards
 bin/phpdocmd
 bin/phpunit
+bin/phpcs
 
 # Assuming every .php file in the root is for testing
 /*.php
diff --git a/.travis.yml b/.travis.yml
index f772fb5..2092a2f 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -23,6 +23,7 @@ before_script:
 
 script:
   - ./bin/phpunit --configuration tests/phpunit.xml
+  - ./bin/phpcs  -v --standard=tests/phpcs/ruleset.xml lib/
 
 notifications:
   irc:
diff --git a/composer.json b/composer.json
index 461d32a..4dce44d 100644
--- a/composer.json
+++ b/composer.json
@@ -30,7 +30,8 @@
     },
     "require-dev" : {
         "phpunit/phpunit" : "~4.1.1",
-        "evert/phpdoc-md" : "~0.0.7"
+        "evert/phpdoc-md" : "~0.0.7",
+        "squizlabs/php_codesniffer": "~1.5.3"
     },
     "suggest" : {
         "ext-curl" : "*",
diff --git a/lib/CalDAV/ICSExportPlugin.php b/lib/CalDAV/ICSExportPlugin.php
index f2bdf5b..e134a6e 100644
--- a/lib/CalDAV/ICSExportPlugin.php
+++ b/lib/CalDAV/ICSExportPlugin.php
@@ -183,7 +183,12 @@ class ICSExportPlugin extends DAV\ServerPlugin {
 
             // queryResult is just a list of base urls. We need to prefix the
             // calendar path.
-            $queryResult = array_map(function($item) use ($path) { return $path . '/' . $item; }, $queryResult);
+            $queryResult = array_map(
+                function($item) use ($path) {
+                    return $path . '/' . $item;
+                },
+                $queryResult
+            );
             $nodes = $this->server->getPropertiesForMultiplePaths($queryResult, [$calDataProp]);
             unset($queryResult);
 
diff --git a/lib/CalDAV/Property/AllowedSharingModes.php b/lib/CalDAV/Property/AllowedSharingModes.php
index ca8312d..3596a64 100644
--- a/lib/CalDAV/Property/AllowedSharingModes.php
+++ b/lib/CalDAV/Property/AllowedSharingModes.php
@@ -59,15 +59,15 @@ class AllowedSharingModes extends DAV\Property {
      */
     public function serialize(DAV\Server $server, \DOMElement $node) {
 
-       $doc = $node->ownerDocument;
-       if ($this->canBeShared) {
+        $doc = $node->ownerDocument;
+        if ($this->canBeShared) {
             $xcomp = $doc->createElement('cs:can-be-shared');
             $node->appendChild($xcomp);
-       }
-       if ($this->canBePublished) {
+        }
+        if ($this->canBePublished) {
             $xcomp = $doc->createElement('cs:can-be-published');
             $node->appendChild($xcomp);
-       }
+        }
 
     }
 
diff --git a/lib/CalDAV/Property/Invite.php b/lib/CalDAV/Property/Invite.php
index f732db0..b430adb 100644
--- a/lib/CalDAV/Property/Invite.php
+++ b/lib/CalDAV/Property/Invite.php
@@ -88,94 +88,94 @@ class Invite extends DAV\Property {
      */
     public function serialize(DAV\Server $server,\DOMElement $node) {
 
-       $doc = $node->ownerDocument;
-
-       if (!is_null($this->organizer)) {
-
-           $xorganizer = $doc->createElement('cs:organizer');
-
-           $href = $doc->createElement('d:href');
-           $href->appendChild($doc->createTextNode($this->organizer['href']));
-           $xorganizer->appendChild($href);
-
-           if (isset($this->organizer['commonName']) && $this->organizer['commonName']) {
-               $commonName = $doc->createElement('cs:common-name');
-               $commonName->appendChild($doc->createTextNode($this->organizer['commonName']));
-               $xorganizer->appendChild($commonName);
-           }
-           if (isset($this->organizer['firstName']) && $this->organizer['firstName']) {
-               $firstName = $doc->createElement('cs:first-name');
-               $firstName->appendChild($doc->createTextNode($this->organizer['firstName']));
-               $xorganizer->appendChild($firstName);
-           }
-           if (isset($this->organizer['lastName']) && $this->organizer['lastName']) {
-               $lastName = $doc->createElement('cs:last-name');
-               $lastName->appendChild($doc->createTextNode($this->organizer['lastName']));
-               $xorganizer->appendChild($lastName);
-           }
-
-           $node->appendChild($xorganizer);
-
-
-       }
-
-       foreach($this->users as $user) {
-
-           $xuser = $doc->createElement('cs:user');
-
-           $href = $doc->createElement('d:href');
-           $href->appendChild($doc->createTextNode($user['href']));
-           $xuser->appendChild($href);
-
-           if (isset($user['commonName']) && $user['commonName']) {
-               $commonName = $doc->createElement('cs:common-name');
-               $commonName->appendChild($doc->createTextNode($user['commonName']));
-               $xuser->appendChild($commonName);
-           }
-
-           switch($user['status']) {
-
-               case SharingPlugin::STATUS_ACCEPTED :
-                   $status = $doc->createElement('cs:invite-accepted');
-                   $xuser->appendChild($status);
-                   break;
-               case SharingPlugin::STATUS_DECLINED :
-                   $status = $doc->createElement('cs:invite-declined');
-                   $xuser->appendChild($status);
-                   break;
-               case SharingPlugin::STATUS_NORESPONSE :
-                   $status = $doc->createElement('cs:invite-noresponse');
-                   $xuser->appendChild($status);
-                   break;
-               case SharingPlugin::STATUS_INVALID :
-                   $status = $doc->createElement('cs:invite-invalid');
-                   $xuser->appendChild($status);
-                   break;
-
-           }
-
-           $xaccess = $doc->createElement('cs:access');
-
-           if ($user['readOnly']) {
-                $xaccess->appendChild(
-                    $doc->createElement('cs:read')
-                );
-           } else {
-                $xaccess->appendChild(
-                    $doc->createElement('cs:read-write')
-                );
-           }
-           $xuser->appendChild($xaccess);
-
-           if (isset($user['summary']) && $user['summary']) {
-               $summary = $doc->createElement('cs:summary');
-               $summary->appendChild($doc->createTextNode($user['summary']));
-               $xuser->appendChild($summary);
-           }
-
-           $node->appendChild($xuser);
-
-       }
+        $doc = $node->ownerDocument;
+
+        if (!is_null($this->organizer)) {
+
+            $xorganizer = $doc->createElement('cs:organizer');
+
+            $href = $doc->createElement('d:href');
+            $href->appendChild($doc->createTextNode($this->organizer['href']));
+            $xorganizer->appendChild($href);
+
+            if (isset($this->organizer['commonName']) && $this->organizer['commonName']) {
+                $commonName = $doc->createElement('cs:common-name');
+                $commonName->appendChild($doc->createTextNode($this->organizer['commonName']));
+                $xorganizer->appendChild($commonName);
+            }
+            if (isset($this->organizer['firstName']) && $this->organizer['firstName']) {
+                $firstName = $doc->createElement('cs:first-name');
+                $firstName->appendChild($doc->createTextNode($this->organizer['firstName']));
+                $xorganizer->appendChild($firstName);
+            }
+            if (isset($this->organizer['lastName']) && $this->organizer['lastName']) {
+                $lastName = $doc->createElement('cs:last-name');
+                $lastName->appendChild($doc->createTextNode($this->organizer['lastName']));
+                $xorganizer->appendChild($lastName);
+            }
+
+            $node->appendChild($xorganizer);
+
+
+        }
+
+        foreach($this->users as $user) {
+
+            $xuser = $doc->createElement('cs:user');
+
+            $href = $doc->createElement('d:href');
+            $href->appendChild($doc->createTextNode($user['href']));
+            $xuser->appendChild($href);
+
+            if (isset($user['commonName']) && $user['commonName']) {
+                $commonName = $doc->createElement('cs:common-name');
+                $commonName->appendChild($doc->createTextNode($user['commonName']));
+                $xuser->appendChild($commonName);
+            }
+
+            switch($user['status']) {
+
+                case SharingPlugin::STATUS_ACCEPTED :
+                    $status = $doc->createElement('cs:invite-accepted');
+                    $xuser->appendChild($status);
+                    break;
+                case SharingPlugin::STATUS_DECLINED :
+                    $status = $doc->createElement('cs:invite-declined');
+                    $xuser->appendChild($status);
+                    break;
+                case SharingPlugin::STATUS_NORESPONSE :
+                    $status = $doc->createElement('cs:invite-noresponse');
+                    $xuser->appendChild($status);
+                    break;
+                case SharingPlugin::STATUS_INVALID :
+                    $status = $doc->createElement('cs:invite-invalid');
+                    $xuser->appendChild($status);
+                    break;
+
+            }
+
+            $xaccess = $doc->createElement('cs:access');
+
+            if ($user['readOnly']) {
+                 $xaccess->appendChild(
+                     $doc->createElement('cs:read')
+                 );
+            } else {
+                 $xaccess->appendChild(
+                     $doc->createElement('cs:read-write')
+                 );
+            }
+            $xuser->appendChild($xaccess);
+
+            if (isset($user['summary']) && $user['summary']) {
+                $summary = $doc->createElement('cs:summary');
+                $summary->appendChild($doc->createTextNode($user['summary']));
+                $xuser->appendChild($summary);
+            }
+
+            $node->appendChild($xuser);
+
+        }
 
 
     }
diff --git a/lib/CalDAV/Property/SupportedCalendarComponentSet.php b/lib/CalDAV/Property/SupportedCalendarComponentSet.php
index 24415a1..d54ff0f 100644
--- a/lib/CalDAV/Property/SupportedCalendarComponentSet.php
+++ b/lib/CalDAV/Property/SupportedCalendarComponentSet.php
@@ -32,7 +32,7 @@ class SupportedCalendarComponentSet extends DAV\Property {
      */
     public function __construct(array $components) {
 
-       $this->components = $components;
+        $this->components = $components;
 
     }
 
@@ -56,14 +56,14 @@ class SupportedCalendarComponentSet extends DAV\Property {
      */
     public function serialize(DAV\Server $server,\DOMElement $node) {
 
-       $doc = $node->ownerDocument;
-       foreach($this->components as $component) {
+        $doc = $node->ownerDocument;
+        foreach($this->components as $component) {
 
             $xcomp = $doc->createElement('cal:comp');
             $xcomp->setAttribute('name',$component);
             $node->appendChild($xcomp);
 
-       }
+        }
 
     }
 
diff --git a/lib/CardDAV/Plugin.php b/lib/CardDAV/Plugin.php
index f587cac..47eb870 100644
--- a/lib/CardDAV/Plugin.php
+++ b/lib/CardDAV/Plugin.php
@@ -652,7 +652,7 @@ class Plugin extends DAV\ServerPlugin {
         }
         $contentType = $propFind->get('{DAV:}getcontenttype');
         if (!$contentType || strpos($contentType, 'text/x-vcard')!==0) {
-           return;
+            return;
         }
         $propFind->set('{DAV:}getcontenttype', 'text/x-vcard');
 
diff --git a/lib/CardDAV/Property/SupportedAddressData.php b/lib/CardDAV/Property/SupportedAddressData.php
index 9d8dd2e..5d0aa8a 100644
--- a/lib/CardDAV/Property/SupportedAddressData.php
+++ b/lib/CardDAV/Property/SupportedAddressData.php
@@ -38,7 +38,7 @@ class SupportedAddressData extends DAV\Property {
             );
         }
 
-       $this->supportedData = $supportedData;
+        $this->supportedData = $supportedData;
 
     }
 
diff --git a/lib/DAV/Browser/Plugin.php b/lib/DAV/Browser/Plugin.php
index b705e6e..12296f1 100644
--- a/lib/DAV/Browser/Plugin.php
+++ b/lib/DAV/Browser/Plugin.php
@@ -200,7 +200,7 @@ class Plugin extends DAV\ServerPlugin {
             'iconstyle' => $this->getAssetUrl('openiconic/open-iconic.css'),
             'logo'      => $this->getAssetUrl('sabredav.png'),
             'baseUrl'   => $this->server->getBaseUri(),
-       ];
+        ];
 
         $html = <<<HTML
 <!DOCTYPE html>
diff --git a/lib/DAV/Browser/PropFindAll.php b/lib/DAV/Browser/PropFindAll.php
index fa765cb..afcc5c1 100644
--- a/lib/DAV/Browser/PropFindAll.php
+++ b/lib/DAV/Browser/PropFindAll.php
@@ -124,7 +124,7 @@ class PropFindAll extends PropFind {
         // If there's nothing in this list, we're adding one fictional item.
         if (!$result) {
             $result[] = '{http://sabredav.org/ns}idk';
-        } 
+        }
         return $result;
 
     }
diff --git a/lib/DAV/Browser/assets/openiconic/open-iconic.css b/lib/DAV/Browser/assets/openiconic/open-iconic.css
index 416b921..e748674 100644
--- a/lib/DAV/Browser/assets/openiconic/open-iconic.css
+++ b/lib/DAV/Browser/assets/openiconic/open-iconic.css
@@ -1,4 +1,3 @@
-
 @font-face {
   font-family: 'Icons';
   src: url('?sabreAction=asset&assetName=openiconic/open-iconic.eot');
diff --git a/lib/DAV/PropFind.php b/lib/DAV/PropFind.php
index 118ece5..810a7db 100644
--- a/lib/DAV/PropFind.php
+++ b/lib/DAV/PropFind.php
@@ -56,7 +56,7 @@ class PropFind {
                 '{DAV:}quota-available-bytes',
                 '{DAV:}getetag',
                 '{DAV:}getcontenttype',
-           ];
+            ];
         }
 
         foreach($this->properties as $propertyName) {
diff --git a/lib/DAV/TemporaryFileFilterPlugin.php b/lib/DAV/TemporaryFileFilterPlugin.php
index 5f785f8..ea08756 100644
--- a/lib/DAV/TemporaryFileFilterPlugin.php
+++ b/lib/DAV/TemporaryFileFilterPlugin.php
@@ -121,8 +121,8 @@ class TemporaryFileFilterPlugin extends ServerPlugin {
                 return $this->httpPropfind($request, $response, $tempLocation);
             case 'DELETE' :
                 return $this->httpDelete($request, $response, $tempLocation);
-         }
-         return true;
+        }
+        return true;
 
     }
 
diff --git a/lib/DAV/Tree/Filesystem.php b/lib/DAV/Tree/Filesystem.php
index a477725..ab34836 100644
--- a/lib/DAV/Tree/Filesystem.php
+++ b/lib/DAV/Tree/Filesystem.php
@@ -48,7 +48,7 @@ class Filesystem extends DAV\Tree {
     public function getNodeForPath($path) {
 
         $realPath = $this->getRealPath($path);
-        if (!file_exists($realPath)) { 
+        if (!file_exists($realPath)) {
             throw new DAV\Exception\NotFound('File at location ' . $realPath . ' not found');
         }
         if (is_dir($realPath)) {
diff --git a/lib/DAV/XMLUtil.php b/lib/DAV/XMLUtil.php
index bf48a40..9b063fe 100644
--- a/lib/DAV/XMLUtil.php
+++ b/lib/DAV/XMLUtil.php
@@ -34,7 +34,10 @@ class XMLUtil {
         if ($dom->nodeType !== XML_ELEMENT_NODE) return null;
 
         // Mapping back to the real namespace, in case it was dav
-        if ($dom->namespaceURI=='urn:DAV') $ns = 'DAV:'; else $ns = $dom->namespaceURI;
+        if ($dom->namespaceURI=='urn:DAV')
+            $ns = 'DAV:';
+        else
+            $ns = $dom->namespaceURI;
 
         // Mapping to clark notation
         return '{' . $ns . '}' . $dom->localName;
diff --git a/tests/phpcs/ruleset.xml b/tests/phpcs/ruleset.xml
new file mode 100644
index 0000000..ec2c4c8
--- /dev/null
+++ b/tests/phpcs/ruleset.xml
@@ -0,0 +1,57 @@
+<?xml version="1.0"?>
+<ruleset name="sabre.php">
+    <description>sabre.io codesniffer ruleset</description>
+
+     <!-- Include the whole PSR-1 standard -->
+     <rule ref="PSR1" />
+
+     <!-- All PHP files MUST use the Unix LF (linefeed) line ending. -->
+     <rule ref="Generic.Files.LineEndings">
+      <properties>
+       <property name="eolChar" value="\n"/>
+      </properties>
+     </rule>
+
+     <!-- The closing ?> tag MUST be omitted from files containing only PHP. -->
+     <rule ref="Zend.Files.ClosingTag"/>
+
+     <!-- There MUST NOT be trailing whitespace at the end of non-blank lines. -->
+     <rule ref="Squiz.WhiteSpace.SuperfluousWhitespace">
+      <properties>
+       <property name="ignoreBlankLines" value="true"/>
+       </properties>
+   </rule>
+
+   <!-- There MUST NOT be more than one statement per line. -->
+   <rule ref="Generic.Formatting.DisallowMultipleStatements"/>
+
+   <rule ref="Generic.WhiteSpace.ScopeIndent">
+      <properties>
+       <property name="ignoreIndentationTokens" type="array" value="T_COMMENT,T_DOC_COMMENT"/>
+      </properties>
+   </rule>
+   <rule ref="Generic.WhiteSpace.DisallowTabIndent"/>
+
+   <!-- PHP keywords MUST be in lower case. -->
+   <rule ref="Generic.PHP.LowerCaseKeyword"/>
+
+   <!-- The PHP constants true, false, and null MUST be in lower case. -->
+   <rule ref="Generic.PHP.LowerCaseConstant"/>
+
+   <!-- <rule ref="Squiz.Scope.MethodScope"/> -->
+   <rule ref="Squiz.WhiteSpace.ScopeKeywordSpacing"/>
+
+   <!-- In the argument list, there MUST NOT be a space before each comma, and there MUST be one space after each comma. -->
+   <!--
+   <rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing">
+    <properties>
+     <property name="equalsSpacing" value="1"/>
+    </properties>
+   </rule>
+   <rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing.SpacingAfterHint">
+    <severity>0</severity>
+   </rule>
+    -->
+   <rule ref="PEAR.WhiteSpace.ScopeClosingBrace"/>
+
+</ruleset>

-- 
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