Modify

Ticket #411 (closed defect: fixed)

Opened 2 years ago

Last modified 2 years ago

PhpEvalTask calculation should not always returns anything

Reported by: yegor256@… Owned by: mrook
Priority: major Milestone: 2.4.0
Component: phing-core Version: 2.3.3
Keywords: Cc:

Description

This is what I have to do in our projects:

<php expression="false; initialize_my_application();">

As you see, looks a bit dirty. Would be much better to have some flag in PhpEvalTask to disable return value at all. Or maybe this task should understand that if there is no returnValue parameter - it should understand it like this:

<php expression="initialize_my_application();">

Attachments

Change History

comment:1 Changed 2 years ago by mrook

  • Status changed from new to assigned

comment:2 Changed 2 years ago by mrook

Not sure what you want to achieve here, the PhpEvalTask is fine with your function not returning a value.

I.e. the following snippet:

<php expression="echo 'test';"/>

works just fine.

comment:3 Changed 2 years ago by yegor256@…

Hm, this is what I'm getting:

PHP Parse error:  syntax error, unexpected T_ECHO in /usr/share/pear/phing/tasks/system/PhpEvalTask.php(114) : eval()'d code on line 1
PHP Stack trace:
PHP   1. {main}() /usr/share/pear/phing.php:0
PHP   2. Phing::fire() /usr/share/pear/phing.php:37
PHP   3. Phing::start() /usr/share/pear/phing/Phing.php:270
PHP   4. Phing->runBuild() /usr/share/pear/phing/Phing.php:170
PHP   5. Project->executeTargets() /usr/share/pear/phing/Phing.php:543
PHP   6. Project->executeTarget() /usr/share/pear/phing/Project.php:687
PHP   7. Target->performTasks() /usr/share/pear/phing/Project.php:714
PHP   8. Target->main() /usr/share/pear/phing/Target.php:263
PHP   9. Task->perform() /usr/share/pear/phing/Target.php:240
PHP  10. PhingTask->main() /usr/share/pear/phing/Task.php:253
PHP  11. PhingTask->processFile() /usr/share/pear/phing/tasks/system/PhingTask.php:150
PHP  12. Project->executeTarget() /usr/share/pear/phing/tasks/system/PhingTask.php:275
PHP  13. Target->performTasks() /usr/share/pear/phing/Project.php:714
PHP  14. Target->main() /usr/share/pear/phing/Target.php:263
PHP  15. Task->perform() /usr/share/pear/phing/Target.php:240
PHP  16. PhpEvalTask->main() /usr/share/pear/phing/Task.php:253
PHP  17. PhpEvalTask->evalExpression() /usr/share/pear/phing/tasks/system/PhpEvalTask.php:64

For this code in my build.xml:

<php expression='echo "APPLICATION_ENV=" . APPLICATION_ENV . "\n";' />

When I'm changing it to this:

<php expression='false; echo "APPLICATION_ENV=" . APPLICATION_ENV . "\n";' />

Everything works fine.

comment:4 Changed 2 years ago by mrook

What PHP and Phing versions are you running? When I try your snippet, Phing returns:

[php] Evaluating PHP expression: echo "APPLICATION_ENV=" . APPLICATION_ENV . "\n";
APPLICATION_ENV=APPLICATION_ENV

comment:5 Changed 2 years ago by mrook

Could you please update this ticket with your Phing and PHP versions?

comment:6 Changed 2 years ago by yegor256@…

Sure, my versions:

$ php --version
PHP 5.3.0 (cli) (built: Dec  4 2009 17:12:12) 
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2009 Zend Technologies
    with Xdebug v2.1.0-dev, Copyright (c) 2002-2009, by Derick Rethans
$ phing -v
Phing version 2.4.0RC2

comment:7 Changed 2 years ago by mrook

(In [680]) Refs #411 - allow expressions that do not return a value (when returnProperty is not set)

comment:8 Changed 2 years ago by mrook

  • Status changed from assigned to closed
  • Resolution set to fixed

My mistake, I had disabled some code which prevented me from reproducing your issue. This has now been fixed in r680 - when returnProperty is not set, the task will simply eval() the expression.

View

Add a comment

Modify Ticket

Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.