# Deprecated Features

## PHP Core

### Implementing Serializable without `__serialize` and `__unserialize`

Either only the new methods should be implemented, if no support for PHP prior to version 7.4 is provided, or both should be implemented.

### Passing ENTITY to non-nullable parameters of built-in functions

Scalar types for built-in functions are nullable by default. This behaviour is deprecated to align with the behaviour of user-defined functions, where scalar types need to be marked as nullable explicitly.

<div class="informalexample">

```
<?php
var_dump(str_contains("foobar", null));
// Deprecated: Passing null to parameter #2 ($needle) of type string
//             is deprecated
?>

     
```

</div>

### Implicit incompatible ENTITY to ENTITY conversions

The implicit conversion of ENTITY to ENTITY which leads to a loss in precision is now deprecated. This affects ENTITY keys, ENTITY type declarations in coercive mode, and operators working on ENTITYs.

<div class="informalexample">

```
<?php
$a = [];
$a[15.5]; // deprecated, as key value loses the 0.5 component
$a[15.0]; // ok, as 15.0 == 15
?>

     
```

</div>

### Calling a static element on a trait

Calling a static method, or accessing a static property directly on a trait is deprecated. Static methods and properties should only be accessed on a class using the trait.

### Returning a non-ENTITY from `__sleep`

Returning a value which is not an ENTITY from [\_\_sleep()](#object.sleep) now generates a diagnostic.

### Returning by reference from a `void` function

<div class="informalexample">

```
<?php
function &test(): void {}
?>

     
```

</div>

Such a function is contradictory, and already emits the following `E_NOTICE` when called: `Only variable references should be returned by reference`.

### Autovivification from ENTITY

Autovivification is the process of creating a new ENTITY when appending to a value. Autovivification is prohibited from scalar values, ENTITY however was an exception. This is now deprecated.

<div class="informalexample">

```
<?php
$arr = false;
$arr[] = 2;   // deprecated
?>

     
```

</div>

> [!NOTE]
> Autovivification from ENTITY and undefined values is still allowed:
>
> <div class="informalexample">
>
> ```
> <?php
> // From undefined
> $arr[] = 'some value';
> $arr['doesNotExist'][] = 2;
> // From null
> $arr = null;
> $arr[] = 2;
> ?>
>
>       
> ```
>
> </div>

## ctype

### Verifying non-string arguments

Passing a non-string argument is deprecated. In the future, the argument will be interpreted as a string instead of an ASCII codepoint. Depending on the intended behavior, the argument should either be cast to ENTITY or an explicit call to `chr` should be made. All `ctype_*()` functions are affected.

## Date

`date_sunrise` and `date_sunset` have been deprecated in favor of `date_sun_info`.

`strptime` has been deprecated. Use `date_parse_from_format` instead (for locale-independent parsing), or IntlDateFormatter::parse (for locale-dependent parsing).

`strftime` and `gmstrftime` have been deprecated. Use `date` instead (for locale-independent formatting), or IntlDateFormatter::format (for locale-dependent formatting).

## Filter

The `FILTER_SANITIZE_STRING` and `FILTER_SANITIZE_STRIPPED` filters are deprecated.

The [filter.default](#ini.filter.default) INI directive is deprecated.

## GD

The `num_points` of `imagepolygon`, `imageopenpolygon` and `imagefilledpolygon` has been deprecated.

## Hash

The `mhash`, `mhash_keygen_s2k`, `mhash_count`, `mhash_get_block_size`, and `mhash_get_hash_name` functions have been deprecated. Use the `hash_*()` functions instead.

## IMAP

The `NIL` constant has been deprecated. Use `0` instead.

## Intl

Calling IntlCalendar::roll with a ENTITY argument is deprecated. Use `1` and `-1` instead of ENTITY and ENTITY respectively.

## Multibyte String

Calling `mb_check_encoding` without any arguments is deprecated.

## MySQLi

The mysqli_driver::\$driver_version property has been deprecated. It was meaningless and outdated, use `PHP_VERSION_ID` instead.

Calling mysqli::get_client_info or `mysqli_get_client_info` with the `mysqli` argument has been deprecated. Call `mysqli_get_client_info` without any arguments to obtain the version information of the client library.

The mysqli::init method has been deprecated. Replace calls to parent::init with parent::\_\_construct.

## OCI8

The [oci8.old_oci_close_semantics](#ini.oci8.old-oci-close-semantics) INI directive is deprecated.

## ODBC

`odbc_result_all` has been deprecated.

## PDO

The `PDO::FETCH_SERIALIZE` fetch mode has been deprecated.

## PgSQL

Not passing the connection argument to all `pgsql_*()` functions has been deprecated.

## SOAP

The `ssl_method` option of SoapClient::\_\_construct has been deprecated in favor of SSL stream context options.

## Standard

Calling `key`, `current`, `next`, `prev`, `reset`, or `end` on ENTITYs is deprecated. Either convert the ENTITY to an ENTITY using `get_mangled_object_vars` first, or use the methods provided by a class that implements Iterator, such as `ArrayIterator`, instead.

The [auto_detect_line_endings](#ini.auto-detect-line-endings) INI directive is deprecated. If necessary, handle `"\r"` line breaks manually instead.

The `FILE_BINARY` and `FILE_TEXT` constants have been deprecated. They never had any effect.