Skip to content

Commit 9bae76c

Browse files
committed
cleanup, php 8.2
1 parent d92e53e commit 9bae76c

File tree

6 files changed

+75
-35
lines changed

6 files changed

+75
-35
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## 1.0.2 - 2023.03.23
6+
Cleanup, PHP 8.2
7+
58
## 1.0.1 - 2022.11.28
69
```
710
+ mask valid/invalid css feedback

composer.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"validation",
1111
"cp"
1212
],
13-
"version": "1.0.1",
13+
"version": "1.0.2",
1414
"type": "craft-plugin",
1515
"license": "MIT",
1616
"authors": [
@@ -22,7 +22,8 @@
2222
"minimum-stability": "dev",
2323
"prefer-stable": true,
2424
"require": {
25-
"craftcms/cms": "^4.0"
25+
"php": "^7.2.5|^8.0",
26+
"craftcms/cms": "^3.0|^4.0"
2627
},
2728
"require-dev": {
2829
"craftcms/ecs": "dev-main",
@@ -37,8 +38,6 @@
3738
"extra": {
3839
"name": "Masked Fields",
3940
"handle": "masked-fields",
40-
"hasCpSection": false,
41-
"hasCpSettings": false,
4241
"class": "leowebguy\\maskedfields\\Plugin"
4342
},
4443
"config": {

src/Plugin.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@ class Plugin extends BasePlugin
2323
{
2424
// Properties
2525
// =========================================================================
26+
2627
public static $plugin;
2728

2829
// Public Methods
2930
// =========================================================================
31+
3032
public function init()
3133
{
3234
parent::init();
@@ -36,9 +38,6 @@ public function init()
3638
return;
3739
}
3840

39-
/**
40-
* Register assets
41-
*/
4241
Event::on(
4342
View::class,
4443
View::EVENT_BEFORE_RENDER_TEMPLATE,
@@ -50,9 +49,6 @@ static function() {
5049
}
5150
);
5251

53-
/**
54-
* Register fields
55-
*/
5652
Event::on(
5753
Fields::class,
5854
Fields::EVENT_REGISTER_FIELD_TYPES,
@@ -61,9 +57,6 @@ function(RegisterComponentTypesEvent $event) {
6157
}
6258
);
6359

64-
/**
65-
* Log info
66-
*/
6760
Craft::info(
6861
'Masked Fields plugin loaded',
6962
__METHOD__

src/assets/js/cp.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
f.addClass('valid')
66
},
77
onKeyPress: (v, e, f, options) => {
8-
if (!v) { return }
8+
if (!v) {
9+
return
10+
}
911
//console.log('A key was pressed!:', v, ' event: ', e, 'currentField: ', currentField, ' options: ', options)
1012
//console.log('onKeyPress')
1113
f.removeClass('valid')
@@ -18,7 +20,9 @@
1820
// console.log('onChange');
1921
// },
2022
onInvalid: (v, e, f, invalid, options) => {
21-
if (!v) { return }
23+
if (!v) {
24+
return
25+
}
2226
//var error = invalid[0]
2327
//console.log('Digit: ', error.v, ' is invalid for the position: ', error.p, '. We expect something like: ', error.e)
2428
//console.log('onInvalid')

src/fields/MaskedField.php

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
use craft\base\ElementInterface;
1515
use craft\base\PreviewableFieldInterface;
1616
use craft\fields\PlainText;
17+
use Twig\Error\LoaderError;
18+
use Twig\Error\RuntimeError;
19+
use Twig\Error\SyntaxError;
20+
use yii\base\Exception;
1721

1822
/**
1923
* @property-read null|string $settingsHtml
@@ -26,12 +30,12 @@ class MaskedField extends PlainText implements PreviewableFieldInterface
2630
/**
2731
* @var string
2832
*/
29-
public $type = 'phoneus';
33+
public string $type = 'phoneus';
3034

3135
/**
3236
* @var string[]
3337
*/
34-
private $_types;
38+
private array $_types;
3539

3640
// Public Methods
3741
// =========================================================================
@@ -79,7 +83,11 @@ public function rules(): array
7983
}
8084

8185
/**
82-
* @inheritdoc
86+
* @return string|null
87+
* @throws Exception
88+
* @throws LoaderError
89+
* @throws RuntimeError
90+
* @throws SyntaxError
8391
*/
8492
public function getSettingsHtml(): ?string
8593
{
@@ -92,7 +100,13 @@ public function getSettingsHtml(): ?string
92100
}
93101

94102
/**
95-
* @inheritdoc
103+
* @param mixed $value
104+
* @param ElementInterface|null $element
105+
* @return string
106+
* @throws LoaderError
107+
* @throws RuntimeError
108+
* @throws SyntaxError
109+
* @throws Exception
96110
*/
97111
public function getInputHtml(mixed $value, ?ElementInterface $element = null): string
98112
{

src/icon.svg

Lines changed: 43 additions & 16 deletions
Loading

0 commit comments

Comments
 (0)