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

PHP 7 on Travis-CI (redux) #7270

Closed
wants to merge 53 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
13d771d
Merge branch 'hotfix/7362'
weierophinney Mar 24, 2015
0de4dd6
add php 7 on .travis.yml
samsonasik Feb 26, 2015
00b5275
update script for xdebug.ini check
samsonasik Feb 26, 2015
4c3ace8
Disable apcu, redis, and memcached features on PHP 7 builds
weierophinney Feb 26, 2015
b48c2af
Broaden test assertion
weierophinney Feb 26, 2015
ef0b6ba
Rename duplicated argument to prevent error
weierophinney Feb 26, 2015
ad5134d
Disable a test that cannot run on v7
weierophinney Feb 26, 2015
ef6cace
Fix expected exception type
weierophinney Feb 26, 2015
e77e759
Ensure session save handler stub has appropriate return values
weierophinney Feb 26, 2015
edb4f56
Better tests for HHVM/PHP7 for conditional travis installs
weierophinney Feb 26, 2015
8e5c7e0
End conditional statements in travis config
weierophinney Feb 26, 2015
1a4e5b1
Disable cache-specific travis integrations
weierophinney Feb 26, 2015
22959f0
Fixed argument redefinition problems
weierophinney Mar 9, 2015
8608973
Fix E_RECOVERABLE_ERROR detection in Zend\Di tests
weierophinney Mar 9, 2015
cb7411b
Skip some Logger tests when under PHP 7
weierophinney Mar 10, 2015
f8fa34b
Ensure height and width are integers
weierophinney Mar 24, 2015
0c11215
Cast data to string before caching
weierophinney Mar 24, 2015
98c103d
ob_implicit_flush expects an integer; dba_replace, a string
weierophinney Mar 24, 2015
b798ca5
Ensure fgets() returns a string before calling explode
weierophinney Mar 24, 2015
f949d21
Ensure we have a string before attempting to trim()
weierophinney Mar 24, 2015
dfbb203
Use string value when performing strtr
weierophinney Mar 24, 2015
69a0f41
Ensure we have a string before calling rtrim()
weierophinney Mar 24, 2015
53a2eaf
Ensure we have a string to pass to base64_decode
weierophinney Mar 24, 2015
2a20efb
Ensure strlen gets a string
weierophinney Mar 24, 2015
452ac65
Ensure strtolower and addcslashes receive string arguments
weierophinney Mar 24, 2015
dbf6be2
Skip tests that cannot run in PHP 7
weierophinney Mar 24, 2015
9bfb48f
importNode() expects integer for argument 2 starting in PHP 7
weierophinney Mar 24, 2015
189414e
DateTime::diff's second argument is actually an integer
weierophinney Mar 24, 2015
ce9ea45
Ensure substr receives an integer 3rd parameter
weierophinney Mar 24, 2015
14a889f
Ensure preg_match receives a string value
weierophinney Mar 24, 2015
a456d29
DateTime::diff's second argument is actually an integer
weierophinney Mar 24, 2015
0dbfb64
Ensure substr receives an integer 3rd argument
weierophinney Mar 24, 2015
0071837
Ensure strtolower receives a string
weierophinney Mar 24, 2015
955af24
Ensure strlen and strpos receive strings
weierophinney Mar 24, 2015
cb69154
Ensure substr receives an integer offset
weierophinney Mar 24, 2015
9d0e449
No need to do substr() if start is 0 and no length provided
weierophinney Mar 24, 2015
8b22263
Ensure explode receives a string 2nd argument
weierophinney Mar 24, 2015
f6f2dc1
Ensure explode receives a string 2nd argument
weierophinney Mar 24, 2015
1cc7429
Skip tests in PHP 7 that we cannot run
weierophinney Mar 24, 2015
29d6fde
Ensure class_exists receives a string
weierophinney Mar 24, 2015
bbf742c
Override MongoDBOptions::__set to validate arguments
weierophinney Mar 24, 2015
e923464
ini_set expects a string as the 2nd argument
weierophinney Mar 24, 2015
f2a94a1
Ensure we have a version string for version_compare
weierophinney Mar 24, 2015
e187b77
Ensure ini_set receives a string value
weierophinney Mar 24, 2015
23f8ba6
Ensure substr receives an integer 2nd parameter
weierophinney Mar 24, 2015
fae07f9
Ensure sscanf receives a string
weierophinney Mar 24, 2015
6ed8959
Ensure substr receives an integer offset, and preg_match receives a s…
weierophinney Mar 24, 2015
8d34295
Updated magic.mime file for PHP 7 testing
weierophinney Mar 24, 2015
eab06c4
Ensure strlen receives a string
weierophinney Mar 24, 2015
b686ef5
Ensure DOMDocument::createElementNS receives a string 3rd argument
weierophinney Mar 24, 2015
99e8520
Ensure imagefilledrectangle receives integers for offset positions
weierophinney Mar 24, 2015
4552cee
Ensure addcslashes receives a string value
weierophinney Mar 24, 2015
fded78e
Ensure idn_to_ascii returns a string
weierophinney Mar 24, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 4 additions & 7 deletions .travis.yml
Expand Up @@ -5,23 +5,19 @@ php:
- 5.4
- 5.5
- 5.6
- 7
- hhvm
- hhvm-nightly

