Skip to content

Commit

Permalink
Merge pull request #1 from tworzenieweb/php7.4
Browse files Browse the repository at this point in the history
Php7.4
  • Loading branch information
tworzenieweb authored Jun 12, 2020
2 parents 88f04d7 + 47b2c5a commit 87fddf2
Show file tree
Hide file tree
Showing 188 changed files with 492 additions and 403 deletions.
34 changes: 4 additions & 30 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,10 @@
language: php
dist: trusty

branches:
only:
- 1.6
- master
- gh-pages
- php7.4

php:
- 5.4
- 5.5
- hhvm
services: docker

env:
- DB=mysql DB_USER=root

before_script:
# MySQL
- sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'SET FOREIGN_KEY_CHECKS = 0; DROP DATABASE IF EXISTS test; DROP SCHEMA IF EXISTS second_hand_books; DROP SCHEMA IF EXISTS contest; DROP DATABASE IF EXISTS reverse_bookstore; DROP SCHEMA IF EXISTS bookstore_schemas; SET FOREIGN_KEY_CHECKS = 1;'; fi"
- sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'CREATE DATABASE test; CREATE SCHEMA bookstore_schemas; CREATE SCHEMA contest; CREATE SCHEMA second_hand_books; CREATE DATABASE reverse_bookstore;'; fi"

# Composer
- wget http://getcomposer.org/composer.phar
- php composer.phar install --prefer-source

- ./test/reset_tests.sh

script: vendor/bin/phpunit

matrix:
include:
- php: 5.3
dist: precise
allow_failures:
- php: hhvm
script:
bash docker/run.sh
15 changes: 11 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@
},
"include-path": ["runtime/lib", "generator/lib"],
"require": {
"php": ">=5.2.4",
"php": "^7.1",
"phing/phing": "~2.4"

},
"require-dev": {
"pear-pear.php.net/PEAR_PackageFileManager2": "@stable",
"phpunit/phpunit": "~4.0||~5.0"
"pear-pear.php.net/pear_packagefilemanager2": "@stable",
"phpunit/phpunit": "^9.0.0",
"phpcompatibility/php-compatibility": "^9.3",
"squizlabs/php_codesniffer": "^3.5"
},
"extra": {
"branch-alias": {
Expand All @@ -32,5 +35,9 @@
"url": "https://pear.php.net"
}
],
"bin": ["generator/bin/propel-gen", "generator/bin/propel-gen.bat"]
"bin": ["generator/bin/propel-gen", "generator/bin/propel-gen.bat"],
"scripts": {
"post-install-cmd": "\"vendor/bin/phpcs\" --config-set installed_paths vendor/phpcompatibility/php-compatibility",
"post-update-cmd" : "\"vendor/bin/phpcs\" --config-set installed_paths vendor/phpcompatibility/php-compatibility"
}
}
11 changes: 11 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM thecodingmachine/php:7.4-v3-cli
USER root
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y locales

RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
dpkg-reconfigure --frontend=noninteractive locales && \
update-locale LANG=en_US.UTF-8

USER docker
ENV LANG en_US.UTF-8

26 changes: 26 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
version: '3'
services:
php:
build:
context: .
dockerfile: Dockerfile
working_dir: /usr/src/app
command: phpunit
volumes:
- ../:/usr/src/app
environment:
- PHP_EXTENSIONS=intl pdo_sqlite sqlite3
- STARTUP_COMMAND_1=composer install
- STARTUP_COMMAND_2=bash test/reset_tests.sh

db:
image: percona
command: >
mysqld
--sql-mode="NO_ENGINE_SUBSTITUTION"
--character-set-server="utf8"
--collation-server="utf8_unicode_ci"
--default-authentication-plugin=mysql_native_password
restart: always
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
4 changes: 4 additions & 0 deletions docker/reset.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash

