PSMinifier icon indicating copy to clipboard operation
PSMinifier copied to clipboard

Function parameters are stripped if defined without "param" keyword

Open koderrr opened this issue 1 year ago • 0 comments

function testfunc($str1, $str2)
{
    'calling testfunc'
    $str1
    $str2
}

function testfunc2 {
    Param([string]$str1, [string]$str2)
    
    'calling testfunc2'
    $str1
    $str2
}

testfunc 'foo' 'bar'
testfunc2 'foo' 'bar'

Output:

calling testfunc
foo
bar
calling testfunc2
foo
bar

After PSMinifier:

function testfunc{'calling testfunc';$str1;$str2};function testfunc2{param([string]$str1,[string]$str2)'calling testfunc2';$str1;$str2};testfunc 'foo' 'bar';testfunc2 'foo' 'bar' Output:

calling testfunc
calling testfunc2
foo
bar

koderrr avatar Aug 13 '24 13:08 koderrr