install:
- if [[ $TRAVIS_PHP_VERSION != '5.6' && $TRAVIS_PHP_VERSION != 'hhvm' && $TRAVIS_PHP_VERSION != 'hhvm-nightly' ]]; then phpenv config-rm xdebug.ini; fi
- IS_HHVM=`echo $TRAVIS_PHP_VERSION | grep "hhvm" | wc -l`
- if [[ $TRAVIS_PHP_VERSION != '5.6' && $TRAVIS_PHP_VERSION != 'hhvm' && $TRAVIS_PHP_VERSION != 'hhvm-nightly' && $TRAVIS_PHP_VERSION != '7' ]]; then phpenv config-rm xdebug.ini; fi
- sudo apt-get install parallel libpcre3-dev
- test $IS_HHVM == "1" || echo "" | pecl install apcu-beta
- test $IS_HHVM == "1" || phpenv config-add tests/travis.php.ini
- composer install --no-interaction --prefer-source

before_script:
- php --version
- sudo /etc/init.d/memcached start
- sudo start redis-server
- mkdir -p build/coverage
- cp tests/TestConfiguration.php.travis tests/TestConfiguration.php
- if [[ $TRAVIS_PHP_VERSION = '5.6' ]]; then mkdir -p build/coverage; fi

script:
# Run tests for the various components in parallel
Expand All @@ -43,5 +39,6 @@ notifications:
matrix:
fast_finish: true
allow_failures:
- php: 7
- php: hhvm
- php: hhvm-nightly
9 changes: 7 additions & 2 deletions library/Zend/Barcode/Renderer/Image.php
Expand Up @@ -204,6 +204,11 @@ protected function initRenderer()
$height = $this->userHeight;
}

// Cast width and height to ensure they are correct type for image
// operations
$width = (int) $width;
$height = (int) $height;

$this->resource = imagecreatetruecolor($width, $height);

$white = imagecolorallocate($this->resource, 255, 255, 255);
Expand Down Expand Up @@ -238,8 +243,8 @@ protected function initRenderer()
$this->resource,
$this->leftOffset,
$this->topOffset,
$this->leftOffset + $barcodeWidth - 1,
$this->topOffset + $barcodeHeight - 1,
(int) ($this->leftOffset + $barcodeWidth - 1),
(int) ($this->topOffset + $barcodeHeight - 1),
$this->imageBackgroundColor
);
}
Expand Down
8 changes: 5 additions & 3 deletions library/Zend/Cache/Pattern/CallbackCache.php
Expand Up @@ -59,7 +59,7 @@ public function call($callback, array $args = array())
$cacheOutput = $options->getCacheOutput();
if ($cacheOutput) {
ob_start();
ob_implicit_flush(false);
ob_implicit_flush(0);
}

