Skip to content

Commit

Permalink
Merge pull request laminas#101 from samsonasik/replace-call-user-func…
Browse files Browse the repository at this point in the history
…-self-invoke

Fixes laminas#34 replace call_user_func* with self invoked function
  • Loading branch information
weierophinney committed Aug 5, 2020
2 parents 7322a65 + 289808b commit 8d038fe
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Transport/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function setOptions(FileOptions $options)
public function send(Message $message)
{
$options = $this->options;
$filename = call_user_func($options->getCallback(), $this);
$filename = $options->getCallback()($this);
$file = $options->getPath() . DIRECTORY_SEPARATOR . $filename;
$email = $message->toString();

Expand Down
2 changes: 1 addition & 1 deletion src/Transport/Sendmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public function send(Mail\Message $message)
$headers = str_replace("\r\n", "\n", $headers);
}

call_user_func($this->callable, $to, $subject, $body, $headers, $params);
($this->callable)($to, $subject, $body, $headers, $params);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions test/Header/AddressListHeaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public function getStringHeaders()
public function testDeserializationFromString($headerLine, $class)
{
$callback = sprintf('%s::fromString', $class);
$header = call_user_func($callback, $headerLine);
$header = $callback($headerLine);
$this->assertInstanceOf($class, $header);
$list = $header->getAddressList();
$this->assertEquals(4, count($list));
Expand Down Expand Up @@ -175,7 +175,7 @@ public function getHeadersWithComments()
public function testAllowsNoWhitespaceBetweenHeaderAndValue($headerLine, $class)
{
$callback = sprintf('%s::fromString', $class);
$header = call_user_func($callback, $headerLine);
$header = $callback($headerLine);
$this->assertInstanceOf($class, $header);
$list = $header->getAddressList();
$this->assertEquals(4, count($list));
Expand Down
2 changes: 1 addition & 1 deletion test/Transport/FileOptionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function testDefaultCallbackIsSetByDefault()
{
$callback = $this->options->getCallback();
$this->assertInternalType('callable', $callback);
$test = call_user_func($callback, '');
$test = $callback('');
$this->assertRegExp('#^LaminasMail_\d+_\d+\.eml$#', $test);
}

Expand Down

0 comments on commit 8d038fe

Please sign in to comment.