Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/qa-tools'
Browse files Browse the repository at this point in the history
Close #94
Close #113
Close #121
  • Loading branch information
weierophinney committed Feb 14, 2017
2 parents 92af932 + 3cf0057 commit 0ac2d12
Show file tree
Hide file tree
Showing 44 changed files with 292 additions and 298 deletions.
1 change: 0 additions & 1 deletion .coveralls.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
coverage_clover: clover.xml
json_path: coveralls-upload.json
src_dir: src
16 changes: 7 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,16 @@ env:
- secure: "D/LfNRozbXUjssR19Yi+6luLML1XyVhTLaky2FPlFAuWb80viVzTxhlvX1QgWPSxxTH8zLRlPm/71E8wYHTN94UGLwJorOthA/btaWKPtdgJtlHXErSgofVVOUqAObvGFOW9sSSuRZ5gFN0c47uuWJmYbiI3HUQkFMjpGpFatXO1SajzK+dCpN4cuhgHW3T41PNbiG8RRCYeFwGBJdpIXEm3HYN6bAWRbFnnu4uCVnQYZnDn/Rprr8+WIU5JFOJQ7ttCQuq1RMP3EC1fVIr0N5gFL91KYX9EyCYmLpZNMS6kF9cPTRQbMEOcKMXqqfGA031MlhvveeOiVWiap/ScMwpId0ugTq9O+sUvBHZuk4FSRtiURcPTLKAmQfUie8Zb+/dxKI18oOWVLsUU919wAEU/hGeTOvATl0WcjqZ2LmxOLVm6UE8+5kM1FhM04XjQaFSJVWK+Asto9KRrOSd310SMpluATutO2ZSN0r7+a7S65M38RRh63NOtdrtbbYIx7+MdAmfPwH5+wr3gekD0pDgnfQd1zLQNWMF/2idTjoxO6xAxTLvthThf5ANXadz1A2Dwqn1EdGsTJ2QItGO7TFwDE+Wfi1O6vtm2FgEy98vwC0t4D1op+0QSRMPr6lFkzINOv4aVO/SB1NF3zwiB95ZsvqReU/Zj2+aDzltf5tY="

matrix:
fast_finish: true
include:
- php: 5.5
env:
- EXECUTE_CS_CHECK=true
- CS_CHECK=true
- php: 5.5
env:
- SERVICE_MANAGER_VERSION="^2.7.5"
- php: 5.6
env:
- EXECUTE_TEST_COVERALLS=true
- TEST_COVERAGE=true
- DEPLOY_DOCS="$(if [[ $TRAVIS_BRANCH == 'master' && $TRAVIS_PULL_REQUEST == 'false' ]]; then echo -n 'true' ; else echo -n 'false' ; fi)"
- PATH="$HOME/.local/bin:$PATH"
- php: 5.6
Expand All @@ -56,22 +55,21 @@ notifications:
email: false

before_install:
- if [[ $EXECUTE_TEST_COVERALLS != 'true' ]]; then phpenv config-rm xdebug.ini || return 0 ; fi
- if [[ $TEST_COVERAGE != 'true' ]]; then phpenv config-rm xdebug.ini || return 0 ; fi
- composer self-update
- if [[ $EXECUTE_TEST_COVERALLS == 'true' ]]; then composer require --dev --no-update satooshi/php-coveralls ; fi
- if [[ $TEST_COVERAGE == 'true' ]]; then composer require --dev --no-update satooshi/php-coveralls ; fi
- composer require --dev --no-update "zendframework/zend-servicemanager:$SERVICE_MANAGER_VERSION"

install:
- travis_retry composer install --no-interaction --ignore-platform-reqs

script:
- if [[ $EXECUTE_TEST_COVERALLS == 'true' ]]; then ./vendor/bin/phpunit --coverage-clover clover.xml ; fi
- if [[ $EXECUTE_TEST_COVERALLS != 'true' ]]; then ./vendor/bin/phpunit ; fi
- if [[ $EXECUTE_CS_CHECK == 'true' ]]; then ./vendor/bin/phpcs ; fi
- if [[ $TEST_COVERAGE == 'true' ]]; then composer test-coverage ; else composer test ; fi
- if [[ $CS_CHECK == 'true' ]]; then composer cs-check ; fi
- if [[ $DEPLOY_DOCS == "true" && "$TRAVIS_TEST_RESULT" == "0" ]]; then wget -O theme-installer.sh "https://raw.githubusercontent.com/zendframework/zf-mkdoc-theme/master/theme-installer.sh" ; chmod 755 theme-installer.sh ; ./theme-installer.sh ; fi

