Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

array_map started to obey strict_types directive in PHP 8.6

未关闭
#23,882 2 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

@TimWolla 已经在做这个了。

开始于 2026年9月24日。

评估

这个 Issue 还没有评估数据。

描述

Bug Status: Verified
Description

The following code:

<?php declare(strict_types=1);

array_map(trim(...), [1]);

Resulted in this output (on PHP 8.6):

PHP Fatal error:  Uncaught TypeError: trim(): Argument #1 ($string) must be of type string, int given in /home/jnoordsij/foo.php:3
Stack trace:
#0 /home/jnoordsij/foo.php(3): trim()
#1 {main}
  thrown in /home/jnoordsij/foo.php on line 3

But I expected this output instead (as it is on PHP 8.5):

(Arguably the first outcome may as well be considered correct/preferable, as there is a type error here; then one could consider this a PHP 8.5 and older bug, but fixing that is probably more impactful)

PHP Version
PHP 8.6.0beta3 (cli) (built: Sep 23 2026 10:57:45) (NTS)
Copyright © The PHP Group and Contributors
Built by Ubuntu
Zend Engine v4.6.0-dev, Copyright © Zend by Perforce
    with Xdebug v3.6.0alpha1, Copyright (c) 2002-2026, by Derick Rethans
    with Zend OPcache v8.6.0beta3, Copyright ©, by Zend by Perforce


Compared to

PHP 8.5.10 (cli) (built: Aug 28 2026 07:23:25) (NTS)
Copyright (c) The PHP Group
Built by Ubuntu
Zend Engine v4.5.10, Copyright (c) Zend Technologies
    with Xdebug v3.5.3, Copyright (c) 2002-2026, by Derick Rethans
    with Zend OPcache v8.5.10, Copyright (c), by Zend Technologies
Operating System

Ubuntu 26.04 (wsl)

Additional notes

Spotted in context of https://github.com/paratestphp/paratest/pull/1130 in https://github.com/paratestphp/paratest/actions/runs/32967771822/job/107268607956?pr=1130#step:5:37 (and subsequently https://github.com/paratestphp/paratest/pull/1138)

主要语言
C
星标
40.4k
派生
8.2k
平均合并
2 天 15 小时
30 天内合并 PR
113

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

php/php-src 的其他 Issue

查看 php/php-src 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。