mirror of
https://github.com/php/doc-pt_br.git
synced 2026-03-23 22:52:12 +01:00
153 lines
3.8 KiB
XML
153 lines
3.8 KiB
XML
<?xml version="1.0" encoding="utf-8"?><!-- EN-Revision: 77325b622f91355b118e8f3bc9ff940e8201f55d Maintainer: leonardolara Status: ready -->
|
|
<reference xml:id="class.override" role="class" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude">
|
|
<title>O atributo Override</title>
|
|
<titleabbrev>Override</titleabbrev>
|
|
|
|
<partintro>
|
|
|
|
<section xml:id="override.intro">
|
|
&reftitle.intro;
|
|
<simpara>
|
|
Este atributo é usado para indicar que um método ou uma propriedade se destina
|
|
a substituir um método ou uma propriedade de uma classe superior ou que ele/ela implementa
|
|
um método ou propriedade definido(a) em uma interface.
|
|
</simpara>
|
|
<simpara>
|
|
Se nenhum método ou propriedade com o mesmo nome existir em uma classe superior ou
|
|
em uma interface implementada, um erro será emitido no momento da
|
|
compilação.
|
|
</simpara>
|
|
<simpara>
|
|
O atributo não pode ser usado no método
|
|
<link linkend="object.construct">__construct()</link>,
|
|
que é isento de verificação de assinaturas.
|
|
</simpara>
|
|
</section>
|
|
|
|
<section xml:id="override.synopsis">
|
|
&reftitle.classsynopsis;
|
|
|
|
<classsynopsis class="class">
|
|
<ooclass>
|
|
<modifier role="attribute">#[\Attribute]</modifier>
|
|
<modifier>final</modifier>
|
|
<classname>Override</classname>
|
|
</ooclass>
|
|
|
|
<classsynopsisinfo role="comment">&Methods;</classsynopsisinfo>
|
|
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.override')/db:refentry/db:refsect1[@role='description']/descendant::db:constructorsynopsis[@role='Override'])">
|
|
<xi:fallback/>
|
|
</xi:include>
|
|
</classsynopsis>
|
|
|
|
</section>
|
|
|
|
<section role="changelog">
|
|
&reftitle.changelog;
|
|
<informaltable>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>&Version;</entry>
|
|
<entry>&Description;</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>8.5.0</entry>
|
|
<entry>
|
|
<classname>Override</classname> pode ser aplicada a propriedades.
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
</section>
|
|
|
|
<section>
|
|
&reftitle.examples;
|
|
<example>
|
|
<title>Uso com métodos</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
|
|
class Base {
|
|
protected function foo(): void {}
|
|
}
|
|
|
|
final class Extended extends Base {
|
|
#[\Override]
|
|
protected function boo(): void {}
|
|
}
|
|
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs.83.similar;
|
|
<screen>
|
|
<![CDATA[
|
|
Fatal error: Extended::boo() has #[\Override] attribute, but no matching parent method exists
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
<example>
|
|
<title>Uso com propriedades</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
|
|
class Base {
|
|
protected string $foo;
|
|
}
|
|
|
|
final class Extended extends Base {
|
|
#[\Override]
|
|
protected string $boo;
|
|
}
|
|
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs.85.similar;
|
|
<screen>
|
|
<![CDATA[
|
|
Fatal error: Extended::$boo has #[\Override] attribute, but no matching parent property exists
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</section>
|
|
|
|
<section xml:id="override.seealso">
|
|
&reftitle.seealso;
|
|
<simplelist>
|
|
<member><link linkend="language.attributes">Visão geral de atributos</link></member>
|
|
</simplelist>
|
|
</section>
|
|
|
|
</partintro>
|
|
|
|
&language.predefined.attributes.override.construct;
|
|
|
|
</reference>
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|