after_success:
- if [[ $DEPLOY_DOCS == "true" ]]; then echo "Preparing to build and deploy documentation" ; ./zf-mkdoc-theme/deploy.sh ; echo "Completed deploying documentation" ; fi

after_script:
- if [[ $EXECUTE_TEST_COVERALLS == 'true' ]]; then ./vendor/bin/coveralls ; fi
- if [[ $TEST_COVERAGE == 'true' ]]; then composer upload-coverage ; fi
14 changes: 7 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,24 +77,24 @@ To do so:

## Running Coding Standards Checks

This component uses [php-cs-fixer](http://cs.sensiolabs.org/) for coding
This component uses [phpcs](https://github.com/squizlabs/PHP_CodeSniffer) for coding
standards checks, and provides configuration for our selected checks.
`php-cs-fixer` is installed by default via Composer.
`phpcs` is installed by default via Composer.

To run checks only:

```console
$ ./vendor/bin/php-cs-fixer fix . -v --diff --dry-run --config-file=.php_cs
$ composer cs-check
```

To have `php-cs-fixer` attempt to fix problems for you, omit the `--dry-run`
flag:
`phpcs` also includes a tool for fixing most CS violations, `phpcbf`:


```console
$ ./vendor/bin/php-cs-fixer fix . -v --diff --config-file=.php_cs
$ composer cs-fix
```

If you allow php-cs-fixer to fix CS issues, please re-run the tests to ensure
If you allow `phpcbf` to fix CS issues, please re-run the tests to ensure
they pass, and make sure you add and commit the changes after verification.

## Recommended Workflow for Contributions
Expand Down
15 changes: 13 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"zendframework/zend-config": "^2.6",
"zendframework/zend-servicemanager": "^2.7.5 || ^3.0.3",
"zendframework/zend-crypt": "^2.6",
"squizlabs/php_codesniffer": "^2.3.1",
"phpunit/phpunit": "^4.8"
"phpunit/phpunit": "^4.8",
"zendframework/zend-coding-standard": "~1.0.0"
},
"suggest": {
"zendframework/zend-servicemanager": "^2.7.5 || ^3.0.3 when using SMTP to deliver messages",
Expand All @@ -46,5 +46,16 @@
"psr-4": {
"ZendTest\\Mail\\": "test/"
}
},
"scripts": {
"check": [
"@cs-check",
"@test"
],
"cs-check": "phpcs",
"cs-fix": "phpcbf",
"test": "phpunit --colors=always",
"test-coverage": "phpunit --colors=always --coverage-clover clover.xml",
"upload-coverage": "coveralls -v"
}
}
16 changes: 1 addition & 15 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -1,22 +1,8 @@
<?xml version="1.0"?>
<ruleset name="Zend Framework coding standard">
<description>Zend Framework coding standard</description>

<!-- display progress -->
<arg value="p"/>
<arg name="colors"/>

<!-- inherit rules from: -->
<rule ref="PSR2"/>
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace">
<properties>
<property name="ignoreBlankLines" value="false"/>
</properties>
</rule>
<rule ref="./vendor/zendframework/zend-coding-standard/ruleset.xml"/>

