All fields

“Type Declarations & Strict Types” in Information Technology

27 questions across 1 technology.

Information Technology

27 questions in 1 technology

#QuestionTechnologyTopicLevel
1What does declaring strict_types=1 at the top of a PHP file actually change about how type declarations are enforced? PHP › Type Declarations & Strict TypesPHPType Declarations & Strict TypesBeginner
2What are type declarations in PHP, and how do they let you specify what kind of value a function parameter or return value should be? PHP › Type Declarations & Strict TypesPHPType Declarations & Strict TypesBeginner
3What are nullable types and union types in PHP, and how do they let you express that a value could be one of several different possible types? PHP › Type Declarations & Strict TypesPHPType Declarations & Strict TypesIntermediate
4How do type declarations improve the effectiveness of static analysis tools and IDE autocompletion when working within a codebase? PHP › Type Declarations & Strict TypesPHPType Declarations & Strict TypesIntermediate
5How does PHP's type variance, specifically covariance and contravariance, affect how return types and parameter types can be safely changed when overriding a method in a child class? PHP › Type Declarations & Strict TypesPHPType Declarations & Strict TypesAdvanced
6What are PHP 8's enums, and how do they provide a more type safe alternative to using plain class constants for representing a fixed set of related values? PHP › Type Declarations & Strict TypesPHPType Declarations & Strict TypesAdvanced
7What are readonly properties in PHP, and how do they help you create objects whose internal state cannot be accidentally changed after they are first constructed? PHP › Type Declarations & Strict TypesPHPType Declarations & Strict TypesIntermediate
8How does PHP's type coercion behave differently in strict types mode compared to the default coercive mode, and what are the implications for function argument and return type validation? PHP › Basics & TypesPHPBasics & TypesAdvanced
9What are the basic data types available in PHP? PHP › Basics & TypesPHPBasics & TypesBeginner
10What is type juggling in PHP, and how does it affect comparisons between values of different types? PHP › Basics & TypesPHPBasics & TypesIntermediate
11How do PHP's integer and float types handle precision limitations, and what issues can arise when performing arithmetic with floating point numbers? PHP › Basics & TypesPHPBasics & TypesAdvanced
12How do function type declarations and return type declarations improve code reliability, and how does PHP handle nullable and union types in function signatures? PHP › Functions & ScopePHPFunctions & ScopeAdvanced
13How do union types and intersection types in PHP 8 provide more expressive and precise type declarations than were previously possible? PHP › PHP 8 Features (Attributes, Enums, Match, Nullsafe Operator)PHPPHP 8 Features (Attributes, Enums, Match, Nullsafe Operator)Advanced
14How do type declarations and PHPDoc comments help a static analysis tool understand your code more accurately and catch more potential issues? PHP › Static Analysis (PHPStan & Psalm)PHPStatic Analysis (PHPStan & Psalm)Intermediate
15How do PHP's string comparison functions and operators handle edge cases involving numeric looking strings, and why is strict, type aware comparison important when working with strings that could be misinterpreted as numbers? PHP › Strings & String FunctionsPHPStrings & String FunctionsAdvanced
16What are analysis levels in PHPStan, and why would a project typically start at a lower level before gradually increasing strictness? PHP › Static Analysis (PHPStan & Psalm)PHPStatic Analysis (PHPStan & Psalm)Beginner
17How do route parameters and route constraints let you capture dynamic segments of a URL while also restricting what values are actually considered a valid match? PHP › Routing & MiddlewarePHPRouting & MiddlewareIntermediate
18How do enums, introduced in PHP 8.1, provide a more type safe alternative to using class constants for representing a fixed set of related values? PHP › Constants & SuperglobalsPHPConstants & SuperglobalsAdvanced
19How do you define and call a basic function in PHP, and what are function parameters and return values? PHP › Functions & ScopePHPFunctions & ScopeBeginner
20What is static analysis, and how do tools like PHPStan and Psalm help catch bugs in PHP code before it is even run? PHP › Static Analysis (PHPStan & Psalm)PHPStatic Analysis (PHPStan & Psalm)Beginner
21What are the different ways to create and combine strings in PHP, and how does string concatenation using the dot operator work? PHP › Strings & String FunctionsPHPStrings & String FunctionsBeginner
22What are assertions in PHPUnit, and how do commonly used assertions like assertEquals and assertTrue let you verify expected behavior within a test? PHP › Unit Testing with PHPUnitPHPUnit Testing with PHPUnitBeginner
23How does the readonly property modifier introduced in PHP 8.1 help enforce immutability for specific class properties? PHP › OOPPHPOOPIntermediate
24How do constructor property promotion, introduced in PHP 8, reduce boilerplate code when defining a class with several properties initialized directly through its constructor? PHP › PHP 8 Features (Attributes, Enums, Match, Nullsafe Operator)PHPPHP 8 Features (Attributes, Enums, Match, Nullsafe Operator)Intermediate
25How do commonly used string functions like strlen, substr, str_replace, and trim help with everyday text processing tasks in PHP? PHP › Strings & String FunctionsPHPStrings & String FunctionsIntermediate
26How does the sprintf function let you build formatted strings with precise control over things like decimal places, padding, and alignment? PHP › Strings & String FunctionsPHPStrings & String FunctionsIntermediate
27How do data providers in PHPUnit let you run the exact same test logic repeatedly against many different sets of input data, without duplicating the test method itself? PHP › Unit Testing with PHPUnitPHPUnit Testing with PHPUnitAdvanced