Skip to content

Commit 7fbb263

Browse files
slepico5
authored andcommitted
BC: Support only PHP 7.1, Nette 3.0 compatibility
1 parent 6e4397d commit 7fbb263

21 files changed

Lines changed: 122 additions & 124 deletions

.travis.yml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
language: php
22

33
php:
4-
- 5.6
5-
- 7.0
6-
- hhvm
7-
8-
matrix:
9-
allow_failures:
10-
- php: hhvm
4+
- 7.1
115

126
before_install:
13-
- if [ $TRAVIS_PHP_VERSION = '5.6' ]; then COVERAGE="-c `php -i | grep 'xdebug.ini'` --coverage coverage.xml --coverage-src=src/ "; else COVERAGE="" && if [ $TRAVIS_PHP_VERSION = '5.6' ]; then phpenv config-rm xdebug.ini; fi; fi
7+
- if [ $TRAVIS_PHP_VERSION = '7.1' ]; then COVERAGE="-c `php -i | grep 'xdebug.ini'` --coverage coverage.xml --coverage-src=src/ "; else COVERAGE="" && if [ $TRAVIS_PHP_VERSION = '7.1' ]; then phpenv config-rm xdebug.ini; fi; fi
148
- composer global require hirak/prestissimo
159

1610
install:
@@ -21,4 +15,4 @@ script:
2115
- vendor/bin/tester -p php $COVERAGE tests/
2216

2317
after_script:
24-
- if [ $TRAVIS_PHP_VERSION = '5.6' ]; then wget https://scrutinizer-ci.com/ocular.phar && php ocular.phar code-coverage:upload --format=php-clover coverage.xml; fi
18+
- if [ $TRAVIS_PHP_VERSION = '7.1' ]; then wget https://scrutinizer-ci.com/ocular.phar && php ocular.phar code-coverage:upload --format=php-clover coverage.xml; fi

composer.json

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,27 +24,32 @@
2424
}
2525
},
2626
"scripts": {
27-
"test": "./vendor/bin/tester --colors 1 -p php tests/",
27+
"test": "./vendor/bin/tester --colors 1 -j 4 -c tests/php-unix.ini -p php tests/",
2828
"syntax": "./vendor/bin/phpcs --standard=standards.xml --colors --encoding=utf-8 -sp src/",
2929
"syntax-fix": "./vendor/bin/phpcbf --standard=standards.xml src/"
3030
},
3131
"require": {
32-
"php": ">=5.6",
33-
"nette/utils": "~2.4",
34-
"nette/forms": "~2.2",
35-
"latte/latte": "~2.3",
36-
"nette/application": "~2.2",
37-
"nette/component-model": "~2.2",
32+
"php": ">=7.1",
33+
"nette/utils": "^3.0",
34+
"nette/forms": "^3.0",
35+
"latte/latte": "^2.5",
36+
"nette/application": "^3.0",
37+
"nette/component-model": "^3.0",
3838
"symfony/property-access": "~3.0"
3939
},
4040
"require-dev": {
41-
"tracy/tracy": "~2.3",
42-
"nette/bootstrap": "~2.3",
43-
"nette/database": "~2.2",
41+
"tracy/tracy": "^2.6",
42+
"nette/bootstrap": "^3.0",
43+
"nette/database": "^3.0",
4444
"nette/tester": "~1.7.1",
45-
"mockery/mockery": "~0.9.3",
46-
"dibi/dibi": "~3.0.1",
47-
"kdyby/doctrine": "~3.3.0",
48-
"squizlabs/php_codesniffer": "~2.5"
49-
}
45+
"mockery/mockery": "^1.0",
46+
"squizlabs/php_codesniffer": "~2.5",
47+
"kdyby/annotations": "^3.0",
48+
"kdyby/console": "dev-master",
49+
"kdyby/doctrine": "dev-master",
50+
"kdyby/events": "dev-master",
51+
"dibi/dibi": "^4.0"
52+
},
53+
"minimum-stability": "dev",
54+
"prefer-stable": true
5055
}

