Skip to content

Commit ddfbf17

Browse files
committed
try and merge in propelorm#1086
2 parents 0f32375 + 5aa667c commit ddfbf17

File tree

177 files changed

+472
-363
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

177 files changed

+472
-363
lines changed

.travis.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,17 @@ language: php
33
services:
44
- mysql
55

6+
#services: docker
7+
68
branches:
79
only:
810
- master
911

1012
php:
11-
- 5.6
1213
- 7.0
1314
- 7.1
1415
- 7.2
16+
- 7.4
1517

1618
env:
1719
- DB=mysql DB_USER=root
@@ -29,3 +31,5 @@ before_script:
2931

3032
script: vendor/bin/phpunit
3133

34+
#script:
35+
# bash docker/run.sh

composer.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,25 @@
1414
},
1515
"include-path": ["runtime/lib", "generator/lib"],
1616
"require": {
17-
"php": ">=5.2.4",
17+
"php": "^7.1",
1818
"phing/phing": "~2.4"
19+
1920
},
2021
"require-dev": {
2122
"pear-pear.php.net/pear_packagefilemanager2" : "@stable",
22-
"phpunit/phpunit": "~4.0||~5.0"
23+
"phpunit/phpunit": "~8|~9",
24+
"phpcompatibility/php-compatibility": "^9.3",
25+
"squizlabs/php_codesniffer": "^3.5"
2326
},
2427
"repositories": [
2528
{
2629
"type": "pear",
2730
"url": "https://pear.php.net"
2831
}
2932
],
30-
"bin": ["generator/bin/propel-gen", "generator/bin/propel-gen.bat"]
33+
"bin": ["generator/bin/propel-gen", "generator/bin/propel-gen.bat"],
34+
"scripts": {
35+
"post-install-cmd": "\"vendor/bin/phpcs\" --config-set installed_paths vendor/phpcompatibility/php-compatibility",
36+
"post-update-cmd" : "\"vendor/bin/phpcs\" --config-set installed_paths vendor/phpcompatibility/php-compatibility"
37+
}
3138
}

docker/Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM thecodingmachine/php:7.4-v3-cli
2+
USER root
3+
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y locales
4+
5+
RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
6+
dpkg-reconfigure --frontend=noninteractive locales && \
7+
update-locale LANG=en_US.UTF-8
8+
9+
USER docker
10+
ENV LANG en_US.UTF-8
11+

docker/docker-compose.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
version: '3'
2+
services:
3+
php:
4+
build:
5+
context: .
6+
dockerfile: Dockerfile
7+
working_dir: /usr/src/app
8+
command: phpunit
9+
volumes:
10+
- ../:/usr/src/app
11+
environment:
12+
- PHP_EXTENSIONS=intl pdo_sqlite sqlite3
13+
- STARTUP_COMMAND_1=composer install
14+
- STARTUP_COMMAND_2=bash test/reset_tests.sh
15+
16+
db:
17+
image: percona
18+
command: >
19+
mysqld
20+
--sql-mode="NO_ENGINE_SUBSTITUTION"
21+
--character-set-server="utf8"
22+
--collation-server="utf8_unicode_ci"
23+
--default-authentication-plugin=mysql_native_password
24+
restart: always
25+
environment:
26+
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'

docker/reset.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env bash
2+
3+
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;'
4+
mysql -u root -e 'CREATE DATABASE test; CREATE SCHEMA bookstore_schemas; CREATE SCHEMA contest; CREATE SCHEMA second_hand_books; CREATE DATABASE reverse_bookstore;'

docker/run.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
cd docker
3+
docker-compose up -d db
4+
sleep 20
5+
docker-compose exec -T db bash < reset.sh
6+
docker-compose build
7+
docker-compose run php

generator/lib/builder/om/PHP5ObjectBuilder.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1411,6 +1411,9 @@ protected function addLazyLoaderBody(&$script, Column $col)
14111411
try {
14121412
\$stmt = " . $this->getPeerClassname() . "::doSelectStmt(\$c, \$con);
14131413
\$row = \$stmt->fetch(PDO::FETCH_NUM);
1414+
if (\$row === false) {
1415+
\$row = [null]; // for backward compatibility
1416+
}
14141417
\$stmt->closeCursor();";
14151418
}
14161419

