Questions tagged [php-7.2]

Use this tag for version-specific issues relating specifically to PHP 7.2.Use with the [php] tag

Deprecations: https://wiki.php.net/rfc/deprecations_php_7_2

GA release is scheduled for 2017-11-30: https://wiki.php.net/todo/php72#timetable

724 questions
281
votes
3 answers

What do strict types do in PHP?

I've seen the following new line in PHP 7, but nobody really explains what it means. I've googled it and all they talk about is will you be enabling it or not like a poll type of thing. declare(strict_types = 1); What does it do? How does it affect…
sufuko
  • 2,829
  • 2
  • 8
  • 3
73
votes
8 answers

Silence "Declaration ... should be compatible" warnings in PHP 7

After upgrade to PHP 7 the logs almost choked on this kind of errors: PHP Warning: Declaration of Example::do($a, $b, $c) should be compatible with ParentOfExample::do($c = null) in Example.php on line 22548 How do I silence these and only these…
sanmai
  • 29,083
  • 12
  • 64
  • 76
66
votes
1 answer

What does question mark (?) before type declaration means in php (?int)

I have seen this code in https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Console/Output/Output.php line number 40 they are using ?int. public function __construct(?int $verbosity = self::VERBOSITY_NORMAL, bool $decorated =…
Jagadesha NH
  • 2,529
  • 2
  • 23
  • 41
49
votes
3 answers

Docker-php-ext-install mcrypt missing folder

I try to install mcrypt in my docker image based on php:7.2-apache. Therefore I use the RUN-Command from the documentation and also answerd here but I receive this error: error: /usr/src/php/ext/mcrypt does not exist usage:…
Gerrit
  • 2,515
  • 5
  • 38
  • 63
36
votes
7 answers

Install phpredis MAC OSX

Can anyone help me install php-redis in MAC OSX . brew install php-redis not working. pecl install php-redis also not working getting - invalid package name/package file "php-redis". Homebrew Error: homebrew_error
Ankit Jain
  • 603
  • 2
  • 6
  • 17
36
votes
2 answers

How do I use the Argon2 algorithm with password_hash?

So I heard that PHP 7.2 introduced the new Argon2 algorithm. But I'm confused on how I can use it with my existing code. For instance, I have this $password = password_hash('somepassword', PASSWORD_DEFAULT, ['cost' => 12]); Does PASSWORD_DEFAULT…
Machavity
  • 30,841
  • 27
  • 92
  • 100
31
votes
2 answers

How to install PHP 7.2 on macOS Big Sur using Homebrew?

I want to install PHP 7.2 on MacBook Pro M1, macOS Big Sur (11.5.2). I already read an article (How To Install a PHP 7.2 on macOS 10.15 Catalina Using Homebrew and PECL), but it doesn't work for me. I used Homebrew to install PHP 7.2 using this…
mustafa hasria
  • 460
  • 1
  • 4
  • 14
26
votes
4 answers

PHP 7.2 Warning: "Cannot change session name when session is active"

Since PHP on our server was upgraded to 7.2 from 7.0. I am getting the following warning (which leads to error) if a new deployment is done. The reason is probably, that old sessions get invalid after deployment. Warning: session_name(): Cannot…
Blackbam
  • 17,496
  • 26
  • 97
  • 150
16
votes
1 answer

PHP 7.2 - Warning: count(): Parameter must be an array or an object that implements Countable

I just upgraded my PHP installation from version 5.6 to 7.2. I used the count() function on my login page like so: if (!empty($_POST['username']) && !empty($_POST['password'])): $records = $conn->prepare('SELECT id,username,password FROM users…
Marwan Khaled
  • 323
  • 1
  • 2
  • 8
13
votes
3 answers

count() emitting an E_WARNING

Prior to PHP 7.2 using count() on a scalar value or non-countable object would return 1 or 0. For example: https://3v4l.org/tGRDE var_dump(count(123)); //int(1) var_dump(count(new stdclass)); //int(1) var_dump(count('hello world')); …
Toskan
  • 13,911
  • 14
  • 95
  • 185
12
votes
2 answers

PhpStorm 2018 - how to inspect whole project to php 7.2 compatibility?

I have a project long time developed in PhpStorm and fully compatible with php 5.6. In any case it work and deployed on server with php 5.6. How to inspect with PhpStorm 2018 this whole project to php 7.2 compatibility and only highlight those…
slava
  • 791
  • 1
  • 11
  • 26
12
votes
6 answers

PHP 7.2 - How to create anonymous function dynamically when having function body in a string

How do I create an anonymous function dynamically when I have function body in a string. For e.g. $user = "John Doe"; $body = "echo 'Hello' . $user;"; $myFunct = function($user) {$body}; // How do I have function body here from…
Aditya Hajare
  • 1,372
  • 1
  • 15
  • 24
12
votes
6 answers

Phpmyadmin export issue: count(): Parameter must be an array or an object that implements Countable

I'm getting issue with PhpMyAdmin when exporting any database. It is coming every time. Please help me if anyone has solution to resolve all these types of issues in PhpMyAdmin
Lakhwinder Singh
  • 5,536
  • 5
  • 27
  • 52
11
votes
5 answers

Laravel: [ErrorException] "continue" targeting switch is equivalent to "break". during "composer install"

When I run ... composer install ... on a server with PHP and nginx installed. I get the following exception: [ErrorException] "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? How can I fix this?
Kumanan
  • 420
  • 1
  • 4
  • 11
11
votes
1 answer

phpunit tests run using PHP7.2 and 7.1 are 3x slower than when run using PHP7.0

If I run my tests using PHP7.2 or PHP7.1 they are about 3x slower than if I run them using PHP7.0. Is there anyway to get to the bottom of why this is happening? Even when I run the test suites (Feature & Unit) separately I still see the slow down.…
Michael
  • 4,282
  • 9
  • 55
  • 89
1
2 3
48 49