src/Components/Export.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ public function handleExport()
163163
* @param \Nette\Http\IResponse $httpResponse
164164
* @return void
165165
*/
166-
public function send(\Nette\Http\IRequest $httpRequest, \Nette\Http\IResponse $httpResponse)
166+
public function send(\Nette\Http\IRequest $httpRequest, \Nette\Http\IResponse $httpResponse): void
167167
{
168168
$encoding = 'utf-8';
169169
$label = $this->label

src/Components/Operation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public function handleOperations(\Nette\Forms\Controls\SubmitButton $button)
131131

132132
foreach ($values as $key => $val) {
133133
if ($val) {
134-
$ids[] = $key;
134+
$ids[] = (string) $key;
135135
}
136136
}
137137

src/Components/Paginator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public function setStepCount($stepCount)
8585
/**
8686
* @return int
8787
*/
88-
public function getPage()
88+
public function getPage(): int
8989
{
9090
if ($this->page === NULL) {
9191
$this->page = parent::getPage();

src/DataSources/DibiFluent.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
* @subpackage DataSources
2121
* @author Petr Bugyík
2222
*
23-
* @property-read \DibiFluent $fluent
23+
* @property-read \Dibi\Fluent $fluent
2424
* @property-read int $limit
2525
* @property-read int $offset
2626
* @property-read int $count
@@ -30,7 +30,7 @@ class DibiFluent implements IDataSource
3030
{
3131
use \Nette\SmartObject;
3232

33-
/** @var \DibiFluent */
33+
/** @var \Dibi\Fluent */
3434
protected $fluent;
3535

3636
/** @var int */
@@ -40,15 +40,15 @@ class DibiFluent implements IDataSource
4040
protected $offset;
4141

4242
/**
43-
* @param \DibiFluent $fluent
43+
* @param \Dibi\Fluent $fluent
4444
*/
45-
public function __construct(\DibiFluent $fluent)
45+
public function __construct(\Dibi\Fluent $fluent)
4646
{
4747
$this->fluent = $fluent;
4848
}
4949

5050
/**
51-
* @return \DibiFluent
51+
* @return \Dibi\Fluent
5252
*/
5353
public function getFluent()
5454
{
@@ -73,9 +73,9 @@ public function getOffset()
7373

7474
/**
7575
* @param \Grido\Components\Filters\Condition $condition
76-
* @param \DibiFluent $fluent
76+
* @param \Dibi\Fluent $fluent
7777
*/
78-
protected function makeWhere(\Grido\Components\Filters\Condition $condition, \DibiFluent $fluent = NULL)
78+
protected function makeWhere(\Grido\Components\Filters\Condition $condition, \Dibi\Fluent $fluent = NULL)
7979
{
8080
$fluent = $fluent === NULL
8181
? $this->fluent

src/DataSources/Doctrine.php

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,23 @@ public function setFetchJoinCollection($fetchJoinCollection)
9797
*/
9898
public function getQuery()
9999
{
100-
return $this->qb->getQuery();
100+
return $this->_getQuery($this->qb);
101+
}
102+
103+
/**
104+
* Workaround for https://github.com/Kdyby/DoctrineCache/issues/23
105+
*
106+
* @param \Doctrine\ORM\QueryBuilder $qb
107+
* @return \Doctrine\ORM\Query
108+
*/
109+
private function _getQuery(\Doctrine\ORM\QueryBuilder $qb)
110+
{
111+
$query = $qb->getQuery();
112+
$ttl = $query->getQueryCacheLifetime();
113+
if (!\is_int($ttl)) {
114+
$query->setQueryCacheLifetime(0);
115+
}
116+
return $query;
101117
}
102118

103119
/**
@@ -205,7 +221,7 @@ public function getData()
205221
// Paginator is better if the query uses ManyToMany associations
206222
$result = $this->qb->getMaxResults() !== NULL || $this->qb->getFirstResult() !== NULL
207223
? new Paginator($this->getQuery())
208-
: $this->qb->getQuery()->getResult();
224+
: $this->getQuery()->getResult();
209225

210226
foreach ($result as $item) {
211227
// Return only entity itself
@@ -279,7 +295,7 @@ public function suggest($column, array $conditions, $limit)
279295
}
280296

281297
$items = [];
282-
$data = $qb->getQuery()->getScalarResult();
298+
$data = $this->_getQuery($qb)->getScalarResult();
283299
foreach ($data as $row) {
284300
if (is_string($column)) {
285301
$value = (string) current($row);

src/DataSources/Model.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class Model
3838
*/
3939
public function __construct($model)
4040
{
41-
if ($model instanceof \DibiFluent) {
41+
if ($model instanceof \Dibi\Fluent) {
4242
$dataSource = new DibiFluent($model);
4343
} elseif ($model instanceof \Nette\Database\Table\Selection) {
4444
$dataSource = new NetteDatabase($model);
@@ -56,7 +56,7 @@ public function __construct($model)
5656
}
5757

5858
/**
59-
* @return \IDataSource
59+
* @return IDataSource
6060
*/
6161
public function getDataSource()
6262
{

src/Grid.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Grido\Components\Filters\Filter;
1919
use Grido\Components\Actions\Action;
2020

21+
use Nette\Application\UI\Presenter;
2122
use Symfony\Component\PropertyAccess\PropertyAccessor;
2223

2324
/**
@@ -140,7 +141,6 @@ class Grid extends Components\Container
140141
*/
141142
public function __construct()
142143
{
143-
parent::__construct();
144144
list($parent, $name) = func_get_args() + [NULL, NULL];
145145
if ($parent !== NULL) {
146146
$parent->addComponent($this, $name);
@@ -701,7 +701,7 @@ public function getCustomization()
701701
* @param array $params
702702
* @internal
703703
*/
704-
public function loadState(array $params)
704+
public function loadState(array $params): void
705705
{
706706
//loads state from session
707707
$session = $this->getRememberSession();
@@ -720,10 +720,10 @@ public function loadState(array $params)
720720
* @param \Nette\Application\UI\PresenterComponentReflection $reflection (internal, used by Presenter)
721721
* @internal
722722
*/
723-
public function saveState(array &$params, $reflection = NULL)
723+
public function saveState(array &$params, $reflection = NULL): void
724724
{
725725
!empty($this->onRegistered) && $this->onRegistered($this);
726-
return parent::saveState($params, $reflection);
726+
parent::saveState($params, $reflection);
727727
}
728728

729729
/**
@@ -832,10 +832,9 @@ public function reload()
832832
/**********************************************************************************************/
833833

834834
/**
835-
* @return \Nette\Templating\FileTemplate
836835
* @internal
837836
*/
838-
public function createTemplate()
837+
public function createTemplate(): \Nette\Application\UI\ITemplate
839838
{
840839
$template = parent::createTemplate();
841840
$template->setFile($this->getCustomization()->getTemplateFiles()[Customization::TEMPLATE_DEFAULT]);
@@ -1029,7 +1028,7 @@ protected function getItemsForCountSelect()
10291028
*/
10301029
public function __triggerUserNotice($message)
10311030
{
1032-
if ($this->getPresenter(FALSE) && $session = $this->getRememberSession()) {
1031+
if ($this->lookup(Presenter::class, FALSE) && $session = $this->getRememberSession()) {
10331032
$session->remove();
10341033
}
10351034

src/Translations/FileTranslator.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,13 @@ protected function getTranslationsFromFile($lang)
6565

6666
/**
6767
* @param string $message
68-
* @param int $count plural
68+
* @param ...$parameters
6969
* @return string
7070
*/
71-
public function translate($message, $count = NULL)
71+
public function translate($message, ...$parameters): string
7272
{
7373
return isset($this->translations[$message])
7474
? $this->translations[$message]
75-
: $message;
75+
: ($message ?? '');
7676
}
7777
}

0 commit comments

Comments
 (0)