// TODO: do not cache on errors using [set|restore]_error_handler
Expand Down Expand Up @@ -137,9 +137,11 @@ protected function generateCallbackKey($callback, array $args)
$callbackKey = strtolower($callbackKey);

// generate a unique key of object callbacks
if (is_object($callback)) { // Closures & __invoke
if (is_object($callback)) {
// Closures & __invoke
$object = $callback;
} elseif (isset($callback[0])) { // array($object, 'method')
} elseif (isset($callback[0])) {
// array($object, 'method')
$object = $callback[0];
}
if (isset($object)) {
Expand Down
2 changes: 1 addition & 1 deletion library/Zend/Cache/Pattern/CaptureCache.php
Expand Up @@ -35,7 +35,7 @@ public function start($pageId = null)
return false;
});

ob_implicit_flush(false);
ob_implicit_flush(0);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion library/Zend/Cache/Pattern/OutputCache.php
Expand Up @@ -60,7 +60,7 @@ public function start($key)
}

ob_start();
ob_implicit_flush(false);
ob_implicit_flush(0);
$this->keyStack[] = $key;
return false;
}
Expand Down
7 changes: 5 additions & 2 deletions library/Zend/Cache/Storage/Adapter/Dba.php
Expand Up @@ -264,7 +264,8 @@ public function clearByPrefix($prefix)

$this->_open();

