|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2019-02-21 01:19 UTC] mberchtold at gmail dot com
Description:
------------
I'm trying to preload zend framework 3. A lot of the following warnings are reported and the class is not preloaded:
PHP Warning: Can't preload class Zend\Db\Sql\Insert with unresolved constants
When I inspect the Zend\Db\Insert class, there are no undefined constants.
Preloading only the file itself does not issue any warnings, only after all the dependent classes are preloaded.
I could not figure out a minimal reproducible example, other than preloading some files from zend\db.
Test script:
---------------
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.optimization_level=-1
opcache.preload={PWD}/preload_undef_const_3.inc
preload_undef_const_3.inc:
<?php
$basedirectory = 'C:/test/';
// dependent classes
opcache_compile_file($basedirectory . 'vendor/zendframework/zend-db/src/Adapter/Platform/PlatformInterface.php');
opcache_compile_file($basedirectory . 'vendor/zendframework/zend-db/src/Sql/SqlInterface.php');
opcache_compile_file($basedirectory . 'vendor/zendframework/zend-db/src/Sql/AbstractSql.php');
opcache_compile_file($basedirectory . 'vendor/zendframework/zend-db/src/Sql/PreparableSqlInterface.php');
opcache_compile_file($basedirectory . 'vendor/zendframework/zend-db/src/Sql/AbstractPreparableSql.php');
// actual class
opcache_compile_file($basedirectory . 'vendor/zendframework/zend-db/src/Sql/Insert.php');
Expected result:
----------------
No warning
Actual result:
--------------
PHP Warning: Can't preload class Zend\Db\Sql\Insert with unresolved constants
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Dec 07 22:00:01 2025 UTC |
Here is a minimal repro: <?php class Foo { protected $prop; } class Bar extends Foo { protected $prop = self::FOOBAR; const FOOBAR = 42; } The problem is that the constant is resolved against the wrong class, because we're reusing a property slot from the parent.