Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[ExpressionLanguage] Added a way to dump the AST#19013

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
fabpot merged 1 commit intosymfony:masterfromlyrixx:el-dump
Jun 13, 2016

Conversation

@lyrixx
Copy link
Member

@lyrixxlyrixx commentedJun 9, 2016
edited
Loading

QA
Branch?master
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets
LicenseMIT
Doc PR

Because it's convenient and it makes easier to inline results of sub/smaller part of the main expression.

$str .=sprintf('%s,',$pair['value']->dump());
}

$str =rtrim($str,',');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

you can return here directly (same everywhere)

@stof
Copy link
Member

stof commentedJun 9, 2016

Cannot be accepted without tests

@lyrixx
Copy link
MemberAuthor

I addressed your comments, and I added some tests.

@lyrixxlyrixx changed the title[ExpressionLanguage] Added a way to dump AST[ExpressionLanguage] Added a way to dump the ASTJun 10, 2016

foreach ($this->getKeyValuePairs()as$pair) {
$key =$pair['key']->attributes['value'];
if (!is_int($key)) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

when int keys are used but not in numerical order, this won"t work, isn't it?

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I don't see why it would not work. but if it's the case, how could I fix it?

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Fixed.

@lyrixxlyrixxforce-pushed theel-dump branch 2 times, most recently from2dbc349 to23a5c66CompareJune 10, 2016 15:24

protectedfunctiondumpEscape($value)
{
returnstr_replace(['\\','"'], ['\\\\','\"'],$value);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

array(...)

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I fixed another one too, and added more tests. RFR ;)

@nicolas-grekas
Copy link
Member

👍

publicfunctiondump(ParsedExpression$expression)
{
return$expression->getNodes()->dump();
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I would remove this method and add adump() method onParsedExpression instead.

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@fabpot I addressed your comments.


publicfunctiondump()
{
returnsprintf('<Dumping a "%s" instance is not supported yet>',get_class($this));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Wouldn't it be better to just throw an exception here? As the dumped expression is not usable anyway.

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I don't know. It was easier to be able to see a "preview" while developing than an exception.
But indeed, as the expression is not valid, let throw an expression. (done)

return$results;
}

publicfunctiondump()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

You should add a phpdoc here.

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Other public method don't have PHPDoc... So it tried to be consistent here ;)

@fabpot
Copy link
Member

Thank you@lyrixx.

@fabpotfabpot merged commit87af6e5 intosymfony:masterJun 13, 2016
fabpot added a commit that referenced this pull requestJun 13, 2016
This PR was merged into the 3.2-dev branch.Discussion----------[ExpressionLanguage] Added a way to dump the AST| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets || License       | MIT| Doc PR        |Because it's convenient and it makes easier to inline results of sub/smaller part of the main expression.Commits-------87af6e5 [ExpressionLanguage] Added a way to dump AST
@lyrixxlyrixx deleted the el-dump branchJune 13, 2016 12:21
fabpot added a commit that referenced this pull requestJun 15, 2016
…en dumping the AST (nicolas-grekas)This PR was merged into the 3.2-dev branch.Discussion----------[ExpressionLanguage] Add a way to hook on each node when dumping the AST| Q             | A| ------------- | ---| Branch?       | "master| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets |#19013| License       | MIT| Doc PR        | -This is an iteration over#19013 to allow writing dumpers that can decorate dumps (e.g. add HTML tags based on each node type to do syntax highlighting).Commits-------66d23db [ExpressionLanguage] Add a way to hook on each node when dumping the AST
@fabpotfabpot mentioned this pull requestOct 27, 2016
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

5 participants

@lyrixx@stof@nicolas-grekas@fabpot@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp