Skip to content

Commit

Permalink
Merge pull request PHPMailer#154 from Synchro/master
Browse files Browse the repository at this point in the history
Add config for scrutinizer
  • Loading branch information
Synchro committed Dec 17, 2013
2 parents e0cfd2a + 379b700 commit 12ce6b1
Show file tree
Hide file tree
Showing 12 changed files with 206 additions and 297 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -2,3 +2,4 @@ docs/phpdoc/
test/message.txt
test/testbootstrap.php
.idea
build/
126 changes: 126 additions & 0 deletions .scrutinizer.yml
@@ -0,0 +1,126 @@
before_commands:
- "composer install --prefer-source"

tools:
# Code Coverage
external_code_coverage:
enabled: true
timeout: 300
filter:
excluded_paths:
- 'docs/*'
- 'examples/*'
- 'extras/*'
- 'test/*'
- 'vendor/*'


php_code_coverage:
enabled: false
test_command: phpunit
filter:
excluded_paths:
- 'docs/*'
- 'examples/*'
- 'extras/*'
- 'test/*'
- 'vendor/*'


# Code Sniffer
php_code_sniffer:
enabled: true
command: phpcs
config:
standard: PSR2
filter:
excluded_paths:
- 'docs/*'
- 'examples/*'
- 'extras/*'
- 'test/*'
- 'vendor/*'


# Copy/Paste Detector
php_cpd:
enabled: true
command: phpcpd
excluded_dirs:
- docs
- examples
- extras
- test
- vendor


# PHP CS Fixer (http://http://cs.sensiolabs.org/).
php_cs_fixer:
enabled: true
command: php-cs-fixer
config:
level: psr2
filter:
excluded_paths:
- 'docs/*'
- 'examples/*'
- 'extras/*'
- 'test/*'
- 'vendor/*'


# Analyzes the size and structure of a PHP project.
php_loc:
enabled: true
command: phploc
excluded_dirs:
- docs
- examples
- extras
- test
- vendor


# PHP Mess Detector (http://phpmd.org).
php_mess_detector:
enabled: true
command: phpmd
config:
rulesets:
- codesize
- unusedcode
- naming
- design
filter:
excluded_paths:
- 'docs/*'
- 'examples/*'
- 'extras/*'
- 'test/*'
- 'vendor/*'


# Analyzes the size and structure of a PHP project.
php_pdepend:
enabled: true
command: pdepend
excluded_dirs:
- docs
- examples
- extras
- test
- vendor

# Runs Scrutinizer's PHP Analyzer Tool
php_analyzer:
enabled: true
filter:
excluded_paths:
- 'docs/*'
- 'examples/*'
- 'extras/*'
- 'test/*'
- 'vendor/*'

