# Code Parser

- Thread: https://externals.io/message/14325
- Original archive: https://news-web.php.net/php.internals/14325
- Started by vikas agrawal on 2005-01-10T14:09:43+00:00
- Messages: 7
- 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

---

## #14325 — vikas agrawal — 2005-01-10T14:09:43+00:00

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

Can some body tell me about the php parser which will
first parse the programmer's code before uploading to
the server? so that php interpreter will interpret
stream lined code/understandable/indentable code for
performance.

Please reply.
Vikas


		
__________________________________ 
Do you Yahoo!? 
The all-new My Yahoo! - What will yours do?
http://my.yahoo.com

---

## #14327 — Derick Rethans — 2005-01-10T15:31:32+00:00

URL: https://externals.io/message/14325#14327 · In reply to: #14325

> Can some body tell me about the php parser which will
> first parse the programmer's code before uploading to
> the server? so that php interpreter will interpret
> stream lined code/understandable/indentable code for
> performance.

What do you want to know about it?

Derick
-- 
Derick Rethans
http://derickrethans.nl | http://ez.no | http://xdebug.org

---

## #14328 — Lukas Smith — 2005-01-10T15:33:47+00:00

URL: https://externals.io/message/14325#14328 · In reply to: #14327

Derick Rethans wrote:
> 
> 
> 
> > […]
> 
> 
> What do you want to know about it?

If you want to check for security related things you may want to have a 
look at:
http://bluga.net/projects/PHPCodeAnalyzer/

However your question sounds more related to using PHP and developing 
PHP. However this list is focused on the development of PHP. Therefore 
php-general seems like the more appropriate list to ask your question.

regards,
Lukas

---

## #14329 — Leonardo Pedretti — 2005-01-10T16:15:32+00:00

URL: https://externals.io/message/14325#14329 · In reply to: #14325

Are there any plans to include type hinting with basic types and type hinting 
for variables? (such as optional declaration)
It would be useful to declare the type of a data member of a class, for 
example, for automation of data fetching from SQL databases or such things.

Regards
-- 

Leonardo Pedretti
Axon Sistemas
Líder de Equipo Proyecto Basalto

---

## #14330 — Derick Rethans — 2005-01-10T20:58:19+00:00

URL: https://externals.io/message/14325#14330 · In reply to: #14329

> Are there any plans to include type hinting with basic types and type hinting
> for variables? (such as optional declaration)

There are no such things planned, except for "array" afaik.

> It would be useful to declare the type of a data member of a class, for
> example, for automation of data fetching from SQL databases or such things.

That is *definitely* not on the list - PHP is weakly typed and will
remain so.

Derick

-- 
Derick Rethans
http://derickrethans.nl | http://ez.no | http://xdebug.org

---

## #14388 — Leonardo Pedretti — 2005-01-14T16:01:43+00:00

URL: https://externals.io/message/14325#14388 · In reply to: #14330

> 
> > […]
>
> There are no such things planned, except for "array" afaik.
That is quite good already, but...
> > […]
>
> That is *definitely* not on the list - PHP is weakly typed and will
> remain so.
I can't understand why being able to point some variable as strongly typed and 
remaining the default as weak typed would make php strongly typed. In fact, 
that assumption IS incorrect, a language is weakly typed when variable types 
are not forced to be respected though they already exist and change 
dynamically, and the programmer actively having to point a variable as 
strongly typed for the scope of a function obviously does not contradict that 
postulate.
Even more, just having that feature in object data members would be heaven. 
Basic type hinting can be emulated using is_int, is_string, and so on on the 
beginning of the function needing that, but for objects it can not be done to 
know the type of a data member previously to it's assignment, and having to 
assign a value in the constructor forces one to declare a specific 
constructor doing that for classes that derive or implement an interface that 
has functions using that type for automation of tasks. Code just would be 
really so cleaner just by allowing one to put a type in front of an object 
data member declaration and allowing to retrieve that type.

For example, consider this code:

abstract class base {
 function __construct() {
  // constructor just sets up some things
 }
 function someoperation() {
  /* this function needs to load the data members of basic types with some 
clear values but everything that is an object or an array must be filled 
through some specific process that can be automated just knowing the specific 
type in advance */
 }
}

class specific_class {
 function construct() {
  $var1 = new SomeClass;
  $var2 = new SomeOtherClass;
 }
 private $var1;
 private $var2;
}

would the types could be showed int the class, function someoperation could 
still perform its task without any change, but specific_class now would be 
just the following:

class specific_class {
 private SomeClass $var1;
 private SomeOtherClass $var2;
}

Which is identical to the upper version. Moreover, specifying the constructor 
parameters in the declaration should not be a problem, as it is equivalent 
code to the upper version.

Well, i hope all this can be useful!

Regards
Leo

>
> Derick
>
> --
> Derick Rethans
> http://derickrethans.nl | http://ez.no | http://xdebug.org

-- 

Leonardo Pedretti
Axon Sistemas
Líder de Equipo Proyecto Basalto

---

## #14399 — Marek Kilimajer — 2005-01-18T00:38:59+00:00

URL: https://externals.io/message/14325#14399 · In reply to: #14325

vikas agrawal wrote:
> Can some body tell me about the php parser which will
> first parse the programmer's code before uploading to
> the server? so that php interpreter will interpret
> stream lined code/understandable/indentable code for
> performance.
> 
> Please reply.
> Vikas

You can use tokenizer:

http://sk.php.net/manual/en/ref.tokenizer.php
