# 补充\*其他特性与变更

## iterable伪类

现在引入了一个新的被称为iterable的伪类 (与[callable](https://php.net/manual/zh/language.types.callable.php)类似)。 这可以被用在参数或者返回值类型中，它代表接受数组或者实现了

**Traversable** 接口的对象。 至于子类，当用作参数时，子类可以收紧父类的iterable类型到[array](https://php.net/manual/zh/language.types.array.php)或一个实现了**Traversable**的对象。对

于返回值，子类可以拓宽父类的[array](https://php.net/manual/zh/language.types.array.php)或对象返回值类型到iterable。

```php
<?php
function iterator(iterable $iter)
{
    foreach ($iter as $val) {
        //
    }
}
```

## ext/openssl 支持 AEAD

通过给 [openssl\_encrypt()](https://php.net/manual/zh/function.openssl-encrypt.php) 和 [openssl\_decrypt()](https://php.net/manual/zh/function.openssl-decrypt.php) 添加额外参数，现在支持了AEAD (模式 GCM and CCM)。

## 通过**Closure::fromCallable()**&#x5C06;callables转为闭包

Closure新增了一个静态方法，用于将callable快速地 转为一个Closure 对象。

```php
<?php
class Test
{
    public function exposeFunction()
    {
        return Closure::fromCallable([$this, 'privateFunction']);
    }

    private function privateFunction($param)
    {
        var_dump($param);
    }
}

$privFunc = (new Test)->exposeFunction();
$privFunc('some value');
```

以上例程会输出：

```
string(10) "some value"
```

## 异步信号处理

一个新的名为**pcntl\_async\_signals()**&#x7684;方法现在被引入， 用于启用无需 ticks （这会带来很多额外的开销）的异步信号处理。

```php
<?php
pcntl_async_signals(true); // turn on async signals

pcntl_signal(SIGHUP,  function($sig) {
    echo "SIGHUP\n";
});

posix_kill(posix_getpid(), SIGHUP);
```

以上例程会输出：

```
SIGHUP
```

## HTTP/2 server push support in ext/curl

对服务器推送的支持现在已经被加入到 CURL 扩展中（ 需要版本 7.46 或更高）。这个可以通过[curl\_multi\_setopt()](https://php.net/manual/zh/function.curl-multi-setopt.php)函数与新的常量`CURLMOPT_PUSHFUNCTION`来进行调节。常量`CURL_PUST_OK`和`CURL_PUSH_DENY`也已经被添加进来，以便服务器推送的回调函数来表明自己会同意或拒绝处理。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://php7.shujuwajue.com/php-71x-xin-te-xing/xin-te-xing/bu-5145-qi-ta-te-xing-yu-bian-geng.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