# Security Advisory Checker
sensiolabs_security_checker: true
8 changes: 7 additions & 1 deletion .travis.yml
Expand Up @@ -9,12 +9,18 @@ before_install:
before_script:
- sudo service postfix stop
- smtp-sink -d "%d.%H.%M.%S" localhost:2500 1000 &
- mkdir -p build/logs
- cd test
- cp testbootstrap-dist.php testbootstrap.php
- chmod +x fakesendmail.sh
- sudo mkdir -p /var/qmail/bin
- sudo cp fakesendmail.sh /var/qmail/bin/sendmail
- sudo cp fakesendmail.sh /usr/sbin/sendmail
- echo 'sendmail_path = "/usr/sbin/sendmail -t -i "' | sudo tee "/home/travis/.phpenv/versions/`php -i|grep "PHP Version"|head -n 1|grep -o -P '\d+\.\d+\.\d+.*'`/etc/conf.d/sendmail.ini"
- pwd
- ls -al
script:
- phpunit phpmailerTest
- phpunit --configuration ../travis.phpunit.xml.dist
after_script:
- wget https://scrutinizer-ci.com/ocular.phar
- php ocular.phar code-coverage:upload --format=php-clover ../build/logs/clover.xml
5 changes: 4 additions & 1 deletion PHPMailerAutoload.php
Expand Up @@ -38,7 +38,10 @@ function PHPMailerAutoload($classname)
spl_autoload_register('PHPMailerAutoload');
}
} else {
//Fall back to traditional autoload for old PHP versions
/**
* Fall back to traditional autoload for old PHP versions
* @param string $classname The name of the class to load
*/
function __autoload($classname)
{
PHPMailerAutoload($classname);
Expand Down
2 changes: 2 additions & 0 deletions README.md
@@ -1,6 +1,8 @@
# PHPMailer - A full-featured email creation and transfer class for PHP

Build status: [![Build Status](https://travis-ci.org/Synchro/PHPMailer.png)](https://travis-ci.org/Synchro/PHPMailer)
[![Scrutinizer Quality Score](https://scrutinizer-ci.com/g/Synchro/PHPMailer/badges/quality-score.png?s=320d104c5f7ae0bdb10abd98ea04e0cb107fe905)](https://scrutinizer-ci.com/g/Synchro/PHPMailer/)
[![Code Coverage](https://scrutinizer-ci.com/g/Synchro/PHPMailer/badges/coverage.png?s=4a55049051633406197503e4f66cc8eeb224c9a4)](https://scrutinizer-ci.com/g/Synchro/PHPMailer/)

## Class Features

Expand Down
20 changes: 7 additions & 13 deletions class.phpmailer.php
Expand Up @@ -396,11 +396,7 @@ class PHPMailer
* The function that handles the result of the send email action.
* It is called out by send() for each email sent.
*
* Value can be:
* - 'function_name' for function names
* - 'Class::Method' for static method calls
* - array($object, 'Method') for calling methods on $object
* See http://php.net/is_callable manual page for more details.
* Value can be any php callable: http://www.php.net/is_callable
*
* Parameters:
* bool $result result of the send action
Expand All @@ -410,7 +406,6 @@ class PHPMailer
* string $subject the subject
* string $body the email body
* string $from email address of sender
*
* @type string
*/
public $action_function = '';
Expand Down Expand Up @@ -638,8 +633,7 @@ protected function edebug($str)
break;
case 'echo':
default:
//Just echoes exactly what was received
echo $str;
echo $str."\n";
}
}

Expand Down Expand Up @@ -759,20 +753,20 @@ protected function addAnAddress($kind, $address, $name = '')
{
if (!preg_match('/^(to|cc|bcc|Reply-To)$/', $kind)) {
$this->setError($this->lang('Invalid recipient array') . ': ' . $kind);
$this->edebug($this->lang('Invalid recipient array') . ': ' . $kind);
if ($this->exceptions) {
throw new phpmailerException('Invalid recipient array: ' . $kind);
}
$this->edebug($this->lang('Invalid recipient array') . ': ' . $kind);
return false;
}
$address = trim($address);
$name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim
if (!$this->validateAddress($address)) {
$this->setError($this->lang('invalid_address') . ': ' . $address);
$this->edebug($this->lang('invalid_address') . ': ' . $address);
if ($this->exceptions) {
throw new phpmailerException($this->lang('invalid_address') . ': ' . $address);
}
$this->edebug($this->lang('invalid_address') . ': ' . $address);
return false;
}
if ($kind != 'Reply-To') {
Expand Down Expand Up @@ -804,10 +798,10 @@ public function setFrom($address, $name = '', $auto = true)
$name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim
if (!$this->validateAddress($address)) {
$this->setError($this->lang('invalid_address') . ': ' . $address);
$this->edebug($this->lang('invalid_address') . ': ' . $address);
if ($this->exceptions) {
throw new phpmailerException($this->lang('invalid_address') . ': ' . $address);
}
$this->edebug($this->lang('invalid_address') . ': ' . $address);
return false;
}
$this->From = $address;
Expand Down Expand Up @@ -1037,10 +1031,10 @@ public function postSend()
}
} catch (phpmailerException $e) {
$this->setError($e->getMessage());
$this->edebug($e->getMessage());
if ($this->exceptions) {
throw $e;
}
$this->edebug($e->getMessage() . "\n");
}
return false;
}
Expand Down Expand Up @@ -2036,10 +2030,10 @@ public function addAttachment($path, $name = '', $encoding = 'base64', $type = '

} catch (phpmailerException $e) {
$this->setError($e->getMessage());
$this->edebug($e->getMessage());
if ($this->exceptions) {
throw $e;
}
$this->edebug($e->getMessage() . "\n");
return false;
}
return true;
Expand Down
4 changes: 2 additions & 2 deletions docs/generatedocs.sh
@@ -1,5 +1,5 @@
#!/bin/sh
# Regenerate PHPMailer documentation
# Run from within the docs folder
rm -rf phpdocs/*
phpdoc --directory .. --target ./phpdoc --ignore test/,examples/,extras/,test_script/ --sourcecode --force --title PHPMailer
rm -rf phpdoc/*
phpdoc --directory .. --target ./phpdoc --ignore test/,examples/,extras/,test_script/ --sourcecode --force --title PHPMailer --template="clean"
2 changes: 1 addition & 1 deletion language/phpmailer.lang-no.php
Expand Up @@ -21,4 +21,4 @@
$PHPMAILER_LANG['signing'] = 'Signeringsfeil: ';
$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() feilet.';
$PHPMAILER_LANG['smtp_error'] = 'SMTP-serverfeil: ';
$PHPMAILER_LANG['variable_set'] = 'Kan ikke sette eller resette variabelen: ';
$PHPMAILER_LANG['variable_set'] = 'Kan ikke sette eller resette variabelen: ';
5 changes: 5 additions & 0 deletions test/bootstrap.php
@@ -0,0 +1,5 @@
<?php
require_once 'vendor/autoload.php';
spl_autoload_register(function ($class) {
require_once strtr($class, '\\_', '//').'.php';
});

0 comments on commit 12ce6b1

Please sign in to comment.