mysql -u root -e 'SET FOREIGN_KEY_CHECKS = 0; DROP DATABASE IF EXISTS test; DROP SCHEMA IF EXISTS second_hand_books; DROP SCHEMA IF EXISTS contest; DROP DATABASE IF EXISTS reverse_bookstore; DROP SCHEMA IF EXISTS bookstore_schemas; SET FOREIGN_KEY_CHECKS = 1;'
mysql -u root -e 'CREATE DATABASE test; CREATE SCHEMA bookstore_schemas; CREATE SCHEMA contest; CREATE SCHEMA second_hand_books; CREATE DATABASE reverse_bookstore;'
7 changes: 7 additions & 0 deletions docker/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
cd docker
docker-compose up -d db
sleep 20
docker-compose exec -T db bash < reset.sh
docker-compose build
docker-compose run php
3 changes: 3 additions & 0 deletions generator/lib/builder/om/PHP5ObjectBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -1411,6 +1411,9 @@ protected function addLazyLoaderBody(&$script, Column $col)
try {
\$stmt = " . $this->getPeerClassname() . "::doSelectStmt(\$c, \$con);
\$row = \$stmt->fetch(PDO::FETCH_NUM);
if (\$row === false) {
\$row = [null]; // for backward compatibility
}
\$stmt->closeCursor();";
}

