|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2019-02-11 19:16 UTC] requinix@php.net
-Status: Open
+Status: Not a bug
-Package: Performance problem
+Package: *General Issues
[2019-02-11 19:16 UTC] requinix@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 21:00:01 2025 UTC |
Description: ------------ PHP 7.2.14 (cli) (built: Jan 8 2019 14:05:15) ( NTS ) [PHP Modules] apcu bcmath bz2 calendar Core ctype curl date dom exif fileinfo filter ftp gd geoip gettext hash iconv igbinary imagick intl json ldap libxml mbstring mcrypt memcached mongodb msgpack mysqli mysqlnd openssl pcntl pcre PDO pdo_mysql pdo_sqlite Phar posix readline redis Reflection session shmop SimpleXML soap sockets SPL sqlite3 standard sysvmsg sysvsem sysvshm tokenizer wddx xdebug xml xmlreader xmlrpc xmlwriter xsl Zend OPcache zip zlib [Zend Modules] Xdebug Zend OPcache Script: we do not have in the test script an exception, since empty() says, in this particular case, that randomProperty of Consumer instance is empty, meanwhile in_array() works correctly and goes through an array [1,2]. Test script: --------------- class BaseEntity { /** * @var array */ protected $globalStack = []; /** * @param $arg * @param $value */ public function __set($arg, $value): void { if (property_exists($this, $arg)) { $this->{$arg} = $value; } else { $this->globalStack[$arg] = $value; } } /** * @param $arg * @return mixed|null */ public function __get($arg) { if (property_exists($this, $arg) && isset($this->{$arg})) { $value = $this->{$arg}; } elseif (isset($this->globalStack[$arg])) { $value = $this->getGlobalStackValue($arg); } else { $value = null; } return $value; } public function getGlobalStackValue($arg) { return $this->globalStack[$arg]; } } class Consumer extends BaseEntity {} $consumer = new Consumer(); $consumer->randomProperty = [1,2]; if (!empty($consumer->randomProperty) && !in_array(4, $consumer->randomProperty)) { throw new \Exception('whatever'); }