Commit Graph

306 Commits

Author SHA1 Message Date
Nikita Popov
04e05907c3 Fix CRLF issue in Serializer\XML test
No idea why this suddenly turned up now.
2015-06-13 18:20:05 +02:00
Nikita Popov
61e060694d Implement generalized yield operator
And split tokens.y off, so I don't waste time debugging this again...
2015-06-13 18:11:40 +02:00
Nikita Popov
602b9807eb Import some UVS tests 2015-06-13 15:42:09 +02:00
Nikita Popov
f372a4c4ab Move modeline handling into CodeTestAbstract 2015-06-13 15:10:46 +02:00
Nikita Popov
d18dcc0c7f Implement UVS 2015-06-13 14:59:24 +02:00
Nikita Popov
74c57eef0e Test PHP 5 and PHP 7 parsers
At this point they should return the same result.
2015-06-13 13:56:45 +02:00
Nikita Popov
dca46febc9 Implement semi-reserved identifiers 2015-06-13 12:47:13 +02:00
Nikita Popov
1a1bd1448d Support mixed group use declarations 2015-06-13 11:27:38 +02:00
Nikita Popov
9620f79cdc Add partial group use support
Supported via Stmt\GroupUse which has Name $prefix in addition to
the usual.

Still missing: Mixed group uses.
2015-06-12 23:05:28 +02:00
Nikita Popov
5d1e3be7d4 Anonymize some callbacks 2015-05-02 22:35:15 +02:00
Nikita Popov
cc75dd3612 Drop support for PHP 7 aliases 2015-05-02 22:21:12 +02:00
Nikita Popov
5f621c5adc Drop support for legacy aliases from v0.9 2015-05-02 22:19:25 +02:00
Nikita Popov
29b9015f51 Drop support for old Node format 2015-05-02 22:17:34 +02:00
Nikita Popov
8b64195cf2 Try .17G print if .16G is not enough
This should be enough for all cases, because: A double has 53 bits
of mantissa (including the implicit 1 bit), which is 53*ln(2)/ln(10)
= 15.95 decimal digits. However the leading decimal digit may encode
less than the usual 3.32 bits, which will push this over the edge to
requiring 17 decimal digits.
2015-05-02 11:48:55 +02:00
Nikita Popov
9caa51b3a5 Add some more tests 2015-05-01 20:18:04 +02:00
Nikita Popov
648800f07f Increase float pretty printing precision
This removes the reliance on the "precision" ini setting.
Furthermore the default of precision=14 is not sufficient.
2015-05-01 19:15:33 +02:00
Nikita Popov
23bf4f0c13 Add some error documentation 2015-04-30 21:58:45 +02:00
Nikita Popov
272ab6c8d8 Add some recovery tests 2015-04-30 19:02:51 +02:00
Nikita Popov
0731b47655 Don't distinguish test-fail / test
With error recovery this is fluid. Using .test for everything.
2015-04-30 17:45:36 +02:00
Nikita Popov
3b7d8e8b5d Enable basic error recovery
Adding only a single recovery rule for now.

The API is now:
 * throwOnError parser option must be disabled.
 * List of Errors is available through $parser->getErrors(). This
   method is available either way.
 * If no recovery is possible $parser->parse() will return null.
   (Obviously only if throwOnError is disabled).
