1. Programming Basics

Description

TYPO3 TYPO3 CD 2020 (zweite Auflage) (1. Programming Basics) Quiz on 1. Programming Basics, created by Ma Hi on 25/03/2021.
Ma Hi
Quiz by Ma Hi, updated more than 1 year ago
Ma Hi
Created by Ma Hi over 3 years ago
10
0

Resource summary

Question 1

Question
What are valid PHP namespaces for TYPO3 extensions? (2)
Answer
  • \typo3\MyExtension
  • \TYPO3\CMS\MyExtension
  • \VendorName\MyExtension
  • \Symfony\Console
  • \vendor_name\my_extension
  • \AwesomeNerds\my_extension

Question 2

Question
What are “return type declarations”? (2)
Answer
  • They declare the type of an extension, e.g. “frontend plugin” or “backend module”.
  • They specify how many methods a PHP class may contain.
  • They specify the maximum time allowed to return an object.
  • They specify the type of the value that is returned from a function or method.
  • Return values can be marked as “nullable” by prefixing the type name with a question mark since PHP version 7.1.

Question 3

Question
What does the “strict mode” do in PHP and how do you enable it? (2)
Answer
  • The strict mode ensures that a variable passed to a function must exactly be of the declared type.
  • The strict mode allows developers to restrict access to class properties.
  • With the strict mode enabled, class names must be written in lowerCamelCase.
  • The strict mode can be enabled and disabled in the TYPO3 Install Tool as required.
  • The strict mode can be enabled by adding the line declare(strict_types = 1); at the top of the PHP file.

Question 4

Question
Which statements about the PHP strict mode in TYPO3 extensions are correct? (3)
Answer
  • The PHP strict mode must not be used in any TYPO3 extension files at all (TYPO3 v9 LTS does not support this feature).
  • The PHP strict mode must not be enabled in the file ext_tables.php.
  • The PHP strict mode must not be enabled in the file ext_localconf.php.
  • The PHP strict mode must not be enabled in any TCA files under Configuration/TCA/.
  • If the PHP strict mode is enabled in controller classes, the output of the action methods is not cached.

Question 5

Question
Which standards should be followed when you develop TYPO3 extensions or contribute to the TYPO3 core? (3)
Answer
  • PHP coding guidelines, following the PSR-2 standard.
  • Style Guide for PHP Code (PEP-8).
  • Specific guidelines apply to PHP file and directory names.
  • The X-Mas Standard Policy applies to XLIFF language files.
  • The Airbnb JavaScript Style Guide should be used for JavaScript files.
  • TYPO3 is open-source software and therefore no coding guidelines exist.

Question 6

Question
Which coding rules apply in TYPO3 according to the PSR standard? (2)
Answer
  • Opening curly braces for classes must go on the same line.
  • Opening curly braces for classes must go on the next line.
  • Opening curly braces for if-statements must go on the same line.
  • Opening curly braces for if-statements must go on the next line.
  • TYPO3 does not adhere to any coding guidelines.

Question 7

Question
Which coding rules apply in TYPO3 according to the PSR standard? (3)
Answer
  • The maximum length of a line must not exceed 80 characters.
  • Code must use four spaces for indenting, not tabs.
  • A PHP file must not contain the closing PHP tag ?> at the end.
  • Spaces are not allowed at the end of lines.
  • Spaces are not allowed after a comma.

Question 8

