1
0
mirror of https://github.com/danog/PHP-Parser.git synced 2024-11-30 04:19:30 +01:00
Commit Graph

269 Commits

Author SHA1 Message Date
nikic
4743e9b0b8 Update constant scalar expression support 2014-04-19 22:53:13 +02:00
nikic
e4e56511b9 Merge branch '0.9' 2014-04-19 22:26:35 +02:00
nikic
5960ecfc10 Disable xdebug.scream while lexing 2014-04-19 22:26:05 +02:00
Nikita Popov
c341ab2ecf Make autoloader for new names PSR-0 compliant 2014-04-02 09:44:45 +02:00
nikic
c62ffedfca Require file only if file exists
Allows usage of class_exists() on undefined classes.
2014-03-27 15:40:08 +01:00
nikic
4c06b0919a Merge branch '0.9'
Conflicts:
	lib/PhpParser/Template.php
	lib/PhpParser/TemplateLoader.php
2014-03-27 12:53:24 +01:00
nikic
8429157ab5 Deprecate templating functionality
Other projects cover this a lot better.
2014-03-27 12:51:13 +01:00
Martin Hasoň
2605b8319e Added support for autoload $prepend 2014-03-27 12:39:30 +01:00
nikic
91f6880734 Improve pretty printing of empty statement lists
The pStmts() method now also includes the leading \n, however only
if the statement list is non-empty.
2014-03-27 12:31:21 +01:00
nikic
b3332184cf Minor cleanups to emulative lexer
Be consistent about version numbers. We'll only emulate until
beta1 of a release, as that's the feature freeze release.
2014-03-27 00:01:39 +01:00
nikic
1cb6e1407c Fix ** emulation wrt comments 2014-03-26 23:41:06 +01:00
nikic
a5e0bbcb62 Support use function/const in name resolver 2014-03-26 23:28:32 +01:00
nikic
3b7829b011 Add support for function and constant import (PHP 5.6) 2014-03-26 22:33:45 +01:00
nikic
bea89a0bf2 Add support for constant scalar expressions (PHP 5.6) 2014-03-26 21:48:12 +01:00
nikic
cda6f575f0 Add support for pow operator (PHP 5.6) 2014-03-26 19:18:16 +01:00
nikic
b5bcfa1168 Add support for argument unpacking (PHP 5.6) 2014-03-26 18:42:46 +01:00
nikic
96f1151ab2 Add support for variadic parameters (PHP 5.6) 2014-03-26 18:23:30 +01:00
nikic
f5be0d30f7 Guarantee that subnodes are always in the right order 2014-03-22 14:49:56 +01:00
Tomáš Polomský
c8c233f900 Correctly pretty print negative floats 2014-03-22 14:24:35 +01:00
nikic
8c59f41d02 Remove inline Name[] creations
This ensures that the attributes on the Name nodes are correct.
2014-03-22 14:24:33 +01:00
nikic
70077039b4 Add Scalar\MagicConst->getName()
Return magic constant name, e.g. __CLASS__.

Resolves #95.
2014-02-21 18:16:18 +01:00
nikic
1c8481bff6 Merge branch '0.9'
Conflicts:
	lib/PhpParser/Lexer.php
	lib/PhpParser/Node/Stmt/Class.php
	lib/PhpParser/Node/Stmt/ClassMethod.php
	lib/PhpParser/Node/Stmt/Interface.php
	lib/PhpParser/Node/Stmt/Namespace.php
	lib/PhpParser/Node/Stmt/UseUse.php
	lib/PhpParser/Parser.php
2014-02-12 20:23:12 +01:00
Martin Hasoň
118f28344d Synchronized error messages with native php error messages 2014-02-12 20:19:48 +01:00
nikic
523e024ba0 Fix a number of other typos 2014-02-12 17:47:34 +01:00
nikic
f82862ec9c Port library to use namespaces, with BC for old names 2014-02-06 20:29:35 +01:00
nikic
10e1c1895c Remove 5.2 compatibilty code in some places 2014-02-05 22:37:07 +01:00
Arne Blankerts
6f36a88993 Ensure no registered error handler will see the 'reset' error 2014-01-24 20:27:42 +01:00
Brikou Carré
72310dd5a3 s/Elseif/ElseIf/ 2013-11-27 15:05:37 +01:00
Jean-François Simon
7f4ab26732 Fix name resolver (class names are case insensitive) 2013-11-15 20:27:56 +01:00
Charles Sprayberry
700847e295 Add NodeTraverser::removeVisitor() 2013-09-28 13:21:30 +02:00
nikic
01123ae6af Fix notices when generating expected tokens list (continued)
Forgot to add regenerated parser
2013-07-27 18:50:08 +02:00
nikic
77c08a75c9 Fix pretty printing of include expressions 2013-07-27 16:23:27 +02:00
nikic
f9c3aa2a22 Improve PrettyPrinter construction perf by not using uniqid
The uniqid function is *very* slow on unix systems. The code has no
particular unique-ness requirements, so the much faster mt_rand()
function is used instead.