do { // Workaround for PHP-Bug #62491 & #62492
// Workaround for PHP-Bug #62491 & #62492
do {
$recheck = false;
$internalKey = dba_firstkey($this->handle);
while ($internalKey !== false && $internalKey !== null) {
Expand Down Expand Up @@ -377,8 +378,10 @@ protected function internalSetItem(& $normalizedKey, & $value)
$prefix = ($namespace === '') ? '' : $namespace . $options->getNamespaceSeparator();
$internalKey = $prefix . $normalizedKey;

$cacheableValue = (string) $value; // dba_replace requires a string

$this->_open();
if (!dba_replace($internalKey, $value, $this->handle)) {
if (!dba_replace($internalKey, $cacheableValue, $this->handle)) {
throw new Exception\RuntimeException("dba_replace('{$internalKey}', ...) failed");
}

Expand Down
5 changes: 5 additions & 0 deletions library/Zend/Cache/Storage/Adapter/Filesystem.php
Expand Up @@ -1498,6 +1498,11 @@ protected function prepareDirectoryStructure($file)
*/
protected function putFileContent($file, $data, $nonBlocking = false, & $wouldblock = null)
{
if (! is_string($data)) {
// Ensure we have a string
$data = (string) $data;
}

$options = $this->getOptions();
$locking = $options->getFileLocking();
$nonBlocking = $locking && $nonBlocking;
Expand Down
2 changes: 1 addition & 1 deletion library/Zend/Config/Processor/Token.php
Expand Up @@ -259,7 +259,7 @@ private function doProcess($value, array $replacements)

if (!is_string($value) && (is_bool($value) || is_numeric($value))) {
$stringVal = (string) $value;
$changedVal = strtr($value, $this->map);
$changedVal = strtr($stringVal, $this->map);

// replace the value only if a string replacement occurred
if ($changedVal !== $stringVal) {
Expand Down
2 changes: 1 addition & 1 deletion library/Zend/Crypt/BlockCipher.php
Expand Up @@ -461,7 +461,7 @@ public function decrypt($data)
}
$hmacSize = Hmac::getOutputSize($this->hash);
$hmac = substr($data, 0, $hmacSize);
$ciphertext = substr($data, $hmacSize);
$ciphertext = substr($data, $hmacSize) ?: '';
if (!$this->binaryOutput) {
$ciphertext = base64_decode($ciphertext);
}
Expand Down
18 changes: 13 additions & 5 deletions library/Zend/Db/Adapter/Driver/Pdo/Connection.php
Expand Up @@ -42,7 +42,9 @@ public function __construct($connectionParameters = null)
} elseif ($connectionParameters instanceof \PDO) {
$this->setResource($connectionParameters);
} elseif (null !== $connectionParameters) {
throw new Exception\InvalidArgumentException('$connection must be an array of parameters, a PDO object or null');
throw new Exception\InvalidArgumentException(
'$connection must be an array of parameters, a PDO object or null'
);
}
}

Expand All @@ -66,7 +68,9 @@ public function setConnectionParameters(array $connectionParameters)
{
$this->connectionParameters = $connectionParameters;
if (isset($connectionParameters['dsn'])) {
$this->driverName = substr($connectionParameters['dsn'], 0,
$this->driverName = substr(
$connectionParameters['dsn'],
0,
strpos($connectionParameters['dsn'], ':')
);
} elseif (isset($connectionParameters['pdodriver'])) {
Expand All @@ -87,7 +91,9 @@ public function setConnectionParameters(array $connectionParameters)
public function getDsn()
{
if (!$this->dsn) {
throw new Exception\RunTimeException("The DSN has not been set or constructed from parameters in connect() for this Connection");
throw new Exception\RunTimeException(
'The DSN has not been set or constructed from parameters in connect() for this Connection'
);
}

return $this->dsn;
Expand Down Expand Up @@ -161,9 +167,11 @@ public function connect()
$dsn = $value;
break;
case 'driver':
$value = strtolower($value);
$value = strtolower((string) $value);
if (strpos($value, 'pdo') === 0) {
$pdoDriver = strtolower(substr(str_replace(array('-', '_', ' '), '', $value), 3));
$pdoDriver = str_replace(array('-', '_', ' '), '', $value);
$pdoDriver = substr($pdoDriver, 3) ?: '';
$pdoDriver = strtolower($pdoDriver);
}
break;
case 'pdodriver':
Expand Down
4 changes: 2 additions & 2 deletions library/Zend/Db/Adapter/Platform/AbstractPlatform.php
Expand Up @@ -108,15 +108,15 @@ public function quoteValue($value)
'Attempting to quote a value in ' . get_class($this) .
' without extension/driver support can introduce security vulnerabilities in a production environment'
);
return '\'' . addcslashes($value, "\x00\n\r\\'\"\x1a") . '\'';
return '\'' . addcslashes((string) $value, "\x00\n\r\\'\"\x1a") . '\'';
}

/**
* {@inheritDoc}
*/
public function quoteTrustedValue($value)
{
return '\'' . addcslashes($value, "\x00\n\r\\'\"\x1a") . '\'';
return '\'' . addcslashes((string) $value, "\x00\n\r\\'\"\x1a") . '\'';
}

/**
Expand Down
3 changes: 2 additions & 1 deletion library/Zend/Db/Adapter/Platform/Sql92.php
Expand Up @@ -25,7 +25,8 @@ public function getName()
public function quoteValue($value)
{
trigger_error(
'Attempting to quote a value without specific driver level support can introduce security vulnerabilities in a production environment.'
'Attempting to quote a value without specific driver level support'
. ' can introduce security vulnerabilities in a production environment.'
);
return '\'' . addcslashes($value, "\x00\n\r\\'\"\x1a") . '\'';
}
Expand Down
11 changes: 7 additions & 4 deletions library/Zend/Feed/Reader/Entry/AbstractEntry.php
Expand Up @@ -122,8 +122,9 @@ public function getEncoding()
*/
public function saveXml()
{
$dom = new DOMDocument('1.0', $this->getEncoding());
$entry = $dom->importNode($this->getElement(), true);
$dom = new DOMDocument('1.0', $this->getEncoding());
$deep = version_compare(PHP_VERSION, '7', 'ge') ? 1 : true;
$entry = $dom->importNode($this->getElement(), $deep);
$dom->appendChild($entry);
return $dom->saveXml();
}
Expand Down Expand Up @@ -202,8 +203,10 @@ public function __call($method, $args)
return call_user_func_array(array($extension, $method), $args);
}
}
throw new Exception\RuntimeException('Method: ' . $method
. ' does not exist and could not be located on a registered Extension');
throw new Exception\RuntimeException(sprintf(
'Method: %s does not exist and could not be located on a registered Extension',
$method
));
}

/**
Expand Down
16 changes: 10 additions & 6 deletions library/Zend/Feed/Reader/Extension/Atom/Entry.php
Expand Up @@ -103,20 +103,21 @@ public function getContent()
case 'html':
case 'text/html':
$content = $el->nodeValue;
break;
break;
case 'xhtml':
$this->getXpath()->registerNamespace('xhtml', 'http://www.w3.org/1999/xhtml');
$xhtml = $this->getXpath()->query(
$this->getXpathPrefix() . '/atom:content/xhtml:div'
)->item(0);
$d = new DOMDocument('1.0', $this->getEncoding());
$xhtmls = $d->importNode($xhtml, true);
$deep = version_compare(PHP_VERSION, '7', 'ge') ? 1 : true;
$xhtmls = $d->importNode($xhtml, $deep);
$d->appendChild($xhtmls);
$content = $this->collectXhtml(
$d->saveXML(),
$d->lookupPrefix('http://www.w3.org/1999/xhtml')
);
break;
break;
}
}

Expand Down Expand Up @@ -296,9 +297,12 @@ public function getBaseUrl()
return $this->data['baseUrl'];
}

$baseUrl = $this->getXpath()->evaluate('string('
. $this->getXpathPrefix() . '/@xml:base[1]'
. ')');
$baseUrl = $this->getXpath()->evaluate(
'string('
. $this->getXpathPrefix()
. '/@xml:base[1]'
. ')'
);

if (!$baseUrl) {
$baseUrl = $this->getXpath()->evaluate('string(//@xml:base[1])');
Expand Down
22 changes: 16 additions & 6 deletions library/Zend/Feed/Writer/Renderer/Entry/Atom.php
Expand Up @@ -265,12 +265,14 @@ protected function _setId(DOMDocument $dom, DOMElement $root)

if (!$this->getDataContainer()->getId()) {
$this->getDataContainer()->setId(
$this->getDataContainer()->getLink());
$this->getDataContainer()->getLink()
);
}
if (!Uri::factory($this->getDataContainer()->getId())->isValid()
&& !preg_match(
"#^urn:[a-zA-Z0-9][a-zA-Z0-9\-]{1,31}:([a-zA-Z0-9\(\)\+\,\.\:\=\@\;\$\_\!\*\-]|%[0-9a-fA-F]{2})*#",
$this->getDataContainer()->getId())
$this->getDataContainer()->getId()
)
&& !$this->_validateTagUri($this->getDataContainer()->getId())
) {
throw new Writer\Exception\InvalidArgumentException('Atom 1.0 IDs must be a valid URI/IRI');
Expand All @@ -289,7 +291,11 @@ protected function _setId(DOMDocument $dom, DOMElement $root)
*/
protected function _validateTagUri($id)
{
if (preg_match('/^tag:(?P<name>.*),(?P<date>\d{4}-?\d{0,2}-?\d{0,2}):(?P<specific>.*)(.*:)*$/', $id, $matches)) {
if (preg_match(
'/^tag:(?P<name>.*),(?P<date>\d{4}-?\d{0,2}-?\d{0,2}):(?P<specific>.*)(.*:)*$/',
$id,
$matches
)) {
$dvalid = false;
$date = $matches['date'];
$d6 = strtotime($date);
Expand Down Expand Up @@ -341,7 +347,8 @@ protected function _setContent(DOMDocument $dom, DOMElement $root)
$element = $dom->createElement('content');
$element->setAttribute('type', 'xhtml');
$xhtmlElement = $this->_loadXhtml($content);
$xhtml = $dom->importNode($xhtmlElement, true);
$deep = version_compare(PHP_VERSION, '7', 'ge') ? 1 : true;
$xhtml = $dom->importNode($xhtmlElement, $deep);
$element->appendChild($xhtml);
$root->appendChild($element);
}
Expand Down Expand Up @@ -369,8 +376,11 @@ protected function _loadXhtml($content)
"/(<[\/]?)([a-zA-Z]+)/"
), '$1xhtml:$2', $xhtml);
$dom = new DOMDocument('1.0', $this->getEncoding());
$dom->loadXML('<xhtml:div xmlns:xhtml="http://www.w3.org/1999/xhtml">'
. $xhtml . '</xhtml:div>');
$dom->loadXML(
'<xhtml:div xmlns:xhtml="http://www.w3.org/1999/xhtml">'
. $xhtml
. '</xhtml:div>'
);
return $dom->documentElement;
}

Expand Down
9 changes: 6 additions & 3 deletions library/Zend/Feed/Writer/Renderer/Feed/Atom.php
Expand Up @@ -40,7 +40,8 @@ public function render()
$this->dom = new DOMDocument('1.0', $this->container->getEncoding());
$this->dom->formatOutput = true;
$root = $this->dom->createElementNS(
Writer\Writer::NAMESPACE_ATOM_10, 'feed'
Writer\Writer::NAMESPACE_ATOM_10,
'feed'
);
$this->setRootElement($root);
$this->dom->appendChild($root);
Expand Down Expand Up @@ -76,7 +77,8 @@ public function render()
} else {
if (!$this->dom->documentElement->hasAttribute('xmlns:at')) {
$this->dom->documentElement->setAttribute(
'xmlns:at', 'http://purl.org/atompub/tombstones/1.0'
'xmlns:at',
'http://purl.org/atompub/tombstones/1.0'
);
}
$renderer = new Renderer\Entry\AtomDeleted($entry);
Expand All @@ -88,7 +90,8 @@ public function render()
$renderer->setRootElement($this->dom->documentElement);
$renderer->render();
$element = $renderer->getElement();
$imported = $this->dom->importNode($element, true);
$deep = version_compare(PHP_VERSION, '7', 'ge') ? 1 : true;
$imported = $this->dom->importNode($element, $deep);
$root->appendChild($imported);
}
return $this;
Expand Down
10 changes: 7 additions & 3 deletions library/Zend/Feed/Writer/Renderer/Feed/Rss.php
Expand Up @@ -85,7 +85,8 @@ public function render()
$renderer->setRootElement($this->dom->documentElement);
$renderer->render();
$element = $renderer->getElement();
$imported = $this->dom->importNode($element, true);
$deep = version_compare(PHP_VERSION, '7', 'ge') ? 1 : true;
$imported = $this->dom->importNode($element, $deep);
$channel->appendChild($imported);
}
return $this;
Expand Down Expand Up @@ -195,8 +196,11 @@ protected function _setDateModified(DOMDocument $dom, DOMElement $root)
protected function _setGenerator(DOMDocument $dom, DOMElement $root)
{
if (!$this->getDataContainer()->getGenerator()) {
$this->getDataContainer()->setGenerator('Zend_Feed_Writer',
Version::VERSION, 'http://framework.zend.com');
$this->getDataContainer()->setGenerator(
'Zend_Feed_Writer',
Version::VERSION,
'http://framework.zend.com'
);
}

$gdata = $this->getDataContainer()->getGenerator();
Expand Down