Skip to content

[BUG] phpunit.xml中配置SCAN_CACHEABLE会报错 #7688

@aogg

Description

@aogg

Execute the command and paste the result below.

Command: uname -a && php -v && composer info | grep hyperf && php --ri swoole

# Paste the result here.

uname -a && php -v && composer info | grep hyperf && php --ri swoole
Linux 8d8f648f0f7b 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64 Linux
PHP 8.4.14 (cli) (built: Oct 24 2025 01:09:06) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.4.14, Copyright (c) Zend Technologies
    with Zend OPcache v8.4.14, Copyright (c), by Zend Technologies
    with Xdebug v3.4.6, Copyright (c) 2002-2025, by Derick Rethans
Composer could not find a composer.json file in 
To initialize a project, please create a composer.json file. See https://getcomposer.org/basic-usage

Description:

<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" bootstrap="./test/bootstrap.php" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
  <testsuites>
    <testsuite name="Tests">
      <directory suffix="Test.php">./test</directory>
    </testsuite>
  </testsuites>
  <php>
    <env name="APP_ENV" value="local" force="true"/>
    <env name="SCAN_CACHEABLE" value="false" force="true"/>
  </php>
  <source>
    <include>
      <directory suffix=".php">./app</directory>
    </include>
  </source>
</phpunit>


Error in bootstrap script: TypeError:
Hyperf\Di\Annotation\ScanConfig::__construct(): Argument #1 ($cacheable) must be of type bool, string given, called in /www/vendor/hyperf/di/src/Annotation/ScanConfig.php on line 88
#0 /www/vendor/hyperf/di/src/Annotation/ScanConfig.php(88): Hyperf\Di\Annotation\ScanConfig->__construct()
#1 /www/vendor/hyperf/di/src/ClassLoader.php(51): Hyperf\Di\Annotation\ScanConfig::instance()
#2 /www/test/bootstrap.php(26): Hyperf\Di\ClassLoader::init()
#3 /www/vendor/phpunit/phpunit/src/TextUI/Application.php(337): include_once('...')
#4 /www/vendor/phpunit/phpunit/src/TextUI/Application.php(109): PHPUnit\TextUI\Application->loadBootstrapScript()
#5 /www/vendor/phpunit/phpunit/phpunit(104): PHPUnit\TextUI\Application->run()
#6 {main}

Steps To Reproduce:

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions