#11 PHP function generated by `-a defun -l php' missing '$'

closed
Kuwata Makoto
5
2005-05-08
2005-05-08
Kuwata Makoto
No

PHP function generated by `-a defun -l php' missing
prefix '$' of argument variables.

example.
<?php
function view_foo($__args) {
$user = $__args['user']
$ item_list = $__args[' item_list']
return _view_foo(user, item_list)
}
function _view_foo(user, item_list) {
ob_start();
....
ob_end_clean();
return $__s;
}
}
?>

version: rev.75, release.2.0.1

Discussion

  • Kuwata Makoto
    Kuwata Makoto
    2005-05-08

    Logged In: YES
    user_id=221589

    patch:

    --- lib/kwartz/defun.rb (revision 75)
    +++ lib/kwartz/defun.rb (working copy)
    @@ -90,6 +90,7 @@
    s << " include ERB::Util" << nl if lang ==
    'erb' && klass
    s << " def #{prefix}#{function}(__args)" << nl
    arguments.split(',').each do |arg|
    + arg.strip!
    s << " #{arg} = __args[:#{arg}]" << nl
    end if arguments
    s << " return _#{function}(#{arguments})" << nl
    @@ -118,16 +119,19 @@
    function = context[:function] ||
    function_name(context[:filename])
    arguments = context[:arguments]

    + args_str = arguments.split(',').collect { |arg|
    "$" + arg.strip.sub(/\ $/,'') }.join(", ")
    nl = (body =~ /(.?)\n/ && $1 == "\r") ? "\r\n" : "\n"
    s = "<?php" << nl
    s << "class #{klass}" << nl if klass
    s << " function #{function}($__args) {" << nl
    arguments.split(',').each do |arg|
    + arg.strip!
    + arg.sub!(/\A\$/, '')
    s << " $#{arg} = $__args['#{arg}']" << nl
    end if arguments
    - s << " return
    _#{function}(#{arguments})" << nl
    + s << " return _#{function}(#{args_str})"
    << nl
    s << " }" << nl
    - s << " function _#{function}(#{arguments})
    {" << nl
    + s << " function _#{function}(#{args_str}) {"
    << nl
    s << " ob_start();" << nl
    s << "?>" << body
    s << "<?php" << nl

    fixed: rev.76, release.2.0.2
    test: defun-test.rb test_defun_php1, test_defun_php2

     
  • Kuwata Makoto
    Kuwata Makoto
    2005-05-08

    • status: open --> closed