Skip to content

Commit

Permalink
#2321 - Add failing test case
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeckerson committed Nov 12, 2021
1 parent db604d1 commit 2e485c2
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
22 changes: 22 additions & 0 deletions stub/closures.zep
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,26 @@ class Closures
{
return call_user_func(this->_function, this->_argument);
}

/**
* @issue https://github.com/zephir-lang/zephir/issues/2321
*/
public function issue2321CallPrivateCallback() -> string
{
return this->issue2321filterQuery("filtered_value");
}

private function issue2321filterQuery(string value) -> string
{
return preg_replace_callback(
"/(?:[^%:!\$&\'\(\)\*\+,;=@\/\?]+|%(?![A-Fa-f0-9]{2}))/u",
[this, "doUrlEncode"],
value
);
}

private function issue2321doUrlEncode(array matches) -> string
{
return rawurlencode(matches[0]);
}
}
7 changes: 7 additions & 0 deletions tests/Extension/ClosureTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,11 @@ public function testIssue1036(): void

$this->assertTrue($test->issue1036Call());
}

public function testIssue2321CallPrivateCallbackViaPrivateMethod(): void
{
$test = new Closures();

$this->assertSame('filtered_value', $test->issue2321CallPrivateCallback());
}
}

0 comments on commit 2e485c2

Please sign in to comment.