Completed
Branch FET/reg-form-builder/main (0b1bec)
by
unknown
14:36 queued 15s
created
core/domain/services/graphql/data/loaders/FormElementLoader.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -15,27 +15,27 @@
 block discarded – undo
15 15
  */
16 16
 class FormElementLoader extends AbstractLoader
17 17
 {
18
-    /**
19
-     * @return EEM_Base
20
-     * @throws EE_Error
21
-     * @throws InvalidArgumentException
22
-     * @throws InvalidDataTypeException
23
-     * @throws InvalidInterfaceException
24
-     * @throws ReflectionException
25
-     */
26
-    protected function getQuery(): EEM_Base
27
-    {
28
-        return EEM_Form_Element::instance();
29
-    }
18
+	/**
19
+	 * @return EEM_Base
20
+	 * @throws EE_Error
21
+	 * @throws InvalidArgumentException
22
+	 * @throws InvalidDataTypeException
23
+	 * @throws InvalidInterfaceException
24
+	 * @throws ReflectionException
25
+	 */
26
+	protected function getQuery(): EEM_Base
27
+	{
28
+		return EEM_Form_Element::instance();
29
+	}
30 30
 
31
-    /**
32
-     * @param array $keys
33
-     * @return array
34
-     */
35
-    protected function getWhereParams(array $keys): array
36
-    {
37
-        return [
38
-            'FIN_UUID' => ['IN', $keys],
39
-        ];
40
-    }
31
+	/**
32
+	 * @param array $keys
33
+	 * @return array
34
+	 */
35
+	protected function getWhereParams(array $keys): array
36
+	{
37
+		return [
38
+			'FIN_UUID' => ['IN', $keys],
39
+		];
40
+	}
41 41
 }
Please login to merge, or discard this patch.
core/domain/services/graphql/abstracts/AbstractRootQueryConnection.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -19,28 +19,28 @@
 block discarded – undo
19 19
 {
20 20
 
21 21
 
22
-    /**
23
-     * @param $entity
24
-     * @param $args
25
-     * @param $context
26
-     * @param $info
27
-     * @return AbstractConnectionResolver
28
-     * @throws Exception
29
-     */
30
-    abstract public function getConnectionResolver($entity, $args, $context, $info): AbstractConnectionResolver;
22
+	/**
23
+	 * @param $entity
24
+	 * @param $args
25
+	 * @param $context
26
+	 * @param $info
27
+	 * @return AbstractConnectionResolver
28
+	 * @throws Exception
29
+	 */
30
+	abstract public function getConnectionResolver($entity, $args, $context, $info): AbstractConnectionResolver;
31 31
 
32 32
 
33
-    /**
34
-     * @param $entity
35
-     * @param $args
36
-     * @param $context
37
-     * @param $info
38
-     * @return mixed|array|Deferred
39
-     * @throws Exception
40
-     */
41
-    public function resolveConnection($entity, $args, $context, $info)
42
-    {
43
-        $resolver = $this->getConnectionResolver($entity, $args, $context, $info);
44
-        return $resolver->get_connection();
45
-    }
33
+	/**
34
+	 * @param $entity
35
+	 * @param $args
36
+	 * @param $context
37
+	 * @param $info
38
+	 * @return mixed|array|Deferred
39
+	 * @throws Exception
40
+	 */
41
+	public function resolveConnection($entity, $args, $context, $info)
42
+	{
43
+		$resolver = $this->getConnectionResolver($entity, $args, $context, $info);
44
+		return $resolver->get_connection();
45
+	}
46 46
 }
Please login to merge, or discard this patch.
core/domain/entities/routing/handlers/shared/GQLRequests.php 1 patch
Indentation   +211 added lines, -211 removed lines patch added patch discarded remove patch
@@ -19,223 +19,223 @@
 block discarded – undo
19 19
  */
20 20
 class GQLRequests extends Route