generator/lib/builder/om/PHP5ObjectNoCollectionBuilder.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ protected function addLazyLoaderBody(&$script, Column $col)
111111
try {
112112
\$stmt = " . $this->getPeerClassname() . "::doSelectStmt(\$c, \$con);
113113
\$row = \$stmt->fetch(PDO::FETCH_NUM);
114+
if (\$row === false) {
115+
\$row = [null]; // for backward compatibility
116+
}
114117
\$stmt->closeCursor();";
115118

116119
if ($col->getType() === PropelTypes::CLOB && $this->getPlatform() instanceof OraclePlatform) {

generator/lib/model/Index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ public function addColumn($data)
181181
}
182182
} else {
183183
$attrib = $data;
184-
$name = $attrib["name"];
184+
$name = $attrib["name"] ?? null;
185185
$this->indexColumns[] = $name;
186186
if (isset($attrib["size"])) {
187187
$this->indexColumnSizes[$name] = $attrib["size"];

generator/lib/platform/DefaultPlatform.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1182,7 +1182,7 @@ public function getPhpArrayString($stringValue)
11821182
$values[] = trim($v);
11831183
}
11841184

1185-
$value = implode($values, ' | ');
1185+
$value = implode(' | ', $values);
11861186
if (empty($value) || ' | ' === $value) {
11871187
return null;
11881188
}

phpunit.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
convertWarningsToExceptions="true"
99
processIsolation="false"
1010
stopOnFailure="false"
11-
syntaxCheck="false"
11+
beStrictAboutTestsThatDoNotTestAnything="false"
1212
bootstrap="test/bootstrap.php"
1313
>
1414

runtime/lib/formatter/PropelArrayFormatter.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,21 @@ public function format(PDOStatement $stmt)
3232
} else {
3333
$collection = array();
3434
}
35+
36+
/**
37+
* @var $collection PropelArrayCollection
38+
*/
39+
3540
if ($this->isWithOneToMany() && $this->hasLimit) {
3641
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.');
3742
}
38-
$items = [];
43+
44+
$data = [];
45+
3946
while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
4047
$object = &$this->getStructuredArrayFromRow($row);
4148
if ($object) {
42-
$items[] =& $object;
49+
$data[] = &$object;
4350
}
4451
}
4552

@@ -50,6 +57,8 @@ public function format(PDOStatement $stmt)
5057
$this->alreadyHydratedObjects = array();
5158
$stmt->closeCursor();
5259

60+
$collection->setData($data);
61+
5362
return $collection;
5463
}
5564

runtime/lib/map/TableMap.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -786,9 +786,10 @@ public function setPrefix($prefix)
786786
*/
787787
protected function hasPrefix($data)
788788
{
789-
if(!$this->prefix) {
789+
if (!$this->prefix) {
790790
return false;
791791
}
792+
792793
return (strpos($data, $this->prefix) === 0);
793794
}
794795

runtime/lib/parser/yaml/sfYamlInline.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,8 @@ public static function load($value)
3737
return '';
3838
}
3939

40-
if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) {
41-
$mbEncoding = mb_internal_encoding();
42-
mb_internal_encoding('ASCII');
43-
}
40+
$mbEncoding = mb_internal_encoding();
41+
mb_internal_encoding('ASCII');
4442