2015-04-30 17:41:57 +02:00
Nikita Popov
a35c2a2067 Add column info to EOF errors
EOF errors are now located one past the end of the file.
2015-04-27 15:37:41 +02:00
Nikita Popov
55b2ead967 Make special class name checks case insensitive 2015-04-26 23:13:27 +02:00
Nikita Popov
e1a0ec3724 Add support for anonymous classes
Has not landed upstream yet, but syntax is unlikely to change.
2015-04-26 23:04:31 +02:00
Nikita Popov
338bc1f8e7 Fix "print" pretty-printing
Precedence was previously ignored.
2015-04-26 11:56:04 +02:00
Nikita Popov
ab80054e97 Add support for "yield from" 2015-04-26 11:56:02 +02:00
Nikita Popov
c8454271e1 Make column info 1-based 2015-04-18 21:20:45 +02:00
Nikita Popov
62f83a0dc2 Add column info for non-syntax errors where relatively precise
Should it also be added if only rough information is available? E.g.
spanning an entire class?
2015-04-18 13:27:58 +02:00
Nikita Popov
611fa5c7f1 Test parser position information (syntax errors) 2015-04-18 13:27:57 +02:00
Nikita Popov
4defbc2174 Make Error column info attribute based 2015-04-18 12:51:26 +02:00
Gerrit Addiks
33a39fae06 added column-numbers to syntax errors 2015-04-18 10:14:49 +02:00
Nikita Popov
617bf0aa41 Fix registering of PHP 7 aliases
The previous approach was causing issues, because "instanceof"
does not invoke the autoloader.
2015-03-24 20:04:50 +01:00
Nikita Popov
dce19b074b Strict type compliance
Were this library to be fully annotated with scalar types and
return types where possible and were strict types to be enabled
for all files, the test suite would now pass.
2015-03-24 11:19:17 +01:00
Matthieu Napoli
729c7bde0c #184 Add a flag to NodeTraverser to avoid cloning nodes 2015-03-22 11:19:04 +13:00
Nikita Popov
8982315b4e Rename Cast\Object as well
As it will very likely be soft-reserved in PHP 7.

Old alias is still available, as usual.
2015-03-21 18:57:55 +01:00
Nikita Popov
7ec277e1e1 Replace another Scalar\String occurance
Also canonicalize NameResover tests to avoid those pesky CRLF
issues.
2015-03-21 18:47:20 +01:00
Nikita Popov
1a627872f0 Rename nodes for compat with PHP 7
The old names will still be available on PHP 5.x.
2015-03-20 21:49:38 +01:00
Nikita Popov
592836c4dc Add support for T_HASHBANG (HHVM) 2015-03-14 19:53:08 +01:00
Nikita Popov
251e689283 Add support for spaceship operator (<=>) [PHP 7]
Added as Expr\BinaryOp\Spaceship.
2015-03-12 23:13:31 +01:00
Nikita Popov
01f4be6b4d Add support for null coalesce operator (??) [PHP 7]
Added as Expr\BinaryOp\Coalesce.
2015-03-12 22:45:56 +01:00
Nikita Popov
dc28449d81 Drop whitespace after ... varargs collection
Also drop an obsolete pretty printer test.
2015-03-12 22:19:34 +01:00
Nikita Popov
3ad0d4b310 Add support for return type declarations [PHP 7]
This adds an additional "returnType" subnode to Stmt\Function_,
Stmt\ClassMethod and Expr\Closure, as well as the corresponding
support in the name resolver and pretty printer.
2015-03-12 22:16:12 +01:00
Nikita Popov
4dbf067b4b Add a few more string interpolation tests
Originally wanted to simplify the pretty-printer output, but ...
edge cases everywhere :/
2015-03-11 20:01:26 +01:00
Nikita Popov
0c34706799 Add "use" builder 2015-03-10 16:05:55 +01:00
Nikita Popov
f9fc2fc9ee Add support for global namespace in NS builder
NULL argument can now be used to create a global namespace {} block.
2015-03-10 15:28:19 +01:00
Nikita Popov
a2d7e8977a Use real properties for storing subnodes
Instead of storing subnodes in a subNodes dictionary, they are
now stored as simple properties. This requires declarating the
properties, assigning them in the constructor, overriding
the getSubNodeNames() method and passing NULL to the first argument
of the NodeAbstract constructor.

[Deprecated: It's still possible to use the old mode of operation
for custom nodes by passing an array of subnodes to the constructor.]

