Completed
Branch fix/escaping-2 (5dcb9a)
by
unknown
13:02 queued 10:26
created
core/services/container/RegistryContainer.php 2 patches
Indentation   +161 added lines, -161 removed lines patch added patch discarded remove patch
@@ -17,165 +17,165 @@
 block discarded – undo
17 17
 class RegistryContainer implements ArrayAccess, CountableTraversableAggregate
18 18
 {
19 19
 
20
-    /**
21
-     * @var array $container
22
-     */
23
-    private $container = [];
24
-
25
-    /**
26
-     * RegistryContainer constructor.
27
-     * Container data can be seeded by passing parameters to constructor.
28
-     * Each parameter will become its own element in the container
29
-     */
30
-    public function __construct()
31
-    {
32
-    }
33
-
34
-
35
-    /**
36
-     * @param mixed $offset
37
-     * @param mixed $value
38
-     */
39
-    public function offsetSet($offset, $value)
40
-    {
41
-        $this->container[ $offset ] = $value;
42
-    }
43
-
44
-
45
-    /**
46
-     * @param mixed $offset
47
-     * @return bool
48
-     */
49
-    public function offsetExists($offset)
50
-    {
51
-        return isset($this->container[ $offset ]);
52
-    }
53
-
54
-
55
-    /**
56
-     * @param mixed $offset
57
-     */
58
-    public function offsetUnset($offset)
59
-    {
60
-        unset($this->container[ $offset ]);
61
-    }
62
-
63
-
64
-    /**
65
-     * @param mixed $offset
66
-     * @return mixed|null
67
-     */
68
-    public function offsetGet($offset)
69
-    {
70
-        return $this->offsetExists($offset) ? $this->container[ $offset ] : null;
71
-    }
72
-
73
-
74
-    /**
75
-     * @return int
76
-     */
77
-    public function count()
78
-    {
79
-        return count($this->container);
80
-    }
81
-
82
-
83
-    /**
84
-     * @return ArrayIterator
85
-     */
86
-    public function getIterator()
87
-    {
88
-        return new ArrayIterator($this->container);
89
-    }
90
-
91
-
92
-    /**
93
-     * @param $offset
94
-     * @param $value
95
-     */
96
-    public function __set($offset, $value)
97
-    {
98
-        $this->offsetSet($offset, $value);
99
-    }
100
-
101
-
102
-    /**
103
-     * @param $offset
104
-     * @return mixed
105
-     * @throws OutOfBoundsException
106
-     */
107
-    public function __get($offset)
108
-    {
109
-        if (! array_key_exists($offset, $this->container)) {
110
-            $trace = debug_backtrace();
111
-            throw new OutOfBoundsException(
112
-                sprintf(
113
-                    esc_html__('Invalid offset: %1$s %2$sCalled from %3$s on line %4$d', 'event_espresso'),
114
-                    $offset,
115
-                    '<br  />',
116
-                    $trace[0]['file'],
117
-                    $trace[0]['line']
118
-                )
119
-            );
120
-        }
121
-        return $this->offsetGet($offset);
122
-    }
123
-
124
-
125
-    /**
126
-     * @param $offset
127
-     * @return bool
128
-     */
129
-    public function __isset($offset)
130
-    {
131
-        return $this->offsetExists($offset);
132
-    }
133
-
134
-
135
-    /**
136
-     * @param $offset
137
-     */
138
-    public function __unset($offset)
139
-    {
140
-        $this->offsetUnset($offset);
141
-    }
142
-
143
-
144
-    /**
145
-     * @param $offset
146
-     * @param $value
147
-     */
148
-    public function add($offset, $value)
149
-    {
150
-        $this->offsetSet($offset, $value);
151
-    }
152
-
153
-
154
-    /**
155
-     * @param $offset
156
-     */
157
-    public function remove($offset)
158
-    {
159
-        $this->offsetUnset($offset);
160
-    }
161
-
162
-
163
-    /**
164
-     * @param $offset
165
-     * @return bool
166
-     */
167
-    public function has($offset)
168
-    {
169
-        return $this->offsetExists($offset);
170
-    }
171
-
172
-
173
-    /**
174
-     * @param $offset
175
-     * @return mixed|null
176
-     */
177
-    public function get($offset)
178
-    {
179
-        return $this->offsetGet($offset);
180
-    }
20
+	/**
21
+	 * @var array $container
22
+	 */
23
+	private $container = [];
24
+
25
+	/**
26
+	 * RegistryContainer constructor.
27
+	 * Container data can be seeded by passing parameters to constructor.
28
+	 * Each parameter will become its own element in the container
29
+	 */
30
+	public function __construct()
31
+	{
32
+	}
33
+
34
+
35
+	/**
36
+	 * @param mixed $offset
37
+	 * @param mixed $value
38
+	 */
39
+	public function offsetSet($offset, $value)
40
+	{
41
+		$this->container[ $offset ] = $value;
42
+	}
43
+
44
+
45
+	/**
46
+	 * @param mixed $offset
47
+	 * @return bool
48
+	 */
49
+	public function offsetExists($offset)
50
+	{
51
+		return isset($this->container[ $offset ]);
52
+	}
53
+
54
+
55
+	/**
56
+	 * @param mixed $offset
57
+	 */
58
+	public function offsetUnset($offset)
59
+	{
60
+		unset($this->container[ $offset ]);
61
+	}
62
+
63
+
64
+	/**
65
+	 * @param mixed $offset
66
+	 * @return mixed|null
67
+	 */
68
+	public function offsetGet($offset)
69
+	{
70
+		return $this->offsetExists($offset) ? $this->container[ $offset ] : null;
71
+	}
72
+
73
+
74
+	/**
75
+	 * @return int
76
+	 */
77
+	public function count()
78
+	{
79
+		return count($this->container);
80
+	}
81
+
82
+
83
+	/**
84
+	 * @return ArrayIterator
85
+	 */
86
+	public function getIterator()
87
+	{
88
+		return new ArrayIterator($this->container);
89
+	}
90
+
91
+
92
+	/**
93
+	 * @param $offset
94
+	 * @param $value
95
+	 */
96
+	public function __set($offset, $value)
97
+	{
98
+		$this->offsetSet($offset, $value);
99
+	}
100
+
101
+
102
+	/**
103
+	 * @param $offset
104
+	 * @return mixed
105
+	 * @throws OutOfBoundsException
106
+	 */
107
+	public function __get($offset)
108
+	{
109
+		if (! array_key_exists($offset, $this->container)) {
110
+			$trace = debug_backtrace();
111
+			throw new OutOfBoundsException(
112
+				sprintf(
113
+					esc_html__('Invalid offset: %1$s %2$sCalled from %3$s on line %4$d', 'event_espresso'),
114
+					$offset,
115
+					'<br  />',
116
+					$trace[0]['file'],
117
+					$trace[0]['line']
118
+				)
119
+			);
120
+		}
121
+		return $this->offsetGet($offset);
122
+	}
123
+
124
+
125
+	/**
126
+	 * @param $offset
127
+	 * @return bool
128
+	 */
129
+	public function __isset($offset)
130
+	{
131
+		return $this->offsetExists($offset);
132
+	}
133
+
134
+
135
+	/**
136
+	 * @param $offset
137
+	 */
138
+	public function __unset($offset)
139
+	{
140
+		$this->offsetUnset($offset);
141
+	}
142
+
143
+
144
+	/**
145
+	 * @param $offset
146
+	 * @param $value
147
+	 */
148
+	public function add($offset, $value)
149
+	{
150
+		$this->offsetSet($offset, $value);
151
+	}
152
+
153
+
154
+	/**
155
+	 * @param $offset
156
+	 */
157
+	public function remove($offset)
158
+	{
159
+		$this->offsetUnset($offset);
160
+	}
161
+
162
+
163
+	/**
164
+	 * @param $offset
165
+	 * @return bool
166
+	 */
167
+	public function has($offset)
168
+	{
169
+		return $this->offsetExists($offset);
170
+	}
171
+
172
+
173
+	/**
174
+	 * @param $offset
175
+	 * @return mixed|null
176
+	 */
177
+	public function get($offset)
178
+	{
179
+		return $this->offsetGet($offset);
180
+	}
181 181
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
      */
39 39
     public function offsetSet($offset, $value)
40 40
     {
41
-        $this->container[ $offset ] = $value;
41
+        $this->container[$offset] = $value;
42 42
     }
43 43
 
44 44
 
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
      */
49 49
     public function offsetExists($offset)
50 50
     {
51
-        return isset($this->container[ $offset ]);
51
+        return isset($this->container[$offset]);
52 52
     }
53 53
 
54 54
 
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
      */
58 58
     public function offsetUnset($offset)
59 59
     {
60
-        unset($this->container[ $offset ]);
60
+        unset($this->container[$offset]);
61 61
     }
62 62
 
63 63
 
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
      */
68 68
     public function offsetGet($offset)
69 69
     {
70
-        return $this->offsetExists($offset) ? $this->container[ $offset ] : null;
70
+        return $this->offsetExists($offset) ? $this->container[$offset] : null;
71 71
     }
72 72
 
73 73
 
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
      */
107 107
     public function __get($offset)
108 108
     {
109
-        if (! array_key_exists($offset, $this->container)) {
109
+        if ( ! array_key_exists($offset, $this->container)) {
110 110
             $trace = debug_backtrace();
111 111
             throw new OutOfBoundsException(
112 112
                 sprintf(
Please login to merge, or discard this patch.
core/services/loaders/Loader.php 1 patch
Indentation   +123 added lines, -123 removed lines patch added patch discarded remove patch
@@ -15,127 +15,127 @@
 block discarded – undo
15 15
 class Loader implements LoaderInterface
16 16
 {
17 17
 
18
-    /**
19
-     * @var LoaderDecoratorInterface $new_loader
20
-     */
21
-    private $new_loader;
22
-
23
-    /**
24
-     * @var LoaderDecoratorInterface $shared_loader
25
-     */
26
-    private $shared_loader;
27
-
28
-    /**
29
-     * @var ClassInterfaceCache $class_cache
30
-     */
31
-    private $class_cache;
32
-
33
-    /**
34
-     * Loader constructor.
35
-     *
36
-     * @param LoaderDecoratorInterface        $new_loader
37
-     * @param CachingLoaderDecoratorInterface $shared_loader
38
-     * @param ClassInterfaceCache             $class_cache
39
-     */
40
-    public function __construct(
41
-        LoaderDecoratorInterface $new_loader,
42
-        CachingLoaderDecoratorInterface $shared_loader,
43
-        ClassInterfaceCache $class_cache
44
-    ) {
45
-        $this->new_loader    = $new_loader;
46
-        $this->shared_loader = $shared_loader;
47
-        $this->class_cache   = $class_cache;
48
-    }
49
-
50
-
51
-    /**
52
-     * @return LoaderDecoratorInterface
53
-     */
54
-    public function getNewLoader()
55
-    {
56
-        return $this->new_loader;
57
-    }
58
-
59
-
60
-    /**
61
-     * @return CachingLoaderDecoratorInterface
62
-     */
63
-    public function getSharedLoader()
64
-    {
65
-        return $this->shared_loader;
66
-    }
67
-
68
-
69
-    /**
70
-     * @param FullyQualifiedName|string $fqcn
71
-     * @param array                     $arguments
72
-     * @param bool                      $shared
73
-     * @return mixed
74
-     */
75
-    public function load($fqcn, array $arguments = array(), $shared = true)
76
-    {
77
-        $fqcn = $this->class_cache->getFqn($fqcn);
78
-        if ($this->class_cache->hasInterface($fqcn, 'EventEspresso\core\interfaces\ReservedInstanceInterface')) {
79
-            $shared = true;
80
-        }
81
-        return $shared
82
-            ? $this->getSharedLoader()->load($fqcn, $arguments, $shared)
83
-            : $this->getNewLoader()->load($fqcn, $arguments, $shared);
84
-    }
85
-
86
-
87
-    /**
88
-     * @param FullyQualifiedName|string $fqcn
89
-     * @param array                     $arguments
90
-     * @return mixed
91
-     */
92
-    public function getNew($fqcn, array $arguments = array())
93
-    {
94
-        return $this->load($fqcn, $arguments, false);
95
-    }
96
-
97
-
98
-    /**
99
-     * @param FullyQualifiedName|string $fqcn
100
-     * @param array                     $arguments
101
-     * @return mixed
102
-     */
103
-    public function getShared($fqcn, array $arguments = array())
104
-    {
105
-        return $this->load($fqcn, $arguments);
106
-    }
107
-
108
-
109
-    /**
110
-     * @param FullyQualifiedName|string $fqcn
111
-     * @param mixed                     $object
112
-     * @return bool
113
-     * @throws InvalidArgumentException
114
-     */
115
-    public function share($fqcn, $object)
116
-    {
117
-        $fqcn = $this->class_cache->getFqn($fqcn);
118
-        return $this->getSharedLoader()->share($fqcn, $object);
119
-    }
120
-
121
-
122
-    /**
123
-     * @param FullyQualifiedName|string $fqcn
124
-     * @return bool
125
-     * @throws InvalidArgumentException
126
-     */
127
-    public function remove($fqcn, array $arguments = [])
128
-    {
129
-        $fqcn = $this->class_cache->getFqn($fqcn);
130
-        return $this->getSharedLoader()->remove($fqcn, $arguments);
131
-    }
132
-
133
-
134
-    /**
135
-     * calls reset() on loaders if that method exists
136
-     */
137
-    public function reset()
138
-    {
139
-        $this->shared_loader->reset();
140
-    }
18
+	/**
19
+	 * @var LoaderDecoratorInterface $new_loader
20
+	 */
21
+	private $new_loader;
22
+
23
+	/**
24
+	 * @var LoaderDecoratorInterface $shared_loader
25
+	 */
26
+	private $shared_loader;
27
+
28
+	/**
29
+	 * @var ClassInterfaceCache $class_cache
30
+	 */
31
+	private $class_cache;
32
+
33
+	/**
34
+	 * Loader constructor.
35
+	 *
36
+	 * @param LoaderDecoratorInterface        $new_loader
37
+	 * @param CachingLoaderDecoratorInterface $shared_loader
38
+	 * @param ClassInterfaceCache             $class_cache
39
+	 */
40
+	public function __construct(
41
+		LoaderDecoratorInterface $new_loader,
42
+		CachingLoaderDecoratorInterface $shared_loader,
43
+		ClassInterfaceCache $class_cache
44
+	) {
45
+		$this->new_loader    = $new_loader;
46
+		$this->shared_loader = $shared_loader;
47
+		$this->class_cache   = $class_cache;
48
+	}
49
+
50
+
51
+	/**
52
+	 * @return LoaderDecoratorInterface
53
+	 */
54
+	public function getNewLoader()
55
+	{
56
+		return $this->new_loader;
57
+	}
58
+
59
+
60
+	/**
61
+	 * @return CachingLoaderDecoratorInterface
62
+	 */
63
+	public function getSharedLoader()
64
+	{
65
+		return $this->shared_loader;
66
+	}
67
+
68
+
69
+	/**
70
+	 * @param FullyQualifiedName|string $fqcn
71
+	 * @param array                     $arguments
72
+	 * @param bool                      $shared
73
+	 * @return mixed
74
+	 */
75
+	public function load($fqcn, array $arguments = array(), $shared = true)
76
+	{
77
+		$fqcn = $this->class_cache->getFqn($fqcn);
78
+		if ($this->class_cache->hasInterface($fqcn, 'EventEspresso\core\interfaces\ReservedInstanceInterface')) {
79
+			$shared = true;
80
+		}
81
+		return $shared
82
+			? $this->getSharedLoader()->load($fqcn, $arguments, $shared)
83
+			: $this->getNewLoader()->load($fqcn, $arguments, $shared);
84
+	}
85
+
86
+
87
+	/**
88
+	 * @param FullyQualifiedName|string $fqcn
89
+	 * @param array                     $arguments
90
+	 * @return mixed
91
+	 */
92
+	public function getNew($fqcn, array $arguments = array())
93
+	{
94
+		return $this->load($fqcn, $arguments, false);
95
+	}
96
+
97
+
98
+	/**
99
+	 * @param FullyQualifiedName|string $fqcn
100
+	 * @param array                     $arguments
101
+	 * @return mixed
102
+	 */
103
+	public function getShared($fqcn, array $arguments = array())
104
+	{
105
+		return $this->load($fqcn, $arguments);
106
+	}
107
+
108
+
109
+	/**
110
+	 * @param FullyQualifiedName|string $fqcn
111
+	 * @param mixed                     $object
112
+	 * @return bool
113
+	 * @throws InvalidArgumentException
114
+	 */
115
+	public function share($fqcn, $object)
116
+	{
117
+		$fqcn = $this->class_cache->getFqn($fqcn);
118
+		return $this->getSharedLoader()->share($fqcn, $object);
119
+	}
120
+
121
+
122
+	/**
123
+	 * @param FullyQualifiedName|string $fqcn
124
+	 * @return bool
125
+	 * @throws InvalidArgumentException
126
+	 */
127
+	public function remove($fqcn, array $arguments = [])
128
+	{
129
+		$fqcn = $this->class_cache->getFqn($fqcn);
130
+		return $this->getSharedLoader()->remove($fqcn, $arguments);
131
+	}
132
+
133
+
134
+	/**
135
+	 * calls reset() on loaders if that method exists
136
+	 */
137
+	public function reset()
138
+	{
139
+		$this->shared_loader->reset();
140
+	}
141 141
 }
Please login to merge, or discard this patch.
core/services/loaders/CachingLoaderDecoratorInterface.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -11,20 +11,20 @@
 block discarded – undo
11 11
 interface CachingLoaderDecoratorInterface extends LoaderDecoratorInterface
12 12
 {
13 13
 
14
-    /**
15
-     * @param string $fqcn
16
-     * @param mixed  $object
17
-     * @return bool
18
-     * @throws InvalidArgumentException
19
-     */
20
-    public function share($fqcn, $object);
14
+	/**
15
+	 * @param string $fqcn
16
+	 * @param mixed  $object
17
+	 * @return bool
18
+	 * @throws InvalidArgumentException
19
+	 */
20
+	public function share($fqcn, $object);
21 21
 
22 22
 
23
-    /**
24
-     * @param string $fqcn
25
-     * @param array  $arguments
26
-     * @return bool
27
-     * @throws InvalidArgumentException
28
-     */
29
-    public function remove($fqcn, array $arguments = []);
23
+	/**
24
+	 * @param string $fqcn
25
+	 * @param array  $arguments
26
+	 * @return bool
27
+	 * @throws InvalidArgumentException
28
+	 */
29
+	public function remove($fqcn, array $arguments = []);
30 30
 }
Please login to merge, or discard this patch.
core/services/loaders/LoaderInterface.php 1 patch
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -8,57 +8,57 @@
 block discarded – undo
8 8
 interface LoaderInterface
9 9
 {
10 10
 
11
-    /**
12
-     * Can be for instantiating a new instance of a class,
13
-     * or for getting a shared instance of a class (default)
14
-     *
15
-     * @param FullyQualifiedName|string $fqcn
16
-     * @param array                     $arguments
17
-     * @param bool                      $shared
18
-     * @return mixed
19
-     */
20
-    public function load($fqcn, array $arguments = array(), $shared = true);
11
+	/**
12
+	 * Can be for instantiating a new instance of a class,
13
+	 * or for getting a shared instance of a class (default)
14
+	 *
15
+	 * @param FullyQualifiedName|string $fqcn
16
+	 * @param array                     $arguments
17
+	 * @param bool                      $shared
18
+	 * @return mixed
19
+	 */
20
+	public function load($fqcn, array $arguments = array(), $shared = true);
21 21
 
22 22
 
23
-    /**
24
-     * Used for instantiating a new instance of a class
25
-     *
26
-     * @param FullyQualifiedName|string $fqcn
27
-     * @param array                     $arguments
28
-     * @return mixed
29
-     */
30
-    public function getNew($fqcn, array $arguments = array());
23
+	/**
24
+	 * Used for instantiating a new instance of a class
25
+	 *
26
+	 * @param FullyQualifiedName|string $fqcn
27
+	 * @param array                     $arguments
28
+	 * @return mixed
29
+	 */
30
+	public function getNew($fqcn, array $arguments = array());
31 31
 
32 32
 
33
-    /**
34
-     * Used for getting a shared instance of a class
35
-     *
36
-     * @param FullyQualifiedName|string $fqcn
37
-     * @param array                     $arguments
38
-     * @return mixed
39
-     */
40
-    public function getShared($fqcn, array $arguments = array());
33
+	/**
34
+	 * Used for getting a shared instance of a class
35
+	 *
36
+	 * @param FullyQualifiedName|string $fqcn
37
+	 * @param array                     $arguments
38
+	 * @return mixed
39
+	 */
40
+	public function getShared($fqcn, array $arguments = array());
41 41
 
42 42
 
43
-    /**
44
-     * @param FullyQualifiedName|string $fqcn
45
-     * @param mixed                     $object
46
-     * @return bool
47
-     * @throws InvalidArgumentException
48
-     */
49
-    public function share($fqcn, $object);
43
+	/**
44
+	 * @param FullyQualifiedName|string $fqcn
45
+	 * @param mixed                     $object
46
+	 * @return bool
47
+	 * @throws InvalidArgumentException
48
+	 */
49
+	public function share($fqcn, $object);
50 50
 
51 51
 
52
-    /**
53
-     * @param FullyQualifiedName|string $fqcn
54
-     * @return bool
55
-     * @throws InvalidArgumentException
56
-     */
57
-    public function remove($fqcn);
52
+	/**
53
+	 * @param FullyQualifiedName|string $fqcn
54
+	 * @return bool
55
+	 * @throws InvalidArgumentException
56
+	 */
57
+	public function remove($fqcn);
58 58
 
59 59
 
60
-    /**
61
-     * calls reset() on loader if method exists
62
-     */
63
-    public function reset();
60
+	/**
61
+	 * calls reset() on loader if method exists
62
+	 */
63
+	public function reset();
64 64
 }
Please login to merge, or discard this patch.
core/services/request/files/FilesDataHandler.php 2 patches
Indentation   +251 added lines, -251 removed lines patch added patch discarded remove patch
@@ -40,279 +40,279 @@
 block discarded – undo
40 40
  */
41 41
 class FilesDataHandler
42 42
 {
43
-    /**
44
-     * @var Request
45
-     */
46
-    protected $request;
43
+	/**
44
+	 * @var Request
45
+	 */
46
+	protected $request;
47 47
 
48
-    /**
49
-     * @var CollectionInterface | FileSubmissionInterface[]
50
-     */
51
-    protected $file_objects;
48
+	/**
49
+	 * @var CollectionInterface | FileSubmissionInterface[]
50
+	 */
51
+	protected $file_objects;
52 52
 
53
-    /**
54
-     * @var bool
55
-     */
56
-    protected $initialized = false;
53
+	/**
54
+	 * @var bool
55
+	 */
56
+	protected $initialized = false;
57 57
 
58 58
 
59
-    /**
60
-     * FilesDataHandler constructor.
61
-     *
62
-     * @param Request $request
63
-     */
64
-    public function __construct(Request $request)
65
-    {
66
-        $this->request = $request;
67
-    }
59
+	/**
60
+	 * FilesDataHandler constructor.
61
+	 *
62
+	 * @param Request $request
63
+	 */
64
+	public function __construct(Request $request)
65
+	{
66
+		$this->request = $request;
67
+	}
68 68
 
69 69
 
70
-    /**
71
-     * @return CollectionInterface | FileSubmissionInterface[]
72
-     * @throws UnexpectedValueException
73
-     * @throws InvalidArgumentException
74
-     * @since 4.9.80.p
75
-     */
76
-    protected function getFileObjects()
77
-    {
78
-        $this->initialize();
79
-        return $this->file_objects;
80
-    }
70
+	/**
71
+	 * @return CollectionInterface | FileSubmissionInterface[]
72
+	 * @throws UnexpectedValueException
73
+	 * @throws InvalidArgumentException
74
+	 * @since 4.9.80.p
75
+	 */
76
+	protected function getFileObjects()
77
+	{
78
+		$this->initialize();
79
+		return $this->file_objects;
80
+	}
81 81
 
82 82
 
83
-    /**
84
-     * Sets up the file objects from the request's $_FILES data.
85
-     *
86
-     * @throws UnexpectedValueException
87
-     * @throws InvalidArgumentException
88
-     * @throws InvalidInterfaceException
89
-     * @since 4.9.80.p
90
-     */
91
-    protected function initialize()
92
-    {
93
-        if ($this->initialized) {
94
-            return;
95
-        }
96
-        $this->file_objects = new Collection(
97
-        // collection interface
98
-            'EventEspresso\core\services\request\files\FileSubmissionInterface',
99
-            // collection name
100
-            'submitted_files'
101
-        );
102
-        $files_raw_data     = $this->request->filesParams();
103
-        if (empty($files_raw_data)) {
104
-            return;
105
-        }
106
-        if ($this->isStrangeFilesArray($files_raw_data)) {
107
-            $data = $this->fixFilesDataArray($files_raw_data);
108
-        } else {
109
-            $data = $files_raw_data;
110
-        }
111
-        $this->createFileObjects($data);
112
-        $this->initialized = true;
113
-    }
83
+	/**
84
+	 * Sets up the file objects from the request's $_FILES data.
85
+	 *
86
+	 * @throws UnexpectedValueException
87
+	 * @throws InvalidArgumentException
88
+	 * @throws InvalidInterfaceException
89
+	 * @since 4.9.80.p
90
+	 */
91
+	protected function initialize()
92
+	{
93
+		if ($this->initialized) {
94
+			return;
95
+		}
96
+		$this->file_objects = new Collection(
97
+		// collection interface
98
+			'EventEspresso\core\services\request\files\FileSubmissionInterface',
99
+			// collection name
100
+			'submitted_files'
101
+		);
102
+		$files_raw_data     = $this->request->filesParams();
103
+		if (empty($files_raw_data)) {
104
+			return;
105
+		}
106
+		if ($this->isStrangeFilesArray($files_raw_data)) {
107
+			$data = $this->fixFilesDataArray($files_raw_data);
108
+		} else {
109
+			$data = $files_raw_data;
110
+		}
111
+		$this->createFileObjects($data);
112
+		$this->initialized = true;
113
+	}
114 114
 
115 115
 
116
-    /**
117
-     * Detects if $_FILES is a weird multi-dimensional array that needs fixing or not.
118
-     *
119
-     * @param $files_data
120
-     * @return bool
121
-     * @throws UnexpectedValueException
122
-     * @since 4.9.80.p
123
-     */
124
-    protected function isStrangeFilesArray($files_data)
125
-    {
126
-        if (! is_array($files_data)) {
127
-            throw new UnexpectedValueException(
128
-                sprintf(
129
-                    esc_html__(
130
-                        'Unexpected PHP $_FILES data format. "%1$s" was expected to be an array.',
131
-                        'event_espresso'
132
-                    ),
133
-                    (string) $files_data
134
-                )
135
-            );
136
-        }
137
-        $first_value = reset($files_data);
138
-        if (! is_array($first_value)) {
139
-            throw new UnexpectedValueException(
140
-                sprintf(
141
-                    esc_html__(
142
-                        'Unexpected PHP $_FILES data format. "%1$s" was expected to be an array.',
143
-                        'event_espresso'
144
-                    ),
145
-                    (string) $first_value
146
-                )
147
-            );
148
-        }
149
-        $first_sub_array_item = reset($first_value);
150
-        if (is_array($first_sub_array_item)) {
151
-            // not just a 2d array
152
-            return true;
153
-        }
154
-        // yep, just 2d array
155
-        return false;
156
-    }
116
+	/**
117
+	 * Detects if $_FILES is a weird multi-dimensional array that needs fixing or not.
118
+	 *
119
+	 * @param $files_data
120
+	 * @return bool
121
+	 * @throws UnexpectedValueException
122
+	 * @since 4.9.80.p
123
+	 */
124
+	protected function isStrangeFilesArray($files_data)
125
+	{
126
+		if (! is_array($files_data)) {
127
+			throw new UnexpectedValueException(
128
+				sprintf(
129
+					esc_html__(
130
+						'Unexpected PHP $_FILES data format. "%1$s" was expected to be an array.',
131
+						'event_espresso'
132
+					),
133
+					(string) $files_data
134
+				)
135
+			);
136
+		}
137
+		$first_value = reset($files_data);
138
+		if (! is_array($first_value)) {
139
+			throw new UnexpectedValueException(
140
+				sprintf(
141
+					esc_html__(
142
+						'Unexpected PHP $_FILES data format. "%1$s" was expected to be an array.',
143
+						'event_espresso'
144
+					),
145
+					(string) $first_value
146
+				)
147
+			);
148
+		}
149
+		$first_sub_array_item = reset($first_value);
150
+		if (is_array($first_sub_array_item)) {
151
+			// not just a 2d array
152
+			return true;
153
+		}
154
+		// yep, just 2d array
155
+		return false;
156
+	}
157 157
 
158 158
 
159
-    /**
160
-     * Takes into account that $_FILES does a weird thing when you have hierarchical form names (eg `<input type="file"
161
-     * name="my[hierarchical][form]">`): it leaves the top-level form part alone, but replaces the SECOND part with
162
-     * "name", "size", "tmp_name", etc. So that file's data is located at "my[name][hierarchical][form]",
163
-     * "my[size][hierarchical][form]", "my[tmp_name][hierarchical][form]", etc. It's really weird.
164
-     *
165
-     * @param $files_data
166
-     * @return array
167
-     * @since 4.9.80.p
168
-     */
169
-    protected function fixFilesDataArray($files_data)
170
-    {
171
-        $sane_files_array = [];
172
-        foreach ($files_data as $top_level_name => $top_level_children) {
173
-            $sub_array                           = [];
174
-            $sane_files_array[ $top_level_name ] = [];
175
-            foreach ($top_level_children as $file_data_part => $second_level_children) {
176
-                foreach ($second_level_children as $next_level_name => $sub_values) {
177
-                    $sub_array[ $next_level_name ] = $this->organizeFilesData($sub_values, $file_data_part);
178
-                }
179
-                $sane_files_array[ $top_level_name ] = array_replace_recursive(
180
-                    $sub_array,
181
-                    $sane_files_array[ $top_level_name ]
182
-                );
183
-            }
184
-        }
185
-        return $sane_files_array;
186
-    }
159
+	/**
160
+	 * Takes into account that $_FILES does a weird thing when you have hierarchical form names (eg `<input type="file"
161
+	 * name="my[hierarchical][form]">`): it leaves the top-level form part alone, but replaces the SECOND part with
162
+	 * "name", "size", "tmp_name", etc. So that file's data is located at "my[name][hierarchical][form]",
163
+	 * "my[size][hierarchical][form]", "my[tmp_name][hierarchical][form]", etc. It's really weird.
164
+	 *
165
+	 * @param $files_data
166
+	 * @return array
167
+	 * @since 4.9.80.p
168
+	 */
169
+	protected function fixFilesDataArray($files_data)
170
+	{
171
+		$sane_files_array = [];
172
+		foreach ($files_data as $top_level_name => $top_level_children) {
173
+			$sub_array                           = [];
174
+			$sane_files_array[ $top_level_name ] = [];
175
+			foreach ($top_level_children as $file_data_part => $second_level_children) {
176
+				foreach ($second_level_children as $next_level_name => $sub_values) {
177
+					$sub_array[ $next_level_name ] = $this->organizeFilesData($sub_values, $file_data_part);
178
+				}
179
+				$sane_files_array[ $top_level_name ] = array_replace_recursive(
180
+					$sub_array,
181
+					$sane_files_array[ $top_level_name ]
182
+				);
183
+			}
184
+		}
185
+		return $sane_files_array;
186
+	}
187 187
 
188 188
 
189
-    /**
190
-     * Recursively explores the array until it finds a leaf node, and tacks `$type` as a final index in front of it.
191
-     *
192
-     * @param $data array|string
193
-     * @param $type 'name', 'tmp_name', 'size', or 'error'
194
-     * @return array
195
-     * @since 4.9.80.p
196
-     */
197
-    protected function organizeFilesData($data, $type)
198
-    {
199
-        if (! is_array($data)) {
200
-            return [
201
-                $type => $data,
202
-            ];
203
-        }
204
-        $organized_data = [];
205
-        foreach ($data as $input_name_part => $sub_inputs_or_value) {
206
-            if (is_array($sub_inputs_or_value)) {
207
-                $organized_data[ $input_name_part ] = $this->organizeFilesData($sub_inputs_or_value, $type);
208
-            } else {
209
-                $organized_data[ $input_name_part ][ $type ] = $sub_inputs_or_value;
210
-            }
211
-        }
212
-        return $organized_data;
213
-    }
189
+	/**
190
+	 * Recursively explores the array until it finds a leaf node, and tacks `$type` as a final index in front of it.
191
+	 *
192
+	 * @param $data array|string
193
+	 * @param $type 'name', 'tmp_name', 'size', or 'error'
194
+	 * @return array
195
+	 * @since 4.9.80.p
196
+	 */
197
+	protected function organizeFilesData($data, $type)
198
+	{
199
+		if (! is_array($data)) {
200
+			return [
201
+				$type => $data,
202
+			];
203
+		}
204
+		$organized_data = [];
205
+		foreach ($data as $input_name_part => $sub_inputs_or_value) {
206
+			if (is_array($sub_inputs_or_value)) {
207
+				$organized_data[ $input_name_part ] = $this->organizeFilesData($sub_inputs_or_value, $type);
208
+			} else {
209
+				$organized_data[ $input_name_part ][ $type ] = $sub_inputs_or_value;
210
+			}
211
+		}
212
+		return $organized_data;
213
+	}
214 214
 
215 215
 
216
-    /**
217
-     * Takes the organized $_FILES array (where all file info is located at the same spot as you'd expect an input
218
-     * to be in post data, with all the file's data located side-by-side in an array) and creates a
219
-     * multi-dimensional array of FileSubmissionInterface objects. Stores it in `$this->file_objects`.
220
-     *
221
-     * @param array $organized_files   $_FILES but organized like $_POST
222
-     * @param array $name_parts_so_far for multidimensional HTML form names,
223
-     * @throws UnexpectedValueException
224
-     * @throws InvalidArgumentException
225
-     * @since 4.9.80.p
226
-     */
227
-    protected function createFileObjects($organized_files, $name_parts_so_far = [])
228
-    {
229
-        if (! is_array($organized_files)) {
230
-            throw new UnexpectedValueException(
231
-                sprintf(
232
-                    esc_html__(
233
-                        'Unexpected PHP $organized_files data format. "%1$s" was expected to be an array.',
234
-                        'event_espresso'
235
-                    ),
236
-                    (string) $organized_files
237
-                )
238
-            );
239
-        }
240
-        foreach ($organized_files as $key => $value) {
241
-            $this_input_name_parts = $name_parts_so_far;
242
-            array_push(
243
-                $this_input_name_parts,
244
-                $key
245
-            );
246
-            if (isset($value['name'], $value['tmp_name'], $value['size'])) {
247
-                $html_name = $this->inputNameFromParts($this_input_name_parts);
248
-                $this->file_objects->add(
249
-                    new FileSubmission(
250
-                        $value['name'],
251
-                        $value['tmp_name'],
252
-                        $value['size'],
253
-                        $value['error']
254
-                    ),
255
-                    $html_name
256
-                );
257
-            } else {
258
-                $this->createFileObjects($value, $this_input_name_parts);
259
-            }
260
-        }
261
-    }
216
+	/**
217
+	 * Takes the organized $_FILES array (where all file info is located at the same spot as you'd expect an input
218
+	 * to be in post data, with all the file's data located side-by-side in an array) and creates a
219
+	 * multi-dimensional array of FileSubmissionInterface objects. Stores it in `$this->file_objects`.
220
+	 *
221
+	 * @param array $organized_files   $_FILES but organized like $_POST
222
+	 * @param array $name_parts_so_far for multidimensional HTML form names,
223
+	 * @throws UnexpectedValueException
224
+	 * @throws InvalidArgumentException
225
+	 * @since 4.9.80.p
226
+	 */
227
+	protected function createFileObjects($organized_files, $name_parts_so_far = [])
228
+	{
229
+		if (! is_array($organized_files)) {
230
+			throw new UnexpectedValueException(
231
+				sprintf(
232
+					esc_html__(
233
+						'Unexpected PHP $organized_files data format. "%1$s" was expected to be an array.',
234
+						'event_espresso'
235
+					),
236
+					(string) $organized_files
237
+				)
238
+			);
239
+		}
240
+		foreach ($organized_files as $key => $value) {
241
+			$this_input_name_parts = $name_parts_so_far;
242
+			array_push(
243
+				$this_input_name_parts,
244
+				$key
245
+			);
246
+			if (isset($value['name'], $value['tmp_name'], $value['size'])) {
247
+				$html_name = $this->inputNameFromParts($this_input_name_parts);
248
+				$this->file_objects->add(
249
+					new FileSubmission(
250
+						$value['name'],
251
+						$value['tmp_name'],
252
+						$value['size'],
253
+						$value['error']
254
+					),
255
+					$html_name
256
+				);
257
+			} else {
258
+				$this->createFileObjects($value, $this_input_name_parts);
259
+			}
260
+		}
261
+	}
262 262
 
263 263
 
264
-    /**
265
-     * Takes the input name parts, like `['my', 'great', 'file', 'input1']`
266
-     * and returns the HTML name for it, "my[great][file][input1]"
267
-     *
268
-     * @throws UnexpectedValueException
269
-     * @since 4.9.80.p
270
-     */
271
-    protected function inputNameFromParts($parts)
272
-    {
273
-        if (! is_array($parts)) {
274
-            throw new UnexpectedValueException(esc_html__('Name parts should be an array.', 'event_espresso'));
275
-        }
276
-        $generated_string = '';
277
-        foreach ($parts as $part) {
278
-            $part = (string) $part;
279
-            // wrap all but the first part in []
280
-            $generated_string .= $generated_string === '' ? $part : '[' . $part . ']';
281
-        }
282
-        return $generated_string;
283
-    }
264
+	/**
265
+	 * Takes the input name parts, like `['my', 'great', 'file', 'input1']`
266
+	 * and returns the HTML name for it, "my[great][file][input1]"
267
+	 *
268
+	 * @throws UnexpectedValueException
269
+	 * @since 4.9.80.p
270
+	 */
271
+	protected function inputNameFromParts($parts)
272
+	{
273
+		if (! is_array($parts)) {
274
+			throw new UnexpectedValueException(esc_html__('Name parts should be an array.', 'event_espresso'));
275
+		}
276
+		$generated_string = '';
277
+		foreach ($parts as $part) {
278
+			$part = (string) $part;
279
+			// wrap all but the first part in []
280
+			$generated_string .= $generated_string === '' ? $part : '[' . $part . ']';
281
+		}
282
+		return $generated_string;
283
+	}
284 284
 
285 285
 
286
-    /**
287
-     * Gets the input by the indicated $name_parts.
288
-     * Eg if you're looking for an input named "my[great][file][input1]", $name_parts
289
-     * should be `['my', 'great', 'file', 'input1']`.
290
-     * Alternatively, you could use `FileDataHandler::getFileObject('my[great][file][input1]');`
291
-     *
292
-     * @param $name_parts
293
-     * @return FileSubmissionInterface
294
-     * @throws UnexpectedValueException
295
-     * @since 4.9.80.p
296
-     */
297
-    public function getFileObjectFromNameParts($name_parts)
298
-    {
299
-        return $this->getFileObjects()->get($this->inputNameFromParts($name_parts));
300
-    }
286
+	/**
287
+	 * Gets the input by the indicated $name_parts.
288
+	 * Eg if you're looking for an input named "my[great][file][input1]", $name_parts
289
+	 * should be `['my', 'great', 'file', 'input1']`.
290
+	 * Alternatively, you could use `FileDataHandler::getFileObject('my[great][file][input1]');`
291
+	 *
292
+	 * @param $name_parts
293
+	 * @return FileSubmissionInterface
294
+	 * @throws UnexpectedValueException
295
+	 * @since 4.9.80.p
296
+	 */
297
+	public function getFileObjectFromNameParts($name_parts)
298
+	{
299
+		return $this->getFileObjects()->get($this->inputNameFromParts($name_parts));
300
+	}
301 301
 
302 302
 
303
-    /**
304
-     * Gets the FileSubmissionInterface corresponding to the HTML name provided.
305
-     *
306
-     * @param $html_name
307
-     * @return mixed
308
-     * @throws InvalidArgumentException
309
-     * @throws UnexpectedValueException
310
-     * @since 4.9.80.p
311
-     */
312
-    public function getFileObject($html_name)
313
-    {
314
-        return $this->getFileObjects()->get($html_name);
315
-    }
303
+	/**
304
+	 * Gets the FileSubmissionInterface corresponding to the HTML name provided.
305
+	 *
306
+	 * @param $html_name
307
+	 * @return mixed
308
+	 * @throws InvalidArgumentException
309
+	 * @throws UnexpectedValueException
310
+	 * @since 4.9.80.p
311
+	 */
312
+	public function getFileObject($html_name)
313
+	{
314
+		return $this->getFileObjects()->get($html_name);
315
+	}
316 316
 }
317 317
 // End of file FilesDataHandler.php
318 318
 // Location: EventEspresso\core\services\request\files/FilesDataHandler.php
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
             // collection name
100 100
             'submitted_files'
101 101
         );
102
-        $files_raw_data     = $this->request->filesParams();
102
+        $files_raw_data = $this->request->filesParams();
103 103
         if (empty($files_raw_data)) {
104 104
             return;
105 105
         }
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
      */
124 124
     protected function isStrangeFilesArray($files_data)
125 125
     {
126
-        if (! is_array($files_data)) {
126
+        if ( ! is_array($files_data)) {
127 127
             throw new UnexpectedValueException(
128 128
                 sprintf(
129 129
                     esc_html__(
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
             );
136 136
         }
137 137
         $first_value = reset($files_data);
138
-        if (! is_array($first_value)) {
138
+        if ( ! is_array($first_value)) {
139 139
             throw new UnexpectedValueException(
140 140
                 sprintf(
141 141
                     esc_html__(
@@ -171,14 +171,14 @@  discard block
 block discarded – undo
171 171
         $sane_files_array = [];
172 172
         foreach ($files_data as $top_level_name => $top_level_children) {
173 173
             $sub_array                           = [];
174
-            $sane_files_array[ $top_level_name ] = [];
174
+            $sane_files_array[$top_level_name] = [];
175 175
             foreach ($top_level_children as $file_data_part => $second_level_children) {
176 176
                 foreach ($second_level_children as $next_level_name => $sub_values) {
177
-                    $sub_array[ $next_level_name ] = $this->organizeFilesData($sub_values, $file_data_part);
177
+                    $sub_array[$next_level_name] = $this->organizeFilesData($sub_values, $file_data_part);
178 178
                 }
179
-                $sane_files_array[ $top_level_name ] = array_replace_recursive(
179
+                $sane_files_array[$top_level_name] = array_replace_recursive(
180 180
                     $sub_array,
181
-                    $sane_files_array[ $top_level_name ]
181
+                    $sane_files_array[$top_level_name]
182 182
                 );
183 183
             }
184 184
         }
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
      */
197 197
     protected function organizeFilesData($data, $type)
198 198
     {
199
-        if (! is_array($data)) {
199
+        if ( ! is_array($data)) {
200 200
             return [
201 201
                 $type => $data,
202 202
             ];
@@ -204,9 +204,9 @@  discard block
 block discarded – undo
204 204
         $organized_data = [];
205 205
         foreach ($data as $input_name_part => $sub_inputs_or_value) {
206 206
             if (is_array($sub_inputs_or_value)) {
207
-                $organized_data[ $input_name_part ] = $this->organizeFilesData($sub_inputs_or_value, $type);
207
+                $organized_data[$input_name_part] = $this->organizeFilesData($sub_inputs_or_value, $type);
208 208
             } else {
209
-                $organized_data[ $input_name_part ][ $type ] = $sub_inputs_or_value;
209
+                $organized_data[$input_name_part][$type] = $sub_inputs_or_value;
210 210
             }
211 211
         }
212 212
         return $organized_data;
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
      */
227 227
     protected function createFileObjects($organized_files, $name_parts_so_far = [])
228 228
     {
229
-        if (! is_array($organized_files)) {
229
+        if ( ! is_array($organized_files)) {
230 230
             throw new UnexpectedValueException(
231 231
                 sprintf(
232 232
                     esc_html__(
@@ -270,14 +270,14 @@  discard block
 block discarded – undo
270 270
      */
271 271
     protected function inputNameFromParts($parts)
272 272
     {
273
-        if (! is_array($parts)) {
273
+        if ( ! is_array($parts)) {
274 274
             throw new UnexpectedValueException(esc_html__('Name parts should be an array.', 'event_espresso'));
275 275
         }
276 276
         $generated_string = '';
277 277
         foreach ($parts as $part) {
278 278
             $part = (string) $part;
279 279
             // wrap all but the first part in []
280
-            $generated_string .= $generated_string === '' ? $part : '[' . $part . ']';
280
+            $generated_string .= $generated_string === '' ? $part : '['.$part.']';
281 281
         }
282 282
         return $generated_string;
283 283
     }
Please login to merge, or discard this patch.
core/services/request/sanitizers/ServerSanitizer.php 1 patch
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -11,59 +11,59 @@
 block discarded – undo
11 11
  */
12 12
 class ServerSanitizer
13 13
 {
14
-    /**
15
-     * @param string $value
16
-     * @return mixed|string
17
-     */
18
-    public function clean($key, $value)
19
-    {
20
-        switch ($key) {
21
-            case 'AUTH_TYPE':
22
-                $valid_types = [
23
-                    'Basic',
24
-                    'Bearer',
25
-                    'Digest',
26
-                    'HOBA',
27
-                    'Mutual',
28
-                    'Negotiate',
29
-                    'OAuth',
30
-                    'SCRAM-SHA-1',
31
-                    'SCRAM-SHA-256',
32
-                    'vapid',
33
-                ];
34
-                return in_array($value, $valid_types, true) ? $value : 'Basic';
35
-            case 'argc':
36
-            case 'HTTP_DNT':
37
-            case 'HTTP_UPGRADE_INSECURE_REQUESTS':
38
-            case 'SERVER_PORT':
39
-            case 'REMOTE_PORT':
40
-            case 'REQUEST_TIME':
41
-                return (int) filter_var($value, FILTER_SANITIZE_NUMBER_INT);
42
-            case 'REQUEST_TIME_FLOAT':
43
-                return (float) filter_var($value, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
44
-            case 'REQUEST_METHOD':
45
-                $valid_types = [
46
-                    'CONNECT',
47
-                    'DELETE',
48
-                    'GET',
49
-                    'HEAD',
50
-                    'OPTIONS',
51
-                    'PATCH',
52
-                    'POST',
53
-                    'PUT',
54
-                    'TRACE',
55
-                ];
56
-                return in_array($value, $valid_types, true) ? $value : 'GET';
57
-            case 'HTTP_HOST':
58
-            case 'QUERY_STRING':
59
-            case 'REQUEST_URI':
60
-            case 'SCRIPT_NAME':
61
-            case 'SERVER_NAME':
62
-                return filter_var($value, FILTER_SANITIZE_URL);
63
-            case 'SERVER_ADMIN':
64
-                return filter_var($value, FILTER_SANITIZE_EMAIL);
65
-            default:
66
-                return filter_var($value, FILTER_SANITIZE_STRING);
67
-        }
68
-    }
14
+	/**
15
+	 * @param string $value
16
+	 * @return mixed|string
17
+	 */
18
+	public function clean($key, $value)
19
+	{
20
+		switch ($key) {
21
+			case 'AUTH_TYPE':
22
+				$valid_types = [
23
+					'Basic',
24
+					'Bearer',
25
+					'Digest',
26
+					'HOBA',
27
+					'Mutual',
28
+					'Negotiate',
29
+					'OAuth',
30
+					'SCRAM-SHA-1',
31
+					'SCRAM-SHA-256',
32
+					'vapid',
33
+				];
34
+				return in_array($value, $valid_types, true) ? $value : 'Basic';
35
+			case 'argc':
36
+			case 'HTTP_DNT':
37
+			case 'HTTP_UPGRADE_INSECURE_REQUESTS':
38
+			case 'SERVER_PORT':
39
+			case 'REMOTE_PORT':
40
+			case 'REQUEST_TIME':
41
+				return (int) filter_var($value, FILTER_SANITIZE_NUMBER_INT);
42
+			case 'REQUEST_TIME_FLOAT':
43
+				return (float) filter_var($value, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
44
+			case 'REQUEST_METHOD':
45
+				$valid_types = [
46
+					'CONNECT',
47
+					'DELETE',
48
+					'GET',
49
+					'HEAD',
50
+					'OPTIONS',
51
+					'PATCH',
52
+					'POST',
53
+					'PUT',
54
+					'TRACE',
55
+				];
56
+				return in_array($value, $valid_types, true) ? $value : 'GET';
57
+			case 'HTTP_HOST':
58
+			case 'QUERY_STRING':
59
+			case 'REQUEST_URI':
60
+			case 'SCRIPT_NAME':
61
+			case 'SERVER_NAME':
62
+				return filter_var($value, FILTER_SANITIZE_URL);
63
+			case 'SERVER_ADMIN':
64
+				return filter_var($value, FILTER_SANITIZE_EMAIL);
65
+			default:
66
+				return filter_var($value, FILTER_SANITIZE_STRING);
67
+		}
68
+	}
69 69
 }
Please login to merge, or discard this patch.
core/services/request/LegacyRequestInterface.php 1 patch
Indentation   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -12,125 +12,125 @@
 block discarded – undo
12 12
 interface LegacyRequestInterface
13 13
 {
14 14
 
15
-    /**
16
-     * @return array
17
-     */
18
-    public function get_params();
15
+	/**
16
+	 * @return array
17
+	 */
18
+	public function get_params();
19 19
 
20 20
 
21
-    /**
22
-     * @return array
23
-     */
24
-    public function post_params();
21
+	/**
22
+	 * @return array
23
+	 */
24
+	public function post_params();
25 25
 
26 26
 
27
-    /**
28
-     * @return array
29
-     */
30
-    public function cookie_params();
27
+	/**
28
+	 * @return array
29
+	 */
30
+	public function cookie_params();
31 31
 
32 32
 
33
-    /**
34
-     * @return array
35
-     */
36
-    public function server_params();
33
+	/**
34
+	 * @return array
35
+	 */
36
+	public function server_params();
37 37
 
38 38
 
39
-    /**
40
-     * returns sanitized contents of $_REQUEST
41
-     *
42
-     * @return array
43
-     */
44
-    public function params();
39
+	/**
40
+	 * returns sanitized contents of $_REQUEST
41
+	 *
42
+	 * @return array
43
+	 */
44
+	public function params();
45 45
 
46 46
 
47
-    /**
48
-     * @param      $key
49
-     * @param      $value
50
-     * @param bool $override_ee
51
-     * @return    void
52
-     */
53
-    public function set($key, $value, $override_ee = false);
47
+	/**
48
+	 * @param      $key
49
+	 * @param      $value
50
+	 * @param bool $override_ee
51
+	 * @return    void
52
+	 */
53
+	public function set($key, $value, $override_ee = false);
54 54
 
55 55
 
56
-    /**
57
-     * returns   the value for a request param if the given key exists
58
-     *
59
-     * @param       $key
60
-     * @param null  $default
61
-     * @return mixed
62
-     */
63
-    public function get($key, $default = null);
56
+	/**
57
+	 * returns   the value for a request param if the given key exists
58
+	 *
59
+	 * @param       $key
60
+	 * @param null  $default
61
+	 * @return mixed
62
+	 */
63
+	public function get($key, $default = null);
64 64
 
65 65
 
66
-    /**
67
-     * check if param exists
68
-     *
69
-     * @param       $key
70
-     * @return bool
71
-     */
72
-    public function is_set($key);
66
+	/**
67
+	 * check if param exists
68
+	 *
69
+	 * @param       $key
70
+	 * @return bool
71
+	 */
72
+	public function is_set($key);
73 73
 
74 74
 
75
-    /**
76
-     * remove param
77
-     *
78
-     * @param      $key
79
-     * @param bool $unset_from_global_too
80
-     */
81
-    public function un_set($key, $unset_from_global_too = false);
75
+	/**
76
+	 * remove param
77
+	 *
78
+	 * @param      $key
79
+	 * @param bool $unset_from_global_too
80
+	 */
81
+	public function un_set($key, $unset_from_global_too = false);
82 82
 
83 83
 
84
-    /**
85
-     * @return string
86
-     */
87
-    public function ip_address();
84
+	/**
85
+	 * @return string
86
+	 */
87
+	public function ip_address();
88 88
 
89 89
 
90
-    /**
91
-     * @return bool
92
-     */
93
-    public function isAdmin();
90
+	/**
91
+	 * @return bool
92
+	 */
93
+	public function isAdmin();
94 94
 
95 95
 
96
-    /**
97
-     * @return mixed
98
-     */
99
-    public function isAjax();
96
+	/**
97
+	 * @return mixed
98
+	 */
99
+	public function isAjax();
100 100
 
101 101
 
102
-    /**
103
-     * @return mixed
104
-     */
105
-    public function isFrontAjax();
102
+	/**
103
+	 * @return mixed
104
+	 */
105
+	public function isFrontAjax();
106 106
 
107 107
 
108
-    /**
109
-     * @return mixed|string
110
-     */
111
-    public function requestUri();
108
+	/**
109
+	 * @return mixed|string
110
+	 */
111
+	public function requestUri();
112 112
 
113 113
 
114
-    /**
115
-     * @return string
116
-     */
117
-    public function userAgent();
114
+	/**
115
+	 * @return string
116
+	 */
117
+	public function userAgent();
118 118
 
119 119
 
120
-    /**
121
-     * @param string $user_agent
122
-     */
123
-    public function setUserAgent($user_agent = '');
120
+	/**
121
+	 * @param string $user_agent
122
+	 */
123
+	public function setUserAgent($user_agent = '');
124 124
 
125 125
 
126
-    /**
127
-     * @return bool
128
-     */
129
-    public function isBot();
126
+	/**
127
+	 * @return bool
128
+	 */
129
+	public function isBot();
130 130
 
131 131
 
132
-    /**
133
-     * @param bool $is_bot
134
-     */
135
-    public function setIsBot($is_bot);
132
+	/**
133
+	 * @param bool $is_bot
134
+	 */
135
+	public function setIsBot($is_bot);
136 136
 }
Please login to merge, or discard this patch.
core/services/privacy/policy/PrivacyPolicyManager.php 1 patch
Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -26,71 +26,71 @@
 block discarded – undo
26 26
 class PrivacyPolicyManager
27 27
 {
28 28
 
29
-    public function __construct()
30
-    {
31
-        add_action('current_screen', array($this, 'addPrivacyPolicy'), 9);
32
-    }
29
+	public function __construct()
30
+	{
31
+		add_action('current_screen', array($this, 'addPrivacyPolicy'), 9);
32
+	}
33 33
 
34 34
 
35
-    /**
36
-     * For all the registered `PrivacyPolicyInterface`s, add their privacy policy content
37
-     *
38
-     * @param WP_Screen $screen
39
-     * @throws InvalidClassException
40
-     * @throws InvalidDataTypeException
41
-     * @throws InvalidEntityException
42
-     * @throws InvalidFilePathException
43
-     * @throws InvalidIdentifierException
44
-     * @throws InvalidInterfaceException
45
-     */
46
-    public function addPrivacyPolicy(WP_Screen $screen)
47
-    {
48
-        /** @var RequestInterface $request */
49
-        $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
35
+	/**
36
+	 * For all the registered `PrivacyPolicyInterface`s, add their privacy policy content
37
+	 *
38
+	 * @param WP_Screen $screen
39
+	 * @throws InvalidClassException
40
+	 * @throws InvalidDataTypeException
41
+	 * @throws InvalidEntityException
42
+	 * @throws InvalidFilePathException
43
+	 * @throws InvalidIdentifierException
44
+	 * @throws InvalidInterfaceException
45
+	 */
46
+	public function addPrivacyPolicy(WP_Screen $screen)
47
+	{
48
+		/** @var RequestInterface $request */
49
+		$request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
50 50
 
51
-        if ($screen->id === 'tools' && $request->requestParamIsSet('wp-privacy-policy-guide')) {
52
-            // load all the privacy policy stuff
53
-            // add post policy text
54
-            foreach ($this->loadPrivacyPolicyCollection() as $privacy_policy) {
55
-                wp_add_privacy_policy_content($privacy_policy->getName(), $privacy_policy->getContent());
56
-            }
57
-        }
58
-    }
51
+		if ($screen->id === 'tools' && $request->requestParamIsSet('wp-privacy-policy-guide')) {
52
+			// load all the privacy policy stuff
53
+			// add post policy text
54
+			foreach ($this->loadPrivacyPolicyCollection() as $privacy_policy) {
55
+				wp_add_privacy_policy_content($privacy_policy->getName(), $privacy_policy->getContent());
56
+			}
57
+		}
58
+	}
59 59
 
60 60
 
61
-    /**
62
-     * @return CollectionInterface|PrivacyPolicyInterface[]
63
-     * @throws InvalidIdentifierException
64
-     * @throws InvalidInterfaceException
65
-     * @throws InvalidFilePathException
66
-     * @throws InvalidEntityException
67
-     * @throws InvalidDataTypeException
68
-     * @throws InvalidClassException
69
-     */
70
-    protected function loadPrivacyPolicyCollection()
71
-    {
72
-        $loader = new CollectionLoader(
73
-            new CollectionDetails(
74
-                // collection name
75
-                'privacy_policies',
76
-                // collection interface
77
-                'EventEspresso\core\services\privacy\policy\PrivacyPolicyInterface',
78
-                // FQCNs for classes to add (all classes within that namespace will be loaded)
79
-                apply_filters(
80
-                    'FHEE__EventEspresso_core_services_privacy_policy_PrivacyPolicyManager__privacy_policies',
81
-                    array('EventEspresso\core\domain\services\admin\privacy\policy\PrivacyPolicy')
82
-                ),
83
-                // filepaths to classes to add
84
-                array(),
85
-                // file mask to use if parsing folder for files to add
86
-                '',
87
-                // what to use as identifier for collection entities
88
-                // using CLASS NAME prevents duplicates (works like a singleton)
89
-                CollectionDetails::ID_CLASS_NAME
90
-            )
91
-        );
92
-        return $loader->getCollection();
93
-    }
61
+	/**
62
+	 * @return CollectionInterface|PrivacyPolicyInterface[]
63
+	 * @throws InvalidIdentifierException
64
+	 * @throws InvalidInterfaceException
65
+	 * @throws InvalidFilePathException
66
+	 * @throws InvalidEntityException
67
+	 * @throws InvalidDataTypeException
68
+	 * @throws InvalidClassException
69
+	 */
70
+	protected function loadPrivacyPolicyCollection()
71
+	{
72
+		$loader = new CollectionLoader(
73
+			new CollectionDetails(
74
+				// collection name
75
+				'privacy_policies',
76
+				// collection interface
77
+				'EventEspresso\core\services\privacy\policy\PrivacyPolicyInterface',
78
+				// FQCNs for classes to add (all classes within that namespace will be loaded)
79
+				apply_filters(
80
+					'FHEE__EventEspresso_core_services_privacy_policy_PrivacyPolicyManager__privacy_policies',
81
+					array('EventEspresso\core\domain\services\admin\privacy\policy\PrivacyPolicy')
82
+				),
83
+				// filepaths to classes to add
84
+				array(),
85
+				// file mask to use if parsing folder for files to add
86
+				'',
87
+				// what to use as identifier for collection entities
88
+				// using CLASS NAME prevents duplicates (works like a singleton)
89
+				CollectionDetails::ID_CLASS_NAME
90
+			)
91
+		);
92
+		return $loader->getCollection();
93
+	}
94 94
 }
95 95
 // End of file PrivacyPolicyManager.php
96 96
 // Location: EventEspresso\core\domain\services\admin/PrivacyPolicyManager.php
Please login to merge, or discard this patch.
core/libraries/payment_methods/EE_Offsite_Gateway.lib.php 1 patch
Indentation   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -15,117 +15,117 @@
 block discarded – undo
15 15
 abstract class EE_Offsite_Gateway extends EE_Gateway
16 16
 {
17 17
 
18
-    /**
19
-     * whether or not the gateway uses an IPN
20
-     * that is sent in a separate request than the returning registrant.
21
-     * if false, then we need to process the payment results manually
22
-     * as soon as the registrant returns from the off-site gateway
23
-     *
24
-     * @type bool
25
-     */
26
-    protected $_uses_separate_IPN_request = false;
18
+	/**
19
+	 * whether or not the gateway uses an IPN
20
+	 * that is sent in a separate request than the returning registrant.
21
+	 * if false, then we need to process the payment results manually
22
+	 * as soon as the registrant returns from the off-site gateway
23
+	 *
24
+	 * @type bool
25
+	 */
26
+	protected $_uses_separate_IPN_request = false;
27 27
 
28 28
 
29
-    /**
30
-     * @return EE_Offsite_Gateway
31
-     */
32
-    public function __construct()
33
-    {
34
-        $this->_supports_receiving_refunds = true;
35
-        parent::__construct();
36
-    }
29
+	/**
30
+	 * @return EE_Offsite_Gateway
31
+	 */
32
+	public function __construct()
33
+	{
34
+		$this->_supports_receiving_refunds = true;
35
+		parent::__construct();
36
+	}
37 37
 
38 38
 
39
-    /**
40
-     * Adds information into the payment object's redirect_url and redirect_args so
41
-     * client code can use that payment to know where (and with what information)
42
-     * to redirect the user to in order to make the payment on the offsite gateway's website.
43
-     * Saving the payment from within this method is unnecessary,
44
-     * as it is the responsibility of client code to save it.
45
-     *
46
-     * @param EE_Payment $payment    to process
47
-     * @param array      $billing_info
48
-     * @param string     $return_url URL to send the user to after a successful payment on the payment provider's
49
-     *                               website
50
-     * @param string     $notify_url URL to send the instant payment notification
51
-     * @param string     $cancel_url URL to send the user to after a cancelled payment attempt on teh payment
52
-     *                               provider's website
53
-     * @return EE_Payment
54
-     */
55
-    abstract public function set_redirection_info(
56
-        $payment,
57
-        $billing_info = array(),
58
-        $return_url = null,
59
-        $notify_url = null,
60
-        $cancel_url = null
61
-    );
39
+	/**
40
+	 * Adds information into the payment object's redirect_url and redirect_args so
41
+	 * client code can use that payment to know where (and with what information)
42
+	 * to redirect the user to in order to make the payment on the offsite gateway's website.
43
+	 * Saving the payment from within this method is unnecessary,
44
+	 * as it is the responsibility of client code to save it.
45
+	 *
46
+	 * @param EE_Payment $payment    to process
47
+	 * @param array      $billing_info
48
+	 * @param string     $return_url URL to send the user to after a successful payment on the payment provider's
49
+	 *                               website
50
+	 * @param string     $notify_url URL to send the instant payment notification
51
+	 * @param string     $cancel_url URL to send the user to after a cancelled payment attempt on teh payment
52
+	 *                               provider's website
53
+	 * @return EE_Payment
54
+	 */
55
+	abstract public function set_redirection_info(
56
+		$payment,
57
+		$billing_info = array(),
58
+		$return_url = null,
59
+		$notify_url = null,
60
+		$cancel_url = null
61
+	);
62 62
 
63 63
 
64
-    /**
65
-     * Often used for IPNs. But applies the info in $update_info to the payment.
66
-     * What is $update_info? Often the contents of request, but not necessarily. Whatever
67
-     * the payment method passes in. Saving the payment from within this method is unnecessary,
68
-     * as it is the responsibility of client code to save it.
69
-     *
70
-     * @param array           $update_info of whatever
71
-     * @param EEI_Transaction $transaction
72
-     * @return EEI_Payment updated
73
-     */
74
-    abstract public function handle_payment_update($update_info, $transaction);
64
+	/**
65
+	 * Often used for IPNs. But applies the info in $update_info to the payment.
66
+	 * What is $update_info? Often the contents of request, but not necessarily. Whatever
67
+	 * the payment method passes in. Saving the payment from within this method is unnecessary,
68
+	 * as it is the responsibility of client code to save it.
69
+	 *
70
+	 * @param array           $update_info of whatever
71
+	 * @param EEI_Transaction $transaction
72
+	 * @return EEI_Payment updated
73
+	 */
74
+	abstract public function handle_payment_update($update_info, $transaction);
75 75
 
76 76
 
77
-    /**
78
-     * uses_separate_IPN_request
79
-     *
80
-     * return true or false for whether or not the gateway uses an IPN
81
-     * that is sent in a separate request than the returning registrant.
82
-     * if false, then we need to process the payment results manually
83
-     * as soon as the registrant returns from the off-site gateway
84
-     *
85
-     * @deprecated since version 4.8.39.rc.001 please use handle_IPN_in_this_request() instead
86
-     *
87
-     * @return bool
88
-     */
89
-    public function uses_separate_IPN_request()
90
-    {
91
-        return $this->_uses_separate_IPN_request;
92
-    }
77
+	/**
78
+	 * uses_separate_IPN_request
79
+	 *
80
+	 * return true or false for whether or not the gateway uses an IPN
81
+	 * that is sent in a separate request than the returning registrant.
82
+	 * if false, then we need to process the payment results manually
83
+	 * as soon as the registrant returns from the off-site gateway
84
+	 *
85
+	 * @deprecated since version 4.8.39.rc.001 please use handle_IPN_in_this_request() instead
86
+	 *
87
+	 * @return bool
88
+	 */
89
+	public function uses_separate_IPN_request()
90
+	{
91
+		return $this->_uses_separate_IPN_request;
92
+	}
93 93
 
94 94
 
95
-    /**
96
-     * set_uses_separate_IPN_request
97
-     *
98
-     * @access protected
99
-     * @param boolean $uses_separate_IPN_request
100
-     */
101
-    protected function set_uses_separate_IPN_request($uses_separate_IPN_request)
102
-    {
103
-        $this->_uses_separate_IPN_request = filter_var($uses_separate_IPN_request, FILTER_VALIDATE_BOOLEAN);
104
-    }
95
+	/**
96
+	 * set_uses_separate_IPN_request
97
+	 *
98
+	 * @access protected
99
+	 * @param boolean $uses_separate_IPN_request
100
+	 */
101
+	protected function set_uses_separate_IPN_request($uses_separate_IPN_request)
102
+	{
103
+		$this->_uses_separate_IPN_request = filter_var($uses_separate_IPN_request, FILTER_VALIDATE_BOOLEAN);
104
+	}
105 105
 
106
-    /**
107
-     * Allows gateway to dynamically decide whether or not to handle a payment update
108
-     * by overriding this method. By default, if this is a "true" IPN (meaning
109
-     * it's a separate request from when the user returns from the offsite gateway)
110
-     * and this gateway class is setup to handle IPNs in separate "true" IPNs, then
111
-     * this will return true, otherwise it will return false.
112
-     * If however, this is a request when the user is returning
113
-     * from an offsite gateway, and this gateway class is setup to process the payment
114
-     * data when the user returns, then this will return true.
115
-     *
116
-     * @param array   $request_data
117
-     * @param boolean $separate_IPN_request
118
-     * @return boolean
119
-     */
120
-    public function handle_IPN_in_this_request($request_data, $separate_IPN_request)
121
-    {
122
-        if ($separate_IPN_request) {
123
-            // payment data being sent in a request separate from the user
124
-            // it is this other request that will update the TXN and payment info
125
-            return $this->_uses_separate_IPN_request;
126
-        } else {
127
-            // it's a request where the user returned from an offsite gateway WITH the payment data
128
-            return ! $this->_uses_separate_IPN_request;
129
-        }
130
-    }
106
+	/**
107
+	 * Allows gateway to dynamically decide whether or not to handle a payment update
108
+	 * by overriding this method. By default, if this is a "true" IPN (meaning
109
+	 * it's a separate request from when the user returns from the offsite gateway)
110
+	 * and this gateway class is setup to handle IPNs in separate "true" IPNs, then
111
+	 * this will return true, otherwise it will return false.
112
+	 * If however, this is a request when the user is returning
113
+	 * from an offsite gateway, and this gateway class is setup to process the payment
114
+	 * data when the user returns, then this will return true.
115
+	 *
116
+	 * @param array   $request_data
117
+	 * @param boolean $separate_IPN_request
118
+	 * @return boolean
119
+	 */
120
+	public function handle_IPN_in_this_request($request_data, $separate_IPN_request)
121
+	{
122
+		if ($separate_IPN_request) {
123
+			// payment data being sent in a request separate from the user
124
+			// it is this other request that will update the TXN and payment info
125
+			return $this->_uses_separate_IPN_request;
126
+		} else {
127
+			// it's a request where the user returned from an offsite gateway WITH the payment data
128
+			return ! $this->_uses_separate_IPN_request;
129
+		}
130
+	}
131 131
 }
Please login to merge, or discard this patch.