<table><tr><td style="">mtijink created this revision.<br />mtijink added a project: KDevelop.<br />Restricted Application added a subscriber: kdevelop-devel.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D6837" rel="noreferrer">View Revision</a></tr></table><br /><div><strong>REVISION SUMMARY</strong><div><p>In bug 381123 KDevelop crashed on certain PHP code. The underlying cause seems to that the <tt style="background: #ebebeb; font-size: 13px;">classDec</tt> does not have an <tt style="background: #ebebeb; font-size: 13px;">internalContext()</tt> set (no clue why, I couldn't figure that out).</p>
<p>This diff fixes the crash, but does not yield the desired behaviour: automatically deriving the type of the foreach variable (i.e. in the example of the test plan: the <tt style="background: #ebebeb; font-size: 13px;">$row</tt> variable should be an <tt style="background: #ebebeb; font-size: 13px;">int</tt>, but is currently calculated as <tt style="background: #ebebeb; font-size: 13px;">mixed</tt>. Placing the foreach after the class definition works, though).</p></div></div><br /><div><strong>TEST PLAN</strong><div><p>The following steps used to crash kdevelop, now they don't.</p>
<ol class="remarkup-list">
<li class="remarkup-list-item">Open the following file and wait until it's been parsed (reduced from the example of Alexander Zighalin as posted on bug 381123)</li>
</ol>
<div class="remarkup-code-block" style="margin: 12px 0;" data-code-lang="php" data-sigil="remarkup-code-block"><pre class="remarkup-code" style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; padding: 12px; margin: 0; background: rgba(71, 87, 120, 0.08);"><span style="color: #304a96"><?php</span>
<span style="color: #74777d">/*</span>
<span style="color: #74777d">/* */</span>
<span style="color: #aa4000">foreach</span><span style="color: #aa2211">(</span><span style="color: #aa4000">new</span> <span style="color: #00702a" data-symbol-name="foo">foo</span><span style="color: #aa2211">()</span> <span style="color: #aa4000">as</span> <span style="color: #001294">$row</span><span style="color: #aa2211">)</span> <span style="color: #aa2211">{}</span>
<span style="color: #aa4000">class</span> <span style="color: #000a65">foo</span> <span style="color: #aa4000">implements</span> <span style="color: #00702a" data-symbol-name="Iterator">Iterator</span> <span style="color: #aa2211">{</span>
<span style="color: #aa4000">public</span> <span style="color: #aa4000">function</span> <span style="color: #000a65">current</span><span style="color: #aa2211">():</span> <span style="color: #000a65">int</span> <span style="color: #aa2211">{</span>
<span style="color: #aa2211">}</span>
<span style="color: #aa2211">}</span></pre></div>
<ol class="remarkup-list" start="2">
<li class="remarkup-list-item">Close the comment on line 2 by hitting enter and closing it with <tt style="background: #ebebeb; font-size: 13px;">*/</tt></li>
</ol></div></div><br /><div><strong>REPOSITORY</strong><div><div>R52 KDevelop: PHP Support</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D6837" rel="noreferrer">https://phabricator.kde.org/D6837</a></div></div><br /><div><strong>AFFECTED FILES</strong><div><div>duchain/builders/typebuilder.cpp</div></div></div><br /><div><strong>To: </strong>mtijink, KDevelop<br /><strong>Cc: </strong>kdevelop-devel, KDevelop, geetamc, Pilzschaf, akshaydeo, surgenight, arrowdodger<br /></div>