The only behavior difference this should cause is that getSubNodeNames()
will always return the original subnode names and skip any additional
properties that were dynamically added. E.g. this means that the
"namespacedName" node added by the NameResolver visitor is not treated
as a subnode, but as a dynamic property instead.

This change improves performance and memory usage.
2015-03-09 08:54:20 +01:00
Thomas Ruiz
73cace360d Implicit public should not generate as explicit public 2015-03-08 20:21:01 +01:00
Nikita Popov
d56ff5a351 Fix lexer tests for HHVM
HHVM does not throw warnings from token_get_all()
for invalid chars and unterminated comments. This
is not really integral functionality, so I'm okay
to just skip it to get a passing HHVM build.
2015-02-26 19:19:40 +01:00
Nikita Popov
3028bc8081 And make it work on PHP 5 as well... 2015-02-26 16:40:21 +01:00
Nikita Popov
91295a0790 Make tests compatible with PHP 7
When parsing on PHP 7 we will no longer be able to deal with
code that contains invalid octal literals. Currently we'll fatal,
after engine exceptions land we'll throw an exception instead.
2015-02-26 16:26:29 +01:00
Tom Rochette
1366e833a1 Move getMethods() to new ClassLike node
Class_, Interface_ and Trait_ extend the ClassLike node, which
provides the getMethods() method.
2015-01-31 22:59:38 +01:00
Nikita Popov
6930feac43 Add some tests for pretty printing expressions 2015-01-18 19:57:09 +01:00
Nikita Popov
0a445c7656 Test lexer returning invalid token 2015-01-18 00:11:10 +01:00
Nikita Popov
9689763e20 Cover both DONT_TRAVERSE_CHILDREN cases 2015-01-18 00:10:01 +01:00
Nikita Popov
4071c4645d Add NodeTraverser::DONT_TRAVERSE_CHILDREN support 2015-01-11 22:13:58 +01:00
Nikita Popov
4cd2b95a23 Fix 5.3 build and some small cleanups 2014-12-19 18:54:56 +01:00
Nikita Popov
7ab88416ac Enforce Name|string for names in builders
While array (with name components) could technically be allowed (as
they are supported by the Name node itself), more likely than not
an array would due to incorrect usage of the API (e.g. array instead
of variadics).
2014-12-19 18:50:16 +01:00
Nikita Popov
ba625063e7 Support fully-qualified and ns-relative names in builders 2014-12-19 18:48:21 +01:00
Nikita Popov
b4b93ccb21 Add integration test for builders 2014-12-19 18:35:19 +01:00
Stepan Anchugov
01643e06d3 Add namespace builder 2014-12-19 18:19:33 +01:00
Nikita Popov
4387454fe0 Add trait builder (for completeness...) 2014-12-19 17:59:23 +01:00
Nikita Popov
e69c9ee38c Fix attribute assigment test with crlf newlines 2014-12-19 17:28:22 +01:00
Nikita Popov
894c3f787d Add test for attribute assignment by parser
Weird that this wasn't tested yet...
2014-12-19 00:37:38 +01:00
Nikita Popov
46975107a7 Support token position attributes in lexer
Also change endFilePos semantics to refer to the last character that
is *included* in the token, rather than one past the last character.
This ensures that all end* attributes have the same semantics.
2014-12-19 00:37:36 +01:00
Nikita Popov
2438848487 Add support for doc comments in builders 2014-12-13 13:44:40 +01:00
nikic
8507af6f4a Add missing require in tests
Test files aren't autoloaded, so this was order-dependent.
2014-11-27 21:01:56 +01:00
nikic
7c98ad6f9b Support file offsets in emulative lexer as well
Also run normal lexer tests against emulative lexer and fix a bug
in __halt_compiler() handling found as a result.
2014-11-27 20:57:38 +01:00
Máximo Cuadros Ortiz
d774dbc1b7 Add optional startFilePos and endFilePos attributes
The lexer can now optionally add startFilePos and endFilePos
attributes, which are offsets in to the lexed code string.

