PHP Parser |
Version 2.0.1 (Feb 17, 2012)
Matthieu Casanova <chocolat.mou@gmail.com>
|
Introduction
In the beginning of 2003 I found the phpeclipse project, a plugin to do php in Eclipse.
I worked on it, and finaly wrote an alternative php parser for the project.
The matter is that I don't like SWT very much so when I discovered discovered jEdit
I loved it. So I decided to write a plugin using my php parser.
It uses ErrorList plugin to show the errors and Sidekick plugin to manage parser.
Usage
Parsing
The parser is now launched by Sidekick plugin. You can ask to reparse the file with the "parse buffer" action of
Sidekick.
You can choose to enable parse on keystroke within Sidekick, it should be slower, but with good computer there
will be
no problem.
Project management
The project management is a feature that will allow you to describe a project. A project is a group of files
(under a
root folder). It supports VFS so you can
have a root on a ftp for example. To manage project please open the dockable view.
When you create a project you'll have to choose a root folder. After that, click on the "reparse" button. It
will
parse all php files in your project
and keep track of them in memory (you can show the parsing progress in the jEdit's IO threads). Of course, each
time
you'll open a file in your project and
work on it, this file will be updated in the project memory. But only files under your root will be added.
This feature will be useful for code completion (there is a little but I hope I'll add a lot more after), and
for code
browsing
Code Browsing
The parser will provide a Sidekick structure view of you file, to show it, use the "Structure browser" of Sidekick
plugin.
There are also 3 actions to browse php code : Find class, Find method and Find in file. Those actions will work if you
have a project up to date.
It will display a small dialog working like OpenIt plugin (I took a lot of ideas from this plugin), and you'll be able
to do incremental search on classes, methods,
displaying a little list of matching class or methods (depends on action you choosed). When you select one, the file
will be opened at the good position.
Code completion
I added some code completion, but it doesn't work very well for the moment. To enable it, please use the action
"Show
completion popup" from Sidekick.
There are completion after the following situation :
- extends
- new
- $this->
- AnyClass::
The completion will work better with a project too, for example after new and extends, I will display
all classes in the project.
After $this-> I'll display methods and fields of the class and superclasses.
After AnyClass:: I'll display methods of the class and superclasses ...
Code analysis
There are some code analysis but you should be very careful because it's far from being perfect. If a variable
is
given to a
method and is assigned by reference, the parser will not know that and report it as variable used but not
assigned ...
History
- 2.0.1
- Bugs fixed
- Fixed parser not accepting public, protected, private, final, static as
field name in class access (#3485279)
- Fixed parsing error when a function do not have a body (#3485282)
- Better handling of function definitions using varargs
- Better handling of number argument type
- double and integer types can be accepted by methods requiring float
- Type.numbers renamed to Type.number
- Better match of function call hyperlinks
- 2.0.0
- New feature
- Added full php function list with code analysis
- Bugs fixed
- Added support for goto with code analysis
- Fixed a bug in list() parsing
- Fixed code analysis of list() declarations
- Added php function definitions (#1940034)
- Fixed Constant are type UNKNOWN by default and not String
- Fixed use namespace syntax when declaring multiple namespaces (#3428773)
- Fixed an exception in catch clauses
- Fixed use of namespace syntax in some expressions (#3435702, #3469455, #3471383, #3471497, #3473467)
- Fixed jEdit that doesn't remember the PHPParser option pane
- 1.4.1
- Bugs fixed
- Fixed detection of used variables in throw statements
- Fixed when a string is starting with \n (#3425249)
- Fixed parsing of abstract methods
- 1.4.0
- Bugs fixed
- Fix \u parsing in strings (#3277545)
- Fix multiple const declaration (#3073213)
- Fix parsing of class access
- Support of static:: syntax
- Fix deadlock (#3405572, patch #3407202 from Evan Wright)
- Support of use keyword for namespaces (#3423954)
- Start of hyperlinks implementation (press ctrl+click on methods or classes)
- 1.3.2
- Bugs fixed
- Fixed evaluable string parsing (#3063857)
- Fixed identifiers allowed after const keyword in class constants.
- Fix fully qualified class instantiation
- Fix else: syntax where there is no statement
- 1.3.1
- Bugs fixed
- Fixed a bug in field parsing
- Fixed const parsing
- Fixed clone($a) syntax
- Fixed position of errors when using tab character
- Do not search for unused parameters in abstract methods
- 1.3.0
Dropped specific php 4 support.
- Features
- conditional expression (ternary/elvis) inspection :
a warning is created if true and false value are the same
(very limited check).
- Added a warning when having $$ in code. While it may be wanted, it is usually a bug.
- Updated to use JavaCC 5.0.
- Bugs fixed
- Fixed parsing of use($x,...) in closure declaration
- fixed parsing of variables in String (#2935111)
- exception during parsing of $ in strings that happens sometimes (#2897416)
- added short ternary operator ($a = $b ?:$c) (#2461597)
- several parsing bug in class declaration
- several parsing bug in double quoted strings (#2944017)
- fixes in heredoc (#2855209)
- better type detection for cast expressions
- 1.2.7
- Bugs fixed
- Added basic namespace keyword support
- Allow $this->return syntax
- fixed an exception when parsing interface declaration (#1910321)
- the variables used in <?=$tutu?> were ignored by code analysis
- Fixed chained method call syntax (#2854175)
- The parser now accept methods with name = null (#2849929)
- closure parsing support (#2461603)
- 1.2.6
- Bugs fixed
- public static method() declaration in interface (#1910321)
- Wrong use check of variables in "instanceof" expression (#1739752)
- "default" keyword confuses the parser (#1891144)
- it is now allowed to extends Object (#2318629)
- 1.2.5
- Bugs fixed
- loading project where several classes have the same name
- Wrong use check of variables in "instanceof" expression (#1739752)
- "default" keyword confuses the parser (#1891144)
- 1.2.4
- Bugs fixed
- clone keyword support
- 1535949 fixed : default method call type was String, it is now Unknown
- syntax class::constant
- Changes
- Quick search sorted by name length (this is better now :)
- 1.2.3
- Bugs fixed
- better modifier parsing
- a bug fixed in code analysis of try statements
- some bugs fixed in dockable panel
- 1458668 fixed (< while ($a) : ?>blabla<?endwhile;?>
- 1432935 fixed
- 1489533 fixed (const keyword)
- Syntax like TR_TreeAction::getInstance('containers')->isRoot(5); fixed
- several fields declared in the same likes is now allowed in php 5
- 1.2.2
- Missing '?>' is now reported as warning and can be deactivated in the options
- Better code completion handling for interfaces
- <?xml token is now ignored (I think if you put such token, your php.ini config will only accept
<?php for
starting php scripts
- Bugs fixed
- php 5 : better handling of type of the method parameters (array and several other keywords
are now allowed)
- Class access are allowed after method calls ( $a->test()->tutu() )
- Interfaces can now extends several interfaces
- 1378327 fixed
- 981809 fixed
- 1066608 fixed
- 1368690 fixed : syntax like if ($a && $b = 3)
- Bug fixed when you had an interface in a project preventing the project to load
- 1.2.1
- Option for conditional expression warning
- Bugs fixed
- Release 1.2.0 was missing some icons
- NPE fixed in smart code completion
- Some code analysis were executed twice
- NPE fixed in ArrayInitializer code analysis array('foo',) syntax
- 1.2.0
- Bugs fixed
- 1203867 bugfix with code analysis
- 1098323 A ?> in an heredoc syntax will not crash the parser anymore
- 1098321 The keyword xor is now supported
- Fix warning in code analysis on global requiring super globals variables
- a memory leak, the PHPErrorSource was instantiated on each parse and never
released
- Keywords that can be method names should now be managed.
- Features
- Sidekick completion
- Project handling
- Quick access to find class and methods
- new warning for syntax case '' ; (semicolon instead of colon)
- Parsing of double quoted strings
- php 5 support
- Others
- Some cleanup in the parser
- 1.1.0
- The files edited with jEdit php mode are parsed, no more option pane to choose them
- Sidekick structure tree
- Parse on keystroke with sidekick
- Code analysis:
- Unused method parameters reported
- Variable used before being assigned are reported
- 1.0.3
- Heredoc support
- My contact adress changed
- 1.0.2
- When you deactivate the parser in the options, it will really be deactivated
- lot of bugfixes in the parsing
known issue
- when you deactivate the parser the errors aren't removed from ErrorList (but is it really a bug or a feature
?)
- When you have several classes or methods with the same name in the project only one is kept in the project
memory
Feedback
Please report bugs to the bug jEdit's plugin tracker on sourceforge.net