Closes PR #65.
2013-07-13 01:03:57 +02:00
nikic
5ccf6196d6 Update changelog 2013-05-23 15:17:59 +02:00
Florent
12faad529e Add interface builder 2013-05-23 15:14:58 +02:00
nikic
c0da1b88b2 Merge pull request #59 from Trismegiste/refactor-adding-an-interface-for-LSP
Adding an interface to the Node Traverser for LSP concern
2013-05-22 14:45:21 -07:00
Florent
900a3f3b7c Implementing the interface for PHPParser_NodeTraverser 2013-05-16 15:44:12 +02:00
Florent
92df3e5add Adding the interface 2013-05-16 15:43:24 +02:00
Jamie Burns
ba91348142 Typo fix 2013-05-15 16:48:42 +02:00
nikic
08f0cde6f9 Add prettyPrintFile() method 2013-04-15 20:53:23 +02:00
nikic
75ec7a3e78 Looks like I forgot to git add some files... 2013-02-14 21:49:08 +01:00
nikic
81d20bf10e Pretty print namespaces in semicolon-style if possible 2013-01-15 18:21:42 +01:00
nikic
db18906dfc Rename PrettyPrinter_Zend to PrettyPrinter_Default 2013-01-15 17:43:36 +01:00
nikic
fbaa1e5fc3 Add information on expected tokens to syntax errors
This now mimics the error messages provided by PHP itself (pre 5.4).
2013-01-15 17:30:14 +01:00
nikic
222c9612ab Use RegexIterator in docs (by @lstrojny)
Also fix formatting in changelog and be more specific in a doc comment.
2012-12-21 13:28:35 +01:00
nikic
cdbad02fb2 Fix endAttributes assignment
The end attributes previously were always assigned from the last read token,
which does not necessarily correspond to the last token in the reduced rule.
In particular this occurs if the parser read a new token and based on that
lookahead decided to reduce a rule. The behavior was only correct if the
newly read token was first shifted and then the rule was reduced.

This is fixed by buffering the endAttributes of the new token in a temporary
variable and only assigning them once the token is shifted.
2012-11-20 16:12:19 +01:00
Nicolò Martini
bdb58ada7c Update lib/PHPParser/BuilderAbstract.php
Updated BuilderAbstract::normalizeValue phpdoc description.
2012-11-06 18:28:15 +01:00
nikic
fc56da59ce Rename pSafe to pNoIndent
Matches the function more closely
2012-10-31 17:50:54 +01:00
nikic
df17d62b40 Fix switch formatting
The switch cases were not indented and fall-through cases had an
unnecessary additional newline.

Patch by @pscheit (PR #39).
2012-10-31 17:46:48 +01:00
nikic
ac6f221c50 Better prededence and associativity handling in pretty printer
Previously the pretty printer added unnecessary and odd-looking parentheses
when several operators with the same precedence were chained:

    'a' . 'b' . 'c' . 'd' . 'e'
    // was printed as
    'a' . ('b' . ('c' . ('d' . 'e')))

Another issue reported as part of #39 was that assignments inside closures
were wrapped in parentheses:

    function() {
        $a = $b;
    }
    // was printed as
    function() {
        ($a = $b);
    }

This was caused by the automatic precedence handling, which just regarded
the closure as an ordinal nested expression.

With the new system the $predenceMap of PrettyPrinterAbstract contains both
precedence and associativity and there is a new method pPrec() which prints
a node taking precedence and associativity into account.

For simpler usage there are additional function pInfixOp(), pPrefixOp() and
pPostfixOp().

Prints not going through pPrec() do not have any precedence handling (fixing
the closure issue).
2012-10-31 17:34:06 +01:00