The end offset currently points one past the last character of
the token - this is pending further discussion.

The attributes are not added by default and have to be enabled
using the new 'usedAttributes' lexer option:

	$lexer = new Lexer([
		'usedAttributes' => [
			'comments', 'startLine', 'endLine',
			'startFilePos', 'endFilePos'
		]
	]);
2014-11-27 20:38:29 +01:00
nikic
e26e63e9b0 Error on final or abstract properties 2014-11-13 20:25:52 +01:00
nikic
0f69f12b94 Use "public" visibility when not explicitly given
Fixes issue #143
2014-11-13 20:21:21 +01:00
nikic
7fbdb79a08 Fix whitespace when printing trait alias modifiers 2014-11-03 16:16:15 +01:00
Arne Blankerts
6fad8ff32a Make NameResolver resolve trait alias and precedence names 2014-11-03 16:06:43 +01:00
nikic
66fd29cb58 Use stricter assertions where possible 2014-09-30 20:38:09 +02:00
nikic
69701430c1 Cover remaining constant scalar expressions 2014-09-28 13:05:23 +02:00
nikic
6dc24fa9f5 Fix coverage annotations 2014-09-28 12:49:12 +02:00
nikic
3e1665bbbd Disallow new without a class name
Fixes #137.
2014-09-28 12:41:35 +02:00
nikic
6423864160 Add Autoloader tests 2014-09-12 13:45:34 +02:00
nikic
fd064dac6c Very that node type is valid in XML unserializer 2014-09-12 00:39:59 +02:00
nikic
d9bd550414 Fix XML unserializer 2014-09-12 00:37:21 +02:00
nikic
94eca2ce44 Remove deprecated Template and TemplateLoader 2014-09-12 00:25:30 +02:00
nikic
452e1c0180 Add constant dereferencing, a list-minute 5.6 change 2014-08-31 16:14:36 +02:00
nikic
6d0589d14f Ensure that special class names are unqualified
Replicates the PHP error message
2014-08-11 22:04:52 +02:00
nikic
ef121e690c Preserve case of "static" class name 2014-08-11 21:44:50 +02:00
Elliot Levin
c0340053d1 Fix case sensitivity for special class names 2014-08-11 21:41:54 +02:00
nikic
1f143393e5 Rewrite namespace handling code
Add a check for disallowed statements between braced namespaces
while at it.
2014-04-21 15:16:00 +02:00
nikic
4743e9b0b8 Update constant scalar expression support 2014-04-19 22:53:13 +02: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
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
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
f82862ec9c Port library to use namespaces, with BC for old names 2014-02-06 20:29:35 +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
77c08a75c9 Fix pretty printing of include expressions 2013-07-27 16:23:27 +02:00
Florent
12faad529e Add interface builder 2013-05-23 15:14:58 +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
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
nikic
9e43acee2c Scalar_String::create() -> Scalar_String::parse()
Directly creating the node isn't necessary anymore, the token only needs
to be parsed. This makes it consistent with the other scalar parsing
methods and removes the need to pass $arguments around.
2012-10-19 15:17:08 +02:00
nikic
9d8e13b4a9 Fix Switch subnode order
Not that it makes much of a difference, but could have caused issues with
"out of order" visiting of nodes.
2012-10-19 14:54:56 +02:00
nikic
af5d288fb3 Add support for expressions in empty (PHP 5.5)
Apart from the grammar modifications this also renames the Empty subnode
from var to expr. This breaks BC.
2012-09-07 23:42:01 +02:00
nikic
f6c1ab6657 Adjust list and yield parsing, update prettyprinter
* nested list()s will now create nested List nodes (instead of just
   nested arrays)
 * yield $k => $v was parsed with key and value swapped. This is now fixed
 * the pretty printer now works with the newly added language constructs
