Skip to content

Commit 6c2649c

Browse files
authored
Merge pull request #2 from codenix-sv/dev
Migrated to PHP 7
2 parents 5b7ebe0 + 7ea606d commit 6c2649c

File tree

8 files changed

+42
-68
lines changed

8 files changed

+42
-68
lines changed

.travis.yml

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
language: php
22

33
php:
4-
- '5.6'
54
- '7.0'
65
- '7.1'
6+
- '7.2'
7+
- '7.3'
8+
- '7.4'
79

810
# faster builds on new travis setup not using sudo
911
sudo: false
@@ -20,12 +22,12 @@ install:
2022
before_script:
2123
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
2224
- chmod +x ./cc-test-reporter
23-
- if [ $(phpenv version-name) = "7.1" ]; then ./cc-test-reporter before-build; fi
25+
- ./cc-test-reporter before-build
2426

2527
script:
2628
- composer validate --strict
2729
- vendor/bin/phpunit
2830

2931
after_script:
30-
- if [ $(phpenv version-name) = "7.1" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT; fi
31-
- if [ $(phpenv version-name) = "7.1" ]; then wget https://scrutinizer-ci.com/ocular.phar; php ocular.phar code-coverage:upload --format=php-clover ./build/logs/clover.xml; fi
32+
- if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT; fi
33+
- if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then wget https://scrutinizer-ci.com/ocular.phar; php ocular.phar code-coverage:upload --format=php-clover ./build/logs/clover.xml; fi

README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Flatpickr is a lightweight and powerful datetime picker written in vanilla javas
1616
![flatpickr-theme-dark](https://user-images.githubusercontent.com/17989224/33085189-a6d0688a-ceec-11e7-8a38-be258ff692b2.png)
1717

1818
## Latest release
19-
The latest stable version of the extension is v1.0
19+
The latest stable version of the extension is v2.0
2020

2121
## Installation
2222

@@ -25,12 +25,12 @@ The preferred way to install this extension is through [composer](http://getcomp
2525
Either run
2626

2727
```bash
28-
$ composer require codenix-sv/yii2-flatpickr:~1.0
28+
$ composer require codenix-sv/yii2-flatpickr:~2.0
2929
```
3030
or add
3131

3232
```json
33-
"codenix-sv/yii2-flatpickr" : "~1.0"
33+
"codenix-sv/yii2-flatpickr" : "~2.0"
3434
```
3535

3636
to the require section of your application's `composer.json` file.
@@ -46,7 +46,7 @@ use codenixsv\flatpickr\Flatpickr;
4646

4747
?>
4848
...
49-
<?= $form->field($model, 'date')->widget(Flatpickr::className()) ?>
49+
<?= $form->field($model, 'date')->widget(Flatpickr::class) ?>
5050
```
5151
### Example of use as a widget:
5252
```php
@@ -61,7 +61,7 @@ use codenixsv\flatpickr\Flatpickr;
6161

6262
?>
6363
...
64-
<?= $form->field($model, 'email')->widget(Flatpickr::className(), [
64+
<?= $form->field($model, 'email')->widget(Flatpickr::class, [
6565
'theme' =>'dark',
6666
'clientOptions' => [
6767
'locale' => 'ru',

composer.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@
2121
}
2222
],
2323
"require": {
24+
"php": ">=7.0",
2425
"yiisoft/yii2": "~2.0.0",
2526
"npm-asset/flatpickr": "~4.0"
2627
},
2728
"require-dev": {
28-
"phpunit/phpunit": "~5.0"
29+
"phpunit/phpunit": "~6.0"
2930
},
3031
"autoload": {
3132
"psr-4": {

src/Flatpickr.php

+9-22
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,18 @@ class Flatpickr extends InputWidget
2525
*/
2626
public $clientOptions = [];
2727

28-
/**
29-
* @var array
30-
*/
28+
/** @var array */
3129
public $defaultOptions = [
3230
'allowInput' => true
3331
];
3432

35-
/**
36-
* @var string
37-
*/
33+
/** @var string */
3834
private $_locale;
3935

40-
/**
41-
* @var string
42-
*/
36+
/** @var string */
4337
public $theme;
4438

45-
/**
46-
* @var string
47-
*/
39+
/** @var string */
4840
private $_id;
4941

5042
/**
@@ -64,17 +56,14 @@ public function init()
6456

6557
/**
6658
* @inheritdoc
67-
* @return string
6859
*/
69-
public function run()
60+
public function run(): string
7061
{
7162
parent::run();
7263

7364
$this->registerClientScript();
7465

75-
$content = $this->renderContent();
76-
77-
return $content;
66+
return $this->renderContent();
7867
}
7968

8069
/**
@@ -96,15 +85,13 @@ private function registerClientScript()
9685

9786
/**
9887
* Renders widget
99-
* @return string
10088
*/
101-
private function renderContent()
89+
private function renderContent(): string
10290
{
10391
$options = ArrayHelper::merge(['class' => 'form-control', 'data-input' => true], $this->options);
104-
$content = $this->hasModel()
92+
93+
return $this->hasModel()
10594
? Html::activeTextInput($this->model, $this->attribute, $options)
10695
: Html::textInput($this->name, $this->value, $options);
107-
108-
return $content;
10996
}
11097
}

src/assets/FlatpickrAsset.php

+5-18
Original file line numberDiff line numberDiff line change
@@ -15,36 +15,23 @@
1515
*/
1616
class FlatpickrAsset extends AssetBundle
1717
{
18-
/**
19-
* @inheritdoc
20-
* @var string
21-
*/
18+
/** @var string */
2219
public $sourcePath = '@npm/flatpickr/dist';
2320

24-
/**
25-
* @inheritdoc
26-
* @var array
27-
*/
21+
/** @var array */
2822
public $js = [
2923
'flatpickr.min.js',
3024
];
3125

32-
/**
33-
* @inheritdoc
34-
* @var array
35-
*/
26+
/** @var array */
3627
public $css = [
3728
'flatpickr.min.css',
3829
];
3930

40-
/**
41-
* @var string
42-
*/
31+
/** @var string */
4332
public $theme;
4433

45-
/**
46-
* @var string
47-
*/
34+
/** @var string */
4835
public $locale;
4936

5037
/**

tests/functional/FlatpickrTest.php

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use tests\data\models\TestModel;
66
use codenixsv\flatpickr\Flatpickr;
7-
use yii\widgets\ActiveForm;
87

98
/**
109
* Class FlatpickrTest

tests/functional/TestCase.php

+9-15
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
namespace codenixsv\flatpickr\tests\functional;
44

55
use yii\web\View;
6-
use \yii\web\Application;
6+
use yii\web\Application;
7+
use Yii;
78

89
/**
910
* Class TestCase
1011
* @package codenixsv\flatpickr\tests\functional
1112
*/
12-
abstract class TestCase extends \PHPUnit_Framework_TestCase
13+
abstract class TestCase extends \PHPUnit\Framework\TestCase
1314
{
1415
/**
1516
* @inheritdoc
@@ -40,9 +41,8 @@ protected function mockApplication()
4041
/**
4142
* Returns vendor directory path
4243
*
43-
* @return string
4444
*/
45-
protected function getVendorPath()
45+
protected function getVendorPath(): string
4646
{
4747
return dirname(dirname(__DIR__)) . '/vendor';
4848
}
@@ -52,28 +52,24 @@ protected function getVendorPath()
5252
*/
5353
protected function destroyApplication()
5454
{
55-
\Yii::$app = null;
55+
Yii::$app = null;
5656
}
5757

5858
/**
5959
* Creates view for testing
6060
*
61-
* @return View
6261
*/
63-
protected function getView()
62+
protected function getView(): View
6463
{
65-
$view = new View();
66-
67-
return $view;
64+
return new View();
6865
}
6966

7067
/**
7168
* Returns config for Application
72-
* @return array
7369
*/
74-
protected function getApplicationConfig()
70+
protected function getApplicationConfig(): array
7571
{
76-
$config = [
72+
return [
7773
'id' => 'testapp',
7874
'basePath' => __DIR__,
7975
'vendorPath' => $this->getVendorPath(),
@@ -101,7 +97,5 @@ protected function getApplicationConfig()
10197
],
10298
],
10399
];
104-
105-
return $config;
106100
}
107101
}

tests/functional/bootstrap.php

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
<?php
2-
// ensure we get report on all possible php errors
2+
33
error_reporting(-1);
44
define('YII_ENABLE_ERROR_HANDLER', false);
55
define('YII_DEBUG', true);
6+
67
$_SERVER['SCRIPT_NAME'] = '/' . __DIR__;
78
$_SERVER['SCRIPT_FILENAME'] = __FILE__;
9+
810
require_once(__DIR__ . '/../../vendor/autoload.php');
911
require_once(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php');
12+
1013
Yii::setAlias('@tests', __DIR__);
11-
require_once(__DIR__ . '/TestCase.php');
14+
15+
require_once(__DIR__ . '/TestCase.php');

0 commit comments

Comments
 (0)