php-8.1 Questions

3

Solved

I am trying to enable sqlsrv drivers for php8.1 on Ubuntu 20.0. It is not showing the extension in phpinfo(). When trying to check the sqlsrv module with commmand php -m, the output is like this: ...
Quean asked 13/11, 2022 at 15:31

2

Is there any way, using reflection or otherwise, to change a readonly property that has already been set? We sometimes do that in tests, and we don't want to avoid using readonly props just for tes...
Hon asked 18/3, 2022 at 17:12

4

Solved

I am just getting started on upgrading my code to be php 8.1 compatible. I have many pieces of code where I am passing potentially null values to internal functions. if (strlen($row) > 0) { ......
Fogarty asked 4/1, 2022 at 4:18

4

Solved

I have basic enum enum Fruit { case APPLE; case ORANGE; case BANANA; } and some function that uses typing with that enum: function eatFruit (Fruit $fruit) { // do stuff } and variable with un...
Popelka asked 9/1, 2022 at 20:25

9

Solved

PHP 8.1 is almost getting released, including support for Enumerations. I was testing some of the enum functionality and couldn't find much documentation about it. Hence my question: how do I get a...
Infancy asked 1/11, 2021 at 7:2

3

I have a project that is using DDEV to run an instance with PHP 8.1. I needed to introduce the pdo_sqlsrv extension to the package, so I added a Dockerfile in the .ddev/web-build/ directory that in...
Rosio asked 3/3, 2023 at 19:48

3

Solved

I am trying to install the phpize on Ubuntu 20.04 PHP 8.1 I tried following commands but no luck sudo apt-get install php8.0-dev E: Unable to locate package php8.0-dev E: Couldn't find any packag...
Plasticize asked 7/6, 2022 at 11:38

4

Solved

Is there a type hint in PHP 8.3 which allows using ExampleClass[] for declaring it is an array of objects of the class ExampleClass? In my specific case, ExampleClass is called Task What I want bu...
Desultory asked 25/2, 2022 at 11:30

14

Solved

PHP 8.1 has deprecated passing null as parameters to a lot of core functions. My main problem is with functions like htmlspecialchars(php) and trim(php), where null no longer is silently converted ...
Anthea asked 1/4, 2022 at 13:0

5

I´m trying to create an php 8.1 enum from a dynamic name. Seems not to be possible. So given an enum enum Foo { case bar; } The following works of course: Foo::bar While this doesn´t: $name = &qu...
Loper asked 7/2, 2022 at 11:44

4

Solved

How can I tell if a variable is of type enum? I have installed PHP 8.1 on my Ubuntu 20.04. I'm testing the new "enum" types. Is something like that possible? is_enum($var) gettype($var) =...
Rimini asked 5/12, 2021 at 17:57

2

Solved

Versions : PHP : 8.1 PHPUnit : 9.5.21 Symfony 6.1 When the following test is run by PhpUnit, I get an error about the session not being able to be started. Does anyone have an idea of the problem...
Bergson asked 20/7, 2022 at 11:55

2

I'm running codeigniter 4.1.5 and php 8.1.0 and when i try to input data this is the error i got Uncaught ErrorException: strtolower(): Passing null to parameter #1 ($string) of type string is depr...
Congregationalism asked 9/12, 2021 at 5:24

3

We are upgrading to PHP 8.1. A new feature is that an undefined array key throws a warning. Unfortunately this interferes with the ability to easily use associative arrays such as $_SESSION v...
Ruelas asked 7/2, 2022 at 20:40

3

Is it possible to run Wordpress on PHP 8.1 right now? I have installed PHP 8.1 in XAMPP, but I can't get Wordpress to work. I get this error message: [23-Nov-2021 18:44:43 UTC] PHP Fatal error: Un...
Divertimento asked 23/11, 2021 at 20:26

2

Solved

In PHP 8.1, the following code, which worked in previous versions: class Example implements Countable { public function count() { return 42; } } Raises a deprecation notice: Deprecated: Return...
Weddle asked 15/2, 2022 at 21:41

4

Solved

Coming across some deprecated errors with 8.1 I want to address. PHP Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in... //explode uids into an ar...
Hypnotist asked 13/2, 2022 at 4:31

4

Solved

After updating PHP 7.4 to PHP 8.1 RC5, PHP has stopped working on my machine and produces following error: PHP Warning: PHP Startup: ^(text/|application/xhtml+xml) (offset=0): unrecognised compile...
Extreme asked 8/11, 2021 at 16:14

3

I am wondering why it is not possible to provide an __toString implementation for enum. IDE says "Enum may not include '__toString'". However it was the first thing I thought about once I...
Maitund asked 5/12, 2021 at 15:25

1

Solved

Since PHP 8.1 the native support for readonly properties arrived. But we already have constants with visibilities. Please help me to answer these two questions: Which differences are between using...
Tribe asked 15/5, 2022 at 12:27

4

Solved

I search for a simple solution to get the case of an enum by a string. There are BackedEnums. For example: <?php enum Status: string { case OK = "OK"; case FAILED = "FAILED&quot...
Yama asked 17/12, 2021 at 13:17

2

Solved

I want to iterate over enum: enum Shapes { case RECTANGLE; case SQUARE; case CIRCLE; case OVAL; } I get Shapes const not defined if I do this: foreach (Shapes as $shape) { } The best solution...
Christalchristalle asked 6/6, 2022 at 6:16

2

Solved

My Code: namespace App\Enum; enum HomeStatus: string { case RENT = 'rent'; case MOVE_IN = 'move_in'; case SOLD = 'sold'; case COMING_SOON = 'coming_soon'; } The code above is executing and wo...
Gymnosperm asked 7/1, 2022 at 13:2

1

We are upgrading PHP to version 8.1. Using MS Sql Server DB. It all seems to work correctly but I see repeated messages in the log file: [03-Feb-2022 11:51:18 America/New_York] PHP Deprecated: Aut...
Intention asked 8/2, 2022 at 14:9

1

Solved

PHP 8.1 introduces readonly class properties. For example, before I would write: class User { public string $name; public function __construct(string $name) { $this->name = $name; } publi...
Astrahan asked 10/1, 2022 at 10:6

© 2022 - 2024 — McMap. All rights reserved.