21 21
 {
22
-    /**
23
-     * @var AssetManifestFactory
24
-     */
25
-    private $manifest_factory;
22
+	/**
23
+	 * @var AssetManifestFactory
24
+	 */
25
+	private $manifest_factory;
26 26
 
27 27
 
28
-    /**
29
-     * AssetRequests constructor.
30
-     *
31
-     * @param EE_Dependency_Map    $dependency_map
32
-     * @param LoaderInterface      $loader
33
-     * @param RequestInterface     $request
34
-     * @param AssetManifestFactory $manifest_factory
35
-     */
36
-    public function __construct(
37
-        EE_Dependency_Map $dependency_map,
38
-        LoaderInterface $loader,
39
-        RequestInterface $request,
40
-        AssetManifestFactory $manifest_factory
41
-    ) {
42
-        $this->manifest_factory = $manifest_factory;
43
-        parent::__construct($dependency_map, $loader, $request);
44
-    }
28
+	/**
29
+	 * AssetRequests constructor.
30
+	 *
31
+	 * @param EE_Dependency_Map    $dependency_map
32
+	 * @param LoaderInterface      $loader
33
+	 * @param RequestInterface     $request
34
+	 * @param AssetManifestFactory $manifest_factory
35
+	 */
36
+	public function __construct(
37
+		EE_Dependency_Map $dependency_map,
38
+		LoaderInterface $loader,
39
+		RequestInterface $request,
40
+		AssetManifestFactory $manifest_factory
41
+	) {
42
+		$this->manifest_factory = $manifest_factory;
43
+		parent::__construct($dependency_map, $loader, $request);
44
+	}
45 45
 
46 46
 
47
-    /**
48
-     * returns true if the current request matches this route
49
-     *
50
-     * @return bool
51
-     * @since   $VID:$
52
-     */
53
-    public function matchesCurrentRequest(): bool
54
-    {
55
-        global $pagenow;
56
-        return (
57
-                   $this->request->isGQL()
58
-                   || $this->request->isUnitTesting()
59
-                   || (
60
-                       $this->request->isAdmin()
61
-                       && $this->request->getRequestParam('page') === 'espresso_events'
62
-                       && (
63
-                           $this->request->getRequestParam('action') === 'create_new'
64
-                           || $this->request->getRequestParam('action') === 'edit'
65
-                       )
66
-                   )
67
-                   || (
68
-                       $pagenow
69
-                       && (
70
-                           $pagenow === 'post-new.php'
71
-                           || (
72
-                               $pagenow === 'post.php'
73
-                               && $this->request->getRequestParam('action') === 'edit'
74
-                           )
75
-                       )
76
-                   )
77
-               );
78
-    }
47
+	/**
48
+	 * returns true if the current request matches this route
49
+	 *
50
+	 * @return bool
51
+	 * @since   $VID:$
52
+	 */
53
+	public function matchesCurrentRequest(): bool
54
+	{
55
+		global $pagenow;
56
+		return (
57
+				   $this->request->isGQL()
58
+				   || $this->request->isUnitTesting()
59
+				   || (
60
+					   $this->request->isAdmin()
61
+					   && $this->request->getRequestParam('page') === 'espresso_events'
62
+					   && (
63
+						   $this->request->getRequestParam('action') === 'create_new'
64
+						   || $this->request->getRequestParam('action') === 'edit'
65
+					   )
66
+				   )
67
+				   || (
68
+					   $pagenow
69
+					   && (
70
+						   $pagenow === 'post-new.php'
71
+						   || (
72
+							   $pagenow === 'post.php'
73
+							   && $this->request->getRequestParam('action') === 'edit'
74
+						   )
75
+					   )
76
+				   )
77
+			   );
78
+	}
79 79
 
80 80
 
81
-    /**
82
-     * @since $VID:$
83
-     */
84
-    protected function registerDependencies()
85
-    {
86
-        $this->dependency_map->registerDependencies(
87
-            'EventEspresso\core\services\graphql\GraphQLManager',
88
-            [
89
-                'EventEspresso\core\services\graphql\ConnectionsManager' => EE_Dependency_Map::load_from_cache,
90
-                'EventEspresso\core\services\graphql\DataLoaderManager'  => EE_Dependency_Map::load_from_cache,
91
-                'EventEspresso\core\services\graphql\EnumsManager'       => EE_Dependency_Map::load_from_cache,
92
-                'EventEspresso\core\services\graphql\InputsManager'      => EE_Dependency_Map::load_from_cache,
93
-                'EventEspresso\core\services\graphql\TypesManager'       => EE_Dependency_Map::load_from_cache,
94
-            ]
95
-        );
96
-        $this->dependency_map->registerDependencies(
97
-            'EventEspresso\core\services\graphql\TypesManager',
98
-            [
99
-                'EventEspresso\core\services\graphql\types\TypeCollection' => EE_Dependency_Map::load_from_cache,
100
-            ]
101
-        );
102
-        $this->dependency_map->registerDependencies(
103
-            'EventEspresso\core\services\graphql\InputsManager',
104
-            [
105
-                'EventEspresso\core\services\graphql\inputs\InputCollection' => EE_Dependency_Map::load_from_cache,
106
-            ]
107
-        );
108
-        $this->dependency_map->registerDependencies(
109
-            'EventEspresso\core\services\graphql\EnumsManager',
110
-            [
111
-                'EventEspresso\core\services\graphql\enums\EnumCollection' => EE_Dependency_Map::load_from_cache,
112
-            ]
113
-        );
114
-        $this->dependency_map->registerDependencies(
115
-            'EventEspresso\core\services\graphql\ConnectionsManager',
116
-            [
117
-                'EventEspresso\core\services\graphql\connections\ConnectionCollection' => EE_Dependency_Map::load_from_cache,
118
-            ]
119
-        );
120
-        $this->dependency_map->registerDependencies(
121
-            'EventEspresso\core\services\graphql\DataLoaderManager',
122
-            [
123
-                'EventEspresso\core\services\graphql\loaders\DataLoaderCollection' => EE_Dependency_Map::load_from_cache,
124
-            ]
125
-        );
126
-        $this->dependency_map->registerDependencies(
127
-            'EventEspresso\core\domain\services\graphql\types\Datetime',
128
-            ['EEM_Datetime' => EE_Dependency_Map::load_from_cache]
129
-        );
130
-        $this->dependency_map->registerDependencies(
131
-            'EventEspresso\core\domain\services\graphql\types\Attendee',
132
-            ['EEM_Attendee' => EE_Dependency_Map::load_from_cache]
133
-        );
134
-        $this->dependency_map->registerDependencies(
135
-            'EventEspresso\core\domain\services\graphql\types\Event',
136
-            ['EEM_Event' => EE_Dependency_Map::load_from_cache]
137
-        );
138
-        $this->dependency_map->registerDependencies(
139
-            'EventEspresso\core\domain\services\graphql\types\FormElement',
140
-            ['EEM_Form_Element' => EE_Dependency_Map::load_from_cache]
141
-        );
142
-        $this->dependency_map->registerDependencies(
143
-            'EventEspresso\core\domain\services\graphql\types\FormSection',
144
-            ['EEM_Form_Section' => EE_Dependency_Map::load_from_cache]
145
-        );
146
-        $this->dependency_map->registerDependencies(
147
-            'EventEspresso\core\domain\services\graphql\types\Ticket',
148
-            ['EEM_Ticket' => EE_Dependency_Map::load_from_cache]
149
-        );
150
-        $this->dependency_map->registerDependencies(
151
-            'EventEspresso\core\domain\services\graphql\types\Price',
152
-            ['EEM_Price' => EE_Dependency_Map::load_from_cache]
153
-        );
154
-        $this->dependency_map->registerDependencies(
155
-            'EventEspresso\core\domain\services\graphql\types\PriceType',
156
-            ['EEM_Price_Type' => EE_Dependency_Map::load_from_cache]
157
-        );
158
-        $this->dependency_map->registerDependencies(
159
-            'EventEspresso\core\domain\services\graphql\types\Venue',
160
-            ['EEM_Venue' => EE_Dependency_Map::load_from_cache]
161
-        );
162
-        $this->dependency_map->registerDependencies(
163
-            'EventEspresso\core\domain\services\graphql\types\State',
164
-            ['EEM_State' => EE_Dependency_Map::load_from_cache]
165
-        );
166
-        $this->dependency_map->registerDependencies(
167
-            'EventEspresso\core\domain\services\graphql\types\Country',
168
-            ['EEM_Country' => EE_Dependency_Map::load_from_cache]
169
-        );
170
-        $this->dependency_map->registerDependencies(
171
-            'EventEspresso\core\domain\services\graphql\connections\EventDatetimesConnection',
172
-            ['EEM_Datetime' => EE_Dependency_Map::load_from_cache]
173
-        );
174
-        $this->dependency_map->registerDependencies(
175
-            'EventEspresso\core\domain\services\graphql\connections\RootQueryDatetimesConnection',
176
-            ['EEM_Datetime' => EE_Dependency_Map::load_from_cache]
177
-        );
178
-        $this->dependency_map->registerDependencies(
179
-            'EventEspresso\core\domain\services\graphql\connections\RootQueryAttendeesConnection',
180
-            ['EEM_Attendee' => EE_Dependency_Map::load_from_cache]
181
-        );
182
-        $this->dependency_map->registerDependencies(
183
-            'EventEspresso\core\domain\services\graphql\connections\RootQueryFormElementsConnection',
184
-            ['EEM_Form_Element' => EE_Dependency_Map::load_from_cache]
185
-        );
186
-        $this->dependency_map->registerDependencies(
187
-            'EventEspresso\core\domain\services\graphql\connections\RootQueryFormSectionsConnection',
188
-            ['EEM_Form_Section' => EE_Dependency_Map::load_from_cache]
189
-        );
190
-        $this->dependency_map->registerDependencies(
191
-            'EventEspresso\core\domain\services\graphql\connections\DatetimeTicketsConnection',
192
-            ['EEM_Ticket' => EE_Dependency_Map::load_from_cache]
193
-        );
194
-        $this->dependency_map->registerDependencies(
195
-            'EventEspresso\core\domain\services\graphql\connections\RootQueryTicketsConnection',
196
-            ['EEM_Ticket' => EE_Dependency_Map::load_from_cache]
197
-        );
198
-        $this->dependency_map->registerDependencies(
199
-            'EventEspresso\core\domain\services\graphql\connections\TicketPricesConnection',
200
-            ['EEM_Price' => EE_Dependency_Map::load_from_cache]
201
-        );
202
-        $this->dependency_map->registerDependencies(
203
-            'EventEspresso\core\domain\services\graphql\connections\RootQueryPricesConnection',
204
-            ['EEM_Price' => EE_Dependency_Map::load_from_cache]
205
-        );
206
-        $this->dependency_map->registerDependencies(
207
-            'EventEspresso\core\domain\services\graphql\connections\RootQueryPriceTypesConnection',
208
-            ['EEM_Price_Type' => EE_Dependency_Map::load_from_cache]
209
-        );
210
-        $this->dependency_map->registerDependencies(
211
-            'EventEspresso\core\domain\services\graphql\connections\TicketDatetimesConnection',
212
-            ['EEM_Datetime' => EE_Dependency_Map::load_from_cache]
213
-        );
214
-        $this->dependency_map->registerDependencies(
215
-            'EventEspresso\core\domain\services\graphql\connections\EventVenuesConnection',
216
-            ['EEM_Venue' => EE_Dependency_Map::load_from_cache]
217
-        );
218
-    }
81
+	/**
82
+	 * @since $VID:$
83
+	 */
84
+	protected function registerDependencies()
85
+	{
86
+		$this->dependency_map->registerDependencies(
87
+			'EventEspresso\core\services\graphql\GraphQLManager',
88
+			[
89
+				'EventEspresso\core\services\graphql\ConnectionsManager' => EE_Dependency_Map::load_from_cache,
90
+				'EventEspresso\core\services\graphql\DataLoaderManager'  => EE_Dependency_Map::load_from_cache,
91
+				'EventEspresso\core\services\graphql\EnumsManager'       => EE_Dependency_Map::load_from_cache,
92
+				'EventEspresso\core\services\graphql\InputsManager'      => EE_Dependency_Map::load_from_cache,
93
+				'EventEspresso\core\services\graphql\TypesManager'       => EE_Dependency_Map::load_from_cache,
94
+			]
95
+		);
96
+		$this->dependency_map->registerDependencies(
97
+			'EventEspresso\core\services\graphql\TypesManager',
98
+			[
99
+				'EventEspresso\core\services\graphql\types\TypeCollection' => EE_Dependency_Map::load_from_cache,
100
+			]
101
+		);
102
+		$this->dependency_map->registerDependencies(
103
+			'EventEspresso\core\services\graphql\InputsManager',
104
+			[
105
+				'EventEspresso\core\services\graphql\inputs\InputCollection' => EE_Dependency_Map::load_from_cache,
106
+			]
107
+		);
108
+		$this->dependency_map->registerDependencies(
109
+			'EventEspresso\core\services\graphql\EnumsManager',
110
+			[
111
+				'EventEspresso\core\services\graphql\enums\EnumCollection' => EE_Dependency_Map::load_from_cache,
112
+			]
113
+		);
114
+		$this->dependency_map->registerDependencies(
115
+			'EventEspresso\core\services\graphql\ConnectionsManager',
116
+			[
117
+				'EventEspresso\core\services\graphql\connections\ConnectionCollection' => EE_Dependency_Map::load_from_cache,
118
+			]
119
+		);
120
+		$this->dependency_map->registerDependencies(
121
+			'EventEspresso\core\services\graphql\DataLoaderManager',
122
+			[
123
+				'EventEspresso\core\services\graphql\loaders\DataLoaderCollection' => EE_Dependency_Map::load_from_cache,
124
+			]
125
+		);
126
+		$this->dependency_map->registerDependencies(
127
+			'EventEspresso\core\domain\services\graphql\types\Datetime',
128
+			['EEM_Datetime' => EE_Dependency_Map::load_from_cache]
129
+		);
130
+		$this->dependency_map->registerDependencies(
131
+			'EventEspresso\core\domain\services\graphql\types\Attendee',
132
+			['EEM_Attendee' => EE_Dependency_Map::load_from_cache]
133
+		);
134
+		$this->dependency_map->registerDependencies(
135
+			'EventEspresso\core\domain\services\graphql\types\Event',
136
+			['EEM_Event' => EE_Dependency_Map::load_from_cache]
137
+		);
138
+		$this->dependency_map->registerDependencies(
139
+			'EventEspresso\core\domain\services\graphql\types\FormElement',
140
+			['EEM_Form_Element' => EE_Dependency_Map::load_from_cache]
141
+		);
142
+		$this->dependency_map->registerDependencies(
143
+			'EventEspresso\core\domain\services\graphql\types\FormSection',
144
+			['EEM_Form_Section' => EE_Dependency_Map::load_from_cache]
145
+		);
146
+		$this->dependency_map->registerDependencies(
147
+			'EventEspresso\core\domain\services\graphql\types\Ticket',
148
+			['EEM_Ticket' => EE_Dependency_Map::load_from_cache]
149
+		);
150
+		$this->dependency_map->registerDependencies(
151
+			'EventEspresso\core\domain\services\graphql\types\Price',
152
+			['EEM_Price' => EE_Dependency_Map::load_from_cache]
153
+		);
154
+		$this->dependency_map->registerDependencies(
155
+			'EventEspresso\core\domain\services\graphql\types\PriceType',
156
+			['EEM_Price_Type' => EE_Dependency_Map::load_from_cache]
157
+		);
158
+		$this->dependency_map->registerDependencies(
159
+			'EventEspresso\core\domain\services\graphql\types\Venue',
160
+			['EEM_Venue' => EE_Dependency_Map::load_from_cache]
161
+		);
162
+		$this->dependency_map->registerDependencies(
163
+			'EventEspresso\core\domain\services\graphql\types\State',
164
+			['EEM_State' => EE_Dependency_Map::load_from_cache]
165
+		);
166
+		$this->dependency_map->registerDependencies(
167
+			'EventEspresso\core\domain\services\graphql\types\Country',
168
+			['EEM_Country' => EE_Dependency_Map::load_from_cache]
169
+		);
170
+		$this->dependency_map->registerDependencies(
171
+			'EventEspresso\core\domain\services\graphql\connections\EventDatetimesConnection',
172
+			['EEM_Datetime' => EE_Dependency_Map::load_from_cache]
173
+		);
174
+		$this->dependency_map->registerDependencies(
175
+			'EventEspresso\core\domain\services\graphql\connections\RootQueryDatetimesConnection',
176
+			['EEM_Datetime' => EE_Dependency_Map::load_from_cache]
177
+		);
178
+		$this->dependency_map->registerDependencies(
179
+			'EventEspresso\core\domain\services\graphql\connections\RootQueryAttendeesConnection',
180
+			['EEM_Attendee' => EE_Dependency_Map::load_from_cache]
181
+		);
182
+		$this->dependency_map->registerDependencies(
183
+			'EventEspresso\core\domain\services\graphql\connections\RootQueryFormElementsConnection',
184
+			['EEM_Form_Element' => EE_Dependency_Map::load_from_cache]
185
+		);
186
+		$this->dependency_map->registerDependencies(
187
+			'EventEspresso\core\domain\services\graphql\connections\RootQueryFormSectionsConnection',
188
+			['EEM_Form_Section' => EE_Dependency_Map::load_from_cache]
189
+		);
190
+		$this->dependency_map->registerDependencies(
191
+			'EventEspresso\core\domain\services\graphql\connections\DatetimeTicketsConnection',
192
+			['EEM_Ticket' => EE_Dependency_Map::load_from_cache]
193
+		);
194
+		$this->dependency_map->registerDependencies(
195
+			'EventEspresso\core\domain\services\graphql\connections\RootQueryTicketsConnection',
196
+			['EEM_Ticket' => EE_Dependency_Map::load_from_cache]
197
+		);
198
+		$this->dependency_map->registerDependencies(
199
+			'EventEspresso\core\domain\services\graphql\connections\TicketPricesConnection',
200
+			['EEM_Price' => EE_Dependency_Map::load_from_cache]
201
+		);
202
+		$this->dependency_map->registerDependencies(
203
+			'EventEspresso\core\domain\services\graphql\connections\RootQueryPricesConnection',
204
+			['EEM_Price' => EE_Dependency_Map::load_from_cache]
205
+		);
206
+		$this->dependency_map->registerDependencies(
207
+			'EventEspresso\core\domain\services\graphql\connections\RootQueryPriceTypesConnection',
208
+			['EEM_Price_Type' => EE_Dependency_Map::load_from_cache]
209
+		);
210
+		$this->dependency_map->registerDependencies(
211
+			'EventEspresso\core\domain\services\graphql\connections\TicketDatetimesConnection',
212
+			['EEM_Datetime' => EE_Dependency_Map::load_from_cache]
213
+		);
214
+		$this->dependency_map->registerDependencies(
215
+			'EventEspresso\core\domain\services\graphql\connections\EventVenuesConnection',
216
+			['EEM_Venue' => EE_Dependency_Map::load_from_cache]
217
+		);
218
+	}
219 219
 
220 220
 
221
-    /**
222
-     * implements logic required to run during request
223
-     *
224
-     * @return bool
225
-     * @since   $VID:$
226
-     */
227
-    protected function requestHandler(): bool
228
-    {
229
-        if (! class_exists('WPGraphQL')) {
230
-            require_once EE_THIRD_PARTY . 'wp-graphql/wp-graphql.php';
231
-        }
232
-        // load handler for EE GraphQL requests
233
-        $graphQL_manager = $this->loader->getShared(
234
-            'EventEspresso\core\services\graphql\GraphQLManager'
235
-        );
236
-        $graphQL_manager->init();
237
-        $manifest = $this->manifest_factory->createFromDomainObject(DomainFactory::getEventEspressoCoreDomain());
238
-        $manifest->initialize();
239
-        return true;
240
-    }
221
+	/**
222
+	 * implements logic required to run during request
223
+	 *
224
+	 * @return bool
225
+	 * @since   $VID:$
226
+	 */
227
+	protected function requestHandler(): bool
228
+	{
229
+		if (! class_exists('WPGraphQL')) {
230
+			require_once EE_THIRD_PARTY . 'wp-graphql/wp-graphql.php';
231
+		}
232
+		// load handler for EE GraphQL requests
233
+		$graphQL_manager = $this->loader->getShared(
234
+			'EventEspresso\core\services\graphql\GraphQLManager'
235
+		);
236
+		$graphQL_manager->init();
237
+		$manifest = $this->manifest_factory->createFromDomainObject(DomainFactory::getEventEspressoCoreDomain());
238
+		$manifest->initialize();
239
+		return true;
240
+	}
241 241
 }