2012-09-07 23:41:59 +02:00
nikic
4259b44a84 Add support for constant dereferencing (PHP 5.5)
Examples: "foo"[2], [1, 2, 3][2]
2012-09-07 23:41:58 +02:00
nikic
417a8bb07e Add support for yield expressions (PHP 5.5)
This adds a new Yield expression type, with subnodes key and value.
2012-09-07 23:41:57 +02:00
nikic
ae3774f0f2 Add support for finally clauses (PHP 5.5)
This adds a new finallyStmts subnode to the TryCatch node. If there is
no finally clause it will be null.
2012-09-07 23:41:56 +02:00
nikic
f8f1e17e41 Add support for list() in foreach (PHP 5.5)
Example: foreach ($coords as list($x, $y)) { ... }

This change slightly breaks backwards compatability, as it changes the
node structure for the previously existing `list(...) = $foo` assignments.
Those no longer have a dedicated `AssignList` node; instead they are
parsed as a normal `Assign` node with a `List` as `var`. Similarly the
use in `foreach` will generate a `List` for `valueVar`.
2012-09-07 23:41:55 +02:00
nikic
5a947e9843 Fix parsing of $foo =& new Bar;
By-reference assignments of new expressions are now parsed as AssignRef
(instead of just Assign).

Closes issue #31.
2012-07-23 11:36:47 +02:00
nikic
eb5991227d Add Class->getMethods() function 2012-07-07 16:24:07 +02:00
nikic
4137d7a7a8 Add modifier accessors for ClassMethod etc 2012-07-07 16:08:37 +02:00
nikic
4972124468 Fix test failures due to precision differences
Travis 5.2 seems to have changed the float output precision, so a test was
failing. Now the numbers in the expected output are also provided by PHP,
so they should be the same.
2012-06-08 18:19:37 +02:00
nikic
44ed30957f Fix two tests which would fail on x64 2012-06-08 18:09:42 +02:00
nikic
35ec185558 Make $line argument for Comment optional
Also add setLine() method.
2012-06-08 17:55:35 +02:00
Jon Cave
0911b2e1ce Add line number information to comments
Line numbers are stored in the $line property of the PHPParser_Comment
and PHPParser_Comment_Doc classes and can be retrieved with getLine().
2012-06-06 14:33:38 +01:00
nikic
e16513a0eb Fix parsing of new expressions in parenthesis
The new dereferencing syntaxes (new Foo)->bar and (new Foo)['bar'] were
causing a shift/reduce conflict with the '(' expr ')' rule. When
(new Foo) was encountered (without dereference operators following) the
parser thus threw a parse error.

The fix simply adds a special '(' new_expr ')' rule to expr. This does not
remove the shift/reduce conflict itself, but makes it irrelevant.

This fixes issue #20.
2012-05-12 14:11:10 +02:00
nikic
81e53ce0ff Insert comments when pretty printing
This changset also adds unit tests for Comments and adds a way to test the
pretty printer.
2012-05-11 16:18:14 +02:00
nikic
a824a2aba7 Fix $node->getDocComment()
getDocComment() now returns the last comment (given that it is a doc
comment). setDocComment() no longer exists, as it doesn't make sense
with the comment objects anymore. getAttribute() now returns by reference,
so it also works in reference contexts.
2012-05-06 18:24:26 +02:00
nikic
9d96dd1796 Adjust XML unserializer for new comments attribute 2012-05-06 18:12:02 +02:00
nikic
603582fe50 Add test coverage for two things 2012-05-06 17:58:31 +02:00
nikic
e587e3f4c6 Collect normal comments too, not only doc comments
Comments and doc comments are now saved in the 'comments' attribute, as an
array. The are instances of PHPParser_Comment[_Doc].
2012-05-06 17:49:04 +02:00
nikic
dd711f2a04 Generalize the attribute generation for nodes
Now two arrays are fetched from the lexer: $startAttributes and
$endAttributes. When constructing the attributes for a node, the
$startAttributes from the first token of the node and the $endAttributes
of the last token of the node are merged.

