<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
    <channel>
        <title>[PHP-DEV] Enforcing final in traits</title>
        <description> This caused a few bugs for us / confusion. The final keyword is accepted inside a trait but it the class also defines a method without the final keyword this takes precedence.

Two solutions:
Enforce final when a trait defines - https://whisky.macvicar.net/patches/0001-If-a-trait-declares-a-method-as-final-enforce-that.patch

Prohibit final form being used in a trait - https://whisky.macvicar.net/patches/002-traits-Disable-use-of-final-keyword.patch

I'm for the first solution here

- S
-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php</description>
        <link>http://www.serverphorums.com/read.php?7,490368,490368#msg-490368</link>
        <lastBuildDate>Fri, 24 May 2013 13:49:49 +0200</lastBuildDate>
        <generator>Phorum 5.2.18</generator>
        <item>
            <guid>http://www.serverphorums.com/read.php?7,490368,490751#msg-490751</guid>
            <title>Re: [PHP-DEV] Enforcing final in traits</title>
            <link>http://www.serverphorums.com/read.php?7,490368,490751#msg-490751</link>
            <description><![CDATA[ On Sat, May 5, 2012 at 1:38 AM, Stefan Marr &lt;php@stefan-marr.de&gt; wrote:<br />
&gt;<br />
&gt; On 04 May 2012, at 21:46, Hannes Magnusson wrote:<br />
&gt;<br />
&gt;&gt; On Fri, May 4, 2012 at 8:30 PM, Scott MacVicar &lt;scott@macvicar.net&gt; wrote:<br />
&gt;&gt;&gt; This caused a few bugs for us / confusion. The final keyword is accepted inside a trait but it the class also defines a method without the final keyword this takes precedence.<br />
&gt;<br />
&gt; The methods in the class always take precedency.<br />
&gt;<br />
&gt; However, the final keyword might just be something I overlooked.<br />
&gt; It sounds sensible that if the final is not explicitly removed during composition to treat it as what final was meant for and check it against the methods defined in the class body as well.<br />
&gt;<br />
&gt; Scott, could you elaborate a bit of the use case of final in a trait?<br />
<br />
Here is an example:<br />
<a href="http://stackoverflow.com/questions/7104957/building-a-singleton-trait-with-php-5-4" target="_blank"  rel="nofollow">http://stackoverflow.com/questions/7104957/building-a-singleton-trait-with-php-5-4</a><br />
<br />
Not the best things to use traits for, but probably something people<br />
*will* try to do.<br />
<br />
Nikita<br />
<br />
-- <br />
PHP Internals - PHP Runtime Development Mailing List<br />
To unsubscribe, visit: <a href="http://www.php.net/unsub.php" target="_blank"  rel="nofollow">http://www.php.net/unsub.php</a>]]></description>
            <dc:creator>Nikita Popov</dc:creator>
            <category>php-internals</category>
            <pubDate>Sat, 05 May 2012 11:30:01 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?7,490368,490644#msg-490644</guid>
            <title>Re: [PHP-DEV] Enforcing final in traits</title>
            <link>http://www.serverphorums.com/read.php?7,490368,490644#msg-490644</link>
            <description><![CDATA[ On 04 May 2012, at 21:46, Hannes Magnusson wrote:<br />
<br />
&gt; On Fri, May 4, 2012 at 8:30 PM, Scott MacVicar &lt;scott@macvicar.net&gt; wrote:<br />
&gt;&gt; This caused a few bugs for us / confusion. The final keyword is accepted inside a trait but it the class also defines a method without the final keyword this takes precedence.<br />
<br />
The methods in the class always take precedency. <br />
<br />
However, the final keyword might just be something I overlooked.<br />
It sounds sensible that if the final is not explicitly removed during composition to treat it as what final was meant for and check it against the methods defined in the class body as well.<br />
<br />
Scott, could you elaborate a bit of the use case of final in a trait?<br />
<br />
<br />
<br />
&gt; it also ignores visibility abstract and static..<br />
<br />
abstract is not ignored.<br />
An abstract method in a trait expresses a requirement to the host class (using class).<br />
<br />
In general, the ppp visibilities are seen as hints for the standard usage of a trait, but can be changed during composition.<br />
<br />
<br />
<br />
Thanks<br />
Stefan<br />
<br />
<br />
<br />
-- <br />
Stefan Marr<br />
Software Languages Lab<br />
Vrije Universiteit Brussel<br />
Pleinlaan 2 / B-1050 Brussels / Belgium<br />
<a href="http://soft.vub.ac.be/~smarr" target="_blank"  rel="nofollow">http://soft.vub.ac.be/~smarr</a><br />
Phone: +32 2 629 2974<br />
Fax:   +32 2 629 3525<br />
<br />
<br />
-- <br />
PHP Internals - PHP Runtime Development Mailing List<br />
To unsubscribe, visit: <a href="http://www.php.net/unsub.php" target="_blank"  rel="nofollow">http://www.php.net/unsub.php</a>]]></description>
            <dc:creator>Stefan Marr</dc:creator>
            <category>php-internals</category>
            <pubDate>Sat, 05 May 2012 01:40:01 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?7,490368,490409#msg-490409</guid>
            <title>Re: [PHP-DEV] Enforcing final in traits</title>
            <link>http://www.serverphorums.com/read.php?7,490368,490409#msg-490409</link>
            <description><![CDATA[ On Fri, May 4, 2012 at 8:30 PM, Scott MacVicar &lt;scott@macvicar.net&gt; wrote:<br />
&gt; This caused a few bugs for us / confusion. The final keyword is accepted inside a trait but it the class also defines a method without the final keyword this takes precedence.<br />
&gt;<br />
<br />
it also ignores visibility abstract and static..<br />
<br />
I thought this was intentional?<br />
<br />
-Hannes<br />
<br />
-- <br />
PHP Internals - PHP Runtime Development Mailing List<br />
To unsubscribe, visit: <a href="http://www.php.net/unsub.php" target="_blank"  rel="nofollow">http://www.php.net/unsub.php</a>]]></description>
            <dc:creator>Hannes Magnusson</dc:creator>
            <category>php-internals</category>
            <pubDate>Fri, 04 May 2012 21:50:02 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?7,490368,490368#msg-490368</guid>
            <title>[PHP-DEV] Enforcing final in traits</title>
            <link>http://www.serverphorums.com/read.php?7,490368,490368#msg-490368</link>
            <description><![CDATA[ This caused a few bugs for us / confusion. The final keyword is accepted inside a trait but it the class also defines a method without the final keyword this takes precedence.<br />
<br />
Two solutions:<br />
Enforce final when a trait defines - <a href="https://whisky.macvicar.net/patches/0001-If-a-trait-declares-a-method-as-final-enforce-that.patch" target="_blank"  rel="nofollow">https://whisky.macvicar.net/patches/0001-If-a-trait-declares-a-method-as-final-enforce-that.patch</a><br />
<br />
Prohibit final form being used in a trait - <a href="https://whisky.macvicar.net/patches/002-traits-Disable-use-of-final-keyword.patch" target="_blank"  rel="nofollow">https://whisky.macvicar.net/patches/002-traits-Disable-use-of-final-keyword.patch</a><br />
<br />
I'm for the first solution here<br />
<br />
- S<br />
-- <br />
PHP Internals - PHP Runtime Development Mailing List<br />
To unsubscribe, visit: <a href="http://www.php.net/unsub.php" target="_blank"  rel="nofollow">http://www.php.net/unsub.php</a>]]></description>
            <dc:creator>Scott MacVicar</dc:creator>
            <category>php-internals</category>
            <pubDate>Fri, 04 May 2012 20:40:02 +0200</pubDate>
        </item>
    </channel>
</rss>