Expand Down
3 changes: 3 additions & 0 deletions generator/lib/builder/om/PHP5ObjectNoCollectionBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ protected function addLazyLoaderBody(&$script, Column $col)
try {
\$stmt = " . $this->getPeerClassname() . "::doSelectStmt(\$c, \$con);
\$row = \$stmt->fetch(PDO::FETCH_NUM);
if (\$row === false) {
\$row = [null]; // for backward compatibility
}
\$stmt->closeCursor();";

if ($col->getType() === PropelTypes::CLOB && $this->getPlatform() instanceof OraclePlatform) {
Expand Down
2 changes: 1 addition & 1 deletion generator/lib/builder/om/PHP5PeerBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -1200,7 +1200,7 @@ public static function getPrimaryKeyFromRow(\$row, \$startcol = 0)
if ($table->hasCompositePrimaryKey()) {
$script .= "
return array(" . implode($pks, ', ') . ");";
return array(" . implode(', ', $pks) . ");";
} else {
$script .= "
Expand Down
4 changes: 2 additions & 2 deletions generator/lib/builder/om/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -415,10 +415,10 @@ protected function addFindPk(&$script)
}
$pkType = 'array';
$pkDescription = "
A Primary key composition: " . '[' . join($colNames, ', ') . ']';
A Primary key composition: " . '[' . join(', ', $colNames) . ']';
$script .= "
* <code>
* \$obj = \$c->findPk(array(" . join($examplePk, ', ') . "), \$con);";
* \$obj = \$c->findPk(array(" . join(', ', $examplePk) . "), \$con);";
} else {
$pkType = 'mixed';
$script .= "
Expand Down
2 changes: 1 addition & 1 deletion generator/lib/config/GeneratorConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public function getClassname($propname)
// Basically, we want to turn ?.?.?.sqliteDataSQLBuilder into ?.?.?.SqliteDataSQLBuilder
$lastdotpos = strrpos($classpath, '.');
if ($lastdotpos !== false) {
$classpath{$lastdotpos + 1} = strtoupper($classpath{$lastdotpos + 1});
$classpath[$lastdotpos + 1] = strtoupper($classpath[$lastdotpos + 1]);
} else {
// Allows to configure full classname instead of a dot-path notation
if (class_exists($classpath)) {
Expand Down
2 changes: 1 addition & 1 deletion generator/lib/config/QuickGeneratorConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ protected function parsePseudoIniFile($filepath)
}
foreach ($lines as $line) {
$line = trim($line);
if ($line == "" || $line{0} == '#' || $line{0} == ';') {
if ($line == "" || $line[0] == '#' || $line[0] == ';') {
continue;
}
$pos = strpos($line, '=');
Expand Down
2 changes: 1 addition & 1 deletion generator/lib/model/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public function addColumn($data)
}
} else {
$attrib = $data;
$name = $attrib["name"];
$name = $attrib["name"] ?? null;
$this->indexColumns[] = $name;
if (isset($attrib["size"])) {
$this->indexColumnSizes[$name] = $attrib["size"];
Expand Down
2 changes: 1 addition & 1 deletion generator/lib/model/XMLElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ protected function getDefaultValueForArray($stringValue)
$values[] = trim($v);
}

$value = implode($values, ' | ');
$value = implode(' | ', $values);
if (empty($value) || ' | ' === $value) {
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion generator/lib/platform/DefaultPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -1182,7 +1182,7 @@ public function getPhpArrayString($stringValue)
$values[] = trim($v);
}

$value = implode($values, ' | ');
$value = implode(' | ', $values);
if (empty($value) || ' | ' === $value) {
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion generator/lib/platform/PgsqlPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ public function getModifyColumnDDL(PropelColumnDiff $columnDiff)
foreach ($changedProperties as $key => $property) {
switch ($key) {
case 'defaultValueType':
continue;
continue 2;
case 'size':
case 'type':
case 'scale':
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
beStrictAboutTestsThatDoNotTestAnything="false"
bootstrap="test/bootstrap.php"
>

Expand Down
17 changes: 14 additions & 3 deletions runtime/lib/formatter/PropelArrayFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,29 @@ public function format(PDOStatement $stmt)
} else {
$collection = array();
}

/**
* @var $collection PropelArrayCollection
*/

if ($this->isWithOneToMany() && $this->hasLimit) {
throw new PropelException('Cannot use limit() in conjunction with with() on a one-to-many relationship. Please remove the with() call, or the limit() call.');
}

$data = [];

while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
if ($object = &$this->getStructuredArrayFromRow($row)) {
$collection[] = $object;
$object = &$this->getStructuredArrayFromRow($row);
if ($object) {
$data[] = &$object;
}
}
$this->currentObjects = array();
$this->alreadyHydratedObjects = array();
$stmt->closeCursor();

$collection->setData($data);

return $collection;
}

Expand Down Expand Up @@ -163,7 +174,7 @@ public function &getStructuredArrayFromRow($row)
return $this->alreadyHydratedObjects[$this->class][$mainKey];
} else {
// we still need to return a reference to something to avoid a warning
return $emptyVariable;
return $this->emptyVariable;
}
}
}
4 changes: 4 additions & 0 deletions runtime/lib/map/TableMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,10 @@ public function setPrefix($prefix)
*/
protected function hasPrefix($data)
{
if (!$this->prefix) {
return false;
}

return (strpos($data, $this->prefix) === 0);
}

Expand Down
10 changes: 5 additions & 5 deletions runtime/lib/parser/PropelCSVParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,19 @@ public function fromArray($array, $isList = false, $includeHeading = true)
$rows = array();
if ($isList) {
if ($includeHeading) {
$rows[] = implode($this->formatRow(array_keys(reset($array))), $this->delimiter);
$rows[] = implode($this->delimiter, $this->formatRow(array_keys(reset($array))));
}
foreach ($array as $row) {
$rows[] = implode($this->formatRow($row), $this->delimiter);
$rows[] = implode($this->delimiter, $this->formatRow($row));
}
} else {
if ($includeHeading) {
$rows[] = implode($this->formatRow(array_keys($array)), $this->delimiter);
$rows[] = implode($this->delimiter, $this->formatRow(array_keys($array)));
}
$rows[] = implode($this->formatRow($array), $this->delimiter);
$rows[] = implode($this->delimiter, $this->formatRow($array));
}

return implode($rows, $this->lineTerminator) . $this->lineTerminator;
return implode($this->lineTerminator, $rows) . $this->lineTerminator;
}

public function listFromArray($array)
Expand Down
8 changes: 3 additions & 5 deletions runtime/lib/parser/yaml/sfYamlInline.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,8 @@ public static function load($value)
return '';
}

if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) {
$mbEncoding = mb_internal_encoding();
mb_internal_encoding('ASCII');
}
$mbEncoding = mb_internal_encoding();
mb_internal_encoding('ASCII');