Question
What issues in the following code violate the official TYPO3 coding guidelines? (2)
Answer
  • The namespace declaration must not start with a backslash \.
  • The opening curly bracket for PHP classes must go on the next line.
  • The opening curly bracket for methods must be on the same line as the method definition.
  • The comments with the annotation must start with /* rather than /**.

Question 9

Question
What issues in the following code violate the official TYPO3 coding guidelines? (2)
Answer
  • The fully qualified class name (FQCN) must always be used.
  • Property names must be written in lowerCamelCase.
  • There must not be a return type hint “string”.
  • There must not be a closing ?> tag.

Question 10

Question
Which coding rules apply to JavaScript files in TYPO3 projects? (2)
Answer
  • JavaScript files of the TYPO3 core must be located under typo3conf/assets/javascript/.
  • JavaScript files in extensions should be located under Resources/Public/JavaScript/.
  • TABs should be used for line indenting.
  • Strings should always use double-quotes (").
  • File endings of JavaScript files should be .js.

Question 11

Question
Which statements about semantic versioning are correct? (2)
Answer
  • A versioning scheme following semantic versioning has exactly two numbers separated by dots, e.g. 1.2.
  • A versioning scheme following semantic versioning has exactly three numbers separated by dots, e.g. 1.2.3.
  • A versioning scheme following semantic versioning has exactly four numbers separated by dots, e.g. 1.2.3.4.
  • The last number represents “patch” versions when developers make backwards-compatible bug fixes.
  • The first number indicates if a release is a long-term support release (LTS).

Question 12

Question
Which statements about semantic versioning are correct? (2)
Answer
  • Semantic versioning dictates that LTS-releases are marked appropriately, e.g. 1.2.3-lts.
  • When developers fix a bug and release a backwards-compatible version, the patch number of the version should be increased.
  • Semantic versioning is part of the PSR-2 coding standard.
  • Semantic versioning introduces conventions about breaking changes and aim to make upgrade dependencies safe.

Question 13

Question
Which statements about the composer.json file of a TYPO3 extension are correct? (2)
Answer
  • The property type must be set to typo3-cms-extension.
  • The property type must be set to plugin, if the extension provides a frontend plugin.
  • The extension version is required and must be set with the property version.
  • PHP classes should be auto-loaded with the appropriate namespace and path information.

Question 14

Question
How do you make sure that a Composer package with a specific version does not get updated when you run the composer update command? (1)
Answer
  • By adding a file DO_NOT_UPDATE to the extension directory.
  • By adding the Composer namespace of the extension to the update-lock property in the composer.json file.
  • By setting the exact version number with composer require.
  • This is not possible, because composer update always forces updates.

Question 15

Question
How do you install version 9.10.2 of the extension “Extension Builder” as an additional extension in an existing TYPO3 instance using Composer, assuming you have not added this package as a requirement yet? (1) Note: the Composer namespace of the extension reads “friendsoftypo3/extension-builder”.
Answer
  • composer install friendsoftypo3/extension-builder:9.10.2
  • composer install friendsoftypo3/extension-builder --version 9.10.2
  • composer require friendsoftypo3/extension-builder/9.10.2
  • composer require friendsoftypo3/extension-builder:9.10.2
  • composer require --version=9.10.2 --vendor=friendsoftypo3 extension-builder

Question 16

Question
What needs to be configured to auto-load PHP classes of a TYPO3 extension in a Composer-based setup? (1)
Answer
  • The PSR-4 autoload information needs to be added to the file ext_localconf.php: $GLOBALS['TYPO3_CONF_VARS']['autoload'][$_EXTKEY] = [ "psr-4" => [ "Vendor\\MyExtension\\": "Classes/" ] ];
  • The PSR-4 autoload information needs to be added to the file composer.json: "autoload": { "psr-4": { "Vendor\\MyExtension\\": "Classes/" } }
  • A configuration file autoload.yaml in the typo3conf/ directory.
  • A configuration file autoload.php in the typo3temp/ directory.

Question 17

Question
You want to update a Composer package that uses semantic versioning. Which version constraint do you use to get bug fixes only? (2)
Answer
  • =1.2.3
  • ^1.2.3
  • ~1.2.3
  • 1.2.*
  • =bugfix

Question 18

Question
You want to update a Composer package that uses semantic versioning. Which version constraint do you use if you want non-breaking updates only? (1)
Answer
  • =1.2.3
  • ^1.2.3
  • ~1.2.3
  • *1.2.3

Question 19

Question
Which statements about importing class names with the help of the use-statement are correct? (3)
Answer
  • They should be used in TCA files located at Configuration/TCA/.
  • They must not be used in the ext_tables.php file.
  • They must not be used in the ext_localconf.php file.
  • They can not be used for type annotations of Extbase model properties.
  • Importing class names require PHP version 7.2 at least.
  • Importing class names only work, if this feature is enabled in the Install Tool.

Question 20

Question
Where can you import class names with the help of the use-statement? (2)
Answer
  • In repository class definitions, when extending the class TYPO3\CMS\Extbase\Persistence\Repository.
  • In ext_localconf.php files of extensions.
  • In type annotations of Extbase controller action arguments.
  • Importing class names is not supported by TYPO3 and Extbase at all.

Question 21

Question
Which of the following DocBlock and inline comments are valid by convention? (2)
Answer
  • /** * @param $blog \Vendor\MyExtension\Domain\Model\Blog */
  • /** * @param \Vendor\MyExtension\Domain\Model\Blog $blog */
  • /** @var $blog \Vendor\MyExtension\Domain\Model\Blog */
  • // @var $blog \Vendor\MyExtension\Domain\Model\Blog
Show full summary Hide full summary

Similar

Romeo and Juliet: Act by Act
PatrickNoonan
10 Study Techniques
PatrickNoonan
3. The Bolshevik's Seizure of Power
ShreyaDas
Geography Coasts Questions
becky_e
GCSE History: The 2014 Source Paper
James McConnell
GCSE AQA Biology 1 Nerves & Hormones
Lilac Potato
How did the Cold War develop?
E A
Animal Farm CONTEXT
Lydia Richards2113
A-LEVEL ENGLISH LANGUAGE : Key Theorists
Eleanor H
How the European Union Works
Sarah Egan
Unit 1.1 Systems Architecture
Mathew Wheatley