<p dir="auto">The scope of a block of PHP code that is enclosed inside of a separate language (ie. within a JS block in a page) is not detected properly if the enclosing PHP tags are both on the same line. If the tags are not separated onto different lines then Atom thinks the code is just part of the enclosing code block.</p>
<p dir="auto">For example, this bit of code is incorrectly detected as part of the JavaScript block:</p>
<div class="highlight highlight-text-html-php notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&lt;html&gt;
&lt;head&gt;
    &lt;script type=&quot;text/javascript&quot;&gt;
    &lt;?php echo 'test'; ?&gt;
    &lt;/script&gt;
&lt;/head&gt;
&lt;/html&gt;"><pre class="notranslate">&lt;html&gt;
&lt;head&gt;
    &lt;script type="<span class="pl-s">text/javascript</span>"&gt;
    <span class="pl-ent">&lt;?php</span> <span class="pl-k">echo</span> <span class="pl-s">'test'</span>; <span class="pl-ent">?&gt;</span>
    <span class="pl-kos">&lt;/</span>script<span class="pl-kos">&gt;</span>
<span class="pl-kos">&lt;/</span>head<span class="pl-kos">&gt;</span>
<span class="pl-kos">&lt;/</span>html<span class="pl-kos">&gt;</span></pre></div>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://cloud.githubusercontent.com/assets/427137/8488254/2724c51c-20c6-11e5-9ca2-2aac8c7c8dbf.png"><img src="https://cloud.githubusercontent.com/assets/427137/8488254/2724c51c-20c6-11e5-9ca2-2aac8c7c8dbf.png" alt="screenshot from 2015-07-02 14 22 25" style="max-width: 100%;"></a></p>
<p dir="auto">While this code is properly detected as being a PHP block:</p>
<div class="highlight highlight-text-html-php notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&lt;html&gt;
&lt;head&gt;
    &lt;script type=&quot;text/javascript&quot;&gt;
    &lt;?php
    echo 'test';
    ?&gt;
    &lt;/script&gt;
&lt;/head&gt;
&lt;/html&gt;"><pre class="notranslate">&lt;html&gt;
&lt;head&gt;
    &lt;script type="<span class="pl-s">text/javascript</span>"&gt;
    <span class="pl-ent">&lt;?php</span>
    <span class="pl-k">echo</span> <span class="pl-s">'test'</span>;
    <span class="pl-ent">?&gt;</span>
    <span class="pl-kos">&lt;/</span>script<span class="pl-kos">&gt;</span>
<span class="pl-kos">&lt;/</span>head<span class="pl-kos">&gt;</span>
<span class="pl-kos">&lt;/</span>html<span class="pl-kos">&gt;</span></pre></div>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://cloud.githubusercontent.com/assets/427137/8488257/2e924252-20c6-11e5-9efa-831ef95bdccc.png"><img src="https://cloud.githubusercontent.com/assets/427137/8488257/2e924252-20c6-11e5-9efa-831ef95bdccc.png" alt="screenshot from 2015-07-02 14 23 06" style="max-width: 100%;"></a></p>
<hr>
<p dir="auto">This issue is present on a completely fresh Atom installation, as well as one with a multitude of plugins.<br>
Atom Version: 1.0.0<br>
Operating Systems:</p>
<ul dir="auto">
<li>Ubuntu 15.04 x64</li>
<li>Windows 8.1 x64</li>
</ul>
<p dir="auto"><a href="https://discuss.atom.io/t/bug-wrong-classes-for-php-inside-js" rel="nofollow">A thread has come up</a> on the forum that points out that <code class="notranslate">&lt;?php ... ?&gt;</code> doesn't get matched as PHP code when on the same line. I did a little bit of poking around and found that the embedded whitespace pattern has a negative lookahead <code class="notranslate">(?![^?]*\\?&gt;)</code> that, when removed, allows single-line PHP comments to display. The thing is, I can't figure out what that negative lookahead was put there to check against. <a href="https://github.com/DamnedScholar/language-php">My fork of this package</a> seems to work just fine.</p>
<p dir="auto">Does anybody know what the negative lookahead was meant to guard against?</p>