Completed
Push — developer ( 5b19f1...d751a3 )
by Błażej
174:33 queued 128:17
created
libraries/htmlpurifier/library/HTMLPurifier/Strategy/FixNesting.php 1 patch
Indentation   +124 added lines, -124 removed lines patch added patch discarded remove patch
@@ -32,130 +32,130 @@
 block discarded – undo
32 32
 class HTMLPurifier_Strategy_FixNesting extends HTMLPurifier_Strategy
33 33
 {
34 34
 
35
-    /**
36
-     * @param HTMLPurifier_Token[] $tokens
37
-     * @param HTMLPurifier_Config $config
38
-     * @param HTMLPurifier_Context $context
39
-     * @return array|HTMLPurifier_Token[]
40
-     */
41
-    public function execute($tokens, $config, $context)
42
-    {
43
-
44
-        //####################################################################//
45
-        // Pre-processing
46
-
47
-        // O(n) pass to convert to a tree, so that we can efficiently
48
-        // refer to substrings
49
-        $top_node = HTMLPurifier_Arborize::arborize($tokens, $config, $context);
50
-
51
-        // get a copy of the HTML definition
52
-        $definition = $config->getHTMLDefinition();
53
-
54
-        $excludes_enabled = !$config->get('Core.DisableExcludes');
55
-
56
-        // setup the context variable 'IsInline', for chameleon processing
57
-        // is 'false' when we are not inline, 'true' when it must always
58
-        // be inline, and an integer when it is inline for a certain
59
-        // branch of the document tree
60
-        $is_inline = $definition->info_parent_def->descendants_are_inline;
61
-        $context->register('IsInline', $is_inline);
62
-
63
-        // setup error collector
64
-        $e =& $context->get('ErrorCollector', true);
65
-
66
-        //####################################################################//
67
-        // Loop initialization
68
-
69
-        // stack that contains all elements that are excluded
70
-        // it is organized by parent elements, similar to $stack,
71
-        // but it is only populated when an element with exclusions is
72
-        // processed, i.e. there won't be empty exclusions.
73
-        $exclude_stack = array($definition->info_parent_def->excludes);
74
-
75
-        // variable that contains the start token while we are processing
76
-        // nodes. This enables error reporting to do its job
77
-        $node = $top_node;
78
-        // dummy token
79
-        list($token, $d) = $node->toTokenPair();
80
-        $context->register('CurrentNode', $node);
81
-        $context->register('CurrentToken', $token);
82
-
83
-        $parent_def = $definition->info_parent_def;
84
-        $stack = array(
85
-            array($top_node,
86
-                  $parent_def->descendants_are_inline,
87
-                  $parent_def->excludes, // exclusions
88
-                  0)
89
-            );
90
-
91
-        while (!empty($stack)) {
92
-            list($node, $is_inline, $excludes, $ix) = array_pop($stack);
93
-            // recursive call
94
-            $go = false;
95
-            $def = empty($stack) ? $definition->info_parent_def : $definition->info[$node->name];
96
-            while (isset($node->children[$ix])) {
97
-                $child = $node->children[$ix++];
98
-                if ($child instanceof HTMLPurifier_Node_Element) {
99
-                    $go = true;
100
-                    $stack[] = array($node, $is_inline, $excludes, $ix);
101
-                    $stack[] = array($child,
102
-                        // ToDo: I don't think it matters if it's def or
103
-                        // child_def, but double check this...
104
-                        $is_inline || $def->descendants_are_inline,
105
-                        empty($def->excludes) ? $excludes
106
-                                              : array_merge($excludes, $def->excludes),
107
-                        0);
108
-                    break;
109
-                }
110
-            };
111
-            if ($go) continue;
112
-            list($token, $d) = $node->toTokenPair();
113
-            // base case
114
-            if ($excludes_enabled && isset($excludes[$node->name])) {
115
-                $node->dead = true;
116
-                if ($e) $e->send(E_ERROR, 'Strategy_FixNesting: Node excluded');
117
-            } else {
118
-                // XXX I suppose it would be slightly more efficient to
119
-                // avoid the allocation here and have children
120
-                // strategies handle it
121
-                $children = array();
122
-                foreach ($node->children as $child) {
123
-                    if (!$child->dead) $children[] = $child;
124
-                }
125
-                $result = $def->child->validateChildren($children, $config, $context);
126
-                if ($result === true) {
127
-                    // nop
128
-                    $node->children = $children;
129
-                } elseif ($result === false) {
130
-                    $node->dead = true;
131
-                    if ($e) $e->send(E_ERROR, 'Strategy_FixNesting: Node removed');
132
-                } else {
133
-                    $node->children = $result;
134
-                    if ($e) {
135
-                        // XXX This will miss mutations of internal nodes. Perhaps defer to the child validators
136
-                        if (empty($result) && !empty($children)) {
137
-                            $e->send(E_ERROR, 'Strategy_FixNesting: Node contents removed');
138
-                        } else if ($result != $children) {
139
-                            $e->send(E_WARNING, 'Strategy_FixNesting: Node reorganized');
140
-                        }
141
-                    }
142
-                }
143
-            }
144
-        }
145
-
146
-        //####################################################################//
147
-        // Post-processing
148
-
149
-        // remove context variables
150
-        $context->destroy('IsInline');
151
-        $context->destroy('CurrentNode');
152
-        $context->destroy('CurrentToken');
153
-
154
-        //####################################################################//
155
-        // Return
156
-
157
-        return HTMLPurifier_Arborize::flatten($node, $config, $context);
158
-    }
35
+	/**
36
+	 * @param HTMLPurifier_Token[] $tokens
37
+	 * @param HTMLPurifier_Config $config
38
+	 * @param HTMLPurifier_Context $context
39
+	 * @return array|HTMLPurifier_Token[]
40
+	 */
41
+	public function execute($tokens, $config, $context)
42
+	{
43
+
44
+		//####################################################################//
45
+		// Pre-processing
46
+
47
+		// O(n) pass to convert to a tree, so that we can efficiently
48
+		// refer to substrings
49
+		$top_node = HTMLPurifier_Arborize::arborize($tokens, $config, $context);
50
+
51
+		// get a copy of the HTML definition
52
+		$definition = $config->getHTMLDefinition();
53
+
54
+		$excludes_enabled = !$config->get('Core.DisableExcludes');
55
+
56
+		// setup the context variable 'IsInline', for chameleon processing
57
+		// is 'false' when we are not inline, 'true' when it must always
58
+		// be inline, and an integer when it is inline for a certain
59
+		// branch of the document tree
60
+		$is_inline = $definition->info_parent_def->descendants_are_inline;
61
+		$context->register('IsInline', $is_inline);
62
+
63
+		// setup error collector
64
+		$e =& $context->get('ErrorCollector', true);
65
+
66
+		//####################################################################//
67
+		// Loop initialization
68
+
69
+		// stack that contains all elements that are excluded
70
+		// it is organized by parent elements, similar to $stack,
71
+		// but it is only populated when an element with exclusions is
72
+		// processed, i.e. there won't be empty exclusions.
73
+		$exclude_stack = array($definition->info_parent_def->excludes);
74
+
75
+		// variable that contains the start token while we are processing
76
+		// nodes. This enables error reporting to do its job
77
+		$node = $top_node;
78
+		// dummy token
79
+		list($token, $d) = $node->toTokenPair();
80
+		$context->register('CurrentNode', $node);
81
+		$context->register('CurrentToken', $token);
82
+
83
+		$parent_def = $definition->info_parent_def;
84
+		$stack = array(
85
+			array($top_node,
86
+				  $parent_def->descendants_are_inline,
87
+				  $parent_def->excludes, // exclusions
88
+				  0)
89
+			);
90
+
91
+		while (!empty($stack)) {
92
+			list($node, $is_inline, $excludes, $ix) = array_pop($stack);
93
+			// recursive call
94
+			$go = false;
95
+			$def = empty($stack) ? $definition->info_parent_def : $definition->info[$node->name];
96
+			while (isset($node->children[$ix])) {
97
+				$child = $node->children[$ix++];
98
+				if ($child instanceof HTMLPurifier_Node_Element) {
99
+					$go = true;
100
+					$stack[] = array($node, $is_inline, $excludes, $ix);
101
+					$stack[] = array($child,
102
+						// ToDo: I don't think it matters if it's def or
103
+						// child_def, but double check this...
104
+						$is_inline || $def->descendants_are_inline,
105
+						empty($def->excludes) ? $excludes
106
+											  : array_merge($excludes, $def->excludes),
107
+						0);
108
+					break;
109
+				}
110
+			};
111
+			if ($go) continue;
112
+			list($token, $d) = $node->toTokenPair();
113
+			// base case
114
+			if ($excludes_enabled && isset($excludes[$node->name])) {
115
+				$node->dead = true;
116
+				if ($e) $e->send(E_ERROR, 'Strategy_FixNesting: Node excluded');
117
+			} else {
118
+				// XXX I suppose it would be slightly more efficient to
119
+				// avoid the allocation here and have children
120
+				// strategies handle it
121
+				$children = array();
122
+				foreach ($node->children as $child) {
123
+					if (!$child->dead) $children[] = $child;
124
+				}
125
+				$result = $def->child->validateChildren($children, $config, $context);
126
+				if ($result === true) {
127
+					// nop
128
+					$node->children = $children;
129
+				} elseif ($result === false) {
130
+					$node->dead = true;
131
+					if ($e) $e->send(E_ERROR, 'Strategy_FixNesting: Node removed');
132
+				} else {
133
+					$node->children = $result;
134
+					if ($e) {
135
+						// XXX This will miss mutations of internal nodes. Perhaps defer to the child validators
136
+						if (empty($result) && !empty($children)) {
137
+							$e->send(E_ERROR, 'Strategy_FixNesting: Node contents removed');
138
+						} else if ($result != $children) {
139
+							$e->send(E_WARNING, 'Strategy_FixNesting: Node reorganized');
140
+						}
141
+					}
142
+				}
143
+			}
144
+		}
145
+
146
+		//####################################################################//
147
+		// Post-processing
148
+
149
+		// remove context variables
150
+		$context->destroy('IsInline');
151
+		$context->destroy('CurrentNode');
152
+		$context->destroy('CurrentToken');
153
+
154
+		//####################################################################//
155
+		// Return
156
+
157
+		return HTMLPurifier_Arborize::flatten($node, $config, $context);
158
+	}
159 159
 }
