[doc-en] master: Soap: Wrap class and method names, CS, replace `__sleep`/`__wakeup` → `__*serialize` (#6129)
| From: | Mikhail Alferov via GitHub | Date: | Mon, 23 Nov 2026 08:20:16 +0000 |
| Subject: | [doc-en] master: Soap: Wrap class and method names, CS, replace `__sleep`/`__wakeup` → `__*serialize` (#6129) | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-23995@lists.php.net to get a copy of this message | ||
Author: Mikhail Alferov (mmalferov)
Committer: GitHub (web-flow)
Pusher: lacatoire
Date: 2026-11-23T09:20:13+01:00
Commit: https://github.com/php/doc-en/commit/c68930acbf73c9e46dc7275afb8212e4f89eca2e
Raw diff: https://github.com/php/doc-en/commit/c68930acbf73c9e46dc7275afb8212e4f89eca2e.diff
Soap: Wrap class and method names, CS, replace
__sleep/__wakeup →
__*serialize (#6129)
* SoapServer::setPersistence Wrap classname, CS
* Replace array() with []
* Update setpersistence.xml
* Update setpersistence.xml
* Update setpersistence.xml
* setpersistence.xml Remove trailing whitespace
* Update setpersistence.xml
* Update setpersistence.xml
* setpersistence.xml Amend typo in constant name, replace SoapObject with specific name
* Update construct.xml
* Update construct.xml
* Update construct.xml
Changed paths:
M reference/soap/soapserver/setpersistence.xml
M reference/soap/soapvar/construct.xml
Diff:
diff --git a/reference/soap/soapserver/setpersistence.xml
b/reference/soap/soapserver/setpersistence.xml
index 14ea81b58430..64b5714f384d 100644
--- a/reference/soap/soapserver/setpersistence.xml
+++ b/reference/soap/soapserver/setpersistence.xml
@@ -12,22 +12,25 @@
<modifier>public</modifier>
<type>void</type><methodname>SoapServer::setPersistence</methodname>
<methodparam><type>int</type><parameter>mode</parameter></methodparam>
</methodsynopsis>
- <para>
- This function allows changing the persistence state of a SoapServer object between
- requests. This function allows saving data between requests utilizing PHP sessions. This method
- only has an affect on a SoapServer after it has exported functions utilizing
<methodname>SoapServer::setClass</methodname>.
- </para>
+ <simpara>
+ This method allows changing the persistence state of a
<classname>SoapServer</classname> object between
+ requests. This method allows saving data between requests utilizing PHP sessions. This method
+ only has an affect on a <classname>SoapServer</classname> after it has exported
functions utilizing <methodname>SoapServer::setClass</methodname>.
+ </simpara>
<note>
- <para>
+ <simpara>
The persistence of <constant>SOAP_PERSISTENCE_SESSION</constant> makes only
- objects of the given class persistent, but not the class static data. In this
- case, use <varname>$this->bar</varname> instead of self::$bar.
- </para>
+ objects of the given class persistent, but not the class static data. In this
+ case, use <varname>$this->bar</varname> instead of
<varname>self::$bar</varname>.
+ </simpara>
</note>
<note>
- <para>
- <constant>SOAP_PERSISTENCE_SESSION</constant> serializes data on the class object
between requests. In order to properly utilize resources (e.g.
<classname>PDO</classname>), <link
linkend="object.wakeup">__wakeup()</link> and <link
linkend="object.sleep">__sleep()</link> magic methods should be utilized.
- </para>
+ <simpara>
+ <constant>SOAP_PERSISTENCE_SESSION</constant> serializes data on the class object
between requests.
+ In order to properly utilize resources (e.g. <classname>PDO</classname>),
+ <link linkend="object.unserialize">__unserialize()</link> and
+ <link linkend="object.serialize">__serialize()</link> magic methods
should be utilized.
+ </simpara>
</note>
</refsect1>
@@ -41,17 +44,17 @@
<para>
One of the
<constant>SOAP_PERSISTENCE_<replaceable>*</replaceable></constant>
constants.
</para>
- <para>
- <constant>SOAP_PERSISTENCE_REQUEST</constant> - SoapServer data does not persist
between
- requests. This is the <emphasis role="bold">default</emphasis>
behavior of any SoapServer
- object after setClass is called.
- </para>
- <para>
- <constant>SOAP_PERSISTENCE_SESSION</constant> - SoapServer data persists between
requests.
- This is accomplished by serializing the SoapServer class data into
- <varname>$_SESSION['_bogus_session_name']</varname>, because of this
- <function>session_start</function> must be called before this persistence mode
is set.
- </para>
+ <simpara>
+ <constant>SOAP_PERSISTENCE_REQUEST</constant> -
<classname>SoapServer</classname> data does not persist between
+ requests. This is the <emphasis role="bold">default</emphasis>
behavior of any <classname>SoapServer</classname>
+ object after <methodname>SoapServer::setClass</methodname> is called.
+ </simpara>
+ <simpara>
+ <constant>SOAP_PERSISTENCE_SESSION</constant> -
<classname>SoapServer</classname> data persists between requests.
+ This is accomplished by serializing the <classname>SoapServer</classname> class
data into
+ <varname>$_SESSION['_bogus_session_name']</varname>, because of this
+ <function>session_start</function> must be called before this persistence mode
is set.
+ </simpara>
</listitem>
</varlistentry>
</variablelist>
@@ -60,9 +63,9 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
- <para>
+ <simpara>
&return.void;
- </para>
+ </simpara>
</refsect1>
<refsect1 role="changelog">
@@ -99,45 +102,50 @@
<programlisting role="php">
<![CDATA[
<?php
- class MyFirstPersistentSoapServer {
- private $resource; // (Such as PDO, mysqli, etc..)
- public $myvar1;
- public $myvar2;
- public function __construct() {
- $this->__wakeup(); // We're calling our wakeup to handle starting our resource
- }
+class MyFirstPersistentSoapServer
+{
+ private $resource; // (Such as PDO, mysqli, etc..)
+ public $myvar1;
+ public $myvar2;
+
+ public function __construct()
+ {
+ $this->__wakeup(); // We're calling our wakeup to handle starting our resource
+ }
- public function __wakeup() {
- $this->resource = CodeToStartOurResourceUp();
- }
+ public function __wakeup()
+ {
+ $this->resource = CodeToStartOurResourceUp();
+ }
- public function __sleep() {
- // We make sure to leave out $resource here, so our session data remains persistent
- // Failure to do so will result in the failure during the unserialization of data
- // on the next request; thus, our SoapObject would not be persistent across requests.
- return array('myvar1','myvar2');
- }
- }
+ public function __sleep()
+ {
+ // We make sure to leave out $resource here, so our session data remains persistent.
+ // Failure to do so will result in the failure during the unserialization of data
+ // on the next request; thus, a MyFirstPersistentSoapServer object would not be persistent
across requests.
+ return ['myvar1', 'myvar2'];
+ }
+}
+
+try {
+ session_start();
+ $server = new SoapServer(null, ['uri' => $_SERVER['REQUEST_URI']]);
+ $server->setClass('MyFirstPersistentSoapServer');
+ // setPersistence MUST be called after setClass, because setClass's
+ // behavior sets SOAP_PERSISTENCE_REQUEST upon enacting the method.
+ $server->setPersistence(SOAP_PERSISTENCE_SESSION);
+ $server->handle();
+} catch (SoapFault $e) {
+ error_log("SOAP ERROR: " . $e->getMessage());
+}
- try {
- session_start();
- $server = new SoapServer(null, array('uri' =>
$_SERVER['REQUEST_URI']));
- $server->setClass('MyFirstPersistentSoapServer');
- // setPersistence MUST be called after setClass, because setClass's
- // behavior sets SESSION_PERSISTENCE_REQUEST upon enacting the method.
- $server->setPersistence(SOAP_PERSISTENCE_SESSION);
- $server->handle();
- } catch(SoapFault $e) {
- error_log("SOAP ERROR: ". $e->getMessage());
- }
-?>
]]>
</programlisting>
</example>
</para>
</refsect1>
-
+
<refsect1 role="seealso">
&reftitle.seealso;
<para>
diff --git a/reference/soap/soapvar/construct.xml b/reference/soap/soapvar/construct.xml
index 3ab6989a1e28..7cb02d618646 100644
--- a/reference/soap/soapvar/construct.xml
+++ b/reference/soap/soapvar/construct.xml
@@ -17,9 +17,9 @@
<methodparam choice="opt"><type
class="union"><type>string</type><type>null</type></type><parameter>nodeName</parameter><initializer>&null;</initializer></methodparam>
<methodparam choice="opt"><type
class="union"><type>string</type><type>null</type></type><parameter>nodeNamespace</parameter><initializer>&null;</initializer></methodparam>
</constructorsynopsis>
- <para>
+ <simpara>
Constructs a new <classname>SoapVar</classname> object.
- </para>
+ </simpara>
</refsect1>
<refsect1 role="parameters">
@@ -29,49 +29,49 @@
<varlistentry>
<term><parameter>data</parameter></term>
<listitem>
- <para>
+ <simpara>
The data to pass or return.
- </para>
+ </simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>encoding</parameter></term>
<listitem>
- <para>
- The encoding ID, one of the <literal>XSD_...</literal> constants.
- </para>
+ <simpara>
+ The encoding ID, one of the
<constant>XSD_<replaceable>*</replaceable></constant> constants.
+ </simpara>
</listitem>
</varlistentry>
<varlistentry>
- <term><parameter>type_name</parameter></term>
+ <term><parameter>typeName</parameter></term>
<listitem>
- <para>
+ <simpara>
The type name.
- </para>
+ </simpara>
</listitem>
</varlistentry>
<varlistentry>
- <term><parameter>type_namespace</parameter></term>
+ <term><parameter>typeNamespace</parameter></term>
<listitem>
- <para>
+ <simpara>
The type namespace.
- </para>
+ </simpara>
</listitem>
</varlistentry>
<varlistentry>
- <term><parameter>node_name</parameter></term>
+ <term><parameter>nodeName</parameter></term>
<listitem>
- <para>
+ <simpara>
The XML node name.
- </para>
+ </simpara>
</listitem>
</varlistentry>
<varlistentry>
- <term><parameter>node_namespace</parameter></term>
+ <term><parameter>nodeNamespace</parameter></term>
<listitem>
- <para>
+ <simpara>
The XML node namespace.
- </para>
+ </simpara>
</listitem>
</varlistentry>
</variablelist>
@@ -118,7 +118,9 @@
<programlisting role="php">
<![CDATA[
<?php
-class SOAPStruct {
+
+class SOAPStruct
+{
function SOAPStruct($s, $i, $f)
{
$this->varString = $s;
@@ -126,12 +128,15 @@ class SOAPStruct {
$this->varFloat = $f;
}
}
-$client = new SoapClient(null, array('location' => "http://localhost/soap.php",
- 'uri' => "http://test-uri/"));
+
+$client = new SoapClient(null, [
+ 'location' => "http://localhost/soap.php",
+ 'uri' => "http://test-uri/"
+]);
$struct = new SOAPStruct('arg', 34, 325.325);
$soapstruct = new SoapVar($struct, SOAP_ENC_OBJECT, "SOAPStruct", "http://soapinterop.org/xsd");
$client->echoStruct(new SoapParam($soapstruct, "inputStruct"));
-?>
+
]]>
</programlisting>
</example>