diff --git a/lib/Stampie/Mailer.php b/lib/Stampie/Mailer.php index 1fda423..cb72328 100644 --- a/lib/Stampie/Mailer.php +++ b/lib/Stampie/Mailer.php @@ -182,7 +182,7 @@ protected function buildIdentityString($identities) *@return array * @see \Stampie\Utils\AttachmentUtils::processAttachments */ - protected function processAttachments(array $attachments, callable $callback) + protected function processAttachments(array $attachments, $callback) { return AttachmentUtils::processAttachments($attachments, $callback); } diff --git a/lib/Stampie/Mailer/MailGun.php b/lib/Stampie/Mailer/MailGun.php index e002a8a..b71746c 100644 --- a/lib/Stampie/Mailer/MailGun.php +++ b/lib/Stampie/Mailer/MailGun.php @@ -137,7 +137,7 @@ protected function handle(ResponseInterface $response) /** * {@inheritdoc} */ - protected function processAttachments(array $attachments, callable $callback){ + protected function processAttachments(array $attachments, $callback){ return array_values(parent::processAttachments($attachments, $callback)); } } diff --git a/lib/Stampie/Mailer/Mandrill.php b/lib/Stampie/Mailer/Mandrill.php index c297f45..a6f6984 100644 --- a/lib/Stampie/Mailer/Mandrill.php +++ b/lib/Stampie/Mailer/Mandrill.php @@ -141,7 +141,7 @@ protected function getAttachmentContent(AttachmentInterface $attachment){ /** * {@inheritdoc} */ - protected function processAttachments(array $attachments, callable $callback) + protected function processAttachments(array $attachments, $callback) { // Strip keys return array_values(parent::processAttachments($attachments, $callback)); diff --git a/lib/Stampie/Mailer/Postmark.php b/lib/Stampie/Mailer/Postmark.php index 7e7e02e..0592bca 100644 --- a/lib/Stampie/Mailer/Postmark.php +++ b/lib/Stampie/Mailer/Postmark.php @@ -120,7 +120,7 @@ protected function getAttachmentContent(AttachmentInterface $attachment){ /** * {@inheritdoc} */ - protected function processAttachments(array $attachments, callable $callback){ + protected function processAttachments(array $attachments, $callback){ // Strip keys return array_values(parent::processAttachments($attachments, $callback)); } diff --git a/lib/Stampie/Util/AttachmentUtils.php b/lib/Stampie/Util/AttachmentUtils.php index cf4ec55..06ae57a 100644 --- a/lib/Stampie/Util/AttachmentUtils.php +++ b/lib/Stampie/Util/AttachmentUtils.php @@ -20,8 +20,12 @@ abstract class AttachmentUtils * * @throws \InvalidArgumentException */ - public static function processAttachments(array $attachments, callable $callback) + public static function processAttachments(array $attachments, $callback) { + if (!is_callable($callback)) { + throw new \InvalidArgumentException('Callback must be callable'); + } + $processed = array(); foreach ($attachments as $attachment) { diff --git a/tests/Stampie/Tests/Mailer/MailGunTest.php b/tests/Stampie/Tests/Mailer/MailGunTest.php index 6e2c783..742a81a 100644 --- a/tests/Stampie/Tests/Mailer/MailGunTest.php +++ b/tests/Stampie/Tests/Mailer/MailGunTest.php @@ -45,9 +45,10 @@ public function testHeaders() public function testGetFiles(){ $self = $this; // PHP5.3 compatibility - $token = self::SERVER_TOKEN; - $buildMocks = function($attachments, &$invoke) use($self, $token){ - $mailer = $self->getMock('\\Stampie\\Mailer\\MailGun', null, array($self->adapter, $token)); + $adapter = $this->adapter; + $token = self::SERVER_TOKEN; + $buildMocks = function($attachments, &$invoke) use($self, $adapter, $token){ + $mailer = $self->getMock('\\Stampie\\Mailer\\MailGun', null, array($adapter, $token)); // Wrap protected method with accessor $mirror = new \ReflectionClass($mailer); diff --git a/tests/Stampie/Tests/Mailer/MandrillTest.php b/tests/Stampie/Tests/Mailer/MandrillTest.php index a41dd0f..e890e61 100644 --- a/tests/Stampie/Tests/Mailer/MandrillTest.php +++ b/tests/Stampie/Tests/Mailer/MandrillTest.php @@ -177,9 +177,10 @@ public function testFormatAttachments() public function testGetFiles(){ $self = $this; // PHP5.3 compatibility - $token = self::SERVER_TOKEN; - $buildMocks = function($attachments, &$invoke) use($self, $token){ - $mailer = $self->getMock('\\Stampie\\Mailer\\Mandrill', null, array($self->adapter, $token)); + $adapter = $this->adapter; + $token = self::SERVER_TOKEN; + $buildMocks = function($attachments, &$invoke) use($self, $adapter, $token){ + $mailer = $self->getMock('\\Stampie\\Mailer\\Mandrill', null, array($adapter, $token)); // Wrap protected method with accessor $mirror = new \ReflectionClass($mailer); diff --git a/tests/Stampie/Tests/Mailer/PostmarkTest.php b/tests/Stampie/Tests/Mailer/PostmarkTest.php index e27179e..cc6e274 100644 --- a/tests/Stampie/Tests/Mailer/PostmarkTest.php +++ b/tests/Stampie/Tests/Mailer/PostmarkTest.php @@ -151,9 +151,10 @@ public function testFormatAttachments() public function testGetFiles(){ $self = $this; // PHP5.3 compatibility - $token = self::SERVER_TOKEN; - $buildMocks = function($attachments, &$invoke) use($self, $token){ - $mailer = $self->getMock('\\Stampie\\Mailer\\Postmark', null, array($self->adapter, $token)); + $adapter = $this->adapter; + $token = self::SERVER_TOKEN; + $buildMocks = function($attachments, &$invoke) use($self, $adapter, $token){ + $mailer = $self->getMock('\\Stampie\\Mailer\\Postmark', null, array($adapter, $token)); // Wrap protected method with accessor $mirror = new \ReflectionClass($mailer); diff --git a/tests/Stampie/Tests/Mailer/SendGridTest.php b/tests/Stampie/Tests/Mailer/SendGridTest.php index 93309f2..131e531 100644 --- a/tests/Stampie/Tests/Mailer/SendGridTest.php +++ b/tests/Stampie/Tests/Mailer/SendGridTest.php @@ -180,9 +180,10 @@ public function testFormatAttachments() public function testGetFiles(){ $self = $this; // PHP5.3 compatibility - $token = self::SERVER_TOKEN; - $buildMocks = function($attachments, &$invoke) use($self, $token){ - $mailer = $self->getMock('\\Stampie\\Mailer\\SendGrid', null, array($self->adapter, $token)); + $adapter = $this->adapter; + $token = self::SERVER_TOKEN; + $buildMocks = function($attachments, &$invoke) use($self, $adapter, $token){ + $mailer = $self->getMock('\\Stampie\\Mailer\\SendGrid', null, array($adapter, $token)); // Wrap protected method with accessor $mirror = new \ReflectionClass($mailer);