php-doc-en/reference/classobj/functions/get-object-vars.xml
Christoph Michael Becker 00ff0a3a0c Fix #78954: get_object_vars not returning typed empty properties
Untyped properties default to NULL, so this sentence is superfluous for those.
Unitialized typed properties are not included in the result, so the sentence is
plain wrong for those.

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@348498 c90b9560-bf6c-de11-be94-00142212c4b1
2019-12-12 17:18:46 +00:00

148 lines
3 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="function.get-object-vars" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>get_object_vars</refname>
<refpurpose>Gets the properties of the given object</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>array</type><methodname>get_object_vars</methodname>
<methodparam><type>object</type><parameter>object</parameter></methodparam>
</methodsynopsis>
<para>
Gets the accessible non-static properties of the given
<parameter>object</parameter> according to scope.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>object</parameter></term>
<listitem>
<para>
An object instance.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns an associative array of defined object accessible non-static properties
for the specified <parameter>object</parameter> in scope.
</para>
</refsect1>
<refsect1 role="changelog">
&reftitle.changelog;
<para>
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry>5.3.0</entry>
<entry>
This function now returns &null; if the
<parameter>object</parameter> isn't an object. Previously &false; was returned.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Use of <function>get_object_vars</function></title>
<programlisting role="php">
<![CDATA[
<?php
class foo {
private $a;
public $b = 1;
public $c;
private $d;
static $e;
public function test() {
var_dump(get_object_vars($this));
}
}
$test = new foo;
var_dump(get_object_vars($test));
$test->test();
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
array(2) {
["b"]=>
int(1)
["c"]=>
NULL
}
array(4) {
["a"]=>
NULL
["b"]=>
int(1)
["c"]=>
NULL
["d"]=>
NULL
}
]]>
</screen>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>get_class_methods</function></member>
<member><function>get_class_vars</function></member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- 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
-->