160 160
 
161 161
 // vim: et sw=4 sts=4
Please login to merge, or discard this patch.
php-debugbar/src/DebugBar/DataCollector/DataCollectorInterface.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -15,17 +15,17 @@
 block discarded – undo
15 15
  */
16 16
 interface DataCollectorInterface
17 17
 {
18
-    /**
19
-     * Called by the DebugBar when data needs to be collected
20
-     *
21
-     * @return array Collected data
22
-     */
23
-    public function collect();
18
+	/**
19
+	 * Called by the DebugBar when data needs to be collected
20
+	 *
21
+	 * @return array Collected data
22
+	 */
23
+	public function collect();
24 24
 
25
-    /**
26
-     * Returns the unique name of the collector
27
-     *
28
-     * @return string
29
-     */
30
-    public function getName();
25
+	/**
26
+	 * Returns the unique name of the collector
27
+	 *
28
+	 * @return string
29
+	 */
30
+	public function getName();
31 31
 }
Please login to merge, or discard this patch.
libraries/php-debugbar/src/DebugBar/DataCollector/AssetProvider.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -15,14 +15,14 @@
 block discarded – undo
15 15
  */
16 16
 interface AssetProvider
17 17
 {
18
-    /**
19
-     * Returns an array with the following keys:
20
-     *  - base_path
21
-     *  - base_url
22
-     *  - css: an array of filenames
23
-     *  - js: an array of filenames
24
-     *
25
-     * @return array
26
-     */
27
-    public function getAssets();
18
+	/**
19
+	 * Returns an array with the following keys:
20
+	 *  - base_path
21
+	 *  - base_url
22
+	 *  - css: an array of filenames
23
+	 *  - js: an array of filenames
24
+	 *
25
+	 * @return array
26
+	 */
27
+	public function getAssets();
28 28
 }
Please login to merge, or discard this patch.
libraries/php-debugbar/src/DebugBar/DataCollector/Renderable.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -15,11 +15,11 @@
 block discarded – undo
15 15
  */
16 16
 interface Renderable
17 17
 {
18
-    /**
19
-     * Returns a hash where keys are control names and their values
20
-     * an array of options as defined in {@see DebugBar\JavascriptRenderer::addControl()}
21
-     *
22
-     * @return array
23
-     */
24
-    public function getWidgets();
18
+	/**
19
+	 * Returns a hash where keys are control names and their values
20
+	 * an array of options as defined in {@see DebugBar\JavascriptRenderer::addControl()}
21
+	 *
22
+	 * @return array
23
+	 */
24
+	public function getWidgets();
25 25
 }
Please login to merge, or discard this patch.