1
0
mirror of https://github.com/php/doc-fr.git synced 2026-03-24 07:02:06 +01:00
Files
archived-doc-fr/language/predefined/stdclass.xml
Louis-Arnaud 1c620df447 Sync doc-fr with doc-en: full quality review (#2478)
Comprehensive review of all doc-fr XML files against doc-en covering:
- Translation quality (orthography, gender agreement, conjugation)
- TRADUCTIONS.txt compliance (etc., chiffrement, bibliothèque, à partir de)
- XML structure sync (tags, sections, constants, examples, changelog)
- Missing content (constants, examples, seealso members, sections)

Files modified across: security/, faq/, install/, language/, appendices/,
and reference/ (intl, funchand, tidy, mhash, mongodb, mysqli, fileinfo,
fpm, mail, xlswriter, strings, spl, stream, uodbc, var, openssl, mcrypt,
password, pdo_cubrid, phar, session, mbstring, errorfunc, snmp, solr,
cubrid, dba, eio, curl, ds, simplexml, sockets, random, info, math, yaf,
zip, mysqlnd)
2026-02-20 13:51:27 +01:00

145 lines
3.7 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: 77325b622f91355b118e8f3bc9ff940e8201f55d Maintainer: pierrick Status: ready -->
<!-- Reviewed: no -->
<reference xml:id="class.stdclass" 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>La classe stdClass</title>
<titleabbrev>stdClass</titleabbrev>
<partintro>
<section xml:id="stdclass.intro">
&reftitle.intro;
<para>
Une classe générique vide avec des propriétés dynamiques.
</para>
<para>
Les objets de cette classe peuvent être instanciés avec l'opérateur
<link linkend="language.oop5.basic.new">new</link> ou créés
en utilisant la <link linkend="language.types.object.casting">conversion en objet</link>.
Plusieurs fonctions PHP créent également des instances de cette classe, par exemple
<function>json_decode</function>, <function>mysqli_fetch_object</function>
ou <methodname>PDOStatement::fetchObject</methodname>.
</para>
<para>
Bien que n'implémentant pas
<link linkend="object.get">__get()</link>/<link linkend="object.set">__set()</link>
cette classe autorise les propriétés dynamiques et ne nécessite pas l'attribut
<code>#[\AllowDynamicProperties]</code>.
</para>
<para>
Ce n'est pas une classe de base car PHP n'a pas de concept de classe de base
universelle. Cependant, il est possible de créer une classe personnalisée qui étend
<classname>stdClass</classname> et qui hérite ainsi de la fonctionnalité
des propriétés dynamiques.
</para>
</section>
<section xml:id="stdclass.synopsis">
&reftitle.classsynopsis;
<classsynopsis class="class">
<ooclass>
<modifier role="attribute">#[\AllowDynamicProperties]</modifier>
<classname>stdClass</classname>
</ooclass>
</classsynopsis>
<para>
Cette classe n'a pas de méthode ni de propriété par défaut.
</para>
</section>
<section xml:id="stdclass.examples" role="examples">
&reftitle.examples;
<example xml:id="stdclass.basic-example">
<title>Créé à la suite d'une conversion de type en objet</title>
<programlisting role="php">
<![CDATA[
<?php
$obj = (object) array('foo' => 'bar');
var_dump($obj);
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
object(stdClass)#1 (1) {
["foo"]=>
string(3) "bar"
}
]]>
</screen>
</example>
<example xml:id="stdclass.json-example">
<title>Créé en tant que résultat de <function>json_decode</function></title>
<programlisting role="php">
<![CDATA[
<?php
$json = '{"foo":"bar"}';
var_dump(json_decode($json));
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
object(stdClass)#1 (1) {
["foo"]=>
string(3) "bar"
}
]]>
</screen>
</example>
<example xml:id="stdclass.properties-example">
<title>Déclaration de propriétés dynamiques</title>
<programlisting role="php">
<![CDATA[
<?php
$obj = new stdClass();
$obj->foo = 42;
$obj->{1} = 42;
var_dump($obj);
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
object(stdClass)#1 (2) {
["foo"]=>
int(42)
["1"]=>
int(42)
}
]]>
</screen>
</example>
</section>
</partintro>
</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
-->