@@ -37,7 +37,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 | */ |
@@ -45,24 +45,24 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | |
@@ -33,7 +33,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 63 | 63 | */ |
| 64 | 64 | public function provides() |
| 65 | 65 | { |
| 66 | - return ['purifier']; |
|
| 66 | + return [ 'purifier' ]; |
|
| 67 | 67 | } |
| 68 | 68 | } |
@@ -65,7 +65,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 | } |