switch ($value[0]) {
case '[':
Expand Down Expand Up @@ -127,7 +125,7 @@ protected static function dumpArray($value)
if (
(1 == count($keys) && '0' == $keys[0])
||
(count($keys) > 1 && array_reduce($keys, create_function('$v,$w', 'return (integer) $v + $w;'), 0) == count($keys) * (count($keys) - 1) / 2))
(count($keys) > 1 && array_reduce($keys, function($v, $w) { return (integer) $v + $w; }, 0) == count($keys) * (count($keys) - 1) / 2))
{
$output = array();
foreach ($value as $val) {
Expand Down
6 changes: 2 additions & 4 deletions runtime/lib/parser/yaml/sfYamlParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,8 @@ public function parse($value)
$this->currentLine = '';
$this->lines = explode("\n", $this->cleanup($value));

if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) {
$mbEncoding = mb_internal_encoding();
mb_internal_encoding('UTF-8');
}
$mbEncoding = mb_internal_encoding();
mb_internal_encoding('UTF-8');

$data = array();
while ($this->moveToNextLine()) {
Expand Down
2 changes: 1 addition & 1 deletion runtime/lib/query/Join.php
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ public function getClause(&$params)
for ($i = 0; $i < $this->count; $i++) {
$conditions [] = $this->getLeftColumn($i) . $this->getOperator($i) . $this->getRightColumn($i);
}
$joinCondition = sprintf('(%s)', implode($conditions, ' AND '));
$joinCondition = sprintf('(%s)', implode(' AND ', $conditions));
} else {
$joinCondition = '';
$this->getJoinCondition()->appendPsTo($joinCondition, $params);
Expand Down
2 changes: 1 addition & 1 deletion runtime/lib/query/ModelCriteria.php
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ public function offset($offset)
*/
public function select($columnArray)
{
if (!count($columnArray) || $columnArray == '') {
if (empty($columnArray)) {
throw new PropelException('You must ask for at least one column');
}

Expand Down
4 changes: 2 additions & 2 deletions runtime/lib/util/BasePeer.php
Original file line number Diff line number Diff line change
Expand Up @@ -397,10 +397,10 @@ public static function doUpdate(Criteria $selectCriteria, Criteria $updateValues
$rawcvt = '';
// parse the $params['raw'] for ? chars
for ($r = 0, $len = strlen($raw); $r < $len; $r++) {
if ($raw{$r} == '?') {
if ($raw[$r] == '?') {
$rawcvt .= ':p' . $p++;
} else {
$rawcvt .= $raw{$r};
$rawcvt .= $raw[$r];
}
}
$sql .= $rawcvt . ', ';
Expand Down
2 changes: 1 addition & 1 deletion runtime/lib/validator/MatchValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class MatchValidator implements BasicValidator
private function prepareRegexp($exp)
{
// remove surrounding '/' marks so that they don't get escaped in next step
if ($exp{0} !== '/' || $exp{strlen($exp) - 1} !== '/') {
if ($exp[0] !== '/' || $exp[strlen($exp) - 1] !== '/') {
$exp = '/' . $exp . '/';
}

Expand Down
2 changes: 1 addition & 1 deletion runtime/lib/validator/NotMatchValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class NotMatchValidator implements BasicValidator
private function prepareRegexp($exp)
{
// remove surrounding '/' marks so that they don't get escaped in next step
if ($exp{0} !== '/' || $exp{strlen($exp) - 1} !== '/') {
if ($exp[0] !== '/' || $exp[strlen($exp) - 1] !== '/') {
$exp = '/' . $exp . '/';
}

Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/bookstore/build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

propel.project = bookstore
propel.database = mysql
propel.database.url = mysql:dbname=test
propel.database.url = mysql:host=db;dbname=test
propel.mysql.tableType = InnoDB
propel.disableIdentifierQuoting = true
propel.schema.autoPrefix = true
Expand Down
Loading

0 comments on commit 87fddf2

Please sign in to comment.