-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathphpapi_up_to_php81_version.yaml
369 lines (369 loc) · 20.6 KB
/
phpapi_up_to_php81_version.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
questions:
-
uuid: 1eebf878-8b97-6494-ae5f-99d84c92580c
question: 'Which configuration file format can be used to define PHP constants as parameters?'
answers:
- { value: php, correct: true }
- { value: XML, correct: true }
- { value: Annotation, correct: false }
- { value: INI, correct: false }
- { value: YAML, correct: true }
help: 'https://symfony.com/doc/current/configuration.html#constants-as-parameters'
-
uuid: 1eebf878-8b98-6740-a71f-99d84c92580c
question: 'Which of the following is not a predefined PHP variable?'
answers:
- { value: $http_response_header, correct: false }
- { value: $php_errormsg, correct: false }
- { value: $_POST, correct: false }
- { value: $_GLOBALS, correct: true }
- { value: $argc, correct: false }
help: 'https://php.net/manual/en/reserved.variables.php'
-
uuid: 1eebf878-8b99-6316-bfed-99d84c92580c
question: 'Which of the following are valid PHP class names ?'
answers:
- { value: '-MyClass', correct: false }
- { value: 123MyClass, correct: false }
- { value: myClass, correct: true }
- { value: _MyClass, correct: true }
help: 'https://www.php.net/manual/en/language.oop5.basic.php'
-
uuid: 1eebf878-8b99-655a-9f19-99d84c92580c
question: "In the following code snippet, what condition should you use to ensure the Location header hasn't already been sent?\nfunction redirect($url) { $header = sprintf('Location: %s', $url); if ( ??? ) { header($header); exit; } }"
answers:
- { value: '!in_array($header, headers_list())', correct: true }
- { value: "!header_exists('Location', $url)", correct: false }
- { value: '!headers_sent()', correct: true }
- { value: "$_SERVER['HTTP_LOCATION'] != $url", correct: false }
- { value: '!http_redirect_to($url)', correct: false }
help: 'https://php.net/manual/en/ref.network.php'
-
uuid: 1eebf878-8b9a-6054-a6cb-99d84c92580c
question: '$a = (object) ["a" => "b"]; $b = (object) ["a" => "c"]; echo $a <=> $b;'
answers:
- { value: '0', correct: false }
- { value: '1', correct: false }
- { value: '-1', correct: true }
help: 'https://php.net/manual/en/language.operators.comparison.php'
-
uuid: 1eebf878-8b9a-6428-aa7e-99d84c92580c
question: 'Regarding this URI : /example?tags.id=2 What will be the content of $request->query->all() ?'
answers:
- { value: "[ 'tags.id' => 2 ]", correct: false }
- { value: "[ 'tags_id' => 2 ]", correct: true }
- { value: "[ 'tags' => ['id' => 2] ]", correct: false }
help: 'https://github.com/symfony/symfony/issues/29664'
-
uuid: 1eebf878-8b9a-6d88-9a1d-99d84c92580c
question: 'Which major PHP version introduced the « traits » feature?'
answers:
- { value: 'PHP 5.3', correct: false }
- { value: 'PHP 6.0', correct: false }
- { value: 'PHP 7.0', correct: false }
- { value: 'PHP 5.4', correct: true }
- { value: 'PHP 5.6', correct: false }
- { value: 'PHP 5.5', correct: false }
help: 'https://php.net/manual/en/language.oop5.traits.php'
-
uuid: 1eebf878-8b9b-6e90-875a-99d84c92580c
question: 'Which of the following APIs are designed to be SAFE from SQL injections?'
answers:
- { value: 'Query methods on the Connection.', correct: false }
- { value: 'Doctrine\DBAL\Connection#update($table, $values, $where, $types)', correct: true }
- { value: 'Doctrine\DBAL\Connection#delete($table, $where, $types)', correct: true }
- { value: 'Doctrine\DBAL\Query\QueryBuilder#setFirstResult($offset)', correct: true }
- { value: 'The QueryBuilder API.', correct: false }
- { value: 'Doctrine\DBAL\Platforms\AbstractPlatform#modifyLimitQuery($sql, $limit, $offset)', correct: true }
- { value: 'Doctrine\DBAL\Connection#insert($table, $values, $types)', correct: true }
- { value: 'Doctrine\DBAL\Query\QueryBuilder#setMaxResults($limit)', correct: true }
help: 'https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/security.html#sql-injection-safe-and-unsafe-apis-for-user-input'
-
uuid: 1eebf878-8b9b-6f80-bc80-99d84c92580c
question: "Which of the following statements best describes the purpose of PHP's extract() function? This function accepts an array as its first argument."
answers:
- { value: 'The passed array is populated by any variables in the current scope.', correct: false }
- { value: 'A variable is created in the current scope for each element in the given associative array.', correct: true }
- { value: "The second argument is used to specify a data type (such as 'string'). All values in the passed array of that type are returned in a new array.", correct: false }
- { value: 'Any ZIP files referenced in the passed array are extracted to the current working directory.', correct: false }
help: 'https://www.php.net/manual/en/function.extract.php'
-
uuid: 1eebf878-8b9c-6656-8085-99d84c92580c
question: 'Which function would best parse the following string by the tab (\t) and newline (\n) characters ? $string = "John\tMark\nTed\tLarry";'
answers:
- { value: 'explode($string, "\t\n");', correct: false }
- { value: strtok($string);, correct: true }
- { value: str_split($string);, correct: false }
- { value: strstr($string);, correct: false }
help: 'https://www.php.net/manual/en/function.strtok.php'
-
uuid: 1eebf878-8b9c-6a02-9efa-99d84c92580c
question: 'By default, which of the following request parameters can be used with built-in providers for a login form?'
answers:
- { value: _remember_me, correct: false }
- { value: _token, correct: true }
- { value: _user, correct: false }
- { value: _password, correct: true }
- { value: _passwd, correct: false }
- { value: _username, correct: true }
help: 'https://symfony.com/doc/current/reference/configuration/security.html#form-login-configuration'
-
uuid: 1eebf878-8b9d-606a-916d-99d84c92580c
question: 'Could the current token be retrieved from Symfony\Component\Security\Core\Security ?'
answers:
- { value: 'Yes', correct: true }
- { value: 'No', correct: false }
help: 'https://symfony.com/doc/current/security.html#securing-other-services'
-
uuid: 1eebf878-8b9d-61f0-8520-99d84c92580c
question: 'What is the signature of the vote() method from VoterInterface?'
answers:
- { value: 'public function vote(TokenInterface $token, $subject, array $attributes)', correct: true }
- { value: 'public function vote(TokenInterface $token, array $attributes, $object)', correct: false }
- { value: 'public function vote(TokenInterface $token, $object, array $attributes)', correct: false }
- { value: 'public function vote(TokenInterface $token, array $attributes, $subject)', correct: false }
help: 'https://github.com/symfony/symfony/blob/6.4/src/Symfony/Component/Security/Core/Authorization/Voter/VoterInterface.php'
-
uuid: 1eebf878-8b9d-6506-af8c-99d84c92580c
question: 'Which class can be used to extracts security errors from a Request?'
answers:
- { value: AuthenticationUtils, correct: true }
- { value: FrameworkUtils, correct: false }
- { value: HttpUtils, correct: false }
- { value: SecurityUtils, correct: false }
- { value: RequestUtils, correct: false }
help: 'https://github.com/symfony/symfony/blob/6.4/src/Symfony/Component/Security/Http/Authentication/AuthenticationUtils.php'
-
uuid: 1eebf878-8ba0-6756-8594-99d84c92580c
question: 'What is the short open tag for PHP?'
answers:
- { value: '<!', correct: false }
- { value: '<%', correct: false }
- { value: '<?', correct: true }
- { value: '<?=', correct: false }
help: 'https://www.php.net/manual/en/language.basic-syntax.phptags.php'
-
uuid: 1eebf878-8ba0-67a6-ad3b-99d84c92580c
question: 'Which of these operators is non-associative?'
answers:
- { value: '!', correct: false }
- { value: '**', correct: false }
- { value: '<', correct: true }
- { value: and, correct: false }
help: 'https://www.php.net/manual/en/language.operators.precedence.php'
-
uuid: 1eebf878-8ba0-67ec-9eef-99d84c92580c
question: 'Since PHP 5.6+, if function foo() is defined in the namespace Myapp\Utils\Bar and your code is in namespace Myapp, what is the correct way to import the foo() function?'
answers:
- { value: 'use function foo;', correct: false }
- { value: 'use Myapp\Utils\Bar\foo;', correct: false }
- { value: 'use function Myapp\Utils\Bar\foo;', correct: true }
- { value: 'use Utils\Bar\Foo;', correct: false }
help: 'https://www.php.net/manual/en/language.namespaces.importing.php'
-
uuid: 1eebf878-8ba0-6878-9688-99d84c92580c
question: 'Which web services are supported natively in PHP?'
answers:
- { value: 'SOAP and XML-RPC', correct: true }
- { value: 'REST and SOAP', correct: false }
- { value: 'Corba and XML-RPC', correct: false }
- { value: 'XML-RPC and REST', correct: false }
help: 'https://www.php.net/manual/en/refs.webservice.php'
-
uuid: 1eebf878-8ba0-699a-b7c4-99d84c92580c
question: 'Which of the following function declarations must be used to return a reference?'
answers:
- { value: 'function &foo() {...}', correct: true }
- { value: 'function $foo() {...}', correct: false }
- { value: 'function %foo() {...}', correct: false }
- { value: 'function $$foo() {...}', correct: false }
help: 'https://www.php.net/manual/en/language.references.return.php'
-
uuid: 1eebf878-8ba0-69e0-80a7-99d84c92580c
question: 'Which keyword is used to indicate that a class or method is incomplete and must be extended or implemented to be used?'
answers:
- { value: abstract, correct: true }
- { value: final, correct: false }
- { value: protected, correct: false }
- { value: incomplete, correct: false }
- { value: implements, correct: false }
help: 'https://www.php.net/manual/en/language.oop5.abstract.php'
-
uuid: 1eebf878-8ba0-6ab2-b754-99d84c92580c
question: 'A closure is a lambda function that is aware of its surrounding context.'
answers:
- { value: 'True', correct: true }
- { value: 'False', correct: false }
help: 'https://www.php.net/manual/en/functions.anonymous.php'
-
uuid: 1eebf878-8ba0-6bd4-9a5b-99d84c92580c
question: 'in a class, public $var4 = self::myStaticMethod(); is a valid property declaration ?'
answers:
- { value: 'True', correct: false }
- { value: 'False', correct: true }
help: 'https://www.php.net/manual/en/language.oop5.properties.php#example-1'
-
uuid: 1eebf878-8ba0-6c6a-b940-99d84c92580c
question: 'Declaring class properties or methods as static makes them accessible without needing an instantiation of the class ?'
answers:
- { value: 'True', correct: true }
- { value: 'False', correct: false }
help: 'https://php.net/manual/en/language.oop5.static.php'
-
uuid: 1eebf878-8ba0-6cb0-91ef-99d84c92580c
question: 'Which keyword permit to use the late static binding ?'
answers:
- { value: self, correct: false }
- { value: static, correct: true }
- { value: parent, correct: false }
help: 'https://php.net/manual/en/language.oop5.late-static-bindings.php'
-
uuid: 1eebf878-8ba1-6b74-9168-99d84c92580c
question: 'Which of the following are supported visibilities for class attributes and methods in PHP ?'
answers:
- { value: Protected, correct: true }
- { value: Friend, correct: false }
- { value: Private, correct: true }
- { value: Public, correct: true }
- { value: Global, correct: false }
help: 'https://php.net/manual/en/language.oop5.visibility.php'
-
uuid: 1eebf878-8ba2-622c-b66a-99d84c92580c
question: 'What PHP function is used to return an array containing values present in two or more passed arrays?'
answers:
- { value: array_common, correct: false }
- { value: array_union, correct: false }
- { value: array_intersect, correct: true }
- { value: array_walk, correct: false }
help: 'https://php.net/array'
-
uuid: 1eebf878-8ba2-648e-9eb7-99d84c92580c
question: 'What is the SPL?'
answers:
- { value: 'The Standard PHP Library, a collection of classes and interfaces which provides common data structures, iterators, exceptions and classes to manipulate files. It also provides functions to handle and configure autoload.', correct: true }
- { value: 'The Session Provider Library, a collection of functions and internals to provide more advanced ways of dealing with sessions in PHP. It provides means to get more user-agent information, store sessions on various persistence platforms, and tracing options', correct: false }
- { value: 'The Sandbox Process Library, an environment designed to run PHP in a completely isolated way to test dangerous or potentially problematic code without risking compromising the rest of the server. I/O operations are completely disabled among other features', correct: false }
- { value: 'The Service Priority List, a set of functions to register classes and objects as services and define their loading priority, for performance optimization purposes.', correct: false }
help: 'https://www.php.net/manual/en/book.spl.php'
-
uuid: 1eebf878-8ba3-6154-81ff-99d84c92580c
question: 'Is the __call feature enabled by default?'
answers:
- { value: 'No', correct: true }
- { value: 'Yes', correct: false }
help: 'https://symfony.com/doc/current/components/property_access/introduction.html#magic-call-method'
-
uuid: 1eebf878-8ba3-653c-8129-99d84c92580c
question: "Consider the following code snippet: trigger_error('This method is deprecated.'); Which of the following is valid way to catch and process errors that were triggered with the trigger_error() function?"
answers:
- { value: "try { trigger_error('This method is deprecated.'); } catch (\\Error $e) { // do something }", correct: true }
- { value: 'set_error_handler(function ($level, $message, $file, $line, array $vars = []) { error_log($message); }))', correct: false }
- { value: '$errors = get_triggered_errors();', correct: false }
- { value: "try { trigger_error('This method is deprecated.'); } catch (\\Exception $e) { // do something ... }", correct: false }
help: 'https://php.net/manual/en/function.error-log.php'
-
uuid: 1eebf878-8ba3-673a-a520-99d84c92580c
question: "Given the following code, what will be displayed? $a = (object) ['a' => 'a']; $b = (object) ['a' => 'a']; echo $b <=> $a;"
answers:
- { value: '0', correct: true }
- { value: '1', correct: false }
- { value: '-1', correct: false }
help: 'https://www.php.net/manual/en/language.operators.comparison.php'
-
uuid: 1eebf878-8ba3-6dc0-bb50-99d84c92580c
question: 'What is the most recommended way to count the number of occurences of each unique value in the following array? $a=[1,1,2,3,4,4,5,6,6,6,3,2,2,2];'
answers:
- { value: '$ = array_unique($a);$k = array_fill(0,count($k), 0);$n = array_combine($k, $v);reset($a);for($i =0; $i < count($a); $i++){++$n[current($a)];', correct: false }
- { value: '$n = array_count_values($a);', correct: true }
- { value: '$n = count($a);', correct: false }
- { value: '$n = array_total_values($a);', correct: false }
- { value: '$ = array_unique($a);$k = array_fill(0,count($k), 0);$n = array_combine($k, $v);foreach( $a as $i){ ++$n[$i];}', correct: false }
help: 'https://php.net/manual/en/function.array-count-values.php'
-
uuid: 1eebf878-8ba3-6e56-af20-99d84c92580c
question: 'Which of the following variables is not serializable to JSON with the json_encode() native function?'
answers:
- { value: "$data ={ 'full_name' =>'Pierre Dupont' ,'location'=>[ 'city' =>'Paris' , 'country' =>'France' ]];", correct: false }
- { value: "$data = new SomeClass('some string' );", correct: false }
- { value: "$data = 'foo bar ';", correct: false }
- { value: '$data = function ($content){ return (strtoupper(strip_tags(content)));};', correct: true }
help: 'https://php.net/manual/en/book.json.php'
-
uuid: 1eebf878-8ba3-6f78-8a74-99d84c92580c
question: 'Which interface should be implemented when putting together all the required parts (token, provider, listener) for a custom authentication system ?'
answers:
- { value: Symfony\Component\Security\Guard\GuardAuthenticatorInterface, correct: false }
- { value: Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface, correct: false }
- { value: Sensio\Bundle\FrameworkExtraBundle\EventListener\SecurityListenerInterface, correct: false }
- { value: Symfony\Component\Security\Http\Authenticator\AbstractAuthenticator, correct: true }
help: 'https://symfony.com/doc/current/security/custom_authenticator.html'
-
uuid: 1eebf878-8ba4-6dc4-8bee-99d84c92580c
question: 'Which encryption means is used to secure credentials when authenticating an HTTP request with the HTTP Basic mechanism?'
answers:
- { value: 'Asymmetric-key encryption', correct: false }
- { value: 'Hashing (md5, sha1, etc.)', correct: false }
- { value: 'Credentials are not encrypted and transmitted in plain text in the HTTP request.', correct: false }
- { value: 'Symmetric-key encryption', correct: false }
- { value: 'Credentials are not encrypted but only Base64 encoded.', correct: true }
help: 'https://en.wikipedia.org/wiki/Basic_access_authentication'
-
uuid: 1eebf878-8ba4-6e14-8119-99d84c92580c
question: 'Can interfaces inherit from other interfaces in PHP?'
answers:
- { value: 'Yes', correct: true }
- { value: 'No', correct: false }
help: 'https://php.net/interfaces'
-
uuid: 1eebf878-8ba4-6f04-8c84-99d84c92580c
question: 'How do you remove an element with the key 0 from the array $numbers?'
answers:
- { value: '$numbers[0] = null;', correct: false }
- { value: 'unset($numbers[0]);', correct: true }
- { value: array_pop($numbers);, correct: false }
- { value: array_shift($numbers);, correct: false }
help: 'https://php.net/manual/en/function.unset.php'
-
uuid: 1eebf878-8ba6-6868-a41d-99d84c92580c
question: 'Since which PHP version can you use generators ?'
answers:
- { value: 'PHP 5.3', correct: false }
- { value: 'PHP 7.0', correct: false }
- { value: 'PHP 5.6', correct: false }
- { value: 'PHP 5.4', correct: false }
- { value: 'PHP 5.5', correct: true }
help: 'https://www.php.net/ChangeLog-5.php'
-
uuid: 1eeda3fc-6f1f-6b00-ba24-216aef5bea70
question: 'What is the purpose of the Chain User Provider ?'
answers:
- { value: 'It combines two or more providers to create a new user provider. sorted they are looked one after the other until user is found', correct: true }
- { value: 'This user provider stores all user information in a configuration file, including their passwords.', correct: false }
- { value: 'User Access are stored in a Chain software like Stackifor.', correct: false }
help: 'https://symfony.com/doc/current/security/user_providers.html#chain-user-provider'
-
uuid: 1eedb041-7713-6f86-9b4d-9d3b2d641bb6
question: 'Why might you pass false to $security->logout(false) in the Security component?'
answers:
- { value: 'To disable CSRF protection', correct: true }
- { value: 'To disable the default redirection', correct: false }
- { value: 'To disable the firewall', correct: false }
- { value: 'To limit login attempts, preventing the user from logging in for 5 minutes', correct: false }
help: 'https://symfony.com/doc/current/security.html#logout-programmatically'
-
uuid: 1eee6d98-7a23-6338-9026-cd57d9ba16db
question: 'Where can be set an attribute whith readonly property ? in php8.1'
answers:
- { value: 'in the _construct method', correct: true }
- { value: 'in a setter method', correct: false }
- { value: 'at the attribute declaration', correct: false }
help: 'https://www.php.net/manual/en/language.oop5.properties.php'
-
uuid: 1ef91ee9-2c61-6638-a132-0bd629c34f6d
question: "Which native function should be used to generate a cryptographically secure random integer?"
answers:
- { value: "random_int()", correct: true }
- { value: "mt_rand()", correct: false }
- { value: "rand()", correct: false }
- { value: "lcg_value()", correct: false }
help: 'https://www.php.net/manual/en/ref.random.php'