Completed
Push — developer ( e65ba3...d7bfd9 )
by Błażej
478:46 queued 446:35
created
libraries/SabreDAV/DAVACL/Xml/Property/Principal.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -172,7 +172,7 @@
 block discarded – undo
172 172
      * the next element.
173 173
      *
174 174
      * @param Reader $reader
175
-     * @return mixed
175
+     * @return Principal
176 176
      */
177 177
     static function xmlDeserialize(Reader $reader) {
178 178
 
Please login to merge, or discard this patch.
Indentation   +172 added lines, -172 removed lines patch added patch discarded remove patch
@@ -20,177 +20,177 @@
 block discarded – undo
20 20
  */
21 21
 class Principal extends DAV\Xml\Property\Href {
22 22
 
23
-    /**
24
-     * To specify a not-logged-in user, use the UNAUTHENTICATED principal
25
-     */
26
-    const UNAUTHENTICATED = 1;
27
-
28
-    /**
29
-     * To specify any principal that is logged in, use AUTHENTICATED
30
-     */
31
-    const AUTHENTICATED = 2;
32
-
33
-    /**
34
-     * Specific principals can be specified with the HREF
35
-     */
36
-    const HREF = 3;
37
-
38
-    /**
39
-     * Everybody, basically
40
-     */
41
-    const ALL = 4;
42
-
43
-    /**
44
-     * Principal-type
45
-     *
46
-     * Must be one of the UNAUTHENTICATED, AUTHENTICATED or HREF constants.
47
-     *
48
-     * @var int
49
-     */
50
-    protected $type;
51
-
52
-    /**
53
-     * Creates the property.
54
-     *
55
-     * The 'type' argument must be one of the type constants defined in this class.
56
-     *
57
-     * 'href' is only required for the HREF type.
58
-     *
59
-     * @param int $type
60
-     * @param string|null $href
61
-     */
62
-    public function __construct($type, $href = null) {
63
-
64
-        $this->type = $type;
65
-        if ($type === self::HREF && is_null($href)) {
66
-            throw new DAV\Exception('The href argument must be specified for the HREF principal type.');
67
-        }
68
-        if ($href) {
69
-            $href = rtrim($href, '/') . '/';
70
-            parent::__construct($href);
71
-        }
72
-
73
-    }
74
-
75
-    /**
76
-     * Returns the principal type
77
-     *
78
-     * @return int
79
-     */
80
-    public function getType() {
81
-
82
-        return $this->type;
83
-
84
-    }
85
-
86
-
87
-    /**
88
-     * The xmlSerialize metod is called during xml writing.
89
-     *
90
-     * Use the $writer argument to write its own xml serialization.
91
-     *
92
-     * An important note: do _not_ create a parent element. Any element
93
-     * implementing XmlSerializble should only ever write what's considered
94
-     * its 'inner xml'.
95
-     *
96
-     * The parent of the current element is responsible for writing a
97
-     * containing element.
98
-     *
99
-     * This allows serializers to be re-used for different element names.
100
-     *
101
-     * If you are opening new elements, you must also close them again.
102
-     *
103
-     * @param Writer $writer
104
-     * @return void
105
-     */
106
-    public function xmlSerialize(Writer $writer) {
107
-
108
-        switch ($this->type) {
109
-
110
-            case self::UNAUTHENTICATED :
111
-                $writer->writeElement('{DAV:}unauthenticated');
112
-                break;
113
-            case self::AUTHENTICATED :
114
-                $writer->writeElement('{DAV:}authenticated');
115
-                break;
116
-            case self::HREF :
117
-                parent::xmlSerialize($writer);
118
-                break;
119
-            case self::ALL :
120
-                $writer->writeElement('{DAV:}all');
121
-                break;
122
-        }
123
-
124
-    }
125
-
126
-    /**
127
-     * Generate html representation for this value.
128
-     *
129
-     * The html output is 100% trusted, and no effort is being made to sanitize
130
-     * it. It's up to the implementor to sanitize user provided values.
131
-     *
132
-     * The output must be in UTF-8.
133
-     *
134
-     * The baseUri parameter is a url to the root of the application, and can
135
-     * be used to construct local links.
136
-     *
137
-     * @param HtmlOutputHelper $html
138
-     * @return string
139
-     */
140
-    public function toHtml(HtmlOutputHelper $html) {
141
-
142
-        switch ($this->type) {
143
-
144
-            case self::UNAUTHENTICATED :
145
-                return '<em>unauthenticated</em>';
146
-            case self::AUTHENTICATED :
147
-                return '<em>authenticated</em>';
148
-            case self::HREF :
149
-                return parent::toHtml($html);
150
-            case self::ALL :
151
-                return '<em>all</em>';
152
-        }
153
-
154
-    }
155
-
156
-    /**
157
-     * The deserialize method is called during xml parsing.
158
-     *
159
-     * This method is called staticly, this is because in theory this method
160
-     * may be used as a type of constructor, or factory method.
161
-     *
162
-     * Often you want to return an instance of the current class, but you are
163
-     * free to return other data as well.
164
-     *
165
-     * Important note 2: You are responsible for advancing the reader to the
166
-     * next element. Not doing anything will result in a never-ending loop.
167
-     *
168
-     * If you just want to skip parsing for this element altogether, you can
169
-     * just call $reader->next();
170
-     *
171
-     * $reader->parseInnerTree() will parse the entire sub-tree, and advance to
172
-     * the next element.
173
-     *
174
-     * @param Reader $reader
175
-     * @return mixed
176
-     */
177
-    static function xmlDeserialize(Reader $reader) {
178
-
179
-        $tree = $reader->parseInnerTree()[0];
180
-
181
-        switch ($tree['name']) {
182
-            case '{DAV:}unauthenticated' :
183
-                return new self(self::UNAUTHENTICATED);
184
-            case '{DAV:}authenticated' :
185
-                return new self(self::AUTHENTICATED);
186
-            case '{DAV:}href':
187
-                return new self(self::HREF, $tree['value']);
188
-            case '{DAV:}all':
189
-                return new self(self::ALL);
190
-            default :
191
-                throw new BadRequest('Unknown or unsupported principal type: ' . $tree['name']);
192
-        }
193
-
194
-    }
23
+	/**
24
+	 * To specify a not-logged-in user, use the UNAUTHENTICATED principal
25
+	 */
26
+	const UNAUTHENTICATED = 1;
27
+
28
+	/**
29
+	 * To specify any principal that is logged in, use AUTHENTICATED
30
+	 */
31
+	const AUTHENTICATED = 2;
32
+
33
+	/**
34
+	 * Specific principals can be specified with the HREF
35
+	 */
36
+	const HREF = 3;
37
+
38
+	/**
39
+	 * Everybody, basically
40
+	 */
41
+	const ALL = 4;
42
+
43
+	/**
44
+	 * Principal-type
45
+	 *
46
+	 * Must be one of the UNAUTHENTICATED, AUTHENTICATED or HREF constants.
47
+	 *
48
+	 * @var int
49
+	 */
50
+	protected $type;
51
+
52
+	/**
53
+	 * Creates the property.
54
+	 *
55
+	 * The 'type' argument must be one of the type constants defined in this class.
56
+	 *
57
+	 * 'href' is only required for the HREF type.
58
+	 *
59
+	 * @param int $type
60
+	 * @param string|null $href
61
+	 */
62
+	public function __construct($type, $href = null) {
63
+
64
+		$this->type = $type;
65
+		if ($type === self::HREF && is_null($href)) {
66
+			throw new DAV\Exception('The href argument must be specified for the HREF principal type.');
67
+		}
68
+		if ($href) {
69
+			$href = rtrim($href, '/') . '/';
70
+			parent::__construct($href);
71
+		}
72
+
73
+	}
74
+
75
+	/**
76
+	 * Returns the principal type
77
+	 *
78
+	 * @return int
79
+	 */
80
+	public function getType() {
81
+
82
+		return $this->type;
83
+
84
+	}
85
+
86
+
87
+	/**
88
+	 * The xmlSerialize metod is called during xml writing.
89
+	 *
90
+	 * Use the $writer argument to write its own xml serialization.
91
+	 *
92
+	 * An important note: do _not_ create a parent element. Any element
93
+	 * implementing XmlSerializble should only ever write what's considered
94
+	 * its 'inner xml'.
95
+	 *
96
+	 * The parent of the current element is responsible for writing a
97
+	 * containing element.
98
+	 *
99
+	 * This allows serializers to be re-used for different element names.
100
+	 *
101
+	 * If you are opening new elements, you must also close them again.
102
+	 *
103
+	 * @param Writer $writer
104
+	 * @return void
105
+	 */
106
+	public function xmlSerialize(Writer $writer) {
107
+
108
+		switch ($this->type) {
109
+
110
+			case self::UNAUTHENTICATED :
111
+				$writer->writeElement('{DAV:}unauthenticated');
112
+				break;
113
+			case self::AUTHENTICATED :
114
+				$writer->writeElement('{DAV:}authenticated');
115
+				break;
116
+			case self::HREF :
117
+				parent::xmlSerialize($writer);
118
+				break;
119
+			case self::ALL :
120
+				$writer->writeElement('{DAV:}all');
121
+				break;
122
+		}
123
+
124
+	}
125
+
126
+	/**
127
+	 * Generate html representation for this value.
128
+	 *
129
+	 * The html output is 100% trusted, and no effort is being made to sanitize
130
+	 * it. It's up to the implementor to sanitize user provided values.
131
+	 *
132
+	 * The output must be in UTF-8.
133
+	 *
134
+	 * The baseUri parameter is a url to the root of the application, and can
135
+	 * be used to construct local links.
136
+	 *
137
+	 * @param HtmlOutputHelper $html
138
+	 * @return string
139
+	 */
140
+	public function toHtml(HtmlOutputHelper $html) {
141
+
142
+		switch ($this->type) {
143
+
144
+			case self::UNAUTHENTICATED :
145
+				return '<em>unauthenticated</em>';
146
+			case self::AUTHENTICATED :
147
+				return '<em>authenticated</em>';
148
+			case self::HREF :
149
+				return parent::toHtml($html);
150
+			case self::ALL :
151
+				return '<em>all</em>';
152
+		}
153
+
154
+	}
155
+
156
+	/**
157
+	 * The deserialize method is called during xml parsing.
158
+	 *
159
+	 * This method is called staticly, this is because in theory this method
160
+	 * may be used as a type of constructor, or factory method.
161
+	 *
162
+	 * Often you want to return an instance of the current class, but you are
163
+	 * free to return other data as well.
164
+	 *
165
+	 * Important note 2: You are responsible for advancing the reader to the
166
+	 * next element. Not doing anything will result in a never-ending loop.
167
+	 *
168
+	 * If you just want to skip parsing for this element altogether, you can
169
+	 * just call $reader->next();
170
+	 *
171
+	 * $reader->parseInnerTree() will parse the entire sub-tree, and advance to
172
+	 * the next element.
173
+	 *
174
+	 * @param Reader $reader
175
+	 * @return mixed
176
+	 */
177
+	static function xmlDeserialize(Reader $reader) {
178
+
179
+		$tree = $reader->parseInnerTree()[0];
180
+
181
+		switch ($tree['name']) {
182
+			case '{DAV:}unauthenticated' :
183
+				return new self(self::UNAUTHENTICATED);
184
+			case '{DAV:}authenticated' :
185
+				return new self(self::AUTHENTICATED);
186
+			case '{DAV:}href':
187
+				return new self(self::HREF, $tree['value']);
188
+			case '{DAV:}all':
189
+				return new self(self::ALL);
190
+			default :
191
+				throw new BadRequest('Unknown or unsupported principal type: ' . $tree['name']);
192
+		}
193
+
194
+	}
195 195
 
196 196
 }
Please login to merge, or discard this patch.
libraries/SabreDAV/DAVACL/Xml/Request/ExpandPropertyReport.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@
 block discarded – undo
51 51
      * the next element.
52 52
      *
53 53
      * @param Reader $reader
54
-     * @return mixed
54
+     * @return ExpandPropertyReport
55 55
      */
56 56
     static function xmlDeserialize(Reader $reader) {
57 57
 
Please login to merge, or discard this patch.
Indentation   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -18,86 +18,86 @@
 block discarded – undo
18 18
  */
19 19
 class ExpandPropertyReport implements XmlDeserializable {
20 20
 
21
-    /**
22
-     * An array with requested properties.
23
-     *
24
-     * The requested properties will be used as keys in this array. The value
25
-     * is normally null.
26
-     *
27
-     * If the value is an array though, it means the property must be expanded.
28
-     * Within the array, the sub-properties, which themselves may be null or
29
-     * arrays.
30
-     *
31
-     * @var array
32
-     */
33
-    public $properties;
34
-
35
-    /**
36
-     * The deserialize method is called during xml parsing.
37
-     *
38
-     * This method is called statictly, this is because in theory this method
39
-     * may be used as a type of constructor, or factory method.
40
-     *
41
-     * Often you want to return an instance of the current class, but you are
42
-     * free to return other data as well.
43
-     *
44
-     * You are responsible for advancing the reader to the next element. Not
45
-     * doing anything will result in a never-ending loop.
46
-     *
47
-     * If you just want to skip parsing for this element altogether, you can
48
-     * just call $reader->next();
49
-     *
50
-     * $reader->parseInnerTree() will parse the entire sub-tree, and advance to
51
-     * the next element.
52
-     *
53
-     * @param Reader $reader
54
-     * @return mixed
55
-     */
56
-    static function xmlDeserialize(Reader $reader) {
57
-
58
-        $elems = $reader->parseInnerTree();
59
-
60
-        $obj = new self();
61
-        $obj->properties = self::traverse($elems);
62
-
63
-        return $obj;
64
-
65
-    }
66
-
67
-    /**
68
-     * This method is used by deserializeXml, to recursively parse the
69
-     * {DAV:}property elements.
70
-     *
71
-     * @param array $elems
72
-     * @return void
73
-     */
74
-    private static function traverse($elems) {
75
-
76
-        $result = [];
77
-
78
-        foreach ($elems as $elem) {
79
-
80
-            if ($elem['name'] !== '{DAV:}property') {
81
-                continue;
82
-            }
83
-
84
-            $namespace = isset($elem['attributes']['namespace']) ?
85
-                $elem['attributes']['namespace'] :
86
-                'DAV:';
87
-
88
-            $propName = '{' . $namespace . '}' . $elem['attributes']['name'];
89
-
90
-            $value = null;
91
-            if (is_array($elem['value'])) {
92
-                $value = self::traverse($elem['value']);
93
-            }
94
-
95
-            $result[$propName] = $value;
96
-
97
-        }
98
-
99
-        return $result;
100
-
101
-    }
21
+	/**
22
+	 * An array with requested properties.
23
+	 *
24
+	 * The requested properties will be used as keys in this array. The value
25
+	 * is normally null.
26
+	 *
27
+	 * If the value is an array though, it means the property must be expanded.
28
+	 * Within the array, the sub-properties, which themselves may be null or
29
+	 * arrays.
30
+	 *
31
+	 * @var array
32
+	 */
33
+	public $properties;
34
+
35
+	/**
36
+	 * The deserialize method is called during xml parsing.
37
+	 *
38
+	 * This method is called statictly, this is because in theory this method
39
+	 * may be used as a type of constructor, or factory method.
40
+	 *
41
+	 * Often you want to return an instance of the current class, but you are
42
+	 * free to return other data as well.
43
+	 *
44
+	 * You are responsible for advancing the reader to the next element. Not
45
+	 * doing anything will result in a never-ending loop.
46
+	 *
47
+	 * If you just want to skip parsing for this element altogether, you can
48
+	 * just call $reader->next();
49
+	 *
50
+	 * $reader->parseInnerTree() will parse the entire sub-tree, and advance to
51
+	 * the next element.
52
+	 *
53
+	 * @param Reader $reader
54
+	 * @return mixed
55
+	 */
56
+	static function xmlDeserialize(Reader $reader) {
57
+
58
+		$elems = $reader->parseInnerTree();
59
+
60
+		$obj = new self();
61
+		$obj->properties = self::traverse($elems);
62
+
63
+		return $obj;
64
+
65
+	}
66
+
67
+	/**
68
+	 * This method is used by deserializeXml, to recursively parse the
69
+	 * {DAV:}property elements.
70
+	 *
71
+	 * @param array $elems
72
+	 * @return void
73
+	 */
74
+	private static function traverse($elems) {
75
+
76
+		$result = [];
77
+
78
+		foreach ($elems as $elem) {
79
+
80
+			if ($elem['name'] !== '{DAV:}property') {
81
+				continue;
82
+			}
83
+
84
+			$namespace = isset($elem['attributes']['namespace']) ?
85
+				$elem['attributes']['namespace'] :
86
+				'DAV:';
87
+
88
+			$propName = '{' . $namespace . '}' . $elem['attributes']['name'];
89
+
90
+			$value = null;
91
+			if (is_array($elem['value'])) {
92
+				$value = self::traverse($elem['value']);
93
+			}
94
+
95
+			$result[$propName] = $value;
96
+
97
+		}
98
+
99
+		return $result;
100
+
101
+	}
102 102
 
103 103
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -82,8 +82,7 @@
 block discarded – undo
82 82
             }
83 83
 
84 84
             $namespace = isset($elem['attributes']['namespace']) ?
85
-                $elem['attributes']['namespace'] :
86
-                'DAV:';
85
+                $elem['attributes']['namespace'] : 'DAV:';
87 86
 
88 87
             $propName = '{' . $namespace . '}' . $elem['attributes']['name'];
89 88
 
Please login to merge, or discard this patch.
libraries/SabreDAV/DAVACL/Xml/Request/PrincipalPropertySearchReport.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@
 block discarded – undo
72 72
      * the next element.
73 73
      *
74 74
      * @param Reader $reader
75
-     * @return mixed
75
+     * @return PrincipalPropertySearchReport
76 76
      */
77 77
     static function xmlDeserialize(Reader $reader) {
78 78
 
Please login to merge, or discard this patch.
Indentation   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -20,108 +20,108 @@
 block discarded – undo
20 20
  */
21 21
 class PrincipalPropertySearchReport implements XmlDeserializable {
22 22
 
23
-    /**
24
-     * The requested properties.
25
-     *
26
-     * @var array|null
27
-     */
28
-    public $properties;
29
-
30
-    /**
31
-     * searchProperties
32
-     *
33
-     * @var array
34
-     */
35
-    public $searchProperties = [];
36
-
37
-    /**
38
-     * By default the property search will be conducted on the url of the http
39
-     * request. If this is set to true, it will be applied to the principal
40
-     * collection set instead.
41
-     *
42
-     * @var bool
43
-     */
44
-    public $applyToPrincipalCollectionSet = false;
45
-
46
-    /**
47
-     * Search for principals matching ANY of the properties (OR) or a ALL of
48
-     * the properties (AND).
49
-     *
50
-     * This property is either "anyof" or "allof".
51
-     *
52
-     * @var string
53
-     */
54
-    public $test;
55
-
56
-    /**
57
-     * The deserialize method is called during xml parsing.
58
-     *
59
-     * This method is called statictly, this is because in theory this method
60
-     * may be used as a type of constructor, or factory method.
61
-     *
62
-     * Often you want to return an instance of the current class, but you are
63
-     * free to return other data as well.
64
-     *
65
-     * You are responsible for advancing the reader to the next element. Not
66
-     * doing anything will result in a never-ending loop.
67
-     *
68
-     * If you just want to skip parsing for this element altogether, you can
69
-     * just call $reader->next();
70
-     *
71
-     * $reader->parseInnerTree() will parse the entire sub-tree, and advance to
72
-     * the next element.
73
-     *
74
-     * @param Reader $reader
75
-     * @return mixed
76
-     */
77
-    static function xmlDeserialize(Reader $reader) {
78
-
79
-        $self = new self();
80
-
81
-        $foundSearchProp = false;
82
-        $self->test = 'allof';
83
-        if ($reader->getAttribute('test') === 'anyof') {
84
-            $self->test = 'anyof';
85
-        }
86
-
87
-        $elemMap = [
88
-            '{DAV:}property-search' => 'Sabre\\Xml\\Element\\KeyValue',
89
-            '{DAV:}prop'            => 'Sabre\\Xml\\Element\\KeyValue',
90
-        ];
23
+	/**
24
+	 * The requested properties.
25
+	 *
26
+	 * @var array|null
27
+	 */
28
+	public $properties;
29
+
30
+	/**
31
+	 * searchProperties
32
+	 *
33
+	 * @var array
34
+	 */
35
+	public $searchProperties = [];
36
+
37
+	/**
38
+	 * By default the property search will be conducted on the url of the http
39
+	 * request. If this is set to true, it will be applied to the principal
40
+	 * collection set instead.
41
+	 *
42
+	 * @var bool
43
+	 */
44
+	public $applyToPrincipalCollectionSet = false;
45
+
46
+	/**
47
+	 * Search for principals matching ANY of the properties (OR) or a ALL of
48
+	 * the properties (AND).
49
+	 *
50
+	 * This property is either "anyof" or "allof".
51
+	 *
52
+	 * @var string
53
+	 */
54
+	public $test;
55
+
56
+	/**
57
+	 * The deserialize method is called during xml parsing.
58
+	 *
59
+	 * This method is called statictly, this is because in theory this method
60
+	 * may be used as a type of constructor, or factory method.
61
+	 *
62
+	 * Often you want to return an instance of the current class, but you are
63
+	 * free to return other data as well.
64
+	 *
65
+	 * You are responsible for advancing the reader to the next element. Not
66
+	 * doing anything will result in a never-ending loop.
67
+	 *
68
+	 * If you just want to skip parsing for this element altogether, you can
69
+	 * just call $reader->next();
70
+	 *
71
+	 * $reader->parseInnerTree() will parse the entire sub-tree, and advance to
72
+	 * the next element.
73
+	 *
74
+	 * @param Reader $reader
75
+	 * @return mixed
76
+	 */
77
+	static function xmlDeserialize(Reader $reader) {
78
+
79
+		$self = new self();
80
+
81
+		$foundSearchProp = false;
82
+		$self->test = 'allof';
83
+		if ($reader->getAttribute('test') === 'anyof') {
84
+			$self->test = 'anyof';
85
+		}
86
+
87
+		$elemMap = [
88
+			'{DAV:}property-search' => 'Sabre\\Xml\\Element\\KeyValue',
89
+			'{DAV:}prop'            => 'Sabre\\Xml\\Element\\KeyValue',
90
+		];
91 91
         
92
-        foreach ($reader->parseInnerTree($elemMap) as $elem) {
93
-
94
-            switch ($elem['name']) {
95
-
96
-                case '{DAV:}prop' :
97
-                    $self->properties = array_keys($elem['value']);
98
-                    break;
99
-                case '{DAV:}property-search' :
100
-                    $foundSearchProp = true;
101
-                    // This property has two sub-elements:
102
-                    //   {DAV:}prop - The property to be searched on. This may
103
-                    //                also be more than one
104
-                    //   {DAV:}match - The value to match with
105
-                    if (!isset($elem['value']['{DAV:}prop']) || !isset($elem['value']['{DAV:}match'])) {
106
-                        throw new BadRequest('The {DAV:}property-search element must contain one {DAV:}match and one {DAV:}prop element');
107
-                    }
108
-                    foreach ($elem['value']['{DAV:}prop'] as $propName => $discard) {
109
-                        $self->searchProperties[$propName] = $elem['value']['{DAV:}match'];
110
-                    }
111
-                    break;
112
-                case '{DAV:}apply-to-principal-collection-set' :
113
-                    $self->applyToPrincipalCollectionSet = true;
114
-                    break;
115
-
116
-            }
117
-
118
-        }
119
-        if (!$foundSearchProp) {
120
-            throw new BadRequest('The {DAV:}principal-property-search report must contain at least 1 {DAV:}property-search element');
121
-        }
122
-
123
-        return $self;
124
-
125
-    }
92
+		foreach ($reader->parseInnerTree($elemMap) as $elem) {
93
+
94
+			switch ($elem['name']) {
95
+
96
+				case '{DAV:}prop' :
97
+					$self->properties = array_keys($elem['value']);
98
+					break;
99
+				case '{DAV:}property-search' :
100
+					$foundSearchProp = true;
101
+					// This property has two sub-elements:
102
+					//   {DAV:}prop - The property to be searched on. This may
103
+					//                also be more than one
104
+					//   {DAV:}match - The value to match with
105
+					if (!isset($elem['value']['{DAV:}prop']) || !isset($elem['value']['{DAV:}match'])) {
106
+						throw new BadRequest('The {DAV:}property-search element must contain one {DAV:}match and one {DAV:}prop element');
107
+					}
108
+					foreach ($elem['value']['{DAV:}prop'] as $propName => $discard) {
109
+						$self->searchProperties[$propName] = $elem['value']['{DAV:}match'];
110
+					}
111
+					break;
112
+				case '{DAV:}apply-to-principal-collection-set' :
113
+					$self->applyToPrincipalCollectionSet = true;
114
+					break;
115
+
116
+			}
117
+
118
+		}
119
+		if (!$foundSearchProp) {
120
+			throw new BadRequest('The {DAV:}principal-property-search report must contain at least 1 {DAV:}property-search element');
121
+		}
122
+
123
+		return $self;
124
+
125
+	}
126 126
 
127 127
 }
Please login to merge, or discard this patch.
Unused Use Statements   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2,9 +2,9 @@
 block discarded – undo
2 2
 
3 3
 namespace Sabre\DAVACL\Xml\Request;
4 4
 
5
+use Sabre\DAV\Exception\BadRequest;
5 6
 use Sabre\Xml\Reader;
6 7
 use Sabre\Xml\XmlDeserializable;
7
-use Sabre\DAV\Exception\BadRequest;
8 8
 
9 9
 /**
10 10
  * PrincipalSearchPropertySetReport request parser.
Please login to merge, or discard this patch.
libraries/SabreDAV/DAVACL/Xml/Request/PrincipalSearchPropertySetReport.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@
 block discarded – undo
39 39
      * the next element.
40 40
      *
41 41
      * @param Reader $reader
42
-     * @return mixed
42
+     * @return PrincipalSearchPropertySetReport
43 43
      */
44 44
     static function xmlDeserialize(Reader $reader) {
45 45
 
Please login to merge, or discard this patch.
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -20,39 +20,39 @@
 block discarded – undo
20 20
  */
21 21
 class PrincipalSearchPropertySetReport implements XmlDeserializable {
22 22
 
23
-    /**
24
-     * The deserialize method is called during xml parsing.
25
-     *
26
-     * This method is called statictly, this is because in theory this method
27
-     * may be used as a type of constructor, or factory method.
28
-     *
29
-     * Often you want to return an instance of the current class, but you are
30
-     * free to return other data as well.
31
-     *
32
-     * You are responsible for advancing the reader to the next element. Not
33
-     * doing anything will result in a never-ending loop.
34
-     *
35
-     * If you just want to skip parsing for this element altogether, you can
36
-     * just call $reader->next();
37
-     *
38
-     * $reader->parseInnerTree() will parse the entire sub-tree, and advance to
39
-     * the next element.
40
-     *
41
-     * @param Reader $reader
42
-     * @return mixed
43
-     */
44
-    static function xmlDeserialize(Reader $reader) {
45
-
46
-        if (!$reader->isEmptyElement) {
47
-            throw new BadRequest('The {DAV:}principal-search-property-set element must be empty');
48
-        }
49
-
50
-        // The element is actually empty, so there's not much to do.
51
-        $reader->next();
52
-
53
-        $self = new self();
54
-        return $self;
55
-
56
-    }
23
+	/**
24
+	 * The deserialize method is called during xml parsing.
25
+	 *
26
+	 * This method is called statictly, this is because in theory this method
27
+	 * may be used as a type of constructor, or factory method.
28
+	 *
29
+	 * Often you want to return an instance of the current class, but you are
30
+	 * free to return other data as well.
31
+	 *
32
+	 * You are responsible for advancing the reader to the next element. Not
33
+	 * doing anything will result in a never-ending loop.
34
+	 *
35
+	 * If you just want to skip parsing for this element altogether, you can
36
+	 * just call $reader->next();
37
+	 *
38
+	 * $reader->parseInnerTree() will parse the entire sub-tree, and advance to
39
+	 * the next element.
40
+	 *
41
+	 * @param Reader $reader
42
+	 * @return mixed
43
+	 */
44
+	static function xmlDeserialize(Reader $reader) {
45
+
46
+		if (!$reader->isEmptyElement) {
47
+			throw new BadRequest('The {DAV:}principal-search-property-set element must be empty');
48
+		}
49
+
50
+		// The element is actually empty, so there's not much to do.
51
+		$reader->next();
52
+
53
+		$self = new self();
54
+		return $self;
55
+
56
+	}
57 57
 
58 58
 }
Please login to merge, or discard this patch.
Unused Use Statements   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2,9 +2,9 @@
 block discarded – undo
2 2
 
3 3
 namespace Sabre\DAVACL\Xml\Request;
4 4
 
5
+use Sabre\DAV\Exception\BadRequest;
5 6
 use Sabre\Xml\Reader;
6 7
 use Sabre\Xml\XmlDeserializable;
7
-use Sabre\DAV\Exception\BadRequest;
8 8
 
9 9
 /**
10 10
  * PrincipalSearchPropertySetReport request parser.
Please login to merge, or discard this patch.
modules/Accounts/Accounts.php 2 patches
Doc Comments   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -611,6 +611,7 @@  discard block
 block discarded – undo
611 611
 	 * @param  integer   $id      		- accountid
612 612
 	 * @param  array   $parent_accounts   - Array of all the parent accounts
613 613
 	 * returns All the parent accounts of the given accountid in array format
614
+	 * @param integer[] $encountered_accounts
614 615
 	 */
615 616
 	public function __getParentAccounts($id, &$parent_accounts, &$encountered_accounts, $depthBase = 0)
616 617
 	{
@@ -673,7 +674,7 @@  discard block
 block discarded – undo
673 674
 	 * Function to Recursively get all the child accounts of a given Account
674 675
 	 * @param  integer   $id      		- accountid
675 676
 	 * @param  array   $child_accounts   - Array of all the child accounts
676
-	 * @param  integer   $depth          - Depth at which the particular account has to be placed in the hierarchy
677
+	 * @param  integer   $depthBase          - Depth at which the particular account has to be placed in the hierarchy
677 678
 	 * returns All the child accounts of the given accountid in array format
678 679
 	 */
679 680
 	public function __getChildAccounts($id, &$child_accounts, $depthBase)
Please login to merge, or discard this patch.
Braces   +23 added lines, -16 removed lines patch added patch discarded remove patch
@@ -111,10 +111,11 @@  discard block
 block discarded – undo
111 111
 		$query .= $this->getNonAdminAccessControlQuery('Accounts', $current_user);
112 112
 		$where_auto = " vtiger_crmentity.deleted = 0 ";
113 113
 
114
-		if ($where != '')
115
-			$query .= sprintf(' where (%s) && %s', $where, $where_auto);
116
-		else
117
-			$query .= sprintf(' where %s', $where_auto);
114
+		if ($where != '') {
115
+					$query .= sprintf(' where (%s) && %s', $where, $where_auto);
116
+		} else {
117
+					$query .= sprintf(' where %s', $where_auto);
118
+		}
118 119
 
119 120
 		\App\Log::trace("Exiting create_export_query method ...");
120 121
 		return $query;
@@ -430,8 +431,9 @@  discard block
 block discarded – undo
430 431
 	public function unlinkRelationship($id, $return_module, $return_id, $relatedName = false)
431 432
 	{
432 433
 
433
-		if (empty($return_module) || empty($return_id))
434
-			return;
434
+		if (empty($return_module) || empty($return_id)) {
435
+					return;
436
+		}
435 437
 
436 438
 		if ($return_module === 'Campaigns') {
437 439
 			App\Db::getInstance()->createCommand()->delete('vtiger_campaign_records', ['crmid' => $id, 'campaignid' => $return_id])->execute();
@@ -444,8 +446,9 @@  discard block
 block discarded – undo
444 446
 
445 447
 	public function save_related_module($module, $crmid, $with_module, $with_crmids, $relatedName = false)
446 448
 	{
447
-		if (!is_array($with_crmids))
448
-			$with_crmids = [$with_crmids];
449
+		if (!is_array($with_crmids)) {
450
+					$with_crmids = [$with_crmids];
451
+		}
449 452
 		if (!in_array($with_module, ['Products', 'Campaigns'])) {
450 453
 			parent::save_related_module($module, $crmid, $with_module, $with_crmids, $relatedName);
451 454
 		} else {
@@ -495,10 +498,12 @@  discard block
 block discarded – undo
495 498
 					continue;
496 499
 				}
497 500
 				// Setup the default JOIN conditions if not specified
498
-				if (empty($relmap[1]))
499
-					$relmap[1] = $other->table_name;
500
-				if (empty($relmap[2]))
501
-					$relmap[2] = $relmap[0];
501
+				if (empty($relmap[1])) {
502
+									$relmap[1] = $other->table_name;
503
+				}
504
+				if (empty($relmap[2])) {
505
+									$relmap[2] = $relmap[0];
506
+				}
502 507
 				$join .= " LEFT JOIN $tname ON $tname.$relmap[0] = $relmap[1].$relmap[2]";
503 508
 			}
504 509
 		}
@@ -523,14 +528,16 @@  discard block
 block discarded – undo
523 528
 	public function getRelatedContactsIds($id = null)
524 529
 	{
525 530
 
526
-		if ($id === null)
527
-			$id = $this->id;
531
+		if ($id === null) {
532
+					$id = $this->id;
533
+		}
528 534
 		$query = (new \App\Db\Query())->select('contactid')->from('vtiger_contactdetails')
529 535
 			->innerJoin('vtiger_crmentity', 'vtiger_contactdetails.contactid = vtiger_crmentity.crmid')
530 536
 			->where(['vtiger_contactdetails.parentid' => $id, 'vtiger_crmentity.deleted' => 0]);
531 537
 		$entityIds = $query->column();
532
-		if (empty($entityIds))
533
-			$entityIds = [];
538
+		if (empty($entityIds)) {
539
+					$entityIds = [];
540
+		}
534 541
 
535 542
 		return $entityIds;
536 543
 	}
Please login to merge, or discard this patch.
modules/Calendar/actions/Calendar.php 1 patch
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -109,6 +109,9 @@
 block discarded – undo
109 109
 		$response->emit();
110 110
 	}
111 111
 
112
+	/**
113
+	 * @param string $datetime
114
+	 */
112 115
 	public function changeDateTime($datetime, $delta)
113 116
 	{
114 117
 		$date = new DateTime($datetime);
Please login to merge, or discard this patch.
modules/Calendar/actions/DragDropAjax.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -119,6 +119,9 @@
 block discarded – undo
119 119
 	 * Function adds days and minutes to datetime string
120 120
 	 */
121 121
 
122
+	/**
123
+	 * @param string $datetime
124
+	 */
122 125
 	public function changeDateTime($datetime, $daysToAdd, $minutesToAdd)
123 126
 	{
124 127
 		$datetime = strtotime($datetime);
Please login to merge, or discard this patch.
Braces   +11 added lines, -8 removed lines patch added patch discarded remove patch
@@ -51,8 +51,9 @@  discard block
 block discarded – undo
51 51
 			$resultDateTime = $this->changeDateTime($oldDateTime, $dayDelta, $minuteDelta);
52 52
 			$parts = explode(' ', $resultDateTime);
53 53
 			$record->set('due_date', $parts[0]);
54
-			if (activitytype != 'Task')
55
-				$record->set('time_end', $parts[1]);
54
+			if (activitytype != 'Task') {
55
+							$record->set('time_end', $parts[1]);
56
+			}
56 57
 
57 58
 			$startDateTime[] = $record->get('date_start');
58 59
 			$startDateTime[] = $record->get('time_start');
@@ -64,10 +65,11 @@  discard block
 block discarded – undo
64 65
 			$endDateTime = implode(' ', $endDateTime);
65 66
 			$endDateTime = new DateTime($endDateTime);
66 67
 			//Checking if startDateTime is less than or equal to endDateTime
67
-			if ($startDateTime <= $endDateTime)
68
-				$record->save();
69
-			else
70
-				$result['error'] = true;
68
+			if ($startDateTime <= $endDateTime) {
69
+							$record->save();
70
+			} else {
71
+							$result['error'] = true;
72
+			}
71 73
 
72 74
 			$response->setResult($result);
73 75
 			$response->emit();
@@ -107,8 +109,9 @@  discard block
 block discarded – undo
107 109
 			$resultDateTime = $this->changeDateTime($oldEndDateTime, $dayDelta, $minuteDelta);
108 110
 			$parts = explode(' ', $resultDateTime);
109 111
 			$record->set('due_date', $parts[0]);
110
-			if (activitytype != 'Task')
111
-				$record->set('time_end', $parts[1]);
112
+			if (activitytype != 'Task') {
113
+							$record->set('time_end', $parts[1]);
114
+			}
112 115
 			$record->save();
113 116
 
114 117
 			$response->setResult($result);
Please login to merge, or discard this patch.
modules/Calendar/Date.php 2 patches
Doc Comments   +1 added lines, -5 removed lines patch added patch discarded remove patch
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
 
385 385
 	/**
386 386
 	 *
387
-	 * @return Date
387
+	 * @return string
388 388
 	 */
389 389
 	public function get_DB_formatted_date()
390 390
 	{
@@ -529,10 +529,6 @@  discard block
 block discarded – undo
529 529
 	 * This should be used whereever possible
530 530
 	 *
531 531
 	 * @param integer       $index - number between 0 to 42
532
-	 * @param string        $day   - date
533
-	 * @param string        $month - month
534
-	 * @param string        $year  - year
535
-	 * return vt_DateTime obj  $datetimevalue
536 532
 	 */
537 533
 	public function getThisMonthsDayByIndex($index)
538 534
 	{
Please login to merge, or discard this patch.
Braces   +37 added lines, -26 removed lines patch added patch discarded remove patch
@@ -87,12 +87,15 @@  discard block
 block discarded – undo
87 87
 	 */
88 88
 	public function getTodayDatetimebyIndex($index, $day = '', $month = '', $year = '')
89 89
 	{
90
-		if ($day === '')
91
-			$day = $this->day;
92
-		if ($month === '')
93
-			$month = $this->month;
94
-		if ($year === '')
95
-			$year = $this->year;
90
+		if ($day === '') {
91
+					$day = $this->day;
92
+		}
93
+		if ($month === '') {
94
+					$month = $this->month;
95
+		}
96
+		if ($year === '') {
97
+					$year = $this->year;
98
+		}
96 99
 		$day_array = array();
97 100
 
98 101
 		if ($index < 0 || $index > 23) {
@@ -140,12 +143,15 @@  discard block
 block discarded – undo
140 143
 	 */
141 144
 	public function getThismonthDaysbyIndex($index, $day = '', $month = '', $year = '')
142 145
 	{
143
-		if ($day == '')
144
-			$day = $index + 1;
145
-		if ($month == '')
146
-			$month = $this->month;
147
-		if ($year == '')
148
-			$year = $this->year;
146
+		if ($day == '') {
147
+					$day = $index + 1;
148
+		}
149
+		if ($month == '') {
150
+					$month = $this->month;
151
+		}
152
+		if ($year == '') {
153
+					$year = $this->year;
154
+		}
149 155
 		$month_array = array();
150 156
 		$month_array['day'] = $day;
151 157
 		$month_array['month'] = $month;
@@ -356,8 +362,9 @@  discard block
 block discarded – undo
356 362
 		} else {
357 363
 			throw new \Exception\AppException('year was not set');
358 364
 		}
359
-		if (empty($hour) && $hour !== 0)
360
-			$hour = 0;
365
+		if (empty($hour) && $hour !== 0) {
366
+					$hour = 0;
367
+		}
361 368
 		$this->ts = mktime($hour, $minute, $second, $month, $day, $year);
362 369
 		$this->setDateTime($this->ts);
363 370
 	}
@@ -399,10 +406,12 @@  discard block
 block discarded – undo
399 406
 	{
400 407
 		$hour = $this->z_hour;
401 408
 		$min = $this->minute;
402
-		if (empty($hour))
403
-			$hour = '00';
404
-		if (empty($min))
405
-			$min = '00';
409
+		if (empty($hour)) {
410
+					$hour = '00';
411
+		}
412
+		if (empty($min)) {
413
+					$min = '00';
414
+		}
406 415
 		return $hour . ':' . $min;
407 416
 	}
408 417
 
@@ -413,10 +422,11 @@  discard block
 block discarded – undo
413 422
 	 */
414 423
 	public function get_changed_day($mode)
415 424
 	{
416
-		if ($mode == 'increment')
417
-			$day = $this->day + 1;
418
-		else
419
-			$day = $this->day - 1;
425
+		if ($mode == 'increment') {
426
+					$day = $this->day + 1;
427
+		} else {
428
+					$day = $this->day - 1;
429
+		}
420 430
 		$date_data = array('day' => $day,
421 431
 			'month' => $this->month,
422 432
 			'year' => $this->year
@@ -432,10 +442,11 @@  discard block
 block discarded – undo
432 442
 	public function get_first_day_of_changed_week($mode)
433 443
 	{
434 444
 		$first_day = $this->getThisweekDaysbyIndex(1);
435
-		if ($mode == 'increment')
436
-			$day = $first_day->day + 7;
437
-		else
438
-			$day = $first_day->day - 7;
445
+		if ($mode == 'increment') {
446
+					$day = $first_day->day + 7;
447
+		} else {
448
+					$day = $first_day->day - 7;
449
+		}
439 450
 		$date_data = array('day' => $day,
440 451
 			'month' => $first_day->month,
441 452
 			'year' => $first_day->year
Please login to merge, or discard this patch.
modules/Import/helpers/Utils.php 1 patch
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -233,6 +233,9 @@
 block discarded – undo
233 233
 		return false;
234 234
 	}
235 235
 
236
+	/**
237
+	 * @param Vtiger_Request $request
238
+	 */
236 239
 	public static function validateFileUpload($request)
237 240
 	{
238 241
 		$current_user = Users_Record_Model::getCurrentUserModel();
Please login to merge, or discard this patch.