svn: /phpdoc/en/trunk/ appendices/migration70/deprecated.xml language/oop5/static.xml language-snippets.ent

From: Date: Mon, 21 Sep 2015 12:17:30 +0000
Subject: svn: /phpdoc/en/trunk/ appendices/migration70/deprecated.xml language/oop5/static.xml language-snippets.ent
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-13754@lists.php.net to get a copy of this message
aharvey Mon, 21 Sep 2015 12:17:30 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=337875 Log: Note the deprecation of static calls to non-static methods. Changed paths: U phpdoc/en/trunk/appendices/migration70/deprecated.xml U phpdoc/en/trunk/language/oop5/static.xml U phpdoc/en/trunk/language-snippets.ent Modified: phpdoc/en/trunk/appendices/migration70/deprecated.xml =================================================================== --- phpdoc/en/trunk/appendices/migration70/deprecated.xml 2015-09-21 12:17:25 UTC (rev 337874) +++ phpdoc/en/trunk/appendices/migration70/deprecated.xml 2015-09-21 12:17:30 UTC (rev 337875) @@ -16,14 +16,14 @@ </sect2> --> <sect2 xml:id="migration70.deprecated.php4-constructors"> - <title>PHP4-style constructors</title> + <title>PHP 4 style constructors</title> <para> - PHP4-style constructors (methods that have the same name as the class they are defined in) - are deprecated. PHP 7 will emit <constant>E_DEPRECATED</constant> whenever a PHP 4 constructor - is defined. When the method name matches the class name, the class is not in a namespace, - and a PHP 5 constructor (__construct) is not present then an <constant>E_DEPRECATED</constant> - will be emitted. + PHP 4 style constructors (methods that have the same name as the class they + are defined in) are deprecated, and may be removed in the future. PHP 7 + will emit <constant>E_DEPRECATED</constant> if a PHP 4 constructor is the + only constructor defined within a class. Classes that implement a + <function>__construct</function> method are unaffected. </para> <informalexample> @@ -47,6 +47,39 @@ </informalexample> </sect2> + <sect2 xml:id="migration70.deprecated.static-calls"> + <title>Static calls to non-static methods</title> + + <para> + <link linkend="language.oop5.static">Static</link> calls to methods that + are not declared <command>static</command> are deprecated, and may be + removed in the future. + </para> + + <informalexample> + <programlisting role="php"> +<![CDATA[ +<?php +class foo { + function bar() { + echo 'I am not static!'; + } +} + +foo::bar(); +?> +]]> + </programlisting> + &example.outputs; + <screen> +<![CDATA[ +Deprecated: Non-static method foo::bar() should not be called statically in - on line 8 +I am not static! +]]> + </screen> + </informalexample> + </sect2> + <sect2 xml:id="migration70.deprecated.pwshash-salt-option"> <title><function>password_hash</function> salt option</title> Modified: phpdoc/en/trunk/language/oop5/static.xml =================================================================== --- phpdoc/en/trunk/language/oop5/static.xml 2015-09-21 12:17:25 UTC (rev 337874) +++ phpdoc/en/trunk/language/oop5/static.xml 2015-09-21 12:17:30 UTC (rev 337875) @@ -30,38 +30,75 @@ as if it was declared as <literal>public</literal>. </para> - <para> - Because static methods are callable without an instance of - the object created, the pseudo-variable <varname>$this</varname> is - not available inside the method declared as static. - </para> + <sect2 xml:id="language.oop5.static.methods"> + <title>Static methods</title> + + <para> + Because static methods are callable without an instance of + the object created, the pseudo-variable <varname>$this</varname> is + not available inside the method declared as static. + </para> + + <caution> + <simpara> + In PHP 5, calling non-static methods statically generates an + <constant>E_STRICT</constant> level warning. + </simpara> + </caution> + + <warning> + <simpara> + In PHP 7, calling non-static methods statically is deprecated, and will + generate an <constant>E_DEPRECATED</constant> warning. Support for + calling non-static methods statically may be removed in the future. + </simpara> + </warning> + + <example> + <title>Static method example</title> + <programlisting role="php"> +<![CDATA[ +<?php +class Foo { + public static function aStaticMethod() { + // ... + } +} + +Foo::aStaticMethod(); +$classname = 'Foo'; +$classname::aStaticMethod(); // As of PHP 5.3.0 +?> +]]> + </programlisting> + </example> + </sect2> - <para> - Static properties cannot be accessed through the object using the arrow - operator -&gt;. - </para> + <sect2 xml:id="language.oop5.static.properties"> + <title>Static properties</title> - <para> - Calling non-static methods statically generates an <constant>E_STRICT</constant> level warning. - </para> + <para> + Static properties cannot be accessed through the object using the arrow + operator -&gt;. + </para> - <para> - Like any other PHP static variable, static properties may only be - initialized using a literal or constant; expressions are not - allowed. So while you may initialize a static property to an - integer or array (for instance), you may not initialize it to - another variable, to a function return value, or to an object. - </para> + <para> + Like any other PHP static variable, static properties may only be + initialized using a literal or constant before PHP 5.6; expressions are + not allowed. In PHP 5.6 and later, the same rules apply as &const; + expressions: some limited expressions are possible, provided they can be + evaluated at compile time. + </para> - <para> - As of PHP 5.3.0, it's possible to reference the class using a variable. - The variable's value cannot be a keyword (e.g. <literal>self</literal>, - <literal>parent</literal> and <literal>static</literal>). - </para> + <para> + As of PHP 5.3.0, it's possible to reference the class using a variable. + The variable's value cannot be a keyword (e.g. <literal>self</literal>, + <literal>parent</literal> and <literal>static</literal>). + </para> - <example> - <title>Static property example</title> - <programlisting role="php"> + <example> + <title>Static property example</title> + <programlisting role="php"> <![CDATA[ <?php class Foo @@ -96,28 +133,9 @@ print $bar->fooStatic() . "\n"; ?> ]]> - </programlisting> - </example> - - <example> - <title>Static method example</title> - <programlisting role="php"> -<![CDATA[ -<?php -class Foo { - public static function aStaticMethod() { - // ... - } -} - -Foo::aStaticMethod(); -$classname = 'Foo'; -$classname::aStaticMethod(); // As of PHP 5.3.0 -?> -]]> </programlisting> - </example> - + </example> + </sect2> </sect1> <!-- Keep this comment at the end of the file Modified: phpdoc/en/trunk/language-snippets.ent =================================================================== --- phpdoc/en/trunk/language-snippets.ent 2015-09-21 12:17:25 UTC (rev 337874) +++ phpdoc/en/trunk/language-snippets.ent 2015-09-21 12:17:30 UTC (rev 337875) @@ -196,6 +196,11 @@ <emphasis>DEPRECATED</emphasis> as of PHP 5.6.0. Relying on this feature is highly discouraged.</simpara></warning>'> +<!ENTITY warn.deprecated.feature-7-0-0 '<warning +xmlns="http://docbook.org/ns/docbook"><simpara>This feature has been +<emphasis>DEPRECATED</emphasis> as of PHP 7.0.0. Relying on this feature +is highly discouraged.</simpara></warning>'> + <!ENTITY removed.php.future 'This deprecated feature <emphasis xmlns="http://docbook.org/ns/docbook">will</emphasis> certainly be <emphasis xmlns="http://docbook.org/ns/docbook">removed</emphasis> in the future.'>

« previous php.doc.cvs (#13754) next »