<!-- Paths to check -->
<file>src</file>
<file>test</file>
<exclude-pattern>test/_files/*</exclude-pattern>
</ruleset>
8 changes: 4 additions & 4 deletions src/AddressList.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function add($emailOrAddress, $name = null)
{
if (is_string($emailOrAddress)) {
$emailOrAddress = $this->createAddress($emailOrAddress, $name);
} elseif (!$emailOrAddress instanceof Address\AddressInterface) {
} elseif (! $emailOrAddress instanceof Address\AddressInterface) {
throw new Exception\InvalidArgumentException(sprintf(
'%s expects an email address or %s\Address object as its first argument; received "%s"',
__METHOD__,
Expand Down Expand Up @@ -90,7 +90,7 @@ public function addMany(array $addresses)
*/
public function addFromString($address)
{
if (!preg_match('/^((?P<name>.*?)<(?P<namedEmail>[^>]+)>|(?P<email>.+))$/', $address, $matches)) {
if (! preg_match('/^((?P<name>.*?)<(?P<namedEmail>[^>]+)>|(?P<email>.+))$/', $address, $matches)) {
throw new Exception\InvalidArgumentException('Invalid address format');
}

Expand Down Expand Up @@ -148,7 +148,7 @@ public function has($email)
public function get($email)
{
$email = strtolower($email);
if (!isset($this->addresses[$email])) {
if (! isset($this->addresses[$email])) {
return false;
}

Expand All @@ -164,7 +164,7 @@ public function get($email)
public function delete($email)
{
$email = strtolower($email);
if (!isset($this->addresses[$email])) {
if (! isset($this->addresses[$email])) {
return false;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Header/AbstractAddressList.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,14 @@ public function getFieldValue($format = HeaderInterface::FORMAT_RAW)
$email = $address->getEmail();
$name = $address->getName();

if (!empty($name) && false !== strstr($name, ',')) {
if (! empty($name) && false !== strstr($name, ',')) {
$name = sprintf('"%s"', $name);
}

if ($format === HeaderInterface::FORMAT_ENCODED
&& 'ASCII' !== $encoding
) {
if (!empty($name)) {
if (! empty($name)) {
$name = HeaderWrap::mimeEncodeValue($name, $encoding);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Header/ContentTransferEncoding.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function setTransferEncoding($transferEncoding)
// Per RFC 1521, the value of the header is not case sensitive
$transferEncoding = strtolower($transferEncoding);

if (!in_array($transferEncoding, static::$allowedTransferEncodings)) {
if (! in_array($transferEncoding, static::$allowedTransferEncodings)) {
throw new Exception\InvalidArgumentException(sprintf(
'%s expects one of "'. implode(', ', static::$allowedTransferEncodings) . '"; received "%s"',
__METHOD__,
Expand Down
4 changes: 2 additions & 2 deletions src/Header/ContentType.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function getFieldValue($format = HeaderInterface::FORMAT_RAW)

$values = [$prepared];
foreach ($this->parameters as $attribute => $value) {
if (HeaderInterface::FORMAT_ENCODED === $format && !Mime::isPrintable($value)) {
if (HeaderInterface::FORMAT_ENCODED === $format && ! Mime::isPrintable($value)) {
$this->encoding = 'UTF-8';
$value = HeaderWrap::wrap($value, $this);
$this->encoding = 'ASCII';
Expand Down Expand Up @@ -111,7 +111,7 @@ public function toString()
*/
public function setType($type)
{
if (!preg_match('/^[a-z-]+\/[a-z0-9.+-]+$/i', $type)) {
if (! preg_match('/^[a-z-]+\/[a-z0-9.+-]+$/i', $type)) {
throw new Exception\InvalidArgumentException(sprintf(
'%s expects a value in the format "type/subtype"; received "%s"',
__METHOD__,
Expand Down
2 changes: 1 addition & 1 deletion src/Header/GenericHeader.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function __construct($fieldName = null, $fieldValue = null)
*/
public function setFieldName($fieldName)
{
if (!is_string($fieldName) || empty($fieldName)) {
if (! is_string($fieldName) || empty($fieldName)) {
throw new Exception\InvalidArgumentException('Header name must be a string');
}

Expand Down
4 changes: 2 additions & 2 deletions src/Header/Sender.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function getFieldValue($format = HeaderInterface::FORMAT_RAW)
$email = sprintf('<%s>', $this->address->getEmail());
$name = $this->address->getName();

if (!empty($name)) {
if (! empty($name)) {
if ($format == HeaderInterface::FORMAT_ENCODED) {
$encoding = $this->getEncoding();
if ('ASCII' !== $encoding) {
Expand Down Expand Up @@ -131,7 +131,7 @@ public function setAddress($emailOrAddress, $name = null)
{
if (is_string($emailOrAddress)) {
$emailOrAddress = new Mail\Address($emailOrAddress, $name);
} elseif (!$emailOrAddress instanceof Mail\Address\AddressInterface) {
} elseif (! $emailOrAddress instanceof Mail\Address\AddressInterface) {
throw new Exception\InvalidArgumentException(sprintf(
'%s expects a string or AddressInterface object; received "%s"',
__METHOD__,
Expand Down
8 changes: 4 additions & 4 deletions src/Headers.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public function getEncoding()
*/
public function addHeaders($headers)
{
if (!is_array($headers) && !$headers instanceof Traversable) {
if (! is_array($headers) && ! $headers instanceof Traversable) {
throw new Exception\InvalidArgumentException(sprintf(
'Expected array or Traversable; received "%s"',
(is_object($headers) ? get_class($headers) : gettype($headers))
Expand Down Expand Up @@ -217,7 +217,7 @@ public function addHeaders($headers)
*/
public function addHeaderLine($headerFieldNameOrLine, $fieldValue = null)
{
if (!is_string($headerFieldNameOrLine)) {
if (! is_string($headerFieldNameOrLine)) {
throw new Exception\InvalidArgumentException(sprintf(
'%s expects its first argument to be a string; received "%s"',
__METHOD__,
Expand Down Expand Up @@ -276,7 +276,7 @@ public function removeHeader($instanceOrFieldName)
$indexes = array_keys($this->headersKeys, $key, true);
}

if (!empty($indexes)) {
if (! empty($indexes)) {
foreach ($indexes as $index) {
unset($this->headersKeys[$index]);
unset($this->headers[$index]);
Expand Down Expand Up @@ -445,7 +445,7 @@ public function toArray($format = Header\HeaderInterface::FORMAT_RAW)
foreach ($this->headers as $header) {
if ($header instanceof Header\MultipleHeadersInterface) {
$name = $header->getFieldName();
if (!isset($headers[$name])) {
if (! isset($headers[$name])) {
$headers[$name] = [];
}
$headers[$name][] = $header->getFieldValue($format);
Expand Down
22 changes: 11 additions & 11 deletions src/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class Message
public function isValid()
{
$from = $this->getFrom();
if (!$from instanceof AddressList) {
if (! $from instanceof AddressList) {
return false;
}
return (bool) count($from);
Expand Down Expand Up @@ -327,7 +327,7 @@ public function getSender()
public function setSubject($subject)
{
$headers = $this->getHeaders();
if (!$headers->has('subject')) {
if (! $headers->has('subject')) {
$header = new Header\Subject();
$headers->addHeader($header);
} else {
Expand All @@ -345,7 +345,7 @@ public function setSubject($subject)
public function getSubject()
{
$headers = $this->getHeaders();
if (!$headers->has('subject')) {
if (! $headers->has('subject')) {
return;
}
$header = $headers->get('subject');
Expand All @@ -361,16 +361,16 @@ public function getSubject()
*/
public function setBody($body)
{
if (!is_string($body) && $body !== null) {
if (!is_object($body)) {
if (! is_string($body) && $body !== null) {
if (! is_object($body)) {
throw new Exception\InvalidArgumentException(sprintf(
'%s expects a string or object argument; received "%s"',
__METHOD__,
gettype($body)
));
}
if (!$body instanceof Mime\Message) {
if (!method_exists($body, '__toString')) {
if (! $body instanceof Mime\Message) {
if (! method_exists($body, '__toString')) {
throw new Exception\InvalidArgumentException(sprintf(
'%s expects object arguments of type Zend\Mime\Message or implementing __toString();'
. ' object of type "%s" received',
Expand All @@ -382,7 +382,7 @@ public function setBody($body)
}
$this->body = $body;

if (!$this->body instanceof Mime\Message) {
if (! $this->body instanceof Mime\Message) {
return $this;
}

Expand All @@ -401,7 +401,7 @@ public function setBody($body)

// MIME single part headers
$parts = $this->body->getParts();
if (!empty($parts)) {
if (! empty($parts)) {
$part = array_shift($parts);
$headers->addHeaders($part->getHeadersArray("\r\n"));
}
Expand Down Expand Up @@ -477,7 +477,7 @@ protected function clearHeaderByName($headerName)
protected function getAddressListFromHeader($headerName, $headerClass)
{
$header = $this->getHeaderByName($headerName, $headerClass);
if (!$header instanceof Header\AbstractAddressList) {
if (! $header instanceof Header\AbstractAddressList) {
throw new Exception\DomainException(sprintf(
'Cannot grab address list from header of type "%s"; not an AbstractAddressList implementation',
get_class($header)
Expand Down Expand Up @@ -509,7 +509,7 @@ protected function updateAddressList(AddressList $addressList, $emailOrAddressOr
$addressList->addMany($emailOrAddressOrList);
return;
}
if (!is_string($emailOrAddressOrList) && !$emailOrAddressOrList instanceof Address\AddressInterface) {
if (! is_string($emailOrAddressOrList) && ! $emailOrAddressOrList instanceof Address\AddressInterface) {
throw new Exception\InvalidArgumentException(sprintf(
'%s expects a string, AddressInterface, array, AddressList, or Traversable as its first argument;'
. ' received "%s"',
Expand Down
Loading

0 comments on commit 0ac2d12

Please sign in to comment.