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

733 questions
197
votes
2 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
  • 1,989
  • 2
  • 6
  • 3
70
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
  • 23,569
  • 11
  • 54
  • 73
40
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
  • 1,969
  • 5
  • 28
  • 48
39
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,145
  • 2
  • 18
  • 33
28
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
  • 28,730
  • 25
  • 78
  • 91
22
votes
3 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
  • 12,200
  • 19
  • 71
  • 117
19
votes
3 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
  • 414
  • 1
  • 4
  • 17
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
12
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
  • 11,184
  • 12
  • 75
  • 144
11
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,048
  • 1
  • 11
  • 22
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
  • 3,822
  • 9
  • 45
  • 84
10
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
  • 309
  • 1
  • 3
  • 8
9
votes
5 answers

Install php72 on MacOS using brew

I'm trying to install php72 using brew. Actually when I do brew install php72 it's downloading "https://homebrew.bintray.com/bottles/php-7.3.0.mojave.bottle.tar.gz". So when I check php version it's showing me PHP 7.3.0 (cli). How can I install…
Ugo Lfe
  • 605
  • 5
  • 18
9
votes
1 answer

PHP Incorrect variable declaration

Debugging legacy code and I have a strange issue. The legacy code is being moved to PHP 7.2. I don't know which version of PHP it was originally written for but it does work in PHP 5.6. Below is my example of the problem... $variable =…
itsliamoco
  • 824
  • 7
  • 26
9
votes
5 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,084
  • 5
  • 24
  • 47
1
2 3
48 49