Now the end line is saved in the endLine attribute.
2012-05-05 17:34:27 +02:00
nikic
2f5ebf7c4d Store line and doc comment as attributes 2012-05-04 10:16:59 +02:00
nikic
3701e02d32 Use inject-once approach for lexer
Now the lexer is injected only once when creating the parser. Instead of

    $parser = new PHPParser_Parser;
    $parser->parse(new PHPParser_Lexer($code));
    $parser->parse(new PHPParser_Lexer($code2));

you write:

    $parser = new PHPParser_Parser(new PHPParser_Lexer);
    $parser->parse($code);
    $parser->parse($code2);
2012-05-04 10:16:46 +02:00
nikic
9329c91591 Merge branch 'codeGeneration'
* codeGeneration:
  Add docs for templates
  Add a filesystem template loader.
  Add simple templating support.
  Add usage example for builders to docs
  Add function builder
  Add ability to specify arrays as default values
  Add property builder
  Add parameter builder
  Add method builder
  Add class builder
2012-04-23 13:32:16 +02:00
nikic
5b27fb40ce Fix line numbers for some list structures
When defining a list in the grammar the list elements have to get a separate
rule, otherwise they'll all be assigned the same line number.
2012-04-19 00:52:44 +02:00
nikic
a45360ccaf Add tests for node attributes
Also fix the @inheritDoc declarations and do some whitespace normalization
2012-04-19 00:22:31 +02:00
nikic
337da5648c Fix XML unserializer
The subNodes array was not initialized, so for empty nodes it would just
be null. Due to the addition of attributes for nodes those have to be
initialized too.
2012-04-04 14:06:08 +02:00
nikic
e17bd0b17f Remove duplicate bootstrap.php
The tests had a separate bootstrap.php, which basically replicated the main
bootstrap.php.
2012-04-04 13:50:21 +02:00
nikic
a048112e2c Add a filesystem template loader.
The template loaders loads templates from a base directory (and can
optionally use a suffix). For example

    $templateLoader = new PHPParser_TemplateLoader(
        $parser, './templates', '.php'
    );

    // loads ./templates/TestTemplate.php
    $templateLoader->load('TestTemplate');

Again the implementation is not optimal. The loader probably shouldn't
intantiate the Template itself, but instead should accept a
TemplateFactory. This seemed like overkill to me, so I left it out.
2012-04-03 23:52:00 +02:00
nikic
19c1f80589 Add simple templating support.
Templates use __name__ placeholders. A variant of the placeholder with a
capitalized first latter can be accessed using __Name__ (this is useful
for camel case identifiers, e.g. get__Name__).

Currently the implemention is not particularly clean, because the Template
instantiates a Lexer itself. Fixing this requires a major refactoring of
the lexer/parser interface.
2012-04-03 22:47:41 +02:00
nikic
77d58a4151 Fix NameResolver tests on PHP 5.2 2012-03-17 13:52:17 +01:00
nikic
b8b68a969c Add function builder 2012-03-11 09:02:52 +01:00
nikic
9e5c95b6aa Add ability to specify arrays as default values 2012-03-11 08:53:04 +01:00
nikic
3ce3542032 Add property builder 2012-03-11 08:42:13 +01:00
nikic
4c8351fa86 Add parameter builder 2012-03-11 00:06:02 +01:00
nikic
48f0322aef Add method builder 2012-03-10 23:25:26 +01:00
nikic
88e1f2eeab Add class builder 2012-03-10 17:56:56 +01:00
nikic
e856fe3944 Remove obsolete test skip
The test no longer depends on PHP 5.4, so don't skip it.
2012-03-10 10:55:34 +01:00
nikic
0c0515c7de Replace /e modifier with callback + eval()
As this also fixes the overescaping issue, some stuff in the tests can be written more nicely now.
2012-03-02 00:28:46 +01:00
nikic
10ba9f8dda Add some tests for the emulative lexer 2012-02-21 18:45:07 +01:00