Please login to merge, or discard this patch.
core/services/graphql/Utils.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -13,18 +13,18 @@
 block discarded – undo
13 13
 class Utils
14 14
 {
15 15
 
16
-    /**
17
-     * Given a string, formats it as GraphQL ENUM value
18
-     *
19
-     * @param string $str The string to format
20
-     *
21
-     * @return string
22
-     */
23
-    public static function formatEnumKey($str)
24
-    {
25
-        // Replace any non-alph-anumeric by underscore
26
-        $str = preg_replace('/[^a-zA-Z0-9]/', '_', $str);
27
-        // Convert to uppercase.
28
-        return strtoupper($str);
29
-    }
16
+	/**
17
+	 * Given a string, formats it as GraphQL ENUM value
18
+	 *
19
+	 * @param string $str The string to format
20
+	 *
21
+	 * @return string
22
+	 */
23
+	public static function formatEnumKey($str)
24
+	{
25
+		// Replace any non-alph-anumeric by underscore
26
+		$str = preg_replace('/[^a-zA-Z0-9]/', '_', $str);
27
+		// Convert to uppercase.
28
+		return strtoupper($str);
29
+	}
30 30
 }
Please login to merge, or discard this patch.
core/services/graphql/types/TypeBase.php 1 patch
Indentation   +266 added lines, -266 removed lines patch added patch discarded remove patch
@@ -35,270 +35,270 @@
 block discarded – undo
35 35
 abstract class TypeBase implements TypeInterface
36 36
 {
37 37
 
38
-    /**
39
-     * @var string $namespace The graphql namespace/prefix.
40
-     */
41
-    protected $namespace = 'Espresso';
42
-
43
-    /**
44
-     * @var EEM_Base $model
45
-     */
46
-    protected $model;
47
-
48
-    /**
49
-     * @var string $name
50
-     */
51
-    protected $name = '';
52
-
53
-    /**
54
-     * @var string $description
55
-     */
56
-    protected $description = '';
57
-
58
-    /**
59
-     * @var GraphQLFieldInterface[] $fields
60
-     */
61
-    protected $fields = [];
62
-
63
-    /**
64
-     * @var array $graphql_to_model_map
65
-     */
66
-    protected $graphql_to_model_map = [];
67
-
68
-    /**
69
-     * @var FieldResolver $field_resolver
70
-     */
71
-    protected $field_resolver;
72
-
73
-    /**
74
-     * @var bool $is_custom_post_type
75
-     */
76
-    protected $is_custom_post_type = false;
77
-
78
-
79
-    /**
80
-     * TypeBase constructor.
81
-     *
82
-     * @param EEM_Base|null $model
83
-     */
84
-    public function __construct(EEM_Base $model = null)
85
-    {
86
-        $this->model = $model;
87
-        $this->setFields($this->getFields());
88
-        $this->field_resolver = new FieldResolver(
89
-            $this->model,
90
-            $this->getFieldsForResolver()
91
-        );
92
-    }
93
-
94
-
95
-    /**
96
-     * @return GraphQLFieldInterface[]
97
-     * @since $VID:$
98
-     */
99
-    abstract protected function getFields(): array;
100
-
101
-
102
-    /**
103
-     * @return string
104
-     */
105
-    public function name(): string
106
-    {
107
-        return $this->name;
108
-    }
109
-
110
-
111
-    /**
112
-     * @param string $name
113
-     */
114
-    protected function setName(string $name)
115
-    {
116
-        $this->name = $name;
117
-    }
118
-
119
-
120
-    /**
121
-     * @return string
122
-     */
123
-    public function description(): string
124
-    {
125
-        return $this->description;
126
-    }
127
-
128
-
129
-    /**
130
-     * @param string $description
131
-     */
132
-    protected function setDescription(string $description)
133
-    {
134
-        $this->description = $description;
135
-    }
136
-
137
-
138
-    /**
139
-     * @return GraphQLFieldInterface[]
140
-     * @since $VID:$
141
-     */
142
-    public function fields(): array
143
-    {
144
-        return (array) $this->fields;
145
-    }
146
-
147
-
148
-    /**
149
-     * @param GraphQLFieldInterface[] $fields
150
-     */
151
-    protected function setFields(array $fields)
152
-    {
153
-        foreach ($fields as $field) {
154
-            if ($field instanceof GraphQLField) {
155
-                $this->fields[] = $field;
156
-            }
157
-        }
158
-    }
159
-
160
-
161
-    /**
162
-     * Creates a key map for internal resolver.
163
-     *
164
-     * @return array
165
-     * @since $VID:$
166
-     */
167
-    public function getFieldsForResolver(): array
168
-    {
169
-        $fields = [];
170
-        foreach ($this->fields() as $field) {
171
-            if ($field->useForOutput()) {
172
-                $fields[ $field->name() ] = $field;
173
-            }
174
-        }
175
-        return $fields;
176
-    }
177
-
178
-
179
-    /**
180
-     * @return bool
181
-     */
182
-    public function isCustomPostType(): bool
183
-    {
184
-        return $this->is_custom_post_type;
185
-    }
186
-
187
-
188
-    /**
189
-     * @param bool $is_custom_post_type
190
-     */
191
-    protected function setIsCustomPostType(bool $is_custom_post_type)
192
-    {
193
-        $this->is_custom_post_type = filter_var($is_custom_post_type, FILTER_VALIDATE_BOOLEAN);
194
-    }
195
-
196
-
197
-    /**
198
-     * @param int|float $value
199
-     * @return int
200
-     * @since $VID:$
201
-     */
202
-    public function parseInfiniteValue($value): int
203
-    {
204
-        $value = trim($value);
205
-        return $value === null
206
-               || $value === ''
207
-               || $value === '∞'
208
-               || $value === 'INF'
209
-               || $value === INF
210
-               || $value === EE_INF
211
-               || is_infinite((float) $value)
212
-            ? -1
213
-            : $value;
214
-    }
215
-
216
-
217
-    /**
218
-     * @param mixed $source
219
-     * @return EE_Base_Class|null
220
-     * @throws EE_Error
221
-     */
222
-    private function getModel($source): ?EE_Base_Class
223
-    {
224
-        // If it comes from a custom connection
225
-        // where the $source is already instantiated.
226
-        if ($source instanceof EE_Base_Class) {
227
-            return $source;
228
-        }
229
-        return $source instanceof Post ? $this->model->get_one_by_ID($source->ID) : null;
230
-    }
231
-
232
-
233
-    /**
234
-     * @param mixed       $source  The source that's passed down the GraphQL queries
235
-     * @param array       $args    The inputArgs on the field
236
-     * @param AppContext  $context The AppContext passed down the GraphQL tree
237
-     * @param ResolveInfo $info    The ResolveInfo passed down the GraphQL tree
238
-     * @return EE_Base_Class|Deferred|string|null
239
-     * @throws EE_Error
240
-     * @throws InvalidDataTypeException
241
-     * @throws InvalidInterfaceException
242
-     * @throws UnexpectedEntityException
243
-     * @throws UserError
244
-     * @throws InvalidArgumentException
245
-     * @throws ReflectionException
246
-     * @since $VID:$
247
-     */
248
-    public function resolveField($source, array $args, AppContext $context, ResolveInfo $info)
249
-    {
250
-        $source = $source instanceof RootQuery ? $source : $this->getModel($source);
251
-
252
-        return $this->field_resolver->resolve($source, $args, $context, $info);
253
-    }
254
-
255
-
256
-    /**
257
-     * @param mixed      $payload The payload returned after mutation
258
-     * @param array      $args    The inputArgs on the field
259
-     * @param AppContext $context The AppContext passed down the GraphQL tree
260
-     * @return EE_Base_Class|EE_Soft_Delete_Base_Class|null
261
-     * @throws EE_Error
262
-     */
263
-    public function resolveFromPayload($payload, array $args, AppContext $context)
264
-    {
265
-        if (empty($payload['id'])) {
266
-            return null;
267
-        }
268
-        return $this->model->get_one_by_ID($payload['id']);
269
-    }
270
-
271
-
272
-    /**
273
-     * Prepares a datetime value in ISO8601/RFC3339 format.
274
-     * It is assumed that the value of $datetime is in the format
275
-     * returned by EE_Base_Class::get_format().
276
-     *
277
-     * @param string        $datetime The datetime value.
278
-     * @param EE_Base_Class $source   The source object.
279
-     * @return string ISO8601/RFC3339 formatted datetime.
280
-     */
281
-    public function formatDatetime(string $datetime, EE_Base_Class $source): string
282
-    {
283
-        $format   = $source->get_format();
284
-        // create date object based on local timezone
285
-        $datetime = DateTime::createFromFormat($format, $datetime, new DateTimeZone($source->get_timezone()));
286
-        // change the timezone to UTC
287
-        $datetime->setTimezone(new DateTimeZone('UTC'));
288
-
289
-        return $datetime->format(DateTime::RFC3339);
290
-    }
291
-
292
-
293
-    /**
294
-     * Converts an object to JSON. The object must have a "toJson" method.
295
-     *
296
-     * @param string        $object   The object/value.
297
-     * @param EE_Base_Class $source   The source object.
298
-     * @return string JSON representation of the object.
299
-     */
300
-    public function toJson(JsonableInterface $object, EE_Base_Class $source): string
301
-    {
302
-        return $object->toJson();
303
-    }
38
+	/**
39
+	 * @var string $namespace The graphql namespace/prefix.
40
+	 */
41
+	protected $namespace = 'Espresso';
42
+
43
+	/**
44
+	 * @var EEM_Base $model
45
+	 */
46
+	protected $model;
47
+
48
+	/**
49
+	 * @var string $name
50
+	 */
51
+	protected $name = '';
52
+
53
+	/**
54
+	 * @var string $description
55
+	 */
56
+	protected $description = '';
57
+
58
+	/**
59
+	 * @var GraphQLFieldInterface[] $fields
60
+	 */
61
+	protected $fields = [];
62
+
63
+	/**
64
+	 * @var array $graphql_to_model_map
65
+	 */
66
+	protected $graphql_to_model_map = [];
67
+
68
+	/**
69
+	 * @var FieldResolver $field_resolver
70
+	 */
71
+	protected $field_resolver;
72
+
73
+	/**
74
+	 * @var bool $is_custom_post_type
75
+	 */
76
+	protected $is_custom_post_type = false;
77
+
78
+
79
+	/**
80
+	 * TypeBase constructor.
81
+	 *
82
+	 * @param EEM_Base|null $model
83
+	 */
84
+	public function __construct(EEM_Base $model = null)
85
+	{
86
+		$this->model = $model;
87
+		$this->setFields($this->getFields());
88
+		$this->field_resolver = new FieldResolver(
89
+			$this->model,
90
+			$this->getFieldsForResolver()
91
+		);
92
+	}
93
+
94
+
95
+	/**
96
+	 * @return GraphQLFieldInterface[]
97
+	 * @since $VID:$
98
+	 */
99
+	abstract protected function getFields(): array;
100
+
101
+
102
+	/**
103
+	 * @return string
104
+	 */
105
+	public function name(): string
106
+	{
107
+		return $this->name;
108
+	}
109
+
110
+
111
+	/**
112
+	 * @param string $name
113
+	 */
114
+	protected function setName(string $name)
115
+	{
116
+		$this->name = $name;
117
+	}
118
+
119
+
120
+	/**
121
+	 * @return string
122
+	 */
123
+	public function description(): string
124
+	{
125
+		return $this->description;
126
+	}
127
+
128
+
129
+	/**
130
+	 * @param string $description
131
+	 */
132
+	protected function setDescription(string $description)
133
+	{
134
+		$this->description = $description;
135
+	}
136
+
137
+
138
+	/**
139
+	 * @return GraphQLFieldInterface[]
140
+	 * @since $VID:$
141
+	 */
142
+	public function fields(): array
143
+	{
144
+		return (array) $this->fields;
145
+	}
146
+
147
+
148
+	/**
149
+	 * @param GraphQLFieldInterface[] $fields
150
+	 */
151
+	protected function setFields(array $fields)
152
+	{
153
+		foreach ($fields as $field) {
154
+			if ($field instanceof GraphQLField) {
155
+				$this->fields[] = $field;
156
+			}
157
+		}
158
+	}
159
+
160
+
161
+	/**
162
+	 * Creates a key map for internal resolver.
163
+	 *
164
+	 * @return array
165
+	 * @since $VID:$
166
+	 */
167
+	public function getFieldsForResolver(): array
168
+	{
169
+		$fields = [];
170
+		foreach ($this->fields() as $field) {
171
+			if ($field->useForOutput()) {
172
+				$fields[ $field->name() ] = $field;
173
+			}
174
+		}
175
+		return $fields;
176
+	}
177
+
178
+
179
+	/**
180
+	 * @return bool
181
+	 */
182
+	public function isCustomPostType(): bool
183
+	{
184
+		return $this->is_custom_post_type;
185
+	}
186
+
187
+
188
+	/**
189
+	 * @param bool $is_custom_post_type
190
+	 */
191
+	protected function setIsCustomPostType(bool $is_custom_post_type)
192
+	{
193
+		$this->is_custom_post_type = filter_var($is_custom_post_type, FILTER_VALIDATE_BOOLEAN);
194
+	}
195
+
196
+
197
+	/**
198
+	 * @param int|float $value
199
+	 * @return int
200
+	 * @since $VID:$
201
+	 */
202
+	public function parseInfiniteValue($value): int
203
+	{
204
+		$value = trim($value);
205
+		return $value === null
206
+			   || $value === ''
207
+			   || $value === '∞'
208
+			   || $value === 'INF'
209
+			   || $value === INF
210
+			   || $value === EE_INF
211
+			   || is_infinite((float) $value)
212
+			? -1
213
+			: $value;
214
+	}
215
+
216
+
217
+	/**
218
+	 * @param mixed $source
219
+	 * @return EE_Base_Class|null
220
+	 * @throws EE_Error
221
+	 */
222
+	private function getModel($source): ?EE_Base_Class
223
+	{
224
+		// If it comes from a custom connection
225
+		// where the $source is already instantiated.
226
+		if ($source instanceof EE_Base_Class) {
227
+			return $source;
228
+		}
229
+		return $source instanceof Post ? $this->model->get_one_by_ID($source->ID) : null;
230
+	}
231
+
232
+
233
+	/**
234
+	 * @param mixed       $source  The source that's passed down the GraphQL queries
235
+	 * @param array       $args    The inputArgs on the field
236
+	 * @param AppContext  $context The AppContext passed down the GraphQL tree
237
+	 * @param ResolveInfo $info    The ResolveInfo passed down the GraphQL tree
238
+	 * @return EE_Base_Class|Deferred|string|null
239
+	 * @throws EE_Error
240
+	 * @throws InvalidDataTypeException
241
+	 * @throws InvalidInterfaceException
242
+	 * @throws UnexpectedEntityException
243
+	 * @throws UserError
244
+	 * @throws InvalidArgumentException
245
+	 * @throws ReflectionException
246
+	 * @since $VID:$
247
+	 */
248
+	public function resolveField($source, array $args, AppContext $context, ResolveInfo $info)
249
+	{
250
+		$source = $source instanceof RootQuery ? $source : $this->getModel($source);
251
+
252
+		return $this->field_resolver->resolve($source, $args, $context, $info);
253
+	}
254
+
255
+
256
+	/**
257
+	 * @param mixed      $payload The payload returned after mutation
258
+	 * @param array      $args    The inputArgs on the field
259
+	 * @param AppContext $context The AppContext passed down the GraphQL tree
260
+	 * @return EE_Base_Class|EE_Soft_Delete_Base_Class|null
261
+	 * @throws EE_Error
262
+	 */
263
+	public function resolveFromPayload($payload, array $args, AppContext $context)
264
+	{
265
+		if (empty($payload['id'])) {
266
+			return null;
267
+		}
268
+		return $this->model->get_one_by_ID($payload['id']);
269
+	}
270
+
271
+
272
+	/**
273
+	 * Prepares a datetime value in ISO8601/RFC3339 format.
274
+	 * It is assumed that the value of $datetime is in the format
275
+	 * returned by EE_Base_Class::get_format().
276
+	 *
277
+	 * @param string        $datetime The datetime value.
278
+	 * @param EE_Base_Class $source   The source object.
279
+	 * @return string ISO8601/RFC3339 formatted datetime.
280
+	 */
281
+	public function formatDatetime(string $datetime, EE_Base_Class $source): string
282
+	{
283
+		$format   = $source->get_format();
284
+		// create date object based on local timezone
285
+		$datetime = DateTime::createFromFormat($format, $datetime, new DateTimeZone($source->get_timezone()));
286
+		// change the timezone to UTC
287
+		$datetime->setTimezone(new DateTimeZone('UTC'));
288
+
289
+		return $datetime->format(DateTime::RFC3339);
290
+	}
291
+
292
+
293
+	/**
294
+	 * Converts an object to JSON. The object must have a "toJson" method.
295
+	 *
296
+	 * @param string        $object   The object/value.
297
+	 * @param EE_Base_Class $source   The source object.
298
+	 * @return string JSON representation of the object.
299
+	 */
300
+	public function toJson(JsonableInterface $object, EE_Base_Class $source): string
301
+	{
302
+		return $object->toJson();
303
+	}
304 304
 }
