<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/migration81.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'tr',
  ),
  'this' => 
  array (
    0 => 'migration81.incompatible.php',
    1 => 'Backward Incompatible Changes',
    2 => 'Backward Incompatible Changes',
  ),
  'up' => 
  array (
    0 => 'migration81.php',
    1 => 'Migrating from PHP 8.0.x to PHP 8.1.x',
  ),
  'prev' => 
  array (
    0 => 'migration81.constants.php',
    1 => 'New Global Constants',
  ),
  'next' => 
  array (
    0 => 'migration81.deprecated.php',
    1 => 'Deprecated Features',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'appendices/migration81/incompatible.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="migration81.incompatible" class="sect1">
 <h2 class="title">Backward Incompatible Changes</h2>

 <div class="sect2" id="migration81.incompatible.core">
  <h3 class="title">PHP Core</h3>

  <div class="sect3" id="migration81.incompatible.core.globals-access">
   <h4 class="title">$GLOBALS Access Restrictions</h4>

   <p class="para">
    Access to the <var class="varname"><a href="reserved.variables.globals.php" class="classname">$GLOBALS</a></var> array is now subject to
    a number of restrictions.
    Read and write access to individual array elements like
    <code class="code">$GLOBALS[&#039;var&#039;]</code> continues to work as-is.
    Read-only access to the entire <var class="varname"><a href="reserved.variables.globals.php" class="classname">$GLOBALS</a></var> array also
    continues to be supported.
    However, write access to the entire <var class="varname"><a href="reserved.variables.globals.php" class="classname">$GLOBALS</a></var> array
    is no longer supported. For example, <code class="code">array_pop($GLOBALS)</code>
    will result in an error.
   </p>
  </div>

  <div class="sect3" id="migration81.incompatible.core.static-variable-inheritance">
   <h4 class="title">
    Usage of <span class="modifier">static</span> Variables in Inherited Methods
   </h4>

   <p class="para">
    When a method using static variables is inherited (but not overridden), the
    inherited method will now share static variables with the parent method.
    <div class="informalexample">
     <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">class </span><span style="color: #0000BB">A </span><span style="color: #007700">{<br />    public static function </span><span style="color: #0000BB">counter</span><span style="color: #007700">() {<br />        static </span><span style="color: #0000BB">$counter </span><span style="color: #007700">= </span><span style="color: #0000BB">0</span><span style="color: #007700">;<br />        </span><span style="color: #0000BB">$counter</span><span style="color: #007700">++;<br />        return </span><span style="color: #0000BB">$counter</span><span style="color: #007700">;<br />    }<br />}<br />class </span><span style="color: #0000BB">B </span><span style="color: #007700">extends </span><span style="color: #0000BB">A </span><span style="color: #007700">{}<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">A</span><span style="color: #007700">::</span><span style="color: #0000BB">counter</span><span style="color: #007700">()); </span><span style="color: #FF8000">// int(1)<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">A</span><span style="color: #007700">::</span><span style="color: #0000BB">counter</span><span style="color: #007700">()); </span><span style="color: #FF8000">// int(2)<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">B</span><span style="color: #007700">::</span><span style="color: #0000BB">counter</span><span style="color: #007700">()); </span><span style="color: #FF8000">// int(3), previously int(1)<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">B</span><span style="color: #007700">::</span><span style="color: #0000BB">counter</span><span style="color: #007700">()); </span><span style="color: #FF8000">// int(4), previously int(2)<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
     </div>

    </div>

    This means that static variables in methods now behave the same way as
    static properties.
   </p>
  </div>

  <div class="sect3" id="migration81.incompatible.core.optional-before-required">
   <h4 class="title">Optional parameters specified before required parameters</h4>

   <p class="para">
    An <a href="functions.arguments.php#functions.arguments.default" class="link">optional parameter</a>
    specified before required parameters is now always treated as required,
    even when called using
    <a href="functions.arguments.php#functions.named-arguments" class="link">named arguments</a>.
    As of PHP 8.0.0, but prior to PHP 8.1.0, the below emits a deprecation notice
    on the definition, but runs successfully when called. As of PHP 8.1.0, an error
    of class <span class="classname"><a href="class.argumentcounterror.php" class="classname">ArgumentCountError</a></span> is thrown, as it would be when
    called with positional arguments.

    <div class="informalexample">
     <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">function </span><span style="color: #0000BB">makeyogurt</span><span style="color: #007700">(</span><span style="color: #0000BB">$container </span><span style="color: #007700">= </span><span style="color: #DD0000">"bowl"</span><span style="color: #007700">, </span><span style="color: #0000BB">$flavour</span><span style="color: #007700">)<br />{<br />    return </span><span style="color: #DD0000">"Making a </span><span style="color: #0000BB">$container</span><span style="color: #DD0000"> of </span><span style="color: #0000BB">$flavour</span><span style="color: #DD0000"> yogurt.\n"</span><span style="color: #007700">;<br />}<br />try<br />{<br />    echo </span><span style="color: #0000BB">makeyogurt</span><span style="color: #007700">(</span><span style="color: #0000BB">flavour</span><span style="color: #007700">: </span><span style="color: #DD0000">"raspberry"</span><span style="color: #007700">);<br />}<br />catch (</span><span style="color: #0000BB">Error $e</span><span style="color: #007700">)<br />{<br />    echo </span><span style="color: #0000BB">get_class</span><span style="color: #007700">(</span><span style="color: #0000BB">$e</span><span style="color: #007700">), </span><span style="color: #DD0000">' - '</span><span style="color: #007700">, </span><span style="color: #0000BB">$e</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getMessage</span><span style="color: #007700">(), </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
     </div>

     <p class="para">
Yukarıdaki örneğin PHP 8.0 çıktısı:</p>
     <div class="example-contents screen">
<div class="cdata"><pre>
Deprecated: Required parameter $flavour follows optional parameter $container
 in example.php on line 3
Making a bowl of raspberry yogurt.
</pre></div>
     </div>
     <p class="para">
Yukarıdaki örneğin PHP 8.1 çıktısı:</p>
     <div class="example-contents screen">
<div class="cdata"><pre>
Deprecated: Optional parameter $container declared before required parameter
 $flavour is implicitly treated as a required parameter in example.php on line 3
ArgumentCountError - makeyogurt(): Argument #1 ($container) not passed
</pre></div>
     </div>
    </div>
   </p>
   <p class="para">
    Note that a default value of <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong> can be used before required parameters to
    specify a <a href="language.types.declarations.php#language.types.declarations.nullable" class="link">nullable type</a>,
    but the parameter will still be required.
   </p>
  </div>

  <div class="sect3" id="migration81.incompatible.core.type-compatibility-internal">
   <h4 class="title">Return Type Compatibility with Internal Classes</h4>

   <p class="para">
    Most non-final internal methods now require overriding methods to declare
    a compatible return type, otherwise a deprecated notice is emitted during
    inheritance validation.
    In case the return type cannot be declared for an overriding method due to
    PHP cross-version compatibility concerns,
    a <span class="classname"><a href="class.returntypewillchange.php" class="classname">ReturnTypeWillChange</a></span> attribute can be added to silence
    the deprecation notice.
   </p>
  </div>

  <div class="sect3" id="migration81.incompatible.core.new-keywords">
   <h4 class="title">New Keywords</h4>
   <p class="para">
    <code class="literal">readonly</code> is a keyword now. However, it still may be used
    as function name.
   </p>
   <p class="para">
    <code class="literal">never</code> is now a reserved word, so it cannot be used to name a class,
    interface or trait, and is also prohibited from being used in namespaces.
   </p>
  </div>
 </div>

 <div class="sect2" id="migration81.incompatible.resource2object">
  <h3 class="title">Resource to Object Migration</h3>

  <p class="para">
   Several <a href="language.types.resource.php" class="link">resource</a>s have been migrated to <span class="type"><a href="language.types.object.php" class="type object">object</a></span>s.
   Return value checks using <span class="function"><a href="function.is-resource.php" class="function">is_resource()</a></span> should be replaced with checks for <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>.
  </p>
  <ul class="itemizedlist">
   <li class="listitem">
    <p class="para">
     The <a href="book.fileinfo.php" class="link">FileInfo</a> functions now accept and return
     <span class="classname"><a href="class.finfo.php" class="classname">finfo</a></span> objects instead of
     <code class="literal">fileinfo</code> <a href="language.types.resource.php" class="link">resource</a>s.
    </p>
   </li>
   <li class="listitem">
    <p class="para">
     The <a href="book.ftp.php" class="link">FTP</a> functions now accept and return
     <span class="classname"><a href="class.ftp-connection.php" class="classname">FTP\Connection</a></span> objects instead of
     <code class="literal">ftp</code> <a href="language.types.resource.php" class="link">resource</a>s.
    </p>
   </li>
   <li class="listitem">
    <p class="para">
     The <a href="book.imap.php" class="link">IMAP</a> functions now accept and return
     <span class="classname"><a href="class.imap-connection.php" class="classname">IMAP\Connection</a></span> objects instead of
     <code class="literal">imap</code> <a href="language.types.resource.php" class="link">resource</a>s.
    </p>
   </li>
   <li class="listitem">
    <p class="para">
     The <a href="book.ldap.php" class="link">LDAP</a> functions now accept and return
     <span class="classname"><a href="class.ldap-connection.php" class="classname">LDAP\Connection</a></span> objects instead of
     <code class="literal">ldap link</code> <a href="language.types.resource.php" class="link">resource</a>s.
    </p>
   </li>
   <li class="listitem">
    <p class="para">
     The <a href="book.ldap.php" class="link">LDAP</a> functions now accept and return
     <span class="classname"><a href="class.ldap-result.php" class="classname">LDAP\Result</a></span> objects instead of
     <code class="literal">ldap result</code> <a href="language.types.resource.php" class="link">resource</a>s.
    </p>
   </li>
   <li class="listitem">
    <p class="para">
     The <a href="book.ldap.php" class="link">LDAP</a> functions now accept and return
     <span class="classname"><a href="class.ldap-result-entry.php" class="classname">LDAP\ResultEntry</a></span> objects instead of
     <code class="literal">ldap result entry</code> <a href="language.types.resource.php" class="link">resource</a>s.
    </p>
   </li>
   <li class="listitem">
    <p class="para">
     The <a href="book.pgsql.php" class="link">PgSQL</a> functions now accept and return
     <span class="classname"><a href="class.pgsql-connection.php" class="classname">PgSql\Connection</a></span> objects instead of
     <code class="literal">pgsql link</code> <a href="language.types.resource.php" class="link">resource</a>s.
    </p>
   </li>
   <li class="listitem">
    <p class="para">
     The <a href="book.pgsql.php" class="link">PgSQL</a> functions now accept and return
     <span class="classname"><a href="class.pgsql-result.php" class="classname">PgSql\Result</a></span> objects instead of
     <code class="literal">pgsql result</code> <a href="language.types.resource.php" class="link">resource</a>s.
    </p>
   </li>
   <li class="listitem">
    <p class="para">
     The <a href="book.pgsql.php" class="link">PgSQL</a> functions now accept and return
     <span class="classname"><a href="class.pgsql-lob.php" class="classname">PgSql\Lob</a></span> objects instead of
     <code class="literal">pgsql large object</code> <a href="language.types.resource.php" class="link">resource</a>s.
    </p>
   </li>
   <li class="listitem">
    <p class="para">
     The <a href="book.pspell.php" class="link">PSpell</a> functions now accept and return
     <span class="classname"><a href="class.pspell-dictionary.php" class="classname">PSpell\Dictionary</a></span> objects instead of
     <code class="literal">pspell</code> <a href="language.types.resource.php" class="link">resource</a>s.
    </p>
   </li>
   <li class="listitem">
    <p class="para">
     The <a href="book.pspell.php" class="link">PSpell</a> functions now accept and return
     <span class="classname"><a href="class.pspell-config.php" class="classname">PSpell\Config</a></span> objects instead of
     <code class="literal">pspell config</code> <a href="language.types.resource.php" class="link">resource</a>s.
    </p>
   </li>
  </ul>
 </div>

 <div class="sect2" id="migration81.incompatible.mysqli">
  <h3 class="title">MySQLi</h3>

  <p class="para">
   <span class="function"><a href="mysqli-result.fetch-fields.php" class="function">mysqli_fetch_fields()</a></span>, and
   <span class="function"><a href="mysqli-result.fetch-field-direct.php" class="function">mysqli_fetch_field_direct()</a></span> will now always return
   <code class="literal">0</code> for the <span class="property">max_length</span>.
   This information can be computed by iterating over the result set,
   and taking the maximum length. This is what PHP was doing
   internally previously.
  </p>

  <p class="para">
   The <strong><code><a href="mysqli.constants.php#constant.mysqli-stmt-attr-update-max-length">MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH</a></code></strong>
   option no longer has any effect.
  </p>

  <p class="para">
   The <strong><code><a href="mysqli.constants.php#constant.mysqli-store-result-copy-data">MYSQLI_STORE_RESULT_COPY_DATA</a></code></strong>
   option no longer has any effect. Passing any value to the
   <code class="parameter">mode</code> parameter of
   <span class="methodname"><a href="mysqli.store-result.php" class="methodname">mysqli::store_result()</a></span> no longer has any effect.
  </p>

  <p class="para">
   <span class="methodname"><a href="mysqli.construct.php" class="methodname">mysqli::connect()</a></span> now returns <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> instead of <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong> on success.
  </p>

  <p class="para">
   The default error handling mode has been changed from &quot;silent&quot; to &quot;exceptions&quot;
   See the <a href="mysqli-driver.report-mode.php" class="link">MySQLi reporting mode</a>
   page for more details on what this entails,
   and how to explicitly set this attribute.
   To restore the previous behaviour use:
   <code class="code">mysqli_report(MYSQLI_REPORT_OFF);</code>
  </p>

  <p class="para">
   Classes extending <span class="methodname"><a href="mysqli-stmt.execute.php" class="methodname">mysqli_stmt::execute()</a></span>
   are now required to specify the additional optional parameter.
  </p>
 </div>

 <div class="sect2" id="migration81.incompatible.mysqlnd">
  <h3 class="title">MySQLnd</h3>

  <p class="para">
   The <a href="mysqlnd.config.php#ini.mysqlnd.fetch_data_copy" class="link">mysqlnd.fetch_data_copy</a>
   INI directive has been removed.
   This should not result in user-visible behavior changes.
  </p>
 </div>

 <div class="sect2" id="migration81.incompatible.openssl">
  <h3 class="title">OpenSSL</h3>

  <p class="para">
   EC private keys will now be exported in <abbr title="Public Key Cryptography Standards">PKCS</abbr>#8 format rather than
   traditional format, just like all other keys.
  </p>
  <p class="para">
   <span class="function"><a href="function.openssl-pkcs7-encrypt.php" class="function">openssl_pkcs7_encrypt()</a></span> and
   <span class="function"><a href="function.openssl-cms-encrypt.php" class="function">openssl_cms_encrypt()</a></span> will now to default using
   AES-128-CBC rather than RC2-40. The RC2-40 cipher is considered
   insecure and not enabled by default by OpenSSL 3.
  </p>
 </div>

 <div class="sect2" id="migration81.incompatible.pdo">
  <h3 class="title">PHP Data Objects</h3>

  <p class="para">
   <strong><code><a href="pdo.constants.php#pdo.constants.attr-stringify-fetches">PDO::ATTR_STRINGIFY_FETCHES</a></code></strong> now stringifies values
   of type <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span> to <code class="literal">&quot;0&quot;</code> or
   <code class="literal">&quot;1&quot;</code>. Previously <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span>s were not stringified.
  </p>
  <p class="para">
   Calling <span class="methodname"><a href="pdostatement.bindcolumn.php" class="methodname">PDOStatement::bindColumn()</a></span> with
   <strong><code><a href="pdo.constants.php#pdo.constants.param-lob">PDO::PARAM_LOB</a></code></strong> will now constantly bind a stream
   result when <strong><code><a href="pdo.constants.php#pdo.constants.attr-stringify-fetches">PDO::ATTR_STRINGIFY_FETCHES</a></code></strong> is not enabled.
   Previously, the result would either be a stream or a string depending on
   the used database driver and the time the binding is performed.
  </p>

  <div class="sect3" id="migration81.incompatible.pdo.mysql">
   <h4 class="title">MySQL Driver</h4>

   <p class="para">
    Integers and floats in result sets will now be returned using native
    PHP types instead of <span class="type"><a href="language.types.string.php" class="type string">string</a></span>s when using emulated prepared statements.
    This matches the behavior of native prepared statements.
    The previous behaviour can be restored by enabling the
    <strong><code><a href="pdo.constants.php#pdo.constants.attr-stringify-fetches">PDO::ATTR_STRINGIFY_FETCHES</a></code></strong> option.
   </p>
  </div>

  <div class="sect3" id="migration81.incompatible.pdo.sqlite">
   <h4 class="title">SQLite Driver</h4>

   <p class="para">
    Integers and floats in results sets will now be returned using native
    PHP types.
    The previous behaviour can be restored by enabling the
    <strong><code><a href="pdo.constants.php#pdo.constants.attr-stringify-fetches">PDO::ATTR_STRINGIFY_FETCHES</a></code></strong> option.
   </p>
  </div>
 </div>

 <div class="sect2" id="migration81.incompatible.phar">
  <h3 class="title">Phar</h3>

  <p class="para">
   To comply with the <span class="interfacename"><a href="class.arrayaccess.php" class="interfacename">ArrayAccess</a></span> interface,
   <span class="methodname"><a href="phar.offsetunset.php" class="methodname">Phar::offsetUnset()</a></span> and
   <span class="methodname"><a href="phardata.offsetunset.php" class="methodname">PharData::offsetUnset()</a></span> no longer return a <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span>.
  </p>
 </div>

 <div class="sect2" id="migration81.incompatible.standard">
  <h3 class="title">Standard</h3>

  <p class="para">
   <span class="function"><a href="function.version-compare.php" class="function">version_compare()</a></span> no longer accepts undocumented operator abbreviations.
  </p>

  <p class="para">
   <span class="function"><a href="function.htmlspecialchars.php" class="function">htmlspecialchars()</a></span>,
   <span class="function"><a href="function.htmlentities.php" class="function">htmlentities()</a></span>,
   <span class="function"><a href="function.htmlspecialchars-decode.php" class="function">htmlspecialchars_decode()</a></span>,
   <span class="function"><a href="function.html-entity-decode.php" class="function">html_entity_decode()</a></span>,
   and <span class="function"><a href="function.get-html-translation-table.php" class="function">get_html_translation_table()</a></span>
   now use <code class="literal">ENT_QUOTES | ENT_SUBSTITUTE</code> rather than
   <strong><code><a href="string.constants.php#constant.ent-compat">ENT_COMPAT</a></code></strong> by default.
   This means that <code class="literal">&#039;</code> is escaped to
   <code class="literal">&amp;#039;</code> while previously nothing was done.
   Additionally, malformed UTF-8 will be replaced by a Unicode substitution
   character, instead of resulting in an empty string.
  </p>

  <p class="para">
   <span class="function"><a href="function.debug-zval-dump.php" class="function">debug_zval_dump()</a></span> now prints the refcount of a reference
   wrappers with their refcount, instead of only prepending
   <code class="literal">&amp;</code> to the value.
   This more accurately models reference representation since PHP 7.0.
  </p>

  <p class="para">
   <span class="function"><a href="function.debug-zval-dump.php" class="function">debug_zval_dump()</a></span> now prints <code class="literal">interned</code>
   instead of a dummy refcount for interned strings and immutable arrays.
  </p>
 </div>

 <div class="sect2" id="migration81.incompatible.spl">
  <h3 class="title">Standard PHP Library (SPL)</h3>

  <p class="para">
   <span class="classname"><a href="class.splfixedarray.php" class="classname">SplFixedArray</a></span>, will now be JSON encoded like an <span class="type"><a href="language.types.array.php" class="type array">array</a></span>
  </p>
 </div>

</div><?php manual_footer($setup); ?>