4543
switch ($value[0]) {
4644
case '[':
@@ -124,10 +122,8 @@ protected static function dumpArray($value)
124122
{
125123
// array
126124
$keys = array_keys($value);
127-
if (
128-
(1 == count($keys) && '0' == $keys[0])
129-
||
130-
(count($keys) > 1 && array_reduce($keys, create_function('$v,$w', 'return (integer) $v + $w;'), 0) == count($keys) * (count($keys) - 1) / 2))
125+
126+
if (count($value) > 0 && array_values($value) === $value)
131127
{
132128
$output = array();
133129
foreach ($value as $val) {

runtime/lib/parser/yaml/sfYamlParser.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,8 @@ public function parse($value)
5656
$this->currentLine = '';
5757
$this->lines = explode("\n", $this->cleanup($value));
5858

59-
if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) {
60-
$mbEncoding = mb_internal_encoding();
61-
mb_internal_encoding('UTF-8');
62-
}
59+
$mbEncoding = mb_internal_encoding();
60+
mb_internal_encoding('UTF-8');
6361

6462
$data = array();
6563
while ($this->moveToNextLine()) {

runtime/lib/validator/NotMatchValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class NotMatchValidator implements BasicValidator
4848
private function prepareRegexp($exp)
4949
{
5050
// remove surrounding '/' marks so that they don't get escaped in next step
51-
if ($exp{0} !== '/' || $exp{strlen($exp) - 1} !== '/') {
51+
if ($exp[0] !== '/' || $exp[strlen($exp) - 1] !== '/') {
5252
$exp = '/' . $exp . '/';
5353
}
5454

test/fixtures/bookstore/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
propel.project = bookstore
1414
propel.database = mysql
15-
propel.database.url = mysql:dbname=test
15+
propel.database.url = mysql:host=db;dbname=test
1616
propel.mysql.tableType = InnoDB
1717
propel.disableIdentifierQuoting = true
1818
propel.schema.autoPrefix = true

test/fixtures/bookstore/runtime-conf.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<!-- Connection parameters. See PDO documentation for DSN format and available option constants. -->
1717
<connection>
1818
<classname>DebugPDO</classname>
19-
<dsn>mysql:dbname=test</dsn>
19+
<dsn>mysql:host=db;dbname=test</dsn>
2020
<!--
2121
For MySQL and Oracle you must specify username + password separate from DSN:
2222
-->
@@ -51,7 +51,7 @@
5151
<adapter>mysql</adapter>
5252
<connection>
5353
<classname>DebugPDO</classname>
54-
<dsn>mysql:dbname=test</dsn>
54+
<dsn>mysql:host=db;dbname=test</dsn>
5555
<!--
5656
For MySQL and Oracle you must specify username + password separate from DSN:
5757
-->
@@ -73,7 +73,7 @@
7373
<adapter>mysql</adapter>
7474
<connection>
7575
<classname>DebugPDO</classname>
76-
<dsn>mysql:dbname=test</dsn>
76+
<dsn>mysql:host=db;dbname=test</dsn>
7777
<!--
7878
For MySQL and Oracle you must specify username + password separate from DSN:
7979
-->

test/fixtures/namespaced/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
propel.project = bookstore_namespaced
1414
propel.database = mysql
15-
propel.database.url = mysql:dbname=test
15+
propel.database.url = mysql:host=db;dbname=test
1616
propel.mysql.tableType = InnoDB
1717
propel.disableIdentifierQuoting=true
1818

test/fixtures/namespaced/runtime-conf.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<!-- Connection parameters. See PDO documentation for DSN format and available option constants. -->
1717
<connection>
1818
<classname>DebugPDO</classname>
19-
<dsn>mysql:dbname=test</dsn>
19+
<dsn>mysql:host=db;dbname=test</dsn>
2020
<!--
2121
For MySQL and Oracle you must specify username + password separate from DSN:
2222
-->

test/fixtures/reverse/mysql/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
propel.project = reverse_bookstore
1414

1515
propel.database = mysql
16-
propel.database.url = mysql:dbname=reverse_bookstore
16+
propel.database.url = mysql:host=db;dbname=reverse_bookstore
1717

1818
# For MySQL or Oracle, you also need to specify username & password
1919
propel.database.user = root

test/fixtures/reverse/mysql/runtime-conf.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<adapter>mysql</adapter>
1515
<connection>
1616
<classname>DebugPDO</classname>
17-
<dsn>mysql:dbname=reverse_bookstore</dsn>
17+
<dsn>mysql:host=db;dbname=reverse_bookstore</dsn>
1818
<!--
1919
For MySQL and Oracle you must specify username + password separate from DSN:
2020
-->

test/fixtures/schemas/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
propel.project = bookstore
1414
propel.database = mysql
15-
propel.database.url = mysql:dbname=test
15+
propel.database.url = mysql:host=db;dbname=test
1616
propel.database.user = root
1717
propel.mysql.tableType = InnoDB
1818
propel.disableIdentifierQuoting = true

test/fixtures/schemas/runtime-conf.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<adapter>mysql</adapter>
1515
<connection>
1616
<classname>DebugPDO</classname>
17-
<dsn>mysql:dbname=test</dsn>
17+
<dsn>mysql:host=db;dbname=test</dsn>
1818
<!--
1919
For MySQL and Oracle you must specify username + password separate from DSN:
2020
-->

test/testsuite/generator/behavior/AlternativeCodingStandardsBehaviorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* @version $Revision$
2020
* @package generator.behavior
2121
*/
22-
class AlternativeCodingStandardsBehaviorTest extends PHPUnit_Framework_TestCase
22+
class AlternativeCodingStandardsBehaviorTest extends \PHPUnit\Framework\TestCase
2323
{
2424
public function convertBracketsNewlineDataProvider()
2525
{

test/testsuite/generator/behavior/DelegateBehaviorTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
* @version $Revision$
2121
* @package generator.behavior
2222
*/
23-
class DelegateBehaviorTest extends PHPUnit_Framework_TestCase
23+
class DelegateBehaviorTest extends \PHPUnit\Framework\TestCase
2424
{
2525

26-
public function setUp()
26+
protected function setUp(): void
2727
{
2828
if (!class_exists('DelegateDelegate')) {
2929
$schema = <<<EOF
@@ -175,6 +175,7 @@ public function testAModelCanHaveSeveralDelegates()
175175
*/
176176
public function testAModelCannotHaveCascadingDelegates()
177177
{
178+
$this->expectException(PropelException::class);
178179
$main = new DelegateMain();
179180
$main->setSummary('bar');
180181
$main->setBody('baz');

test/testsuite/generator/behavior/NamespacedBehaviorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
require_once __DIR__.'/../../../fixtures/generator/behavior/Foobar.php';
33

4-
class NamespacedBehaviorTest extends PHPUnit_Framework_TestCase
4+
class NamespacedBehaviorTest extends \PHPUnit\Framework\TestCase
55
{
66
/**
77
* test if issue 425 is resolved

test/testsuite/generator/behavior/SoftDeleteBehaviorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
class SoftDeleteBehaviorTest extends BookstoreTestBase
2222
{
2323

24-
protected function setUp()
24+
protected function setUp(): void
2525
{
2626
parent::setUp();
2727
Table4Peer::disableSoftDelete();

test/testsuite/generator/behavior/TableBehaviorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
* @author Francois Zaninotto
1515
* @package generator.behavior
1616
*/
17-
class TableBehaviorTest extends PHPUnit_Framework_TestCase
17+
class TableBehaviorTest extends \PHPUnit\Framework\TestCase
1818
{
19-
protected function setUp()
19+
protected function setUp(): void
2020
{
2121
parent::setUp();
2222
set_include_path(get_include_path() . PATH_SEPARATOR . "fixtures/bookstore/build/classes");

0 commit comments

Comments
 (0)