Please login to merge, or discard this patch.
core/services/container/Mirror.php 2 patches
Indentation   +294 added lines, -294 removed lines patch added patch discarded remove patch
@@ -21,298 +21,298 @@
 block discarded – undo
21 21
 class Mirror
22 22
 {
23 23
 
24
-    /**
25
-     * @var ReflectionClass[]
26
-     */
27
-    private $classes = [];
28
-
29
-    /**
30
-     * @var ReflectionMethod[]
31
-     */
32
-    private $constructors = [];
33
-
34
-    /**
35
-     * @var ReflectionParameter[][]
36
-     */
37
-    private $parameters = [];
38
-
39
-    /**
40
-     * @var ReflectionParameter[][]
41
-     */
42
-    private $parameter_classes = [];
43
-
44
-    /**
45
-     * @var ReflectionProperty[][]
46
-     */
47
-    private $properties = [];
48
-
49
-    /**
50
-     * @var ReflectionMethod[][]
51
-     */
52
-    private $methods = [];
53
-
54
-    /**
55
-     * @var array
56
-     */
57
-    private $default_properties = [];
58
-
59
-    /**
60
-     * @var array
61
-     */
62
-    private $static_properties = [];
63
-
64
-
65
-    /**
66
-     * @param string $class_name
67
-     * @return ReflectionClass
68
-     * @throws ReflectionException
69
-     * @throws InvalidDataTypeException
70
-     */
71
-    public function getReflectionClass(string $class_name): ReflectionClass
72
-    {
73
-        if (! is_string($class_name)) {
74
-            throw new InvalidDataTypeException($class_name, '$class_name', 'string (fully qualified class name)');
75
-        }
76
-        if (! isset($this->classes[ $class_name ])) {
77
-            $this->classes[ $class_name ] = new ReflectionClass($class_name);
78
-        }
79
-        return $this->classes[ $class_name ];
80
-    }
81
-
82
-
83
-    /**
84
-     * @param string $class_name
85
-     * @return ReflectionMethod|null
86
-     * @throws InvalidDataTypeException
87
-     * @throws ReflectionException
88
-     */
89
-    public function getConstructor(string $class_name): ?ReflectionMethod
90
-    {
91
-        if (! is_string($class_name)) {
92
-            throw new InvalidDataTypeException($class_name, '$class_name', 'string (fully qualified class name)');
93
-        }
94
-        if (! isset($this->constructors[ $class_name ])) {
95
-            $reflection_class                  = $this->getReflectionClass($class_name);
96
-            $this->constructors[ $class_name ] = $reflection_class->getConstructor();
97
-        }
98
-        return $this->constructors[ $class_name ];
99
-    }
100
-
101
-
102
-    /**
103
-     * @param ReflectionClass $reflection_class
104
-     * @return ReflectionMethod|null
105
-     * @throws InvalidDataTypeException
106
-     * @throws ReflectionException
107
-     */
108
-    public function getConstructorFromReflection(ReflectionClass $reflection_class): ?ReflectionMethod
109
-    {
110
-        return $this->getConstructor($reflection_class->getName());
111
-    }
112
-
113
-
114
-    /**
115
-     * @param string $class_name
116
-     * @return ReflectionParameter[]
117
-     * @throws InvalidDataTypeException
118
-     * @throws ReflectionException
119
-     */
120
-    public function getParameters(string $class_name): array
121
-    {
122
-        if (! isset($this->parameters[ $class_name ])) {
123
-            $constructor                     = $this->getConstructor($class_name);
124
-            $this->parameters[ $class_name ] = $constructor->getParameters();
125
-        }
126
-        return $this->parameters[ $class_name ];
127
-    }
128
-
129
-
130
-    /**
131
-     * @param ReflectionClass $reflection_class
132
-     * @return ReflectionParameter[]
133
-     * @throws InvalidDataTypeException
134
-     * @throws ReflectionException
135
-     */
136
-    public function getParametersFromReflection(ReflectionClass $reflection_class): array
137
-    {
138
-        return $this->getParameters($reflection_class->getName());
139
-    }
140
-
141
-
142
-    /**
143
-     * @param ReflectionMethod $constructor
144
-     * @return ReflectionParameter[]
145
-     * @throws InvalidDataTypeException
146
-     * @throws ReflectionException
147
-     */
148
-    public function getParametersFromReflectionConstructor(ReflectionMethod $constructor): array
149
-    {
150
-        return $this->getParameters($constructor->getDeclaringClass());
151
-    }
152
-
153
-
154
-    /**
155
-     * returns array of ReflectionParameter objects for parameters that are NOT optional
156
-     *
157
-     * @param string $class_name
158
-     * @return ReflectionParameter[]
159
-     * @throws InvalidDataTypeException
160
-     * @throws ReflectionException
161
-     */
162
-    public function getRequiredParameters(string $class_name): array
163
-    {
164
-        $required_parameters = [];
165
-        $parameters          = $this->getParameters($class_name);
166
-        foreach ($parameters as $parameter) {
167
-            if ($parameter instanceof ReflectionParameter && ! $parameter->isOptional()) {
168
-                $required_parameters[] = $parameter;
169
-            }
170
-        }
171
-        return $required_parameters;
172
-    }
173
-
174
-
175
-    /**
176
-     * @param ReflectionParameter $param
177
-     * @param string              $class_name
178
-     * @param string              $index
179
-     * @return string|null
180
-     */
181
-    public function getParameterClassName(ReflectionParameter $param, string $class_name, string $index): ?string
182
-    {
183
-        if (isset($this->parameter_classes[ $class_name ][ $index ]['param_class_name'])) {
184
-            return $this->parameter_classes[ $class_name ][ $index ]['param_class_name'];
185
-        }
186
-        if (! isset($this->parameter_classes[ $class_name ])) {
187
-            $this->parameter_classes[ $class_name ] = [];
188
-        }
189
-        if (! isset($this->parameter_classes[ $class_name ][ $index ])) {
190
-            $this->parameter_classes[ $class_name ][ $index ] = [];
191
-        }
192
-        // ReflectionParameter::getClass() is deprecated in PHP 8+
193
-        if (PHP_VERSION_ID >= 80000) {
194
-            $this->parameter_classes[ $class_name ][ $index ]['param_class_name'] =
195
-                $param->getType() instanceof ReflectionNamedType
196
-                    ? $param->getType()->getName()
197
-                    : null;
198
-        } else {
199
-            $this->parameter_classes[ $class_name ][ $index ]['param_class_name'] = $param->getClass()
200
-                    ? $param->getClass()->getName()
201
-                    : null;
202
-        }
203
-        return $this->parameter_classes[ $class_name ][ $index ]['param_class_name'];
204
-    }
205
-
206
-
207
-    /**
208
-     * @param ReflectionParameter $param
209
-     * @param string              $class_name
210
-     * @param string              $index
211
-     * @return array|string|null
212
-     * @throws ReflectionException
213
-     */
214
-    public function getParameterDefaultValue(ReflectionParameter $param, string $class_name, string $index)
215
-    {
216
-        if (isset($this->parameter_classes[ $class_name ][ $index ]['param_class_default'])) {
217
-            return $this->parameter_classes[ $class_name ][ $index ]['param_class_default'];
218
-        }
219
-        if (! isset($this->parameter_classes[ $class_name ])) {
220
-            $this->parameter_classes[ $class_name ] = [];
221
-        }
222
-        if (! isset($this->parameter_classes[ $class_name ][ $index ])) {
223
-            $this->parameter_classes[ $class_name ][ $index ] = [];
224
-        }
225
-        $this->parameter_classes[ $class_name ][ $index ]['param_class_default'] = $param->isDefaultValueAvailable()
226
-            ? $param->getDefaultValue()
227
-            : null;
228
-        return $this->parameter_classes[ $class_name ][ $index ]['param_class_default'];
229
-    }
230
-
231
-
232
-    /**
233
-     * @param string $class_name
234
-     * @return ReflectionProperty[]
235
-     * @throws InvalidDataTypeException
236
-     * @throws ReflectionException
237
-     */
238
-    public function getProperties(string $class_name): array
239
-    {
240
-        if (! isset($this->properties[ $class_name ])) {
241
-            $reflection_class                = $this->getReflectionClass($class_name);
242
-            $this->properties[ $class_name ] = $reflection_class->getProperties();
243
-        }
244
-        return $this->properties[ $class_name ];
245
-    }
246
-
247
-
248
-    /**
249
-     * @param ReflectionClass $reflection_class
250
-     * @return ReflectionProperty[]
251
-     * @throws InvalidDataTypeException
252
-     * @throws ReflectionException
253
-     */
254
-    public function getPropertiesFromReflection(ReflectionClass $reflection_class): array
255
-    {
256
-        return $this->getProperties($reflection_class->getName());
257
-    }
258
-
259
-
260
-    /**
261
-     * @param string $class_name
262
-     * @return ReflectionMethod[]
263
-     * @throws InvalidDataTypeException
264
-     * @throws ReflectionException
265
-     */
266
-    public function getMethods(string $class_name): array
267
-    {
268
-        if (! isset($this->methods[ $class_name ])) {
269
-            $reflection_class             = $this->getReflectionClass($class_name);
270
-            $this->methods[ $class_name ] = $reflection_class->getMethods();
271
-        }
272
-        return $this->methods[ $class_name ];
273
-    }
274
-
275
-
276
-    /**
277
-     * @param ReflectionClass $reflection_class )
278
-     * @return ReflectionMethod[]
279
-     * @throws InvalidDataTypeException
280
-     * @throws ReflectionException
281
-     */
282
-    public function getMethodsFromReflection(ReflectionClass $reflection_class): array
283
-    {
284
-        return $this->getMethods($reflection_class->getName());
285
-    }
286
-
287
-
288
-    /**
289
-     * @param string $class_name
290
-     * @return array
291
-     * @throws InvalidDataTypeException
292
-     * @throws ReflectionException
293
-     */
294
-    public function getDefaultProperties(string $class_name): array
295
-    {
296
-        if (! isset($this->default_properties[ $class_name ])) {
297
-            $reflection_class                        = $this->getReflectionClass($class_name);
298
-            $this->default_properties[ $class_name ] = $reflection_class->getDefaultProperties();
299
-        }
300
-        return $this->default_properties[ $class_name ];
301
-    }
302
-
303
-
304
-    /**
305
-     * @param string $class_name
306
-     * @return array
307
-     * @throws InvalidDataTypeException
308
-     * @throws ReflectionException
309
-     */
310
-    public function getStaticProperties(string $class_name): array
311
-    {
312
-        if (! isset($this->static_properties[ $class_name ])) {
313
-            $reflection_class                       = $this->getReflectionClass($class_name);
314
-            $this->static_properties[ $class_name ] = $reflection_class->getStaticProperties();
315
-        }
316
-        return $this->static_properties[ $class_name ];
317
-    }
24
+	/**
25
+	 * @var ReflectionClass[]
26
+	 */
27
+	private $classes = [];
28
+
29
+	/**
30
+	 * @var ReflectionMethod[]
31
+	 */
32
+	private $constructors = [];
33
+
34
+	/**
35
+	 * @var ReflectionParameter[][]
36
+	 */
37
+	private $parameters = [];
38
+
39
+	/**
40
+	 * @var ReflectionParameter[][]
41
+	 */
42
+	private $parameter_classes = [];
43
+
44
+	/**
45
+	 * @var ReflectionProperty[][]
46
+	 */
47
+	private $properties = [];
48
+
49
+	/**
50
+	 * @var ReflectionMethod[][]
51
+	 */
52
+	private $methods = [];
53
+
54
+	/**
55
+	 * @var array
56
+	 */
57
+	private $default_properties = [];
58
+
59
+	/**
60
+	 * @var array
61
+	 */
62
+	private $static_properties = [];
63
+
64
+
65
+	/**
66
+	 * @param string $class_name
67
+	 * @return ReflectionClass
68
+	 * @throws ReflectionException
69
+	 * @throws InvalidDataTypeException
70
+	 */
71
+	public function getReflectionClass(string $class_name): ReflectionClass
72
+	{
73
+		if (! is_string($class_name)) {
74
+			throw new InvalidDataTypeException($class_name, '$class_name', 'string (fully qualified class name)');
75
+		}
76
+		if (! isset($this->classes[ $class_name ])) {
77
+			$this->classes[ $class_name ] = new ReflectionClass($class_name);
78
+		}
79
+		return $this->classes[ $class_name ];
80
+	}
81
+
82
+
83
+	/**
84
+	 * @param string $class_name
85
+	 * @return ReflectionMethod|null
86
+	 * @throws InvalidDataTypeException
87
+	 * @throws ReflectionException
88
+	 */
89
+	public function getConstructor(string $class_name): ?ReflectionMethod
90
+	{
91
+		if (! is_string($class_name)) {
92
+			throw new InvalidDataTypeException($class_name, '$class_name', 'string (fully qualified class name)');
93
+		}
94
+		if (! isset($this->constructors[ $class_name ])) {
95
+			$reflection_class                  = $this->getReflectionClass($class_name);
96
+			$this->constructors[ $class_name ] = $reflection_class->getConstructor();
97
+		}
98
+		return $this->constructors[ $class_name ];
99
+	}
100
+
101
+
102
+	/**
103
+	 * @param ReflectionClass $reflection_class
104
+	 * @return ReflectionMethod|null
105
+	 * @throws InvalidDataTypeException
106
+	 * @throws ReflectionException
107
+	 */
108
+	public function getConstructorFromReflection(ReflectionClass $reflection_class): ?ReflectionMethod
109
+	{
110
+		return $this->getConstructor($reflection_class->getName());
111
+	}
112
+
113
+
114
+	/**
115
+	 * @param string $class_name
116
+	 * @return ReflectionParameter[]
117
+	 * @throws InvalidDataTypeException
118
+	 * @throws ReflectionException
119
+	 */
120
+	public function getParameters(string $class_name): array
121
+	{
122
+		if (! isset($this->parameters[ $class_name ])) {
123
+			$constructor                     = $this->getConstructor($class_name);
124
+			$this->parameters[ $class_name ] = $constructor->getParameters();
125
+		}
126
+		return $this->parameters[ $class_name ];
127
+	}
128
+
129
+
130
+	/**
131
+	 * @param ReflectionClass $reflection_class
132
+	 * @return ReflectionParameter[]
133
+	 * @throws InvalidDataTypeException
134
+	 * @throws ReflectionException
135
+	 */
136
+	public function getParametersFromReflection(ReflectionClass $reflection_class): array
137
+	{
138
+		return $this->getParameters($reflection_class->getName());
139
+	}
140
+
141
+
142
+	/**
143
+	 * @param ReflectionMethod $constructor
144
+	 * @return ReflectionParameter[]
145
+	 * @throws InvalidDataTypeException
146
+	 * @throws ReflectionException
147
+	 */
148
+	public function getParametersFromReflectionConstructor(ReflectionMethod $constructor): array
149
+	{
150
+		return $this->getParameters($constructor->getDeclaringClass());
151
+	}
152
+
153
+
154
+	/**
155
+	 * returns array of ReflectionParameter objects for parameters that are NOT optional
156
+	 *
157
+	 * @param string $class_name
158
+	 * @return ReflectionParameter[]
159
+	 * @throws InvalidDataTypeException
160
+	 * @throws ReflectionException
161
+	 */
162
+	public function getRequiredParameters(string $class_name): array
163
+	{
164
+		$required_parameters = [];
165
+		$parameters          = $this->getParameters($class_name);
166
+		foreach ($parameters as $parameter) {
167
+			if ($parameter instanceof ReflectionParameter && ! $parameter->isOptional()) {
168
+				$required_parameters[] = $parameter;
169
+			}
170
+		}
171
+		return $required_parameters;
172
+	}
173
+
174
+
175
+	/**
176
+	 * @param ReflectionParameter $param
177
+	 * @param string              $class_name
178
+	 * @param string              $index
179
+	 * @return string|null
180
+	 */
181
+	public function getParameterClassName(ReflectionParameter $param, string $class_name, string $index): ?string
182
+	{
183
+		if (isset($this->parameter_classes[ $class_name ][ $index ]['param_class_name'])) {
184
+			return $this->parameter_classes[ $class_name ][ $index ]['param_class_name'];
185
+		}
186
+		if (! isset($this->parameter_classes[ $class_name ])) {
187
+			$this->parameter_classes[ $class_name ] = [];
188
+		}
189
+		if (! isset($this->parameter_classes[ $class_name ][ $index ])) {
190
+			$this->parameter_classes[ $class_name ][ $index ] = [];
191
+		}
192
+		// ReflectionParameter::getClass() is deprecated in PHP 8+
193
+		if (PHP_VERSION_ID >= 80000) {
194
+			$this->parameter_classes[ $class_name ][ $index ]['param_class_name'] =
195
+				$param->getType() instanceof ReflectionNamedType
196
+					? $param->getType()->getName()
197
+					: null;
198
+		} else {
199
+			$this->parameter_classes[ $class_name ][ $index ]['param_class_name'] = $param->getClass()
200
+					? $param->getClass()->getName()
201
+					: null;
202
+		}
203
+		return $this->parameter_classes[ $class_name ][ $index ]['param_class_name'];
204
+	}
205
+
206
+
207
+	/**
208
+	 * @param ReflectionParameter $param
209
+	 * @param string              $class_name
210
+	 * @param string              $index
211
+	 * @return array|string|null
212
+	 * @throws ReflectionException
213
+	 */
214
+	public function getParameterDefaultValue(ReflectionParameter $param, string $class_name, string $index)
215
+	{
216
+		if (isset($this->parameter_classes[ $class_name ][ $index ]['param_class_default'])) {
217
+			return $this->parameter_classes[ $class_name ][ $index ]['param_class_default'];
218
+		}
219
+		if (! isset($this->parameter_classes[ $class_name ])) {
220
+			$this->parameter_classes[ $class_name ] = [];
221
+		}
222
+		if (! isset($this->parameter_classes[ $class_name ][ $index ])) {
223
+			$this->parameter_classes[ $class_name ][ $index ] = [];
224
+		}
225
+		$this->parameter_classes[ $class_name ][ $index ]['param_class_default'] = $param->isDefaultValueAvailable()
226
+			? $param->getDefaultValue()
227
+			: null;
228
+		return $this->parameter_classes[ $class_name ][ $index ]['param_class_default'];
229
+	}
230
+
231
+
232
+	/**
233
+	 * @param string $class_name
234
+	 * @return ReflectionProperty[]
235
+	 * @throws InvalidDataTypeException
236
+	 * @throws ReflectionException
237
+	 */
238
+	public function getProperties(string $class_name): array
239
+	{
240
+		if (! isset($this->properties[ $class_name ])) {
241
+			$reflection_class                = $this->getReflectionClass($class_name);
242
+			$this->properties[ $class_name ] = $reflection_class->getProperties();
243
+		}
244
+		return $this->properties[ $class_name ];
245
+	}
246
+
247
+
248
+	/**
249
+	 * @param ReflectionClass $reflection_class
250
+	 * @return ReflectionProperty[]
251
+	 * @throws InvalidDataTypeException
252
+	 * @throws ReflectionException
253
+	 */
254
+	public function getPropertiesFromReflection(ReflectionClass $reflection_class): array
255
+	{
256
+		return $this->getProperties($reflection_class->getName());
257
+	}
258
+
259
+
260
+	/**
261
+	 * @param string $class_name
262
+	 * @return ReflectionMethod[]
263
+	 * @throws InvalidDataTypeException
264
+	 * @throws ReflectionException
265
+	 */
266
+	public function getMethods(string $class_name): array
267
+	{
268
+		if (! isset($this->methods[ $class_name ])) {
269
+			$reflection_class             = $this->getReflectionClass($class_name);
270
+			$this->methods[ $class_name ] = $reflection_class->getMethods();
271
+		}
272
+		return $this->methods[ $class_name ];
273
+	}
274
+
275
+
276
+	/**
277
+	 * @param ReflectionClass $reflection_class )
278
+	 * @return ReflectionMethod[]
279
+	 * @throws InvalidDataTypeException
280
+	 * @throws ReflectionException
281
+	 */
282
+	public function getMethodsFromReflection(ReflectionClass $reflection_class): array
283
+	{
284
+		return $this->getMethods($reflection_class->getName());
285
+	}
286
+
287
+
288
+	/**
289
+	 * @param string $class_name
290
+	 * @return array
291
+	 * @throws InvalidDataTypeException
292
+	 * @throws ReflectionException
293
+	 */
294
+	public function getDefaultProperties(string $class_name): array
295
+	{
296
+		if (! isset($this->default_properties[ $class_name ])) {
297
+			$reflection_class                        = $this->getReflectionClass($class_name);
298
+			$this->default_properties[ $class_name ] = $reflection_class->getDefaultProperties();
299
+		}
300
+		return $this->default_properties[ $class_name ];
301
+	}
302
+
303
+
304
+	/**
305
+	 * @param string $class_name
306
+	 * @return array
307
+	 * @throws InvalidDataTypeException
308
+	 * @throws ReflectionException
309
+	 */
310
+	public function getStaticProperties(string $class_name): array
311
+	{
312
+		if (! isset($this->static_properties[ $class_name ])) {
313
+			$reflection_class                       = $this->getReflectionClass($class_name);
314
+			$this->static_properties[ $class_name ] = $reflection_class->getStaticProperties();
315
+		}
316
+		return $this->static_properties[ $class_name ];
317
+	}
318 318
 }
