# [RFC] Line markers in PHP

- Thread: https://externals.io/message/54501
- Original archive: https://news-web.php.net/php.internals/54501
- Started by Gwynne Raskind on 2011-08-11T04:29:49+00:00
- Messages: 3
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #54501 — Gwynne Raskind — 2011-08-11T04:29:49+00:00

URL: https://externals.io/message/54501#54501

I've just created a new RFC, https://wiki.php.net/rfc/linecontrol ,
regarding adding cpp(1)'s linemarkers to PHP. Discussion is invited.

-- Gwynne

---

## #54503 — Nikita Popov — 2011-08-11T05:34:36+00:00

URL: https://externals.io/message/54501#54503 · In reply to: #54501

In my eyes this change isn't necessary and if it is, not with this syntax.

First the syntax: PHP is not C, we do not have preprocessing
instructions using hash notation. Such a syntax seems unfamiliar in
PHP. Additionally # is already used for single line comments so
there's actually is no backwards compatability: Old code that
accidentally was of your proposed form would trigger a line marker,
potentially causing much confusion when debugging. If we really do
need such a feature it should follow PHP's declare syntax:

declare(line=17, file='hi');
// or
declare(line=5) {
   // ...
}

Now concerning your use cases: It is fairly easy to rewrite PHP
errors. One of the examples you give are Smarty templates. Twig
(another template engine), already does line number rewrites by
inserting `// line ...` comments into the template and extracting that
information using the tokenizer.
(https://github.com/fabpot/Twig/blob/master/lib/Twig/Error.php#L147)
It's not terribly complicated. And this is the most complex case,
where line number distribution is not just off-by-n, but really
requires line-hints in the source. For the PHPT tests a simple
addition of the number of lines before the actual test will suffice.
Even no tokenizer needed.

(Sorry, forgot to send to list)

---

## #54505 — Stas Malyshev — 2011-08-11T08:29:11+00:00

URL: https://externals.io/message/54501#54505 · In reply to: #54501

Hi!


> I've just created a new RFC, https://wiki.php.net/rfc/linecontrol ,
> regarding adding cpp(1)'s linemarkers to PHP. Discussion is invited.
>
> -- Gwynne
>

Frankly, this seems to be pretty narrow use case for language syntax 
change. Though you could in theory run PHP through all kinds of 
preprocessors, including cpp, in practice this is rarely done, and one 
could as well write a short app which parses error messages and does 
necessary substitutions for these narrow cases.

-- 
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227
