Completed
Pull Request — master (#1010)
by
unknown
09:19
created
core/services/locators/FqcnLocator.php 2 patches
Indentation   +154 added lines, -154 removed lines patch added patch discarded remove patch
@@ -17,158 +17,158 @@
 block discarded – undo
17 17
 class FqcnLocator extends Locator
18 18
 {
19 19
 
20
-    /**
21
-     * @var array $FQCNs
22
-     */
23
-    protected $FQCNs = array();
24
-
25
-    /**
26
-     * @var array $namespaces
27
-     */
28
-    protected $namespaces = array();
29
-
30
-
31
-    /**
32
-     * @access protected
33
-     * @param string $namespace
34
-     * @param string $namespace_base_dir
35
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
36
-     */
37
-    protected function setNamespace($namespace, $namespace_base_dir)
38
-    {
39
-        if (! is_string($namespace)) {
40
-            throw new InvalidDataTypeException('$namespace', $namespace, 'string');
41
-        }
42
-        if (! is_string($namespace_base_dir)) {
43
-            throw new InvalidDataTypeException('$namespace_base_dir', $namespace_base_dir, 'string');
44
-        }
45
-        $this->namespaces[ $namespace ] = $namespace_base_dir;
46
-    }
47
-
48
-
49
-    /**
50
-     * @access public
51
-     * @return array
52
-     */
53
-    public function getFQCNs()
54
-    {
55
-        return $this->FQCNs;
56
-    }
57
-
58
-
59
-    /**
60
-     * @access public
61
-     * @return int
62
-     */
63
-    public function count()
64
-    {
65
-        return count($this->FQCNs);
66
-    }
67
-
68
-
69
-    /**
70
-     * given a valid namespace, will find all files that match the provided mask
71
-     *
72
-     * @access public
73
-     * @param string|array $namespaces
74
-     * @return FilesystemIterator
75
-     * @throws \EventEspresso\core\exceptions\InvalidClassException
76
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
77
-     */
78
-    public function locate($namespaces)
79
-    {
80
-        if (! (is_string($namespaces) || is_array($namespaces))) {
81
-            throw new InvalidDataTypeException('$namespaces', $namespaces, 'string or array');
82
-        }
83
-        foreach ((array) $namespaces as $namespace) {
84
-            foreach ($this->FindFQCNsByNamespace($namespace) as $key => $file) {
85
-                $this->FQCNs[ $key ] = $file;
86
-            }
87
-        }
88
-        return $this->FQCNs;
89
-    }
90
-
91
-
92
-    // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
93
-
94
-    /**
95
-     * given a partial namespace, will find all files in that folder
96
-     * ** PLZ NOTE **
97
-     * This assumes that all files within the specified folder should be loaded
98
-     *
99
-     * @access protected
100
-     * @param array $partial_namespace
101
-     * @return FilesystemIterator
102
-     * @throws \EventEspresso\core\exceptions\InvalidClassException
103
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
104
-     */
105
-    protected function FindFQCNsByNamespace($partial_namespace)
106
-    {
107
-        $iterator = new FilesystemIterator(
108
-            $this->getDirectoryFromPartialNamespace($partial_namespace)
109
-        );
110
-        foreach ($this->flags as $flag) {
111
-            $iterator->setFlags($flag);
112
-        }
113
-        if (iterator_count($iterator) === 0) {
114
-            return array();
115
-        }
116
-        foreach ($iterator as $file) {
117
-            $file = \EEH_File::standardise_directory_separators($file);
118
-            foreach ($this->namespaces as $namespace => $base_dir) {
119
-                $namespace .= Psr4Autoloader::NS;
120
-                if (strpos($file, $base_dir) === 0) {
121
-                    $this->FQCNs[] = Psr4Autoloader::NS . str_replace(
122
-                        array($base_dir, DS, '.php'),
123
-                        array($namespace, Psr4Autoloader::NS, ''),
124
-                        $file
125
-                    );
126
-                }
127
-            }
128
-        }
129
-        return $this->FQCNs;
130
-    }
131
-
132
-
133
-    /**
134
-     * getDirectoryFromPartialNamespace
135
-     *
136
-     * @access protected
137
-     * @param  string $partial_namespace almost fully qualified class name ?
138
-     * @return string
139
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
140
-     * @throws \EventEspresso\core\exceptions\InvalidClassException
141
-     */
142
-    protected function getDirectoryFromPartialNamespace($partial_namespace)
143
-    {
144
-        if (empty($partial_namespace)) {
145
-            throw new InvalidClassException($partial_namespace);
146
-        }
147
-        // load our PSR-4 Autoloader so we can get the list of registered namespaces from it
148
-        $psr4_loader = \EE_Psr4AutoloaderInit::psr4_loader();
149
-        // breakup the incoming namespace into segments then loop thru them
150
-        $namespace_segments = explode(Psr4Autoloader::NS, trim($partial_namespace, Psr4Autoloader::NS));
151
-        $prefix = null;
152
-        $namespace_segments_to_try = $namespace_segments;
153
-        $removed_namespace_segments = [];
154
-        while( ! empty($namespace_segments_to_try)) {
155
-            $namespace_to_try = implode( Psr4Autoloader::NS, $namespace_segments_to_try);
156
-            // check if there's a base directory registered for that namespace
157
-            $prefix = $psr4_loader->prefixes($namespace_to_try . Psr4Autoloader::NS);
158
-            // nope? then the incoming namespace is invalid
159
-            if (! empty($prefix) && ! empty($prefix[0])) {
160
-                break;
161
-            }
162
-            array_unshift(
163
-                $removed_namespace_segments,
164
-                array_pop($namespace_segments_to_try)
165
-            );
166
-        }// nope? then the incoming namespace is invalid
167
-        if (empty($prefix) || empty($prefix[0])) {
168
-            throw new InvalidClassException($partial_namespace);
169
-        }
170
-        $this->setNamespace($namespace_to_try, $prefix[0]);
171
-        // but if it's good, add that base directory to the rest of the path, and return it
172
-        return $prefix[0] . implode(DS, $removed_namespace_segments) . DS;
173
-    }
20
+	/**
21
+	 * @var array $FQCNs
22
+	 */
23
+	protected $FQCNs = array();
24
+
25
+	/**
26
+	 * @var array $namespaces
27
+	 */
28
+	protected $namespaces = array();
29
+
30
+
31
+	/**
32
+	 * @access protected
33
+	 * @param string $namespace
34
+	 * @param string $namespace_base_dir
35
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
36
+	 */
37
+	protected function setNamespace($namespace, $namespace_base_dir)
38
+	{
39
+		if (! is_string($namespace)) {
40
+			throw new InvalidDataTypeException('$namespace', $namespace, 'string');
41
+		}
42
+		if (! is_string($namespace_base_dir)) {
43
+			throw new InvalidDataTypeException('$namespace_base_dir', $namespace_base_dir, 'string');
44
+		}
45
+		$this->namespaces[ $namespace ] = $namespace_base_dir;
46
+	}
47
+
48
+
49
+	/**
50
+	 * @access public
51
+	 * @return array
52
+	 */
53
+	public function getFQCNs()
54
+	{
55
+		return $this->FQCNs;
56
+	}
57
+
58
+
59
+	/**
60
+	 * @access public
61
+	 * @return int
62
+	 */
63
+	public function count()
64
+	{
65
+		return count($this->FQCNs);
66
+	}
67
+
68
+
69
+	/**
70
+	 * given a valid namespace, will find all files that match the provided mask
71
+	 *
72
+	 * @access public
73
+	 * @param string|array $namespaces
74
+	 * @return FilesystemIterator
75
+	 * @throws \EventEspresso\core\exceptions\InvalidClassException
76
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
77
+	 */
78
+	public function locate($namespaces)
79
+	{
80
+		if (! (is_string($namespaces) || is_array($namespaces))) {
81
+			throw new InvalidDataTypeException('$namespaces', $namespaces, 'string or array');
82
+		}
83
+		foreach ((array) $namespaces as $namespace) {
84
+			foreach ($this->FindFQCNsByNamespace($namespace) as $key => $file) {
85
+				$this->FQCNs[ $key ] = $file;
86
+			}
87
+		}
88
+		return $this->FQCNs;
89
+	}
90
+
91
+
92
+	// phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
93
+
94
+	/**
95
+	 * given a partial namespace, will find all files in that folder
96
+	 * ** PLZ NOTE **
97
+	 * This assumes that all files within the specified folder should be loaded
98
+	 *
99
+	 * @access protected
100
+	 * @param array $partial_namespace
101
+	 * @return FilesystemIterator
102
+	 * @throws \EventEspresso\core\exceptions\InvalidClassException
103
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
104
+	 */
105
+	protected function FindFQCNsByNamespace($partial_namespace)
106
+	{
107
+		$iterator = new FilesystemIterator(
108
+			$this->getDirectoryFromPartialNamespace($partial_namespace)
109
+		);
110
+		foreach ($this->flags as $flag) {
111
+			$iterator->setFlags($flag);
112
+		}
113
+		if (iterator_count($iterator) === 0) {
114
+			return array();
115
+		}
116
+		foreach ($iterator as $file) {
117
+			$file = \EEH_File::standardise_directory_separators($file);
118
+			foreach ($this->namespaces as $namespace => $base_dir) {
119
+				$namespace .= Psr4Autoloader::NS;
120
+				if (strpos($file, $base_dir) === 0) {
121
+					$this->FQCNs[] = Psr4Autoloader::NS . str_replace(
122
+						array($base_dir, DS, '.php'),
123
+						array($namespace, Psr4Autoloader::NS, ''),
124
+						$file
125
+					);
126
+				}
127
+			}
128
+		}
129
+		return $this->FQCNs;
130
+	}
131
+
132
+
133
+	/**
134
+	 * getDirectoryFromPartialNamespace
135
+	 *
136
+	 * @access protected
137
+	 * @param  string $partial_namespace almost fully qualified class name ?
138
+	 * @return string
139
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
140
+	 * @throws \EventEspresso\core\exceptions\InvalidClassException
141
+	 */
142
+	protected function getDirectoryFromPartialNamespace($partial_namespace)
143
+	{
144
+		if (empty($partial_namespace)) {
145
+			throw new InvalidClassException($partial_namespace);
146
+		}
147
+		// load our PSR-4 Autoloader so we can get the list of registered namespaces from it
148
+		$psr4_loader = \EE_Psr4AutoloaderInit::psr4_loader();
149
+		// breakup the incoming namespace into segments then loop thru them
150
+		$namespace_segments = explode(Psr4Autoloader::NS, trim($partial_namespace, Psr4Autoloader::NS));
151
+		$prefix = null;
152
+		$namespace_segments_to_try = $namespace_segments;
153
+		$removed_namespace_segments = [];
154
+		while( ! empty($namespace_segments_to_try)) {
155
+			$namespace_to_try = implode( Psr4Autoloader::NS, $namespace_segments_to_try);
156
+			// check if there's a base directory registered for that namespace
157
+			$prefix = $psr4_loader->prefixes($namespace_to_try . Psr4Autoloader::NS);
158
+			// nope? then the incoming namespace is invalid
159
+			if (! empty($prefix) && ! empty($prefix[0])) {
160
+				break;
161
+			}
162
+			array_unshift(
163
+				$removed_namespace_segments,
164
+				array_pop($namespace_segments_to_try)
165
+			);
166
+		}// nope? then the incoming namespace is invalid
167
+		if (empty($prefix) || empty($prefix[0])) {
168
+			throw new InvalidClassException($partial_namespace);
169
+		}
170
+		$this->setNamespace($namespace_to_try, $prefix[0]);
171
+		// but if it's good, add that base directory to the rest of the path, and return it
172
+		return $prefix[0] . implode(DS, $removed_namespace_segments) . DS;
173
+	}
174 174
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -36,13 +36,13 @@  discard block
 block discarded – undo
36 36
      */
37 37
     protected function setNamespace($namespace, $namespace_base_dir)
38 38
     {
39
-        if (! is_string($namespace)) {
39
+        if ( ! is_string($namespace)) {
40 40
             throw new InvalidDataTypeException('$namespace', $namespace, 'string');
41 41
         }
42
-        if (! is_string($namespace_base_dir)) {
42
+        if ( ! is_string($namespace_base_dir)) {
43 43
             throw new InvalidDataTypeException('$namespace_base_dir', $namespace_base_dir, 'string');
44 44
         }
45
-        $this->namespaces[ $namespace ] = $namespace_base_dir;
45
+        $this->namespaces[$namespace] = $namespace_base_dir;
46 46
     }
47 47
 
48 48
 
@@ -77,12 +77,12 @@  discard block
 block discarded – undo
77 77
      */
78 78
     public function locate($namespaces)
79 79
     {
80
-        if (! (is_string($namespaces) || is_array($namespaces))) {
80
+        if ( ! (is_string($namespaces) || is_array($namespaces))) {
81 81
             throw new InvalidDataTypeException('$namespaces', $namespaces, 'string or array');
82 82
         }
83 83
         foreach ((array) $namespaces as $namespace) {
84 84
             foreach ($this->FindFQCNsByNamespace($namespace) as $key => $file) {
85
-                $this->FQCNs[ $key ] = $file;
85
+                $this->FQCNs[$key] = $file;
86 86
             }
87 87
         }
88 88
         return $this->FQCNs;
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
             foreach ($this->namespaces as $namespace => $base_dir) {
119 119
                 $namespace .= Psr4Autoloader::NS;
120 120
                 if (strpos($file, $base_dir) === 0) {
121
-                    $this->FQCNs[] = Psr4Autoloader::NS . str_replace(
121
+                    $this->FQCNs[] = Psr4Autoloader::NS.str_replace(
122 122
                         array($base_dir, DS, '.php'),
123 123
                         array($namespace, Psr4Autoloader::NS, ''),
124 124
                         $file
@@ -151,12 +151,12 @@  discard block
 block discarded – undo
151 151
         $prefix = null;
152 152
         $namespace_segments_to_try = $namespace_segments;
153 153
         $removed_namespace_segments = [];
154
-        while( ! empty($namespace_segments_to_try)) {
155
-            $namespace_to_try = implode( Psr4Autoloader::NS, $namespace_segments_to_try);
154
+        while ( ! empty($namespace_segments_to_try)) {
155
+            $namespace_to_try = implode(Psr4Autoloader::NS, $namespace_segments_to_try);
156 156
             // check if there's a base directory registered for that namespace
157
-            $prefix = $psr4_loader->prefixes($namespace_to_try . Psr4Autoloader::NS);
157
+            $prefix = $psr4_loader->prefixes($namespace_to_try.Psr4Autoloader::NS);
158 158
             // nope? then the incoming namespace is invalid
159
-            if (! empty($prefix) && ! empty($prefix[0])) {
159
+            if ( ! empty($prefix) && ! empty($prefix[0])) {
160 160
                 break;
161 161
             }
162 162
             array_unshift(
@@ -169,6 +169,6 @@  discard block
 block discarded – undo
169 169
         }
170 170
         $this->setNamespace($namespace_to_try, $prefix[0]);
171 171
         // but if it's good, add that base directory to the rest of the path, and return it
172
-        return $prefix[0] . implode(DS, $removed_namespace_segments) . DS;
172
+        return $prefix[0].implode(DS, $removed_namespace_segments).DS;
173 173
     }
174 174
 }
Please login to merge, or discard this patch.
core/services/options/JsonWpOptionManager.php 1 patch
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -16,39 +16,39 @@
 block discarded – undo
16 16
  */
17 17
 class JsonWpOptionManager
18 18
 {
19
-    /**
20
-     * Updates the object with what's in the DB (specifically, the wp_options table). If nothing is in the DB, leaves
21
-     * the object alone and returns false.
22
-     * @since $VID:$
23
-     * @param JsonWpOptionSerializableInterface $obj
24
-     * @return bool
25
-     */
26
-    public function populateFromDb(JsonWpOptionSerializableInterface $obj)
27
-    {
28
-        $option = get_option($obj->getWpOptionName());
29
-        if ($option) {
30
-            $json = json_decode($option);
31
-            if (is_array($json) || $json instanceof stdClass) {
32
-                return $obj->fromJsonSerializedData($json);
33
-            }
34
-        }
35
-        return false;
36
-    }
19
+	/**
20
+	 * Updates the object with what's in the DB (specifically, the wp_options table). If nothing is in the DB, leaves
21
+	 * the object alone and returns false.
22
+	 * @since $VID:$
23
+	 * @param JsonWpOptionSerializableInterface $obj
24
+	 * @return bool
25
+	 */
26
+	public function populateFromDb(JsonWpOptionSerializableInterface $obj)
27
+	{
28
+		$option = get_option($obj->getWpOptionName());
29
+		if ($option) {
30
+			$json = json_decode($option);
31
+			if (is_array($json) || $json instanceof stdClass) {
32
+				return $obj->fromJsonSerializedData($json);
33
+			}
34
+		}
35
+		return false;
36
+	}
37 37
 
38
-    /**
39
-     * Saves the object's data to the wp_options table for later use.
40
-     * @since $VID:$
41
-     * @param JsonWpOptionSerializableInterface $obj
42
-     * @return bool
43
-     */
44
-    public function saveToDb(JsonWpOptionSerializableInterface $obj)
45
-    {
46
-        return update_option(
47
-            $obj->getWpOptionName(),
48
-            wp_json_encode($obj->toJsonSerializableData()),
49
-            false
50
-        );
51
-    }
38
+	/**
39
+	 * Saves the object's data to the wp_options table for later use.
40
+	 * @since $VID:$
41
+	 * @param JsonWpOptionSerializableInterface $obj
42
+	 * @return bool
43
+	 */
44
+	public function saveToDb(JsonWpOptionSerializableInterface $obj)
45
+	{
46
+		return update_option(
47
+			$obj->getWpOptionName(),
48
+			wp_json_encode($obj->toJsonSerializableData()),
49
+			false
50
+		);
51
+	}
52 52
 
53 53
 }
54 54
 // End of file JsonWpOptionManager.php
Please login to merge, or discard this patch.
core/services/options/JsonWpOptionSerializableInterface.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -17,13 +17,13 @@
 block discarded – undo
17 17
  */
18 18
 interface JsonWpOptionSerializableInterface extends JsonSerializableAndUnserializable
19 19
 {
20
-    /**
21
-     * Gets the value to use for wp_options.option_name. Note this is not static, so it can use object properties to
22
-     * determine what option name to use.
23
-     * @since $VID:$
24
-     * @return string
25
-     */
26
-    public function getWpOptionName();
20
+	/**
21
+	 * Gets the value to use for wp_options.option_name. Note this is not static, so it can use object properties to
22
+	 * determine what option name to use.
23
+	 * @since $VID:$
24
+	 * @return string
25
+	 */
26
+	public function getWpOptionName();
27 27
 }
28 28
 // End of file JsonWpOptionSerializableInterface.php
29 29
 // Location: EventEspresso\core\services\options/JsonWpOptionSerializableInterface.php
Please login to merge, or discard this patch.
core/services/json/JsonSerializableAndUnserializable.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -15,21 +15,21 @@
 block discarded – undo
15 15
  */
16 16
 interface JsonSerializableAndUnserializable
17 17
 {
18
-    /**
19
-     * Creates a simple PHP array or stdClass from this object's properties, which can be easily serialized using
20
-     * wp_json_serialize().
21
-     * @since $VID:$
22
-     * @return mixed
23
-     */
24
-    public function toJsonSerializableData();
18
+	/**
19
+	 * Creates a simple PHP array or stdClass from this object's properties, which can be easily serialized using
20
+	 * wp_json_serialize().
21
+	 * @since $VID:$
22
+	 * @return mixed
23
+	 */
24
+	public function toJsonSerializableData();
25 25
 
26
-    /**
27
-     * Initializes this object from data
28
-     * @since $VID:$
29
-     * @param mixed $data
30
-     * @return boolean success
31
-     */
32
-    public function fromJsonSerializedData($data);
26
+	/**
27
+	 * Initializes this object from data
28
+	 * @since $VID:$
29
+	 * @param mixed $data
30
+	 * @return boolean success
31
+	 */
32
+	public function fromJsonSerializedData($data);
33 33
 
34 34
 }
35 35
 // End of file JsonSerializableAndUnserializable.php
Please login to merge, or discard this patch.
core/services/request/files/FileSubmission.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
      */
72 72
     public function getType()
73 73
     {
74
-        if (!$this->type) {
74
+        if ( ! $this->type) {
75 75
             $this->type = $this->determineType();
76 76
         }
77 77
         return $this->type;
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
      */
84 84
     protected function determineType()
85 85
     {
86
-        if (!$this->getTmpFile()) {
86
+        if ( ! $this->getTmpFile()) {
87 87
             return '';
88 88
         }
89 89
         $finfo = new finfo(FILEINFO_MIME_TYPE);
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
      */
98 98
     public function getExtension()
99 99
     {
100
-        if (!$this->extension) {
100
+        if ( ! $this->extension) {
101 101
             $this->extension = $this->determineExtension();
102 102
         }
103 103
         return $this->extension;
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
      */
111 111
     protected function determineExtension()
112 112
     {
113
-        if (!$this->getTmpFile()) {
113
+        if ( ! $this->getTmpFile()) {
114 114
             return '';
115 115
         }
116 116
         return pathinfo($this->getTmpFile(), PATHINFO_EXTENSION);
Please login to merge, or discard this patch.
Indentation   +154 added lines, -154 removed lines patch added patch discarded remove patch
@@ -19,160 +19,160 @@
 block discarded – undo
19 19
  */
20 20
 class FileSubmission implements FileSubmissionInterface
21 21
 {
22
-    /**
23
-     * @var string original name on the client machine
24
-     */
25
-    protected $name;
26
-
27
-    /**
28
-     * @var string mime type
29
-     */
30
-    protected $type;
31
-
32
-    /**
33
-     * @var string file extension
34
-     */
35
-    protected $extension;
36
-
37
-    /**
38
-     * @var int in bytes
39
-     */
40
-    protected $size;
41
-
42
-    /**
43
-     * @var string local filepath to the temporary file
44
-     */
45
-    protected $tmp_file;
46
-
47
-    /**
48
-     * @var int one of UPLOAD_ERR_OK, UPLOAD_ERR_NO_FILE, UPLOAD_ERR_INI_SIZE, UPLOAD_ERR_FORM_SIZE or other values
49
-     * although those aren't expected.
50
-     */
51
-    protected $error_code;
52
-
53
-    /**
54
-     * FileSubmission constructor.
55
-     * @param $name
56
-     * @param $tmp_file
57
-     * @param $size
58
-     * @param null $error_code
59
-     * @throws InvalidArgumentException
60
-     */
61
-    public function __construct($name, $tmp_file, $size, $error_code = null)
62
-    {
63
-        $this->name = basename($name);
64
-        $scheme = parse_url($tmp_file, PHP_URL_SCHEME);
65
-        if (in_array($scheme, ['http', 'https'])) {
66
-            // Wait a minute- just local filepaths please, no URL schemes allowed!
67
-            throw new InvalidArgumentException(
68
-                sprintf(
69
-                    // @codingStandardsIgnoreStart
70
-                    esc_html__('The scheme ("%1$s") on the temporary file ("%2$s") indicates is located elsewhere, that’s not ok!', 'event_espresso'),
71
-                    // @codingStandardsIgnoreEnd
72
-                    $scheme,
73
-                    $tmp_file
74
-                )
75
-            );
76
-        }
77
-        $this->tmp_file = (string) $tmp_file;
78
-        $this->size = (int) $size;
79
-        $this->error_code = (int) $error_code;
80
-    }
81
-
82
-    /**
83
-     * @return string
84
-     */
85
-    public function getName()
86
-    {
87
-        return $this->name;
88
-    }
89
-
90
-    /**
91
-     * Gets the file's mime type
92
-     * @return string
93
-     */
94
-    public function getType()
95
-    {
96
-        if (!$this->type) {
97
-            $this->type = $this->determineType();
98
-        }
99
-        return $this->type;
100
-    }
101
-
102
-    /**
103
-     * @since $VID:$
104
-     * @return string
105
-     */
106
-    protected function determineType()
107
-    {
108
-        if (!$this->getTmpFile()) {
109
-            return '';
110
-        }
111
-        $finfo = new finfo(FILEINFO_MIME_TYPE);
112
-        return $finfo->file($this->getTmpFile());
113
-    }
114
-
115
-    /**
116
-     * Gets the file's extension.
117
-     * @since $VID:$
118
-     * @return string
119
-     */
120
-    public function getExtension()
121
-    {
122
-        if (!$this->extension) {
123
-            $this->extension = $this->determineExtension();
124
-        }
125
-        return $this->extension;
126
-    }
127
-
128
-    /**
129
-     * Determine's the file's extension given the temporary file.
130
-     * @since $VID:$
131
-     * @return string
132
-     */
133
-    protected function determineExtension()
134
-    {
135
-        if (!$this->getTmpFile()) {
136
-            return '';
137
-        }
138
-        return pathinfo($this->getTmpFile(), PATHINFO_EXTENSION);
139
-    }
140
-
141
-    /**
142
-     * Gets the size of the file
143
-     * @return int
144
-     */
145
-    public function getSize()
146
-    {
147
-        return $this->size;
148
-    }
149
-
150
-    /**
151
-     * Gets the path to the temporary file which was uploaded.
152
-     * @return string
153
-     */
154
-    public function getTmpFile()
155
-    {
156
-        return $this->tmp_file;
157
-    }
158
-
159
-    /**
160
-     * @since $VID:$
161
-     * @return string
162
-     */
163
-    public function __toString()
164
-    {
165
-        return $this->getTmpFile();
166
-    }
167
-
168
-    /**
169
-     * Gets the error code PHP reported for the file upload.
170
-     * @return string
171
-     */
172
-    public function getErrorCode()
173
-    {
174
-        return $this->error_code;
175
-    }
22
+	/**
23
+	 * @var string original name on the client machine
24
+	 */
25
+	protected $name;
26
+
27
+	/**
28
+	 * @var string mime type
29
+	 */
30
+	protected $type;
31
+
32
+	/**
33
+	 * @var string file extension
34
+	 */
35
+	protected $extension;
36
+
37
+	/**
38
+	 * @var int in bytes
39
+	 */
40
+	protected $size;
41
+
42
+	/**
43
+	 * @var string local filepath to the temporary file
44
+	 */
45
+	protected $tmp_file;
46
+
47
+	/**
48
+	 * @var int one of UPLOAD_ERR_OK, UPLOAD_ERR_NO_FILE, UPLOAD_ERR_INI_SIZE, UPLOAD_ERR_FORM_SIZE or other values
49
+	 * although those aren't expected.
50
+	 */
51
+	protected $error_code;
52
+
53
+	/**
54
+	 * FileSubmission constructor.
55
+	 * @param $name
56
+	 * @param $tmp_file
57
+	 * @param $size
58
+	 * @param null $error_code
59
+	 * @throws InvalidArgumentException
60
+	 */
61
+	public function __construct($name, $tmp_file, $size, $error_code = null)
62
+	{
63
+		$this->name = basename($name);
64
+		$scheme = parse_url($tmp_file, PHP_URL_SCHEME);
65
+		if (in_array($scheme, ['http', 'https'])) {
66
+			// Wait a minute- just local filepaths please, no URL schemes allowed!
67
+			throw new InvalidArgumentException(
68
+				sprintf(
69
+					// @codingStandardsIgnoreStart
70
+					esc_html__('The scheme ("%1$s") on the temporary file ("%2$s") indicates is located elsewhere, that’s not ok!', 'event_espresso'),
71
+					// @codingStandardsIgnoreEnd
72
+					$scheme,
73
+					$tmp_file
74
+				)
75
+			);
76
+		}
77
+		$this->tmp_file = (string) $tmp_file;
78
+		$this->size = (int) $size;
79
+		$this->error_code = (int) $error_code;
80
+	}
81
+
82
+	/**
83
+	 * @return string
84
+	 */
85
+	public function getName()
86
+	{
87
+		return $this->name;
88
+	}
89
+
90
+	/**
91
+	 * Gets the file's mime type
92
+	 * @return string
93
+	 */
94
+	public function getType()
95
+	{
96
+		if (!$this->type) {
97
+			$this->type = $this->determineType();
98
+		}
99
+		return $this->type;
100
+	}
101
+
102
+	/**
103
+	 * @since $VID:$
104
+	 * @return string
105
+	 */
106
+	protected function determineType()
107
+	{
108
+		if (!$this->getTmpFile()) {
109
+			return '';
110
+		}
111
+		$finfo = new finfo(FILEINFO_MIME_TYPE);
112
+		return $finfo->file($this->getTmpFile());
113
+	}
114
+
115
+	/**
116
+	 * Gets the file's extension.
117
+	 * @since $VID:$
118
+	 * @return string
119
+	 */
120
+	public function getExtension()
121
+	{
122
+		if (!$this->extension) {
123
+			$this->extension = $this->determineExtension();
124
+		}
125
+		return $this->extension;
126
+	}
127
+
128
+	/**
129
+	 * Determine's the file's extension given the temporary file.
130
+	 * @since $VID:$
131
+	 * @return string
132
+	 */
133
+	protected function determineExtension()
134
+	{
135
+		if (!$this->getTmpFile()) {
136
+			return '';
137
+		}
138
+		return pathinfo($this->getTmpFile(), PATHINFO_EXTENSION);
139
+	}
140
+
141
+	/**
142
+	 * Gets the size of the file
143
+	 * @return int
144
+	 */
145
+	public function getSize()
146
+	{
147
+		return $this->size;
148
+	}
149
+
150
+	/**
151
+	 * Gets the path to the temporary file which was uploaded.
152
+	 * @return string
153
+	 */
154
+	public function getTmpFile()
155
+	{
156
+		return $this->tmp_file;
157
+	}
158
+
159
+	/**
160
+	 * @since $VID:$
161
+	 * @return string
162
+	 */
163
+	public function __toString()
164
+	{
165
+		return $this->getTmpFile();
166
+	}
167
+
168
+	/**
169
+	 * Gets the error code PHP reported for the file upload.
170
+	 * @return string
171
+	 */
172
+	public function getErrorCode()
173
+	{
174
+		return $this->error_code;
175
+	}
176 176
 }
177 177
 // End of file FileSubmission.php
178 178
 // Location: EventEspresso\core\services\request\files/FileSubmission.php
Please login to merge, or discard this patch.
core/services/request/files/FileSubmissionInterface.php 1 patch
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -15,36 +15,36 @@
 block discarded – undo
15 15
 interface FileSubmissionInterface
16 16
 {
17 17
 
18
-    /**
19
-     * @return string
20
-     */
21
-    public function getName();
22
-
23
-    /**
24
-     * @return string
25
-     */
26
-    public function getType();
27
-
28
-    /**
29
-     * @return int
30
-     */
31
-    public function getSize();
32
-
33
-    /**
34
-     * @return string
35
-     */
36
-    public function getTmpFile();
37
-
38
-    /**
39
-     * @since $VID:$
40
-     * @return string
41
-     */
42
-    public function __toString();
43
-
44
-    /**
45
-     * @return string
46
-     */
47
-    public function getErrorCode();
18
+	/**
19
+	 * @return string
20
+	 */
21
+	public function getName();
22
+
23
+	/**
24
+	 * @return string
25
+	 */
26
+	public function getType();
27
+
28
+	/**
29
+	 * @return int
30
+	 */
31
+	public function getSize();
32
+
33
+	/**
34
+	 * @return string
35
+	 */
36
+	public function getTmpFile();
37
+
38
+	/**
39
+	 * @since $VID:$
40
+	 * @return string
41
+	 */
42
+	public function __toString();
43
+
44
+	/**
45
+	 * @return string
46
+	 */
47
+	public function getErrorCode();
48 48
 }
49 49
 // End of file FileSubmissionInterface.php
50 50
 // Location: EventEspresso\core\services\request\files/FileSubmissionInterface.php
Please login to merge, or discard this patch.
core/services/request/files/FilesDataHandler.php 2 patches
Indentation   +242 added lines, -242 removed lines patch added patch discarded remove patch
@@ -38,260 +38,260 @@
 block discarded – undo
38 38
  */
39 39
 class FilesDataHandler
40 40
 {
41
-    /**
42
-     * @var Request
43
-     */
44
-    protected $request;
41
+	/**
42
+	 * @var Request
43
+	 */
44
+	protected $request;
45 45
 
46
-    /**
47
-     * @var CollectionInterface | FileSubmissionInterface[]
48
-     */
49
-    protected $file_objects;
46
+	/**
47
+	 * @var CollectionInterface | FileSubmissionInterface[]
48
+	 */
49
+	protected $file_objects;
50 50
 
51
-    /**
52
-     * @var bool
53
-     */
54
-    protected $initialized = false;
51
+	/**
52
+	 * @var bool
53
+	 */
54
+	protected $initialized = false;
55 55
 
56
-    /**
57
-     * FilesDataHandler constructor.
58
-     * @param Request $request
59
-     */
60
-    public function __construct(Request $request)
61
-    {
62
-        $this->request = $request;
63
-    }
56
+	/**
57
+	 * FilesDataHandler constructor.
58
+	 * @param Request $request
59
+	 */
60
+	public function __construct(Request $request)
61
+	{
62
+		$this->request = $request;
63
+	}
64 64
 
65
-    /**
66
-     * @since $VID:$
67
-     * @return CollectionInterface | FileSubmissionInterface[]
68
-     * @throws UnexpectedValueException
69
-     * @throws InvalidArgumentException
70
-     */
71
-    protected function getFileObjects()
72
-    {
73
-        $this->initialize();
74
-        return $this->file_objects;
75
-    }
65
+	/**
66
+	 * @since $VID:$
67
+	 * @return CollectionInterface | FileSubmissionInterface[]
68
+	 * @throws UnexpectedValueException
69
+	 * @throws InvalidArgumentException
70
+	 */
71
+	protected function getFileObjects()
72
+	{
73
+		$this->initialize();
74
+		return $this->file_objects;
75
+	}
76 76
 
77
-    /**
78
-     * Sets up the file objects from the request's $_FILES data.
79
-     * @since $VID:$
80
-     * @throws UnexpectedValueException
81
-     * @throws InvalidArgumentException
82
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
83
-     */
84
-    protected function initialize()
85
-    {
86
-        if ($this->initialized) {
87
-            return;
88
-        }
89
-        $this->file_objects = new Collection(
90
-            // collection interface
91
-            'EventEspresso\core\services\request\files\FileSubmissionInterface',
92
-            // collection name
93
-            'submitted_files'
94
-        );
95
-        $files_raw_data = $this->request->filesParams();
96
-        if (empty($files_raw_data)) {
97
-            return;
98
-        }
99
-        if ($this->isStrangeFilesArray($files_raw_data)) {
100
-            $data = $this->fixFilesDataArray($files_raw_data);
101
-        } else {
102
-            $data = $files_raw_data;
103
-        }
104
-        $this->createFileObjects($data);
105
-        $this->initialized = true;
106
-    }
77
+	/**
78
+	 * Sets up the file objects from the request's $_FILES data.
79
+	 * @since $VID:$
80
+	 * @throws UnexpectedValueException
81
+	 * @throws InvalidArgumentException
82
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
83
+	 */
84
+	protected function initialize()
85
+	{
86
+		if ($this->initialized) {
87
+			return;
88
+		}
89
+		$this->file_objects = new Collection(
90
+			// collection interface
91
+			'EventEspresso\core\services\request\files\FileSubmissionInterface',
92
+			// collection name
93
+			'submitted_files'
94
+		);
95
+		$files_raw_data = $this->request->filesParams();
96
+		if (empty($files_raw_data)) {
97
+			return;
98
+		}
99
+		if ($this->isStrangeFilesArray($files_raw_data)) {
100
+			$data = $this->fixFilesDataArray($files_raw_data);
101
+		} else {
102
+			$data = $files_raw_data;
103
+		}
104
+		$this->createFileObjects($data);
105
+		$this->initialized = true;
106
+	}
107 107
 
108
-    /**
109
-     * Detects if $_FILES is a weird multi-dimensional array that needs fixing or not.
110
-     * @since $VID:$
111
-     * @param $files_data
112
-     * @return bool
113
-     * @throws UnexpectedValueException
114
-     */
115
-    protected function isStrangeFilesArray($files_data)
116
-    {
117
-        if (!is_array($files_data)) {
118
-            throw new UnexpectedValueException(
119
-                sprintf(
120
-                    esc_html__(
121
-                        'Unexpected PHP $_FILES data format. "%1$s" was expected to be an array.',
122
-                        'event_espresso'
123
-                    ),
124
-                    (string) $files_data
125
-                )
126
-            );
127
-        }
128
-        $first_value = reset($files_data);
129
-        if (!is_array($first_value)) {
130
-            throw new UnexpectedValueException(
131
-                sprintf(
132
-                    esc_html__(
133
-                        'Unexpected PHP $_FILES data format. "%1$s" was expected to be an array.',
134
-                        'event_espresso'
135
-                    ),
136
-                    (string) $first_value
137
-                )
138
-            );
139
-        }
140
-        $first_sub_array_item = reset($first_value);
141
-        if (is_array($first_sub_array_item)) {
142
-            // not just a 2d array
143
-            return true;
144
-        }
145
-        // yep, just 2d array
146
-        return false;
147
-    }
108
+	/**
109
+	 * Detects if $_FILES is a weird multi-dimensional array that needs fixing or not.
110
+	 * @since $VID:$
111
+	 * @param $files_data
112
+	 * @return bool
113
+	 * @throws UnexpectedValueException
114
+	 */
115
+	protected function isStrangeFilesArray($files_data)
116
+	{
117
+		if (!is_array($files_data)) {
118
+			throw new UnexpectedValueException(
119
+				sprintf(
120
+					esc_html__(
121
+						'Unexpected PHP $_FILES data format. "%1$s" was expected to be an array.',
122
+						'event_espresso'
123
+					),
124
+					(string) $files_data
125
+				)
126
+			);
127
+		}
128
+		$first_value = reset($files_data);
129
+		if (!is_array($first_value)) {
130
+			throw new UnexpectedValueException(
131
+				sprintf(
132
+					esc_html__(
133
+						'Unexpected PHP $_FILES data format. "%1$s" was expected to be an array.',
134
+						'event_espresso'
135
+					),
136
+					(string) $first_value
137
+				)
138
+			);
139
+		}
140
+		$first_sub_array_item = reset($first_value);
141
+		if (is_array($first_sub_array_item)) {
142
+			// not just a 2d array
143
+			return true;
144
+		}
145
+		// yep, just 2d array
146
+		return false;
147
+	}
148 148
 
149
-    /**
150
-     * Takes into account that $_FILES does a weird thing when you have hierarchical form names (eg `<input type="file"
151
-     * name="my[hierarchical][form]">`): it leaves the top-level form part alone, but replaces the SECOND part with
152
-     * "name", "size", "tmp_name", etc. So that file's data is located at "my[name][hierarchical][form]",
153
-     * "my[size][hierarchical][form]", "my[tmp_name][hierarchical][form]", etc. It's really weird.
154
-     * @since $VID:$
155
-     * @param $files_data
156
-     * @return array
157
-     */
158
-    protected function fixFilesDataArray($files_data)
159
-    {
160
-        $sane_files_array = [];
161
-        foreach ($files_data as $top_key => $top_key_value) {
162
-            foreach ($top_key_value as $lower_key => $lower_key_value) {
163
-                foreach ($lower_key_value as $lowest_key => $lowest_key_value) {
164
-                    $next_data = [
165
-                        $top_key => [
166
-                            $lowest_key => $this->organizeFilesData($lowest_key_value, $lower_key, $lowest_key)
167
-                        ]
168
-                    ];
169
-                    $sane_files_array = array_merge_recursive(
170
-                        $sane_files_array,
171
-                        $next_data
172
-                    );
173
-                }
174
-            }
175
-        }
176
-        return $sane_files_array;
177
-    }
149
+	/**
150
+	 * Takes into account that $_FILES does a weird thing when you have hierarchical form names (eg `<input type="file"
151
+	 * name="my[hierarchical][form]">`): it leaves the top-level form part alone, but replaces the SECOND part with
152
+	 * "name", "size", "tmp_name", etc. So that file's data is located at "my[name][hierarchical][form]",
153
+	 * "my[size][hierarchical][form]", "my[tmp_name][hierarchical][form]", etc. It's really weird.
154
+	 * @since $VID:$
155
+	 * @param $files_data
156
+	 * @return array
157
+	 */
158
+	protected function fixFilesDataArray($files_data)
159
+	{
160
+		$sane_files_array = [];
161
+		foreach ($files_data as $top_key => $top_key_value) {
162
+			foreach ($top_key_value as $lower_key => $lower_key_value) {
163
+				foreach ($lower_key_value as $lowest_key => $lowest_key_value) {
164
+					$next_data = [
165
+						$top_key => [
166
+							$lowest_key => $this->organizeFilesData($lowest_key_value, $lower_key, $lowest_key)
167
+						]
168
+					];
169
+					$sane_files_array = array_merge_recursive(
170
+						$sane_files_array,
171
+						$next_data
172
+					);
173
+				}
174
+			}
175
+		}
176
+		return $sane_files_array;
177
+	}
178 178
 
179
-    /**
180
-     * Recursively explores the array until it finds a leaf node, and tacks `$type` as a final index in front of it.
181
-     * @since $VID:$
182
-     * @param $data either 'name', 'tmp_name', 'size', or 'error'
183
-     * @param $type
184
-     * @return array
185
-     */
186
-    protected function organizeFilesData($data, $type)
187
-    {
188
-        $organized_data = [];
189
-        foreach ($data as $key => $val) {
190
-            if (is_array($val)) {
191
-                $organized_data[ $key ] = $this->organizeFilesData($val, $type);
192
-            } else {
193
-                $organized_data[ $key ][ $type ] = $val;
194
-            }
195
-        }
196
-        return $organized_data;
197
-    }
179
+	/**
180
+	 * Recursively explores the array until it finds a leaf node, and tacks `$type` as a final index in front of it.
181
+	 * @since $VID:$
182
+	 * @param $data either 'name', 'tmp_name', 'size', or 'error'
183
+	 * @param $type
184
+	 * @return array
185
+	 */
186
+	protected function organizeFilesData($data, $type)
187
+	{
188
+		$organized_data = [];
189
+		foreach ($data as $key => $val) {
190
+			if (is_array($val)) {
191
+				$organized_data[ $key ] = $this->organizeFilesData($val, $type);
192
+			} else {
193
+				$organized_data[ $key ][ $type ] = $val;
194
+			}
195
+		}
196
+		return $organized_data;
197
+	}
198 198
 
199
-    /**
200
-     * Takes the organized $_FILES array (where all file info is located at the same spot as you'd expect an input
201
-     * to be in $_GET or $_POST, with all the file's data located side-by-side in an array) and creates a
202
-     * multi-dimensional array of FileSubmissionInterface objects. Stores it in `$this->file_objects`.
203
-     * @since $VID:$
204
-     * @param array $organized_files $_FILES but organized like $_POST
205
-     * @param array $name_parts_so_far for multidimensional HTML form names,
206
-     * @throws UnexpectedValueException
207
-     * @throws InvalidArgumentException
208
-     */
209
-    protected function createFileObjects($organized_files, $name_parts_so_far = [])
210
-    {
211
-        if (!is_array($organized_files)) {
212
-            throw new UnexpectedValueException(
213
-                sprintf(
214
-                    esc_html__(
215
-                        'Unexpected PHP $organized_files data format. "%1$s" was expected to be an array.',
216
-                        'event_espresso'
217
-                    ),
218
-                    (string) $organized_files
219
-                )
220
-            );
221
-        }
222
-        foreach ($organized_files as $key => $value) {
223
-            array_push(
224
-                $name_parts_so_far,
225
-                $key
226
-            );
227
-            if (isset($value['name'], $value['tmp_name'], $value['size'])) {
228
-                $html_name = $this->inputNameFromParts($name_parts_so_far);
229
-                $this->file_objects->add(
230
-                    new FileSubmission(
231
-                        $html_name,
232
-                        $value['name'],
233
-                        $value['tmp_name'],
234
-                        $value['size'],
235
-                        $value['error']
236
-                    ),
237
-                    $html_name
238
-                );
239
-            } else {
240
-                $this->createFileObjects($value, $name_parts_so_far);
241
-            }
242
-        }
243
-    }
199
+	/**
200
+	 * Takes the organized $_FILES array (where all file info is located at the same spot as you'd expect an input
201
+	 * to be in $_GET or $_POST, with all the file's data located side-by-side in an array) and creates a
202
+	 * multi-dimensional array of FileSubmissionInterface objects. Stores it in `$this->file_objects`.
203
+	 * @since $VID:$
204
+	 * @param array $organized_files $_FILES but organized like $_POST
205
+	 * @param array $name_parts_so_far for multidimensional HTML form names,
206
+	 * @throws UnexpectedValueException
207
+	 * @throws InvalidArgumentException
208
+	 */
209
+	protected function createFileObjects($organized_files, $name_parts_so_far = [])
210
+	{
211
+		if (!is_array($organized_files)) {
212
+			throw new UnexpectedValueException(
213
+				sprintf(
214
+					esc_html__(
215
+						'Unexpected PHP $organized_files data format. "%1$s" was expected to be an array.',
216
+						'event_espresso'
217
+					),
218
+					(string) $organized_files
219
+				)
220
+			);
221
+		}
222
+		foreach ($organized_files as $key => $value) {
223
+			array_push(
224
+				$name_parts_so_far,
225
+				$key
226
+			);
227
+			if (isset($value['name'], $value['tmp_name'], $value['size'])) {
228
+				$html_name = $this->inputNameFromParts($name_parts_so_far);
229
+				$this->file_objects->add(
230
+					new FileSubmission(
231
+						$html_name,
232
+						$value['name'],
233
+						$value['tmp_name'],
234
+						$value['size'],
235
+						$value['error']
236
+					),
237
+					$html_name
238
+				);
239
+			} else {
240
+				$this->createFileObjects($value, $name_parts_so_far);
241
+			}
242
+		}
243
+	}
244 244
 
245
-    /**
246
-     * Takes the input name parts, like `['my', 'great', 'file', 'input1']`
247
-     * and returns the HTML name for it, "my[great][file][input1]"
248
-     * @since $VID:$
249
-     * @param $parts
250
-     * @throws UnexpectedValueException
251
-     */
252
-    protected function inputNameFromParts($parts)
253
-    {
254
-        if (!is_array($parts)) {
255
-            throw new UnexpectedValueException(esc_html__('Name parts should be an array.', 'event_espresso'));
256
-        }
257
-        $generated_string = '';
258
-        foreach ($parts as $part) {
259
-            if ($generated_string === '') {
260
-                $generated_string = (string) $part;
261
-            } else {
262
-                $generated_string .= '[' . (string) $part . ']';
263
-            }
264
-        }
265
-        return $generated_string;
266
-    }
245
+	/**
246
+	 * Takes the input name parts, like `['my', 'great', 'file', 'input1']`
247
+	 * and returns the HTML name for it, "my[great][file][input1]"
248
+	 * @since $VID:$
249
+	 * @param $parts
250
+	 * @throws UnexpectedValueException
251
+	 */
252
+	protected function inputNameFromParts($parts)
253
+	{
254
+		if (!is_array($parts)) {
255
+			throw new UnexpectedValueException(esc_html__('Name parts should be an array.', 'event_espresso'));
256
+		}
257
+		$generated_string = '';
258
+		foreach ($parts as $part) {
259
+			if ($generated_string === '') {
260
+				$generated_string = (string) $part;
261
+			} else {
262
+				$generated_string .= '[' . (string) $part . ']';
263
+			}
264
+		}
265
+		return $generated_string;
266
+	}
267 267
 
268
-    /**
269
-     * Gets the input by the indicated $name_parts.
270
-     * Eg if you're looking for an input named "my[great][file][input1]", $name_parts
271
-     * should be `['my', 'great', 'file', 'input1']`.
272
-     * Alternatively, you could use `FileDataHandler::getFileObject('my[great][file][input1]');`
273
-     * @since $VID:$
274
-     * @param $name_parts
275
-     * @throws UnexpectedValueException
276
-     * @return FileSubmissionInterface
277
-     */
278
-    public function getFileObjectFromNameParts($name_parts)
279
-    {
280
-        return $this->getFileObjects()->get($this->inputNameFromParts($name_parts));
281
-    }
268
+	/**
269
+	 * Gets the input by the indicated $name_parts.
270
+	 * Eg if you're looking for an input named "my[great][file][input1]", $name_parts
271
+	 * should be `['my', 'great', 'file', 'input1']`.
272
+	 * Alternatively, you could use `FileDataHandler::getFileObject('my[great][file][input1]');`
273
+	 * @since $VID:$
274
+	 * @param $name_parts
275
+	 * @throws UnexpectedValueException
276
+	 * @return FileSubmissionInterface
277
+	 */
278
+	public function getFileObjectFromNameParts($name_parts)
279
+	{
280
+		return $this->getFileObjects()->get($this->inputNameFromParts($name_parts));
281
+	}
282 282
 
283
-    /**
284
-     * Gets the FileSubmissionInterface corresponding to the HTML name provided.
285
-     * @since $VID:$
286
-     * @param $html_name
287
-     * @return mixed
288
-     * @throws InvalidArgumentException
289
-     * @throws UnexpectedValueException
290
-     */
291
-    public function getFileObject($html_name)
292
-    {
293
-        return $this->getFileObjects()->get($html_name);
294
-    }
283
+	/**
284
+	 * Gets the FileSubmissionInterface corresponding to the HTML name provided.
285
+	 * @since $VID:$
286
+	 * @param $html_name
287
+	 * @return mixed
288
+	 * @throws InvalidArgumentException
289
+	 * @throws UnexpectedValueException
290
+	 */
291
+	public function getFileObject($html_name)
292
+	{
293
+		return $this->getFileObjects()->get($html_name);
294
+	}
295 295
 }
296 296
 // End of file FilesDataHandler.php
297 297
 // Location: EventEspresso\core\services\request\files/FilesDataHandler.php
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
      */
115 115
     protected function isStrangeFilesArray($files_data)
116 116
     {
117
-        if (!is_array($files_data)) {
117
+        if ( ! is_array($files_data)) {
118 118
             throw new UnexpectedValueException(
119 119
                 sprintf(
120 120
                     esc_html__(
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
             );
127 127
         }
128 128
         $first_value = reset($files_data);
129
-        if (!is_array($first_value)) {
129
+        if ( ! is_array($first_value)) {
130 130
             throw new UnexpectedValueException(
131 131
                 sprintf(
132 132
                     esc_html__(
@@ -188,9 +188,9 @@  discard block
 block discarded – undo
188 188
         $organized_data = [];
189 189
         foreach ($data as $key => $val) {
190 190
             if (is_array($val)) {
191
-                $organized_data[ $key ] = $this->organizeFilesData($val, $type);
191
+                $organized_data[$key] = $this->organizeFilesData($val, $type);
192 192
             } else {
193
-                $organized_data[ $key ][ $type ] = $val;
193
+                $organized_data[$key][$type] = $val;
194 194
             }
195 195
         }
196 196
         return $organized_data;
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
      */
209 209
     protected function createFileObjects($organized_files, $name_parts_so_far = [])
210 210
     {
211
-        if (!is_array($organized_files)) {
211
+        if ( ! is_array($organized_files)) {
212 212
             throw new UnexpectedValueException(
213 213
                 sprintf(
214 214
                     esc_html__(
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
      */
252 252
     protected function inputNameFromParts($parts)
253 253
     {
254
-        if (!is_array($parts)) {
254
+        if ( ! is_array($parts)) {
255 255
             throw new UnexpectedValueException(esc_html__('Name parts should be an array.', 'event_espresso'));
256 256
         }
257 257
         $generated_string = '';
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
             if ($generated_string === '') {
260 260
                 $generated_string = (string) $part;
261 261
             } else {
262
-                $generated_string .= '[' . (string) $part . ']';
262
+                $generated_string .= '['.(string) $part.']';
263 263
             }
264 264
         }
265 265
         return $generated_string;
Please login to merge, or discard this patch.
core/entities/forms/UploadedFile.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@
 block discarded – undo
59 59
      * Makes sure the input has the desired key and casts it as the appropriate type.
60 60
      * @since $VID:$
61 61
      * @param $php_file_info_array
62
-     * @param $desired_key
62
+     * @param string $desired_key
63 63
      * @param string $cast_as "string" or "int"
64 64
      * @return int|string
65 65
      * @throws InvalidArgumentException
Please login to merge, or discard this patch.
Indentation   +103 added lines, -103 removed lines patch added patch discarded remove patch
@@ -17,121 +17,121 @@
 block discarded – undo
17 17
  */
18 18
 class UploadedFile
19 19
 {
20
-    /**
21
-     * @var string original name on the client machine
22
-     */
23
-    protected $name;
20
+	/**
21
+	 * @var string original name on the client machine
22
+	 */
23
+	protected $name;
24 24
 
25
-    /**
26
-     * @var string mime type
27
-     */
28
-    protected $type;
25
+	/**
26
+	 * @var string mime type
27
+	 */
28
+	protected $type;
29 29
 
30
-    /**
31
-     * @var int in bytes
32
-     */
33
-    protected $size;
30
+	/**
31
+	 * @var int in bytes
32
+	 */
33
+	protected $size;
34 34
 
35
-    /**
36
-     * @var string local filepath to the temporary file
37
-     */
38
-    protected $tmp_name;
35
+	/**
36
+	 * @var string local filepath to the temporary file
37
+	 */
38
+	protected $tmp_name;
39 39
 
40
-    /**
41
-     * @var string one of https://secure.php.net/manual/en/features.file-upload.errors.php
42
-     */
43
-    protected $error;
40
+	/**
41
+	 * @var string one of https://secure.php.net/manual/en/features.file-upload.errors.php
42
+	 */
43
+	protected $error;
44 44
 
45
-    public function __construct($php_file_info)
46
-    {
47
-        $this->name = $this->extractFromArrayOrThrowException($php_file_info, 'name');
48
-        try {
49
-            $this->type = $this->extractFromArrayOrThrowException($php_file_info, 'type');
50
-        } catch (InvalidArgumentException $e) {
51
-            // The browser must have not provided the mimetype, oh well.
52
-            $this->type = 'text/html';
53
-        }
54
-        $this->size = $this->extractFromArrayOrThrowException($php_file_info, 'size', 'int');
55
-        $this->tmp_name = $this->extractFromArrayOrThrowException($php_file_info, 'tmp_name');
56
-    }
45
+	public function __construct($php_file_info)
46
+	{
47
+		$this->name = $this->extractFromArrayOrThrowException($php_file_info, 'name');
48
+		try {
49
+			$this->type = $this->extractFromArrayOrThrowException($php_file_info, 'type');
50
+		} catch (InvalidArgumentException $e) {
51
+			// The browser must have not provided the mimetype, oh well.
52
+			$this->type = 'text/html';
53
+		}
54
+		$this->size = $this->extractFromArrayOrThrowException($php_file_info, 'size', 'int');
55
+		$this->tmp_name = $this->extractFromArrayOrThrowException($php_file_info, 'tmp_name');
56
+	}
57 57
 
58
-    /**
59
-     * Makes sure the input has the desired key and casts it as the appropriate type.
60
-     * @since $VID:$
61
-     * @param $php_file_info_array
62
-     * @param $desired_key
63
-     * @param string $cast_as "string" or "int"
64
-     * @return int|string
65
-     * @throws InvalidArgumentException
66
-     */
67
-    protected function extractFromArrayOrThrowException($php_file_info_array, $desired_key, $cast_as = 'string')
68
-    {
69
-        if (!isset($php_file_info_array[$desired_key])) {
70
-            throw new InvalidArgumentException(
71
-                sprintf(
72
-                    esc_html__('PHP Upload data for a file was missing the key %1$s', 'event_espresso'),
73
-                    $desired_key
74
-                )
75
-            );
76
-        }
77
-        $raw_value = $php_file_info_array[$desired_key];
78
-        switch ($cast_as) {
79
-            case 'int':
80
-                return (int)$raw_value;
81
-            case 'string':
82
-            default:
83
-                return (string)$raw_value;
84
-        }
85
-    }
58
+	/**
59
+	 * Makes sure the input has the desired key and casts it as the appropriate type.
60
+	 * @since $VID:$
61
+	 * @param $php_file_info_array
62
+	 * @param $desired_key
63
+	 * @param string $cast_as "string" or "int"
64
+	 * @return int|string
65
+	 * @throws InvalidArgumentException
66
+	 */
67
+	protected function extractFromArrayOrThrowException($php_file_info_array, $desired_key, $cast_as = 'string')
68
+	{
69
+		if (!isset($php_file_info_array[$desired_key])) {
70
+			throw new InvalidArgumentException(
71
+				sprintf(
72
+					esc_html__('PHP Upload data for a file was missing the key %1$s', 'event_espresso'),
73
+					$desired_key
74
+				)
75
+			);
76
+		}
77
+		$raw_value = $php_file_info_array[$desired_key];
78
+		switch ($cast_as) {
79
+			case 'int':
80
+				return (int)$raw_value;
81
+			case 'string':
82
+			default:
83
+				return (string)$raw_value;
84
+		}
85
+	}
86 86
 
87
-    /**
88
-     * @return string
89
-     */
90
-    public function getName()
91
-    {
92
-        return $this->name;
93
-    }
87
+	/**
88
+	 * @return string
89
+	 */
90
+	public function getName()
91
+	{
92
+		return $this->name;
93
+	}
94 94
 
95
-    /**
96
-     * @return string
97
-     */
98
-    public function getType()
99
-    {
100
-        return $this->type;
101
-    }
95
+	/**
96
+	 * @return string
97
+	 */
98
+	public function getType()
99
+	{
100
+		return $this->type;
101
+	}
102 102
 
103
-    /**
104
-     * @return int
105
-     */
106
-    public function getSize()
107
-    {
108
-        return $this->size;
109
-    }
103
+	/**
104
+	 * @return int
105
+	 */
106
+	public function getSize()
107
+	{
108
+		return $this->size;
109
+	}
110 110
 
111
-    /**
112
-     * @return string
113
-     */
114
-    public function getTmpName()
115
-    {
116
-        return $this->tmp_name;
117
-    }
111
+	/**
112
+	 * @return string
113
+	 */
114
+	public function getTmpName()
115
+	{
116
+		return $this->tmp_name;
117
+	}
118 118
 
119
-    /**
120
-     * @return string
121
-     */
122
-    public function getError()
123
-    {
124
-        return $this->error;
125
-    }
119
+	/**
120
+	 * @return string
121
+	 */
122
+	public function getError()
123
+	{
124
+		return $this->error;
125
+	}
126 126
 
127
-    /**
128
-     * @since $VID:$
129
-     * @return string
130
-     */
131
-    public function __toString()
132
-    {
133
-        return $this->getTmpName();
134
-    }
127
+	/**
128
+	 * @since $VID:$
129
+	 * @return string
130
+	 */
131
+	public function __toString()
132
+	{
133
+		return $this->getTmpName();
134
+	}
135 135
 }
136 136
 // End of file UploadedFile.php
137 137
 // Location: EventEspresso\core\entities\forms/UploadedFile.php
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
      */
67 67
     protected function extractFromArrayOrThrowException($php_file_info_array, $desired_key, $cast_as = 'string')
68 68
     {
69
-        if (!isset($php_file_info_array[$desired_key])) {
69
+        if ( ! isset($php_file_info_array[$desired_key])) {
70 70
             throw new InvalidArgumentException(
71 71
                 sprintf(
72 72
                     esc_html__('PHP Upload data for a file was missing the key %1$s', 'event_espresso'),
@@ -77,10 +77,10 @@  discard block
 block discarded – undo
77 77
         $raw_value = $php_file_info_array[$desired_key];
78 78
         switch ($cast_as) {
79 79
             case 'int':
80
-                return (int)$raw_value;
80
+                return (int) $raw_value;
81 81
             case 'string':
82 82
             default:
83
-                return (string)$raw_value;
83
+                return (string) $raw_value;
84 84
         }
85 85
     }
86 86
 
Please login to merge, or discard this patch.
core/libraries/form_sections/inputs/EE_File_Input.input.php 2 patches
Indentation   +125 added lines, -125 removed lines patch added patch discarded remove patch
@@ -15,59 +15,59 @@  discard block
 block discarded – undo
15 15
  */
16 16
 class EE_File_Input extends EE_Form_Input_Base
17 17
 {
18
-    /**
19
-     * @var array
20
-     */
21
-    protected $allowed_file_extensions;
18
+	/**
19
+	 * @var array
20
+	 */
21
+	protected $allowed_file_extensions;
22 22
 
23
-    /**
24
-     * @var
25
-     */
26
-    protected $allowed_mime_types;
23
+	/**
24
+	 * @var
25
+	 */
26
+	protected $allowed_mime_types;
27 27
 
28
-    /**
29
-     * @param array $options
30
-     * @throws InvalidArgumentException
31
-     */
32
-    public function __construct($options = array())
33
-    {
34
-        if (isset($options['allowed_file_extensions'])) {
35
-            if (!is_array($options['allowed_file_extensions'])) {
36
-                throw new InvalidArgumentException(esc_html__('A valid allowed_file_extensions array was not provided to EE_File_Input', 'event_espresso'));
37
-            }
38
-            $this->allowed_file_extensions = $options['allowed_file_extensions'];
39
-        } else {
40
-            $this->allowed_file_extensions = ['csv'];
41
-        }
42
-        if (isset($options['allowed_mime_types'])) {
43
-            if (!is_array($options['allowed_mime_types'])) {
44
-                throw new InvalidArgumentException(esc_html__('A valid allowed_mime_types array was not provided to EE_File_Input', 'event_espresso'));
45
-            }
46
-            $this->allowed_mime_types = $options['allowed_file_extensions'];
47
-        } else {
48
-            $this->allowed_mime_types = ['text/csv'];
49
-        }
28
+	/**
29
+	 * @param array $options
30
+	 * @throws InvalidArgumentException
31
+	 */
32
+	public function __construct($options = array())
33
+	{
34
+		if (isset($options['allowed_file_extensions'])) {
35
+			if (!is_array($options['allowed_file_extensions'])) {
36
+				throw new InvalidArgumentException(esc_html__('A valid allowed_file_extensions array was not provided to EE_File_Input', 'event_espresso'));
37
+			}
38
+			$this->allowed_file_extensions = $options['allowed_file_extensions'];
39
+		} else {
40
+			$this->allowed_file_extensions = ['csv'];
41
+		}
42
+		if (isset($options['allowed_mime_types'])) {
43
+			if (!is_array($options['allowed_mime_types'])) {
44
+				throw new InvalidArgumentException(esc_html__('A valid allowed_mime_types array was not provided to EE_File_Input', 'event_espresso'));
45
+			}
46
+			$this->allowed_mime_types = $options['allowed_file_extensions'];
47
+		} else {
48
+			$this->allowed_mime_types = ['text/csv'];
49
+		}
50 50
 
51
-        $this->_set_display_strategy(new EE_File_Input_Display_Strategy());
52
-        $this->_set_normalization_strategy(new EE_File_Normalization());
53
-        $this->add_validation_strategy(
54
-            new EE_Text_Validation_Strategy(
55
-                sprintf(
56
-                // translators: %1$s is a list of allowed file extensions.
57
-                    esc_html__('Please provide a file of the requested filetype: %1$s', 'event_espresso'),
58
-                    implode(', ', $this->allowed_file_extensions)
59
-                ),
60
-                '~.*\.(' . implode('|', $this->allowed_file_extensions) . ')$~'
61
-            )
62
-        );
63
-        parent::__construct($options);
51
+		$this->_set_display_strategy(new EE_File_Input_Display_Strategy());
52
+		$this->_set_normalization_strategy(new EE_File_Normalization());
53
+		$this->add_validation_strategy(
54
+			new EE_Text_Validation_Strategy(
55
+				sprintf(
56
+				// translators: %1$s is a list of allowed file extensions.
57
+					esc_html__('Please provide a file of the requested filetype: %1$s', 'event_espresso'),
58
+					implode(', ', $this->allowed_file_extensions)
59
+				),
60
+				'~.*\.(' . implode('|', $this->allowed_file_extensions) . ')$~'
61
+			)
62
+		);
63
+		parent::__construct($options);
64 64
 
65 65
 //        It would be great to add this HTML attribute, but jQuery validate chokes on it.
66
-        $this->set_other_html_attributes(
67
-            $this->other_html_attributes()
68
-            . ' extension="'
69
-            . implode(
70
-                ',',
66
+		$this->set_other_html_attributes(
67
+			$this->other_html_attributes()
68
+			. ' extension="'
69
+			. implode(
70
+				',',
71 71
 //                array_merge(
72 72
 //                    array_map(
73 73
 //                        function ($mime_type) {
@@ -80,86 +80,86 @@  discard block
 block discarded – undo
80 80
 //                        },
81 81
 //                        $this->allowed_mime_types
82 82
 //                    )
83
-                    array_map(
84
-                        function ($file_extension) {
85
-                            return  $file_extension;
86
-                        },
87
-                        $this->allowed_file_extensions
88
-                    )
83
+					array_map(
84
+						function ($file_extension) {
85
+							return  $file_extension;
86
+						},
87
+						$this->allowed_file_extensions
88
+					)
89 89
 //                )
90
-            )
91
-            . '"'
92
-        );
93
-    }
90
+			)
91
+			. '"'
92
+		);
93
+	}
94 94
 
95
-    /**
96
-     * Takes into account that $_FILES does a weird thing when you have hierarchical form names (eg `<input type="file"
97
-     * name="my[hierarchical][form]">`): it leaves the top-level form part alone, but replaces the SECOND part with
98
-     * "name", "size", "temp_file", etc. So that file's data is located at "my[name][hierarchical][form]",
99
-     * "my[size][hierarchical][form]", "my[temp_name][hierarchical][form]", etc. It's really weird.
100
-     * @since $VID:$
101
-     * @param array $req_data
102
-     * @return array|mixed|NULL
103
-     * @throws EE_Error
104
-     */
105
-    public function find_form_data_for_this_section($req_data)
106
-    {
107
-        $name_parts = $this->getInputNameParts();
108
-        // now get the value for the input
109
-        $value = $this->findFileData($name_parts, $req_data);
95
+	/**
96
+	 * Takes into account that $_FILES does a weird thing when you have hierarchical form names (eg `<input type="file"
97
+	 * name="my[hierarchical][form]">`): it leaves the top-level form part alone, but replaces the SECOND part with
98
+	 * "name", "size", "temp_file", etc. So that file's data is located at "my[name][hierarchical][form]",
99
+	 * "my[size][hierarchical][form]", "my[temp_name][hierarchical][form]", etc. It's really weird.
100
+	 * @since $VID:$
101
+	 * @param array $req_data
102
+	 * @return array|mixed|NULL
103
+	 * @throws EE_Error
104
+	 */
105
+	public function find_form_data_for_this_section($req_data)
106
+	{
107
+		$name_parts = $this->getInputNameParts();
108
+		// now get the value for the input
109
+		$value = $this->findFileData($name_parts, $req_data);
110 110
 
111
-        if (empty($value)) {
112
-            $value = $this->findFileData($name_parts, $_FILES);
113
-        }
114
-        if (empty($value)) {
115
-            array_shift($name_parts);
116
-            // check if this thing's name is at the TOP level of the request data
117
-            $value = $this->findFileData($name_parts, $req_data);
118
-        }
119
-        return $value;
120
-    }
111
+		if (empty($value)) {
112
+			$value = $this->findFileData($name_parts, $_FILES);
113
+		}
114
+		if (empty($value)) {
115
+			array_shift($name_parts);
116
+			// check if this thing's name is at the TOP level of the request data
117
+			$value = $this->findFileData($name_parts, $req_data);
118
+		}
119
+		return $value;
120
+	}
121 121
 
122
-    /**
123
-     * Look for the file's data in this request data.
124
-     * @since $VID:$
125
-     * @param $name_parts
126
-     * @param $req_data
127
-     * @return array
128
-     */
129
-    protected function findFileData($name_parts, $req_data)
130
-    {
131
-        $file_parts = [
132
-            'name',
133
-            'error',
134
-            'size',
135
-            'tmp_name',
136
-            'type'
137
-        ];
138
-        $file_data = [];
139
-        foreach($file_parts as $file_part){
140
-            $datum = $this->findRequestForSectionUsingNameParts($this->getFileDataNameParts($name_parts, $file_part),$req_data);
141
-            if(!empty($datum)) {
142
-                $file_data[$file_part] = $datum;
143
-            }
144
-        }
145
-        return $file_data;
146
-    }
122
+	/**
123
+	 * Look for the file's data in this request data.
124
+	 * @since $VID:$
125
+	 * @param $name_parts
126
+	 * @param $req_data
127
+	 * @return array
128
+	 */
129
+	protected function findFileData($name_parts, $req_data)
130
+	{
131
+		$file_parts = [
132
+			'name',
133
+			'error',
134
+			'size',
135
+			'tmp_name',
136
+			'type'
137
+		];
138
+		$file_data = [];
139
+		foreach($file_parts as $file_part){
140
+			$datum = $this->findRequestForSectionUsingNameParts($this->getFileDataNameParts($name_parts, $file_part),$req_data);
141
+			if(!empty($datum)) {
142
+				$file_data[$file_part] = $datum;
143
+			}
144
+		}
145
+		return $file_data;
146
+	}
147 147
 
148
-    /**
149
-     * Finds the file name parts for the desired file data.
150
-     * @since $VID:$
151
-     * @param $original_name_parts
152
-     * @param $file_data_sought
153
-     * @return array
154
-     */
155
-    protected function getFileDataNameParts($original_name_parts, $file_data_sought){
156
-        return
157
-            array_merge(
158
-                [
159
-                    $original_name_parts[0],
160
-                    $file_data_sought
161
-                ],
162
-            array_slice($original_name_parts, 1)
163
-        );
164
-    }
148
+	/**
149
+	 * Finds the file name parts for the desired file data.
150
+	 * @since $VID:$
151
+	 * @param $original_name_parts
152
+	 * @param $file_data_sought
153
+	 * @return array
154
+	 */
155
+	protected function getFileDataNameParts($original_name_parts, $file_data_sought){
156
+		return
157
+			array_merge(
158
+				[
159
+					$original_name_parts[0],
160
+					$file_data_sought
161
+				],
162
+			array_slice($original_name_parts, 1)
163
+		);
164
+	}
165 165
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
     public function __construct($options = array())
33 33
     {
34 34
         if (isset($options['allowed_file_extensions'])) {
35
-            if (!is_array($options['allowed_file_extensions'])) {
35
+            if ( ! is_array($options['allowed_file_extensions'])) {
36 36
                 throw new InvalidArgumentException(esc_html__('A valid allowed_file_extensions array was not provided to EE_File_Input', 'event_espresso'));
37 37
             }
38 38
             $this->allowed_file_extensions = $options['allowed_file_extensions'];
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
             $this->allowed_file_extensions = ['csv'];
41 41
         }
42 42
         if (isset($options['allowed_mime_types'])) {
43
-            if (!is_array($options['allowed_mime_types'])) {
43
+            if ( ! is_array($options['allowed_mime_types'])) {
44 44
                 throw new InvalidArgumentException(esc_html__('A valid allowed_mime_types array was not provided to EE_File_Input', 'event_espresso'));
45 45
             }
46 46
             $this->allowed_mime_types = $options['allowed_file_extensions'];
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
                     esc_html__('Please provide a file of the requested filetype: %1$s', 'event_espresso'),
58 58
                     implode(', ', $this->allowed_file_extensions)
59 59
                 ),
60
-                '~.*\.(' . implode('|', $this->allowed_file_extensions) . ')$~'
60
+                '~.*\.('.implode('|', $this->allowed_file_extensions).')$~'
61 61
             )
62 62
         );
63 63
         parent::__construct($options);
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 //                        $this->allowed_mime_types
82 82
 //                    )
83 83
                     array_map(
84
-                        function ($file_extension) {
84
+                        function($file_extension) {
85 85
                             return  $file_extension;
86 86
                         },
87 87
                         $this->allowed_file_extensions
@@ -136,9 +136,9 @@  discard block
 block discarded – undo
136 136
             'type'
137 137
         ];
138 138
         $file_data = [];
139
-        foreach($file_parts as $file_part){
140
-            $datum = $this->findRequestForSectionUsingNameParts($this->getFileDataNameParts($name_parts, $file_part),$req_data);
141
-            if(!empty($datum)) {
139
+        foreach ($file_parts as $file_part) {
140
+            $datum = $this->findRequestForSectionUsingNameParts($this->getFileDataNameParts($name_parts, $file_part), $req_data);
141
+            if ( ! empty($datum)) {
142 142
                 $file_data[$file_part] = $datum;
143 143
             }
144 144
         }
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
      * @param $file_data_sought
153 153
      * @return array
154 154
      */
155
-    protected function getFileDataNameParts($original_name_parts, $file_data_sought){
155
+    protected function getFileDataNameParts($original_name_parts, $file_data_sought) {
156 156
         return
157 157
             array_merge(
158 158
                 [
Please login to merge, or discard this patch.