Completed
Pull Request — master (#82)
by
unknown
10:19
created
src/PurifierServiceProvider.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@
 block discarded – undo
49 49
     /**
50 50
      * Get the services provided by the provider.
51 51
      *
52
-     * @return array
52
+     * @return string[]
53 53
      */
54 54
     public function provides()
55 55
     {
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
     {
34 34
         $source = realpath(__DIR__.'/../config/purifier.php');
35 35
         if ($this->app instanceof LaravelApplication && $this->app->runningInConsole()) {
36
-            $this->publishes([$source => config_path('purifier.php')]);
36
+            $this->publishes([ $source => config_path('purifier.php') ]);
37 37
         } elseif ($this->app instanceof LumenApplication) {
38 38
             $this->app->configure('purifier');
39 39
         }
@@ -48,9 +48,9 @@  discard block
 block discarded – undo
48 48
      */
49 49
     public function register()
50 50
     {
51
-        $this->app->singleton('purifier', function (Container $app) {
52
-            $configBuilder = new PurifierConfigBuilder($app['config']);
53
-            return new Purifier($configBuilder, $app['files'], $app['config']);
51
+        $this->app->singleton('purifier', function(Container $app) {
52
+            $configBuilder = new PurifierConfigBuilder($app[ 'config' ]);
53
+            return new Purifier($configBuilder, $app[ 'files' ], $app[ 'config' ]);
54 54
         });
55 55
 
56 56
         $this->app->alias('purifier', Purifier::class);
@@ -63,6 +63,6 @@  discard block
 block discarded – undo
63 63
      */
64 64
     public function provides()
65 65
     {
66
-        return ['purifier'];
66
+        return [ 'purifier' ];
67 67
     }
68 68
 }
Please login to merge, or discard this patch.
config/purifier.php 2 patches
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -42,23 +42,23 @@  discard block
 block discarded – undo
42 42
             'debug' => false,
43 43
             'elements' => [
44 44
                 // http://developers.whatwg.org/sections.html
45
-                ['section', 'Block', 'Flow', 'Common'],
46
-                ['nav',     'Block', 'Flow', 'Common'],
47
-                ['article', 'Block', 'Flow', 'Common'],
48
-                ['aside',   'Block', 'Flow', 'Common'],
49
-                ['header',  'Block', 'Flow', 'Common'],
50
-                ['footer',  'Block', 'Flow', 'Common'],
45
+                [ 'section', 'Block', 'Flow', 'Common' ],
46
+                [ 'nav', 'Block', 'Flow', 'Common' ],
47
+                [ 'article', 'Block', 'Flow', 'Common' ],
48
+                [ 'aside', 'Block', 'Flow', 'Common' ],
49
+                [ 'header', 'Block', 'Flow', 'Common' ],
50
+                [ 'footer', 'Block', 'Flow', 'Common' ],
51 51
 				
52 52
 				// Content model actually excludes several tags, not modelled here
53
-                ['address', 'Block', 'Flow', 'Common'],
54
-                ['hgroup', 'Block', 'Required: h1 | h2 | h3 | h4 | h5 | h6', 'Common'],
53
+                [ 'address', 'Block', 'Flow', 'Common' ],
54
+                [ 'hgroup', 'Block', 'Required: h1 | h2 | h3 | h4 | h5 | h6', 'Common' ],
55 55
 				
56 56
 				// http://developers.whatwg.org/grouping-content.html
57
-                ['figure', 'Block', 'Optional: (figcaption, Flow) | (Flow, figcaption) | Flow', 'Common'],
58
-                ['figcaption', 'Inline', 'Flow', 'Common'],
57
+                [ 'figure', 'Block', 'Optional: (figcaption, Flow) | (Flow, figcaption) | Flow', 'Common' ],
58
+                [ 'figcaption', 'Inline', 'Flow', 'Common' ],
59 59
 				
60 60
 				// http://developers.whatwg.org/the-video-element.html#the-video-element
61
-                ['video', 'Block', 'Optional: (source, Flow) | (Flow, source) | Flow', 'Common', [
61
+                [ 'video', 'Block', 'Optional: (source, Flow) | (Flow, source) | Flow', 'Common', [
62 62
                     'src' => 'URI',
63 63
 					'type' => 'Text',
64 64
 					'width' => 'Length',
@@ -66,39 +66,39 @@  discard block
 block discarded – undo
66 66
 					'poster' => 'URI',
67 67
 					'preload' => 'Enum#auto,metadata,none',
68 68
 					'controls' => 'Bool',
69
-                ]],
70
-                ['source', 'Block', 'Flow', 'Common', [
69
+                ] ],
70
+                [ 'source', 'Block', 'Flow', 'Common', [
71 71
 					'src' => 'URI',
72 72
 					'type' => 'Text',
73
-                ]],
73
+                ] ],
74 74
 
75 75
 				// http://developers.whatwg.org/text-level-semantics.html
76
-                ['s',    'Inline', 'Inline', 'Common'],
77
-                ['var',  'Inline', 'Inline', 'Common'],
78
-                ['sub',  'Inline', 'Inline', 'Common'],
79
-                ['sup',  'Inline', 'Inline', 'Common'],
80
-                ['mark', 'Inline', 'Inline', 'Common'],
81
-                ['wbr',  'Inline', 'Empty', 'Core'],
76
+                [ 's', 'Inline', 'Inline', 'Common' ],
77
+                [ 'var', 'Inline', 'Inline', 'Common' ],
78
+                [ 'sub', 'Inline', 'Inline', 'Common' ],
79
+                [ 'sup', 'Inline', 'Inline', 'Common' ],
80
+                [ 'mark', 'Inline', 'Inline', 'Common' ],
81
+                [ 'wbr', 'Inline', 'Empty', 'Core' ],
82 82
 				
83 83
 				// http://developers.whatwg.org/edits.html
84
-                ['ins', 'Block', 'Flow', 'Common', ['cite' => 'URI', 'datetime' => 'CDATA']],
85
-                ['del', 'Block', 'Flow', 'Common', ['cite' => 'URI', 'datetime' => 'CDATA']],
84
+                [ 'ins', 'Block', 'Flow', 'Common', [ 'cite' => 'URI', 'datetime' => 'CDATA' ] ],
85
+                [ 'del', 'Block', 'Flow', 'Common', [ 'cite' => 'URI', 'datetime' => 'CDATA' ] ],
86 86
             ],
87 87
             'attributes' => [
88
-                ['iframe', 'allowfullscreen', 'Bool'],
89
-                ['table', 'height', 'Text'],
90
-                ['td', 'border', 'Text'],
91
-                ['th', 'border', 'Text'],
92
-                ['tr', 'width', 'Text'],
93
-                ['tr', 'height', 'Text'],
94
-                ['tr', 'border', 'Text'],
88
+                [ 'iframe', 'allowfullscreen', 'Bool' ],
89
+                [ 'table', 'height', 'Text' ],
90
+                [ 'td', 'border', 'Text' ],
91
+                [ 'th', 'border', 'Text' ],
92
+                [ 'tr', 'width', 'Text' ],
93
+                [ 'tr', 'height', 'Text' ],
94
+                [ 'tr', 'border', 'Text' ],
95 95
             ],
96 96
         ],
97 97
         'custom_attributes' => [
98
-            ['a', 'target', 'Enum#_blank,_self,_target,_top'],
98
+            [ 'a', 'target', 'Enum#_blank,_self,_target,_top' ],
99 99
         ],
100 100
         'custom_elements' => [
101
-            ['u', 'Inline', 'Inline', 'Common'],
101
+            [ 'u', 'Inline', 'Inline', 'Common' ],
102 102
         ],
103 103
     ],
104 104
 
Please login to merge, or discard this patch.
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -49,30 +49,30 @@  discard block
 block discarded – undo
49 49
                 ['header',  'Block', 'Flow', 'Common'],
50 50
                 ['footer',  'Block', 'Flow', 'Common'],
51 51
 				
52
-				// Content model actually excludes several tags, not modelled here
52
+                // Content model actually excludes several tags, not modelled here
53 53
                 ['address', 'Block', 'Flow', 'Common'],
54 54
                 ['hgroup', 'Block', 'Required: h1 | h2 | h3 | h4 | h5 | h6', 'Common'],
55 55
 				
56
-				// http://developers.whatwg.org/grouping-content.html
56
+                // http://developers.whatwg.org/grouping-content.html
57 57
                 ['figure', 'Block', 'Optional: (figcaption, Flow) | (Flow, figcaption) | Flow', 'Common'],
58 58
                 ['figcaption', 'Inline', 'Flow', 'Common'],
59 59
 				
60
-				// http://developers.whatwg.org/the-video-element.html#the-video-element
60
+                // http://developers.whatwg.org/the-video-element.html#the-video-element
61 61
                 ['video', 'Block', 'Optional: (source, Flow) | (Flow, source) | Flow', 'Common', [
62 62
                     'src' => 'URI',
63
-					'type' => 'Text',
64
-					'width' => 'Length',
65
-					'height' => 'Length',
66
-					'poster' => 'URI',
67
-					'preload' => 'Enum#auto,metadata,none',
68
-					'controls' => 'Bool',
63
+                    'type' => 'Text',
64
+                    'width' => 'Length',
65
+                    'height' => 'Length',
66
+                    'poster' => 'URI',
67
+                    'preload' => 'Enum#auto,metadata,none',
68
+                    'controls' => 'Bool',
69 69
                 ]],
70 70
                 ['source', 'Block', 'Flow', 'Common', [
71
-					'src' => 'URI',
72
-					'type' => 'Text',
71
+                    'src' => 'URI',
72
+                    'type' => 'Text',
73 73
                 ]],
74 74
 
75
-				// http://developers.whatwg.org/text-level-semantics.html
75
+                // http://developers.whatwg.org/text-level-semantics.html
76 76
                 ['s',    'Inline', 'Inline', 'Common'],
77 77
                 ['var',  'Inline', 'Inline', 'Common'],
78 78
                 ['sub',  'Inline', 'Inline', 'Common'],
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
                 ['mark', 'Inline', 'Inline', 'Common'],
81 81
                 ['wbr',  'Inline', 'Empty', 'Core'],
82 82
 				
83
-				// http://developers.whatwg.org/edits.html
83
+                // http://developers.whatwg.org/edits.html
84 84
                 ['ins', 'Block', 'Flow', 'Common', ['cite' => 'URI', 'datetime' => 'CDATA']],
85 85
                 ['del', 'Block', 'Flow', 'Common', ['cite' => 'URI', 'datetime' => 'CDATA']],
86 86
             ],
Please login to merge, or discard this patch.
src/helpers.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (!function_exists('clean')) {
3
+if ( ! function_exists('clean')) {
4 4
     function clean($dirty, $config = null)
5 5
     {
6 6
         return app('purifier')->clean($dirty, $config);
Please login to merge, or discard this patch.
src/PurifierConfigBuilder.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
     /**
38 38
      * @param null $config
39 39
      *
40
-     * @return mixed|null
40
+     * @return HTMLPurifier_Config
41 41
      */
42 42
     public function getConfig($config = null)
43 43
     {
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
     }
220 220
 
221 221
     /**
222
-     * @param $allowed
222
+     * @param string $allowed
223 223
      * @param \HTMLPurifier_Config $configObject
224 224
      * @return mixed
225 225
      */
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
     }
243 243
 
244 244
     /**
245
-     * @param $name
245
+     * @param string $name
246 246
      * @param $value
247 247
      * @param \HTMLPurifier_Config $configObject
248 248
      */
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -45,24 +45,24 @@  discard block
 block discarded – undo
45 45
         $configObject = HTMLPurifier_Config::createDefault();
46 46
 
47 47
         // Allow configuration to be modified
48
-        if (! $this->config->get('purifier.finalize')) {
48
+        if ( ! $this->config->get('purifier.finalize')) {
49 49
             $configObject->autoFinalize = false;
50 50
         }
51 51
 
52 52
         // Set default config
53
-        $defaultConfig = [];
54
-        $defaultConfig['Core.Encoding'] = $this->config->get('purifier.encoding');
55
-        $defaultConfig['Cache.SerializerPath'] = $this->config->get('purifier.cachePath');
56
-        $defaultConfig['Cache.SerializerPermissions'] = $this->config->get('purifier.cacheFileMode', 0755);
53
+        $defaultConfig = [ ];
54
+        $defaultConfig[ 'Core.Encoding' ] = $this->config->get('purifier.encoding');
55
+        $defaultConfig[ 'Cache.SerializerPath' ] = $this->config->get('purifier.cachePath');
56
+        $defaultConfig[ 'Cache.SerializerPermissions' ] = $this->config->get('purifier.cacheFileMode', 0755);
57 57
 
58
-        if (! $config) {
58
+        if ( ! $config) {
59 59
             $config = $this->config->get('purifier.settings.default');
60 60
         } elseif (is_string($config)) {
61
-            $config = $this->config->get('purifier.settings.' . $config);
61
+            $config = $this->config->get('purifier.settings.'.$config);
62 62
         }
63 63
 
64
-        if (! is_array($config)) {
65
-            $config = [];
64
+        if ( ! is_array($config)) {
65
+            $config = [ ];
66 66
         }
67 67
 
68 68
         // Merge configurations
@@ -104,30 +104,30 @@  discard block
 block discarded – undo
104 104
      */
105 105
     private function addCustomDefinition(array $definitionConfig, $configObject = null)
106 106
     {
107
-        if (! $configObject) {
107
+        if ( ! $configObject) {
108 108
             $configObject = HTMLPurifier_Config::createDefault();
109 109
             $configObject->loadArray($this->getConfig());
110 110
         }
111 111
 
112 112
         // Setup the custom definition
113
-        $configObject->set('HTML.DefinitionID', $definitionConfig['id']);
114
-        $configObject->set('HTML.DefinitionRev', $definitionConfig['rev']);
113
+        $configObject->set('HTML.DefinitionID', $definitionConfig[ 'id' ]);
114
+        $configObject->set('HTML.DefinitionRev', $definitionConfig[ 'rev' ]);
115 115
 
116 116
         // Enable debug mode
117
-        if (! isset($definitionConfig['debug']) || $definitionConfig['debug']) {
117
+        if ( ! isset($definitionConfig[ 'debug' ]) || $definitionConfig[ 'debug' ]) {
118 118
             $configObject->set('Cache.DefinitionImpl', null);
119 119
         }
120 120
 
121 121
         // Start configuring the definition
122 122
         if ($def = $configObject->maybeGetRawHTMLDefinition()) {
123 123
             // Create the definition attributes
124
-            if (! empty($definitionConfig['attributes'])) {
125
-                $this->addCustomAttributes($definitionConfig['attributes'], $def);
124
+            if ( ! empty($definitionConfig[ 'attributes' ])) {
125
+                $this->addCustomAttributes($definitionConfig[ 'attributes' ], $def);
126 126
             }
127 127
 
128 128
             // Create the definition elements
129
-            if (! empty($definitionConfig['elements'])) {
130
-                $this->addCustomElements($definitionConfig['elements'], $def, $configObject);
129
+            if ( ! empty($definitionConfig[ 'elements' ])) {
130
+                $this->addCustomElements($definitionConfig[ 'elements' ], $def, $configObject);
131 131
             }
132 132
         }
133 133
 
@@ -146,10 +146,10 @@  discard block
 block discarded – undo
146 146
     {
147 147
         foreach ($attributes as $attribute) {
148 148
             // Get configuration of attribute
149
-            $required = ! empty($attribute[3]) ? true : false;
150
-            $onElement = $attribute[0];
151
-            $attrName = $required ? $attribute[1] . '*' : $attribute[1];
152
-            $validValues = $attribute[2];
149
+            $required = ! empty($attribute[ 3 ]) ? true : false;
150
+            $onElement = $attribute[ 0 ];
151
+            $attrName = $required ? $attribute[ 1 ].'*' : $attribute[ 1 ];
152
+            $validValues = $attribute[ 2 ];
153 153
 
154 154
             $definition->addAttribute($onElement, $attrName, $validValues);
155 155
         }
@@ -167,19 +167,19 @@  discard block
 block discarded – undo
167 167
      * @return HTMLPurifier_HTMLDefinition $definition
168 168
      */
169 169
     private function addCustomElements(array $elements, HTMLPurifier_HTMLDefinition $definition, HTMLPurifier_Config $configObject) {
170
-        $customElements = [];
170
+        $customElements = [ ];
171 171
 
172 172
         foreach ($elements as $element) {
173 173
             // Get configuration of element
174
-            $name = $element[0];
175
-            $contentSet = $element[1];
176
-            $allowedChildren = $element[2];
177
-            $attributeCollection = $element[3];
178
-            $attributes = isset($element[4]) ? $element[4] : null;
174
+            $name = $element[ 0 ];
175
+            $contentSet = $element[ 1 ];
176
+            $allowedChildren = $element[ 2 ];
177
+            $attributeCollection = $element[ 3 ];
178
+            $attributes = isset($element[ 4 ]) ? $element[ 4 ] : null;
179 179
 
180
-            $customElements[] = $name;
180
+            $customElements[ ] = $name;
181 181
 
182
-            if (! empty($attributes)) {
182
+            if ( ! empty($attributes)) {
183 183
                 $definition->addElement($name, $contentSet, $allowedChildren, $attributeCollection, $attributes);
184 184
             } else {
185 185
                 $definition->addElement($name, $contentSet, $allowedChildren, $attributeCollection);
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 
194 194
         // We must append custom elements to the list of allowed elements if it is provided
195 195
         if ($allowed = $this->getAllowedProperty($configObject)) {
196
-            $allowed = $allowed . ',' . implode(',', $customElements);
196
+            $allowed = $allowed.','.implode(',', $customElements);
197 197
 
198 198
             $this->setAllowedProperty($allowed, $configObject);
199 199
         }
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
         // when setting properties from HTML namespace
253 253
         // So we  use closure to access protected property and set modified value directly
254 254
         // Closure much faster than ReflectionProperty
255
-        $plistClosure = \Closure::bind(function ($configObject) {
255
+        $plistClosure = \Closure::bind(function($configObject) {
256 256
             return $configObject->plist;
257 257
         }, null, HTMLPurifier_Config::class);
258 258
 
Please login to merge, or discard this patch.
src/Purifier.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
      */
66 66
     private function setUp()
67 67
     {
68
-        if (!$this->config->has('purifier')) {
68
+        if ( ! $this->config->has('purifier')) {
69 69
             throw new Exception('Configuration parameters not loaded!');
70 70
         }
71 71
 
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
         $cachePath = $this->config->get('purifier.cachePath');
86 86
 
87 87
         if ($cachePath) {
88
-            if (!$this->files->isDirectory($cachePath)) {
88
+            if ( ! $this->files->isDirectory($cachePath)) {
89 89
                 $this->files->makeDirectory($cachePath, $this->config->get('purifier.cacheFileMode', 0755));
90 90
             }
91 91
         }
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
     public function clean($dirty, $config = null)
101 101
     {
102 102
         if (is_array($dirty)) {
103
-            return array_map(function ($item) use ($config) {
103
+            return array_map(function($item) use ($config) {
104 104
                 return $this->clean($item, $config);
105 105
             }, $dirty);
106 106
         }
Please login to merge, or discard this patch.