Please login to merge, or discard this patch.
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -70,13 +70,13 @@  discard block
 block discarded – undo
70 70
      */
71 71
     public function getReflectionClass(string $class_name): ReflectionClass
72 72
     {
73
-        if (! is_string($class_name)) {
73
+        if ( ! is_string($class_name)) {
74 74
             throw new InvalidDataTypeException($class_name, '$class_name', 'string (fully qualified class name)');
75 75
         }
76
-        if (! isset($this->classes[ $class_name ])) {
77
-            $this->classes[ $class_name ] = new ReflectionClass($class_name);
76
+        if ( ! isset($this->classes[$class_name])) {
77
+            $this->classes[$class_name] = new ReflectionClass($class_name);
78 78
         }
79
-        return $this->classes[ $class_name ];
79
+        return $this->classes[$class_name];
80 80
     }
81 81
 
82 82
 
@@ -88,14 +88,14 @@  discard block
 block discarded – undo
88 88
      */
89 89
     public function getConstructor(string $class_name): ?ReflectionMethod
90 90
     {
91
-        if (! is_string($class_name)) {
91
+        if ( ! is_string($class_name)) {
92 92
             throw new InvalidDataTypeException($class_name, '$class_name', 'string (fully qualified class name)');
93 93
         }
94
-        if (! isset($this->constructors[ $class_name ])) {
94
+        if ( ! isset($this->constructors[$class_name])) {
95 95
             $reflection_class                  = $this->getReflectionClass($class_name);
96
-            $this->constructors[ $class_name ] = $reflection_class->getConstructor();
96
+            $this->constructors[$class_name] = $reflection_class->getConstructor();
97 97
         }
98
-        return $this->constructors[ $class_name ];
98
+        return $this->constructors[$class_name];
99 99
     }
100 100
 
101 101
 
@@ -119,11 +119,11 @@  discard block
 block discarded – undo
119 119
      */
120 120
     public function getParameters(string $class_name): array
121 121
     {
122
-        if (! isset($this->parameters[ $class_name ])) {
122
+        if ( ! isset($this->parameters[$class_name])) {
123 123
             $constructor                     = $this->getConstructor($class_name);
124
-            $this->parameters[ $class_name ] = $constructor->getParameters();
124
+            $this->parameters[$class_name] = $constructor->getParameters();
125 125
         }
126
-        return $this->parameters[ $class_name ];
126
+        return $this->parameters[$class_name];
127 127
     }
128 128
 
129 129
 
@@ -180,27 +180,27 @@  discard block
 block discarded – undo
180 180
      */
181 181
     public function getParameterClassName(ReflectionParameter $param, string $class_name, string $index): ?string
182 182
     {
183
-        if (isset($this->parameter_classes[ $class_name ][ $index ]['param_class_name'])) {
184
-            return $this->parameter_classes[ $class_name ][ $index ]['param_class_name'];
183
+        if (isset($this->parameter_classes[$class_name][$index]['param_class_name'])) {
184
+            return $this->parameter_classes[$class_name][$index]['param_class_name'];
185 185
         }
186
-        if (! isset($this->parameter_classes[ $class_name ])) {
187
-            $this->parameter_classes[ $class_name ] = [];
186
+        if ( ! isset($this->parameter_classes[$class_name])) {
187
+            $this->parameter_classes[$class_name] = [];
188 188
         }
189
-        if (! isset($this->parameter_classes[ $class_name ][ $index ])) {
190
-            $this->parameter_classes[ $class_name ][ $index ] = [];
189
+        if ( ! isset($this->parameter_classes[$class_name][$index])) {
190
+            $this->parameter_classes[$class_name][$index] = [];
191 191
         }
192 192
         // ReflectionParameter::getClass() is deprecated in PHP 8+
193 193
         if (PHP_VERSION_ID >= 80000) {
194
-            $this->parameter_classes[ $class_name ][ $index ]['param_class_name'] =
194
+            $this->parameter_classes[$class_name][$index]['param_class_name'] =
195 195
                 $param->getType() instanceof ReflectionNamedType
196 196
                     ? $param->getType()->getName()
197 197
                     : null;
198 198
         } else {
199
-            $this->parameter_classes[ $class_name ][ $index ]['param_class_name'] = $param->getClass()
199
+            $this->parameter_classes[$class_name][$index]['param_class_name'] = $param->getClass()
200 200
                     ? $param->getClass()->getName()
201 201
                     : null;
202 202
         }
203
-        return $this->parameter_classes[ $class_name ][ $index ]['param_class_name'];
203
+        return $this->parameter_classes[$class_name][$index]['param_class_name'];
204 204
     }
205 205
 
206 206
 
@@ -213,19 +213,19 @@  discard block
 block discarded – undo
213 213
      */
214 214
     public function getParameterDefaultValue(ReflectionParameter $param, string $class_name, string $index)
215 215
     {
216
-        if (isset($this->parameter_classes[ $class_name ][ $index ]['param_class_default'])) {
217
-            return $this->parameter_classes[ $class_name ][ $index ]['param_class_default'];
216
+        if (isset($this->parameter_classes[$class_name][$index]['param_class_default'])) {
217
+            return $this->parameter_classes[$class_name][$index]['param_class_default'];
218 218
         }
219
-        if (! isset($this->parameter_classes[ $class_name ])) {
220
-            $this->parameter_classes[ $class_name ] = [];
219
+        if ( ! isset($this->parameter_classes[$class_name])) {
220
+            $this->parameter_classes[$class_name] = [];
221 221
         }
222
-        if (! isset($this->parameter_classes[ $class_name ][ $index ])) {
223
-            $this->parameter_classes[ $class_name ][ $index ] = [];
222
+        if ( ! isset($this->parameter_classes[$class_name][$index])) {
223
+            $this->parameter_classes[$class_name][$index] = [];
224 224
         }
225
-        $this->parameter_classes[ $class_name ][ $index ]['param_class_default'] = $param->isDefaultValueAvailable()
225
+        $this->parameter_classes[$class_name][$index]['param_class_default'] = $param->isDefaultValueAvailable()
226 226
             ? $param->getDefaultValue()
227 227
             : null;
228
-        return $this->parameter_classes[ $class_name ][ $index ]['param_class_default'];
228
+        return $this->parameter_classes[$class_name][$index]['param_class_default'];
229 229
     }
230 230
 
231 231
 
@@ -237,11 +237,11 @@  discard block
 block discarded – undo
237 237
      */
238 238
     public function getProperties(string $class_name): array
239 239
     {
240
-        if (! isset($this->properties[ $class_name ])) {
240
+        if ( ! isset($this->properties[$class_name])) {
241 241
             $reflection_class                = $this->getReflectionClass($class_name);
242
-            $this->properties[ $class_name ] = $reflection_class->getProperties();
242
+            $this->properties[$class_name] = $reflection_class->getProperties();
243 243
         }
244
-        return $this->properties[ $class_name ];
244
+        return $this->properties[$class_name];
245 245
     }
246 246
 
247 247
 
@@ -265,11 +265,11 @@  discard block
 block discarded – undo
265 265
      */
266 266
     public function getMethods(string $class_name): array
267 267
     {
268
-        if (! isset($this->methods[ $class_name ])) {
268
+        if ( ! isset($this->methods[$class_name])) {
269 269
             $reflection_class             = $this->getReflectionClass($class_name);
270
-            $this->methods[ $class_name ] = $reflection_class->getMethods();
270
+            $this->methods[$class_name] = $reflection_class->getMethods();
271 271
         }
272
-        return $this->methods[ $class_name ];
272
+        return $this->methods[$class_name];
273 273
     }
274 274
 
275 275
 
@@ -293,11 +293,11 @@  discard block
 block discarded – undo
293 293
      */
294 294
     public function getDefaultProperties(string $class_name): array
295 295
     {
296
-        if (! isset($this->default_properties[ $class_name ])) {
296
+        if ( ! isset($this->default_properties[$class_name])) {
297 297
             $reflection_class                        = $this->getReflectionClass($class_name);
298
-            $this->default_properties[ $class_name ] = $reflection_class->getDefaultProperties();
298
+            $this->default_properties[$class_name] = $reflection_class->getDefaultProperties();
299 299
         }
300
-        return $this->default_properties[ $class_name ];
300
+        return $this->default_properties[$class_name];
301 301
     }
302 302
 
303 303
 
@@ -309,10 +309,10 @@  discard block
 block discarded – undo
309 309
      */
310 310
     public function getStaticProperties(string $class_name): array
311 311
     {
312
-        if (! isset($this->static_properties[ $class_name ])) {
312
+        if ( ! isset($this->static_properties[$class_name])) {
313 313
             $reflection_class                       = $this->getReflectionClass($class_name);
314
-            $this->static_properties[ $class_name ] = $reflection_class->getStaticProperties();
314
+            $this->static_properties[$class_name] = $reflection_class->getStaticProperties();
315 315
         }
316
-        return $this->static_properties[ $class_name ];
316
+        return $this->static_properties[$class_name];
317 317
     }
318 318
 }
Please login to merge, or discard this patch.
core/services/form/meta/JsonableInterface.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -11,15 +11,15 @@
 block discarded – undo
11 11
  */
12 12
 interface JsonableInterface
13 13
 {
14
-    /**
15
-     * @param string $json
16
-     * @return mixed
17
-     */
18
-    public static function fromJson(string $json);
14
+	/**
15
+	 * @param string $json
16
+	 * @return mixed
17
+	 */
18
+	public static function fromJson(string $json);
19 19
 
20 20
 
21
-    /**
22
-     * @return string
23
-     */
24
-    public function toJson(): string;
21
+	/**
22
+	 * @return string
23
+	 */
24
+	public function toJson(): string;
25 25
 }
Please login to merge, or discard this patch.
core/services/form/meta/Attributes.php 2 patches
Indentation   +180 added lines, -180 removed lines patch added patch discarded remove patch
@@ -17,184 +17,184 @@
 block discarded – undo
17 17
 class Attributes implements JsonableInterface
18 18
 {
19 19
 
20
-    /**
21
-     * @var JsonDataHandler
22
-     */
23
-    private $json_data_handler;
24
-
25
-    /**
26
-     * @var InputTypes
27
-     */
28
-    private $input_types;
29
-
30
-    /**
31
-     * @var array
32
-     */
33
-    private $attributes = [];
34
-
35
-    /**
36
-     * @var array
37
-     */
38
-    private $attribute_types = [
39
-        'accept'          => 'string',
40
-        'accesskey'       => 'string',
41
-        'alt'             => 'string',
42
-        'autocomplete'    => 'bool',
43
-        'autofocus'       => 'bool',
44
-        'checked'         => 'bool',
45
-        // Custom HTML classes to be applied to the form input's container
46
-        'class'           => 'string',
47
-        'contenteditable' => 'bool',
48
-        'dir'             => 'string',
49
-        'disabled'        => 'bool',
50
-        'height'          => 'string',
51
-        'hidden'          => 'bool',
52
-        'id'              => 'string',
53
-        'list'            => 'string',
54
-        // Maximum numeric value allowed for form input answer.
55
-        'max'             => 'int',
56
-        // Maximum characters allowed for form input answer.
57
-        'maxlength'       => 'int',
58
-        // Minimum numeric value allowed for form input answer.
59
-        'min'             => 'int',
60
-        'multiple'        => 'bool',
61
-        'name'            => 'string',
62
-        'pattern'         => 'string',
63
-        // Example text displayed within an input to assist users with completing the form.
64
-        'placeholder'     => 'string',
65
-        'readonly'        => 'bool',
66
-        'size'            => 'int',
67
-        'spellcheck'      => 'bool',
68
-        'step'            => 'float',
69
-        'style'           => 'string',
70
-        'tabindex'        => 'int',
71
-        'title'           => 'string',
72
-        'translate'       => 'bool',
73
-        // Form input type. Values correspond to the Input::TYPE_* constants.
74
-        'type'            => 'string',
75
-        'value'           => 'string',
76
-        'width'           => 'string',
77
-    ];
78
-
79
-
80
-    /**
81
-     * Attributes constructor.
82
-     *
83
-     * @param JsonDataHandler $json_data_handler
84
-     * @param InputTypes      $element_types
85
-     * @param array           $attributes
86
-     */
87
-    public function __construct(JsonDataHandler $json_data_handler, array $attributes, InputTypes $element_types)
88
-    {
89
-        $this->json_data_handler = $json_data_handler;
90
-        $this->input_types       = $element_types;
91
-        $this->setAttributes($attributes);
92
-    }
93
-
94
-
95
-    /**
96
-     * @param string $json
97
-     * @return Attributes
98
-     */
99
-    public static function fromJson(string $json): Attributes
100
-    {
101
-        $json_data_handler = new JsonDataHandler();
102
-        $json_data_handler->configure(JsonDataHandler::DATA_TYPE_ARRAY);
103
-        $attributes = $json_data_handler->decodeJson($json);
104
-        /** @var InputTypes */
105
-        $element_types = LoaderFactory::getShared('EventEspresso\core\services\form\meta\InputTypes');
106
-        return LoaderFactory::getNew(Attributes::class, [ $json_data_handler, $attributes, $element_types ]);
107
-    }
108
-
109
-
110
-    /**
111
-     * @return array
112
-     */
113
-    public function toArray(): array
114
-    {
115
-        return $this->attributes();
116
-    }
117
-
118
-
119
-    /**
120
-     * @return string
121
-     */
122
-    public function toJson(): string
123
-    {
124
-        return $this->json_data_handler->encodeData($this->attributes());
125
-    }
126
-
127
-
128
-    /**
129
-     * @param string                $attribute
130
-     * @param bool|float|int|string $value
131
-     * @return bool|float|int|string
132
-     */
133
-    private function sanitize(string $attribute, $value)
134
-    {
135
-        if ($attribute === 'type') {
136
-            $valid_types = $this->input_types->validTypeOptions();
137
-            return in_array($value, $valid_types, true) ?: Text::TYPE_TEXT;
138
-        }
139
-        $type = $this->attribute_types[ $attribute ] ?? 'string';
140
-        switch ($type) {
141
-            case 'bool':
142
-                return filter_var($value, FILTER_VALIDATE_BOOLEAN);
143
-            case 'int':
144
-                return filter_var($value, FILTER_SANITIZE_NUMBER_INT);
145
-            case 'float':
146
-                return filter_var($value, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
147
-            case 'string':
148
-            default:
149
-                return filter_var(
150
-                    $value,
151
-                    FILTER_SANITIZE_STRING,
152
-                    FILTER_FLAG_ENCODE_LOW | FILTER_FLAG_ENCODE_HIGH | FILTER_FLAG_ENCODE_AMP
153
-                );
154
-        }
155
-    }
156
-
157
-
158
-    /**
159
-     * Custom HTML classes to be applied to this form input's help text.
160
-     * returns a concatenated string unless $as_array is set to true
161
-     *
162
-     * @return array
163
-     */
164
-    public function attributes(): array
165
-    {
166
-        return $this->attributes;
167
-    }
168
-
169
-
170
-    /**
171
-     * @param string                $attribute
172
-     * @param bool|float|int|string $value
173
-     */
174
-    public function addAttribute(string $attribute, $value): void
175
-    {
176
-        if (array_key_exists($attribute, $this->attribute_types)) {
177
-            $this->attributes[ $attribute ] = $this->sanitize($attribute, $value);
178
-        }
179
-    }
180
-
181
-
182
-    /**
183
-     * @param string $attribute
184
-     */
185
-    public function removeAttribute(string $attribute): void
186
-    {
187
-        unset($this->attributes[ $attribute ]);
188
-    }
189
-
190
-
191
-    /**
192
-     * @param array $attributes array where keys are the attribute name and values are the attribute's value
193
-     */
194
-    public function setAttributes(array $attributes): void
195
-    {
196
-        foreach ($attributes as $attribute => $value) {
197
-            $this->addAttribute($attribute, $value);
198
-        }
199
-    }
20
+	/**
21
+	 * @var JsonDataHandler
22
+	 */
23
+	private $json_data_handler;
24
+
25
+	/**
26
+	 * @var InputTypes
27
+	 */
28
+	private $input_types;
29
+
30
+	/**
31
+	 * @var array
32
+	 */
33
+	private $attributes = [];
34
+
35
+	/**
36
+	 * @var array
37
+	 */
38
+	private $attribute_types = [
39
+		'accept'          => 'string',
40
+		'accesskey'       => 'string',
41
+		'alt'             => 'string',
42
+		'autocomplete'    => 'bool',
43
+		'autofocus'       => 'bool',
44
+		'checked'         => 'bool',
45
+		// Custom HTML classes to be applied to the form input's container
46
+		'class'           => 'string',
47
+		'contenteditable' => 'bool',
48
+		'dir'             => 'string',
49
+		'disabled'        => 'bool',
50
+		'height'          => 'string',
51
+		'hidden'          => 'bool',
52
+		'id'              => 'string',
53
+		'list'            => 'string',
54
+		// Maximum numeric value allowed for form input answer.
55
+		'max'             => 'int',
56
+		// Maximum characters allowed for form input answer.
57
+		'maxlength'       => 'int',
58
+		// Minimum numeric value allowed for form input answer.
59
+		'min'             => 'int',
60
+		'multiple'        => 'bool',
61
+		'name'            => 'string',
62
+		'pattern'         => 'string',
63
+		// Example text displayed within an input to assist users with completing the form.
64
+		'placeholder'     => 'string',
65
+		'readonly'        => 'bool',
66
+		'size'            => 'int',
67
+		'spellcheck'      => 'bool',
68
+		'step'            => 'float',
69
+		'style'           => 'string',
70
+		'tabindex'        => 'int',
71
+		'title'           => 'string',
72
+		'translate'       => 'bool',
73
+		// Form input type. Values correspond to the Input::TYPE_* constants.
74
+		'type'            => 'string',
75
+		'value'           => 'string',
76
+		'width'           => 'string',
77
+	];
78
+
79
+
80
+	/**
81
+	 * Attributes constructor.
82
+	 *
83
+	 * @param JsonDataHandler $json_data_handler
84
+	 * @param InputTypes      $element_types
85
+	 * @param array           $attributes
86
+	 */
87
+	public function __construct(JsonDataHandler $json_data_handler, array $attributes, InputTypes $element_types)
88
+	{
89
+		$this->json_data_handler = $json_data_handler;
90
+		$this->input_types       = $element_types;
91
+		$this->setAttributes($attributes);
92
+	}
93
+
94
+
95
+	/**
96
+	 * @param string $json
97
+	 * @return Attributes
98
+	 */
99
+	public static function fromJson(string $json): Attributes
100
+	{
101
+		$json_data_handler = new JsonDataHandler();
102
+		$json_data_handler->configure(JsonDataHandler::DATA_TYPE_ARRAY);
103
+		$attributes = $json_data_handler->decodeJson($json);
104
+		/** @var InputTypes */
105
+		$element_types = LoaderFactory::getShared('EventEspresso\core\services\form\meta\InputTypes');
106
+		return LoaderFactory::getNew(Attributes::class, [ $json_data_handler, $attributes, $element_types ]);
107
+	}
108
+
109
+
110
+	/**
111
+	 * @return array
112
+	 */
113
+	public function toArray(): array
114
+	{
115
+		return $this->attributes();
116
+	}
117
+
118
+
119
+	/**
120
+	 * @return string
121
+	 */
122
+	public function toJson(): string
123
+	{
124
+		return $this->json_data_handler->encodeData($this->attributes());
125
+	}
126
+
127
+
128
+	/**
129
+	 * @param string                $attribute
130
+	 * @param bool|float|int|string $value
131
+	 * @return bool|float|int|string
132
+	 */
133
+	private function sanitize(string $attribute, $value)
134
+	{
135
+		if ($attribute === 'type') {
136
+			$valid_types = $this->input_types->validTypeOptions();
137
+			return in_array($value, $valid_types, true) ?: Text::TYPE_TEXT;
138
+		}
139
+		$type = $this->attribute_types[ $attribute ] ?? 'string';
140
+		switch ($type) {
141
+			case 'bool':
142
+				return filter_var($value, FILTER_VALIDATE_BOOLEAN);
143
+			case 'int':
144
+				return filter_var($value, FILTER_SANITIZE_NUMBER_INT);
145
+			case 'float':
146
+				return filter_var($value, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
147
+			case 'string':
148
+			default:
149
+				return filter_var(
150
+					$value,
151
+					FILTER_SANITIZE_STRING,
152
+					FILTER_FLAG_ENCODE_LOW | FILTER_FLAG_ENCODE_HIGH | FILTER_FLAG_ENCODE_AMP
153
+				);
154
+		}
155
+	}
156
+
157
+
158
+	/**
159
+	 * Custom HTML classes to be applied to this form input's help text.
160
+	 * returns a concatenated string unless $as_array is set to true
161
+	 *
162
+	 * @return array
163
+	 */
164
+	public function attributes(): array
165
+	{
166
+		return $this->attributes;
167
+	}
168
+
169
+
170
+	/**
171
+	 * @param string                $attribute
172
+	 * @param bool|float|int|string $value
173
+	 */
174
+	public function addAttribute(string $attribute, $value): void
175
+	{
176
+		if (array_key_exists($attribute, $this->attribute_types)) {
177
+			$this->attributes[ $attribute ] = $this->sanitize($attribute, $value);
178
+		}
179
+	}
180
+
181
+
182
+	/**
183
+	 * @param string $attribute
184
+	 */
185
+	public function removeAttribute(string $attribute): void
186
+	{
187
+		unset($this->attributes[ $attribute ]);
188
+	}
189
+
190
+
191
+	/**
192
+	 * @param array $attributes array where keys are the attribute name and values are the attribute's value
193
+	 */
194
+	public function setAttributes(array $attributes): void
195
+	{
196
+		foreach ($attributes as $attribute => $value) {
197
+			$this->addAttribute($attribute, $value);
198
+		}
199
+	}
200 200
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
         $attributes = $json_data_handler->decodeJson($json);
104 104
         /** @var InputTypes */
105 105
         $element_types = LoaderFactory::getShared('EventEspresso\core\services\form\meta\InputTypes');
106
-        return LoaderFactory::getNew(Attributes::class, [ $json_data_handler, $attributes, $element_types ]);
106
+        return LoaderFactory::getNew(Attributes::class, [$json_data_handler, $attributes, $element_types]);
107 107
     }
108 108
 
109 109
 
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
             $valid_types = $this->input_types->validTypeOptions();
137 137
             return in_array($value, $valid_types, true) ?: Text::TYPE_TEXT;
138 138
         }
139
-        $type = $this->attribute_types[ $attribute ] ?? 'string';
139
+        $type = $this->attribute_types[$attribute] ?? 'string';
140 140
         switch ($type) {
141 141
             case 'bool':
142 142
                 return filter_var($value, FILTER_VALIDATE_BOOLEAN);
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
     public function addAttribute(string $attribute, $value): void
175 175
     {
176 176
         if (array_key_exists($attribute, $this->attribute_types)) {
177
-            $this->attributes[ $attribute ] = $this->sanitize($attribute, $value);
177
+            $this->attributes[$attribute] = $this->sanitize($attribute, $value);
178 178
         }
179 179
     }
180 180
 
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
      */
185 185
     public function removeAttribute(string $attribute): void
186 186
     {
187
-        unset($this->attributes[ $attribute ]);
187
+        unset($this->attributes[$attribute]);
188 188
     }
189 189
 
190 190
 
Please login to merge, or discard this patch.
core/services/form/meta/FormStatus.php 2 patches
Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -15,74 +15,74 @@
 block discarded – undo
15 15
 class FormStatus
16 16
 {
17 17
 
18
-    /**
19
-     * indicates that element is not archived or trashed
20
-     */
21
-    public const ACTIVE = 'active';
18
+	/**
19
+	 * indicates that element is not archived or trashed
20
+	 */
21
+	public const ACTIVE = 'active';
22 22
 
23
-    /**
24
-     * indicates that element is archived and should no longer be displayed on public forms
25
-     * but may still be required due to existing answers when form was completed prior to input being archived
26
-     */
27
-    public const ARCHIVED = 'archived';
23
+	/**
24
+	 * indicates that element is archived and should no longer be displayed on public forms
25
+	 * but may still be required due to existing answers when form was completed prior to input being archived
26
+	 */
27
+	public const ARCHIVED = 'archived';
28 28
 
29
-    /**
30
-     * indicates that element should be automatically added to newly created forms
31
-     */
32
-    public const DEFAULT = 'default';
29
+	/**
30
+	 * indicates that element should be automatically added to newly created forms
31
+	 */
32
+	public const DEFAULT = 'default';
33 33
 
34
-    /**
35
-     * indicates that a copy of the form section will be saved for use in other events but not loaded by default
36
-     */
37
-    public const SHARED = 'shared';
34
+	/**
35
+	 * indicates that a copy of the form section will be saved for use in other events but not loaded by default
36
+	 */
37
+	public const SHARED = 'shared';
38 38
 
39
-    /**
40
-     * indicates that element is no longer needed, has no existing answers, and can be moved to the trash
41
-     */
42
-    public const TRASHED = 'trashed';
39
+	/**
40
+	 * indicates that element is no longer needed, has no existing answers, and can be moved to the trash
41
+	 */
42
+	public const TRASHED = 'trashed';
43 43
 
44
-    /**
45
-     * @var array
46
-     */
47
-    private $valid_status_options;
44
+	/**
45
+	 * @var array
46
+	 */
47
+	private $valid_status_options;
48 48
 
49 49
 
50
-    public function __construct()
51
-    {
52
-        $this->valid_status_options = apply_filters(
53
-            'FHEE__EventEspresso_core_services_form_meta_FormStatus__valid_status_options',
54
-            [
55
-                FormStatus::ACTIVE   => esc_html__('Active', 'event_espresso'),
56
-                FormStatus::ARCHIVED => esc_html__('Archived', 'event_espresso'),
57
-                FormStatus::DEFAULT  => esc_html__('Default', 'event_espresso'),
58
-                FormStatus::SHARED   => esc_html__('Shared', 'event_espresso'),
59
-                FormStatus::TRASHED  => esc_html__('Trashed', 'event_espresso'),
60
-            ]
61
-        );
62
-    }
50
+	public function __construct()
51
+	{
52
+		$this->valid_status_options = apply_filters(
53
+			'FHEE__EventEspresso_core_services_form_meta_FormStatus__valid_status_options',
54
+			[
55
+				FormStatus::ACTIVE   => esc_html__('Active', 'event_espresso'),
56
+				FormStatus::ARCHIVED => esc_html__('Archived', 'event_espresso'),
57
+				FormStatus::DEFAULT  => esc_html__('Default', 'event_espresso'),
58
+				FormStatus::SHARED   => esc_html__('Shared', 'event_espresso'),
59
+				FormStatus::TRASHED  => esc_html__('Trashed', 'event_espresso'),
60
+			]
61
+		);
62
+	}
63 63
 
64 64
 
65
-    /**
66
-     * @return array
67
-     */
68
-    public function getFormStatusValues(): array
69
-    {
70
-        $values = [];
71
-        foreach ($this->valid_status_options as $value => $description) {
72
-            $values[ GQLUtils::formatEnumKey($value) ] = compact('value', 'description');
73
-        }
74
-        return $values;
75
-    }
65
+	/**
66
+	 * @return array
67
+	 */
68
+	public function getFormStatusValues(): array
69
+	{
70
+		$values = [];
71
+		foreach ($this->valid_status_options as $value => $description) {
72
+			$values[ GQLUtils::formatEnumKey($value) ] = compact('value', 'description');
73
+		}
74
+		return $values;
75
+	}
76 76
 
77 77
 
78
-    /**
79
-     * @param bool $constants_only
80
-     * @return array
81
-     */
82
-    public function validStatusOptions(bool $constants_only = false): array
83
-    {
84
-        return $constants_only
85
-            ? array_keys($this->valid_status_options)
86
-            : $this->valid_status_options;
87
-    }
78
+	/**
79
+	 * @param bool $constants_only
80
+	 * @return array
81
+	 */
82
+	public function validStatusOptions(bool $constants_only = false): array
83
+	{
84
+		return $constants_only
85
+			? array_keys($this->valid_status_options)
86
+			: $this->valid_status_options;
87
+	}
88 88
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@
 block discarded – undo
69 69
     {
70 70
         $values = [];
71 71
         foreach ($this->valid_status_options as $value => $description) {
72
-            $values[ GQLUtils::formatEnumKey($value) ] = compact('value', 'description');
72
+            $values[GQLUtils::formatEnumKey($value)] = compact('value', 'description');
73 73
         }
74 74
         return $values;
75 75
     }
Please login to merge, or discard this patch.