Questions tagged [php-8.2]

For questions specific to the usage and new features of PHP 8.2. Also, include the more generic [php] tag when using this tag.

PHP 8.2 was released in November 2022

A list of features and changes can be found in the migration guide

80 questions
21
votes
3 answers

Is there a type hint for an array of objects of a specific class in PHP 8.2?

Is there a type hint in PHP 8.2 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 but does not work: private Task[] $tasks; My PHPStorm…
WebDevPassion
  • 422
  • 1
  • 4
  • 12
3
votes
5 answers

PHP and PHPUnit: How to invoke method (or function) with wrong parameter type and then to success?

I want to test (with PHPUnit) a method that contains a foreach loop. I want the full path coverage. The original code is little too complex, so I created a minimal example below to illustrate my problem. There are 3 cases for the foreach loop in the…
Michas
  • 8,534
  • 6
  • 38
  • 62
3
votes
3 answers

Imagick Docker Alpine Linux php8.2

I'm trying to install imagick on alpine linux for php8.2 and I don't really understand how to do it. I see that the imagick extension is still in testing. From what I read I can install it by specifying a different repository. However when I do…
Carl Wirkus
  • 523
  • 1
  • 8
  • 19
2
votes
2 answers

How to terminate PHP script due to unsupported PHP version?

Does anyone know how to terminate PHP script with too low unsupported version before an error occurs in the same script (due to calling an unsupported function/feature)? Heres an example with readonly class which was introduced in PHP…
Andrew
  • 1,386
  • 1
  • 9
  • 8
2
votes
3 answers

How to do Dependency Injection in a way that PhpStorm understands it

I'm currently working on a PHP project where I've implemented dependency injection in my code. The code is functioning correctly, but I'm encountering an issue with PhpStorm (version 2023.1) misinterpreting the code, which is causing typehinting to…
2
votes
0 answers

What does starting an Xdebug session do?

TL;DR: I have some PHP code that makes use of deprecated dynamic properties. If E_DEPRECATED is disabled in the .ini, the code: Executes successfully if an xdebug session is triggered Fails (in under a second) with a 502 if an xdebug session is not…
Laef
  • 1,086
  • 2
  • 11
  • 27
2
votes
1 answer

PHP Creation of dynamic property is deprecated, AllowDynamicProperties not working

I'm working with a 3rd party composer library that doesn't currently support PHP 8.2 and trying to add compatibility to my application. The 3rd party package has the following classes: class Configuration { } class ApiClient extends Configuration {…
MattRogowski
  • 726
  • 2
  • 7
  • 22
2
votes
1 answer

Upgrade to PHP 8.2: ksort and krsort changes

I am preparing upgrade to PHP 8.2 on a big application, and obviously going through changes between PHP 8.1 and 8.2. One of the BC breaking changes mentioned HERE is: ksort() and krsort() now do numeric string comparison under SORT_REGULAR using…
callmebob
  • 6,128
  • 5
  • 29
  • 46
1
vote
1 answer

get_option() not returning dB value for users_can_register after upgrading to PHP 8.2 and WP 6.3

I have a crazy bug I cannot figure out. I recently upgraded to PHP 8.2 and Wordpress 6.3. At about the same time, I was trying to prevent spam registrations, so I added reCaptcha to the login and registration page via WordFence plugin (and later…
1
vote
1 answer

php8.2 in ubuntu 18.04 : E: Unable to locate package php8.2

Need some help, I cant install php8.2-fpm in ubuntu 18, heres my commands sudo apt install lsb-release apt-transport-https ca-certificates software-properties-common -y sudo add-apt-repository ppa:ondrej/php sudo apt update sudo apt install…
rkevx21
  • 2,441
  • 5
  • 19
  • 40
1
vote
1 answer

PHP pdflib binary not working and also showing error in compiling

I want to use pdflib for php 8.2 in Alma 9 or Ubuntu 22.04. There is no pecl binary available. I downloaded php_pdflib.so and added it in php.ini. The required functions are available now. But PDF_new() or pdf_new() is not available. I tried to…
srvnk
  • 13
  • 3
1
vote
0 answers

PHP 8.2 Curl OpenSSL SSL_read: error:0A000126 unexpected eof while reading

First off, it sounds like this may be related to https://bugs.php.net/bug.php?id=79589, but I'm using PHP 8.2.5 so whatever fix is implemented doesn't appear to be preventing this. I've looked at other questions related to this error on here without…
MJC
  • 57
  • 9
1
vote
0 answers

How do I compare a csrf Token with a current Session Token in PHP 8?

Perhaps I am doing this wrong for php-fpm PHP 8. It seems to work otherwise on my local test server. Server is Running Apache 2.4 and php-fpm v8.1.15 I have tried changing around the following bootstrap settings: ini_set('session.use_only_cookies',…
1
vote
1 answer

"Cannot use temporary expression in write context" when assigning to prop on class instance defined as constant

The following code snippet will produce an error on PHP 8.2: bar = 'baz'; echo foo->bar; ?> I would expect that an error would not occur, since I am assigning to the prop rather than trying to reassign the…
schoodic
  • 13
  • 3
1
vote
1 answer

Resolve calling class from static parent method

I have to refactor some code from PHP 7 to PHP 8.2. I need to resolve, from a parent static method, the child class that calls it via call_user_func_array. But the syntax of callables has changed in PHP 8.2 and I can't find the correct…
Jomiquel
  • 45
  • 4
1
2 3 4 5 6