[TikiWiki-commits] [Git][tikiwiki/tiki][master] [REF] PSR12 Migration Changes For NumStyle and D classes
"SoftStart Code \(@softstartcode\) via TikiWiki-cvs" <[email protected]>
| Newsgroups | gmane.comp.cms.tiki.cvs |
|---|---|
| Message-ID | <689e747234276_2c5e89914516b2@gitlab-sidekiq-low-urgency-cpu-bound-v2-56796cf4dc-kt2sn.mail> |
SoftStart Code pushed to branch master at Tiki Wiki CMS Groupware / Tiki
Commits:
f564db8a by Sandeep D at 2025-08-14T23:34:58+00:00
[REF] PSR12 Migration Changes For NumStyle and D classes
---
* [REF] PSR12 Migration Changes For NumStyle and D classes
See merge request tikiwiki/tiki!8258
- - - - -
7 changed files:
- .gitattributes
- doc/devtools/codesniffer/standards/TikiIgnore/ignore_list.json
- lib/core/Tiki/PSR12Migration/Autoload.php
- lib/smarty_tiki/Modifier/D.php
- lib/smarty_tiki/Modifier/NumStyle.php
- + lib/smarty_tiki/Utils/SmartyKint.php
- + lib/smarty_tiki/Utils/StyleType.php
Changes:
=====================================
.gitattributes
=====================================
@@ -4272,6 +4272,10 @@ lib/smarty_tiki/prefilter.log_tpl.php -text
lib/smarty_tiki/prefilter.tr.php -text
lib/smarty_tiki/resource.tplwiki.php -text
lib/smarty_tiki/resource.wiki.php -text
+lib/smarty_tiki/Modifier/NumStyle.php -text
+lib/smarty_tiki/Utils/StyleType.php -text
+lib/smarty_tiki/Modifier/D.php -text
+lib/smarty_tiki/Utils/SmartyKint.php -text
lib/soap/index.php -text
lib/soap/nusoap/index.php -text
lib/soap/nusoap/nusoap.php -text
=====================================
doc/devtools/codesniffer/standards/TikiIgnore/ignore_list.json
=====================================
@@ -6239,12 +6239,6 @@
"lib\/shipping\/shippinglib.php": {
"class:CustomShippingProvider": true,
"class:ShippingLib": true
- },
- "lib\/smarty_tiki\/Modifier\/NumStyle.php": {
- "class:StyleType": true
- },
- "lib\/smarty_tiki\/Modifier\/D.php": {
- "class:SmartyKint": true
}
},
"PSR1.Methods.CamelCapsMethodName.NotCamelCaps": {
=====================================
lib/core/Tiki/PSR12Migration/Autoload.php
=====================================
@@ -155,6 +155,8 @@ class Autoload
'Tiki_Security_Policy' => 'Tiki\\Smarty\\SecurityPolicy',
'Smarty_Tiki' => 'Tiki\\Smarty\\SmartyTiki',
'SmartyTikiErrorHandler' => 'Tiki\\Smarty\\SmartyTikiErrorHandler',
+ 'StyleType' => 'SmartyTiki\\Utils\\StyleType',
+ 'SmartyKint' => 'SmartyTiki\\Utils\\SmartyKint',
'TikiAcceptanceTestDBRestorer' => 'Tiki\\Lib\\Test\\AcceptanceTests\\AbstractDBRestorer',
'TikiAcceptanceTestDBRestorerSQLDumps' => 'Tiki\\Lib\\Test\\AcceptanceTests\\DBRestorerSQLDumps',
'TikiAcceptanceTestDBRestorerBinaryDumps' => 'Tiki\\Lib\\Test\\AcceptanceTests\\DBRestorerBinaryDumps',
=====================================
lib/smarty_tiki/Modifier/D.php
=====================================
@@ -8,11 +8,7 @@
namespace SmartyTiki\Modifier;
use Kint\Kint;
-use Kint\Parser\Parser;
-use Kint\Parser\PluginBeginInterface;
-use Kint\Value\AbstractValue;
-use Kint\Value\Context\BaseContext;
-use Kint\Value\Context\ContextInterface;
+use SmartyTiki\Utils\SmartyKint;
/**
* If installed, this modifier will use Kint (from https://github.com/kint-php/kint/)
@@ -61,43 +57,3 @@ class D
}
}
}
-
-if (class_exists('Kint')) {
-// https://kint-php.github.io/kint/writing-plugins/
- class SmartyKint implements PluginBeginInterface
- {
- protected $parser;
-
- public function setParser(Parser $p): void
- {
- $this->parser = $p;
- }
-
- public function getTypes(): array
- {
- return ['integer', 'string', 'array', 'object'];
- }
-
- public function getTriggers(): int
- {
- return Parser::TRIGGER_BEGIN;
- }
- public function parseBegin(&$var, ContextInterface $c): ?AbstractValue
- {
- // TODO: Implement parseBegin() method.
- $accessPath = $c->getAccessPath();
- if ($accessPath !== null) {
- $replace = preg_replace('/.*\[\'([^\']+)\']->value/', '$$1', $accessPath);
- if ($accessPath !== $replace) {
- $base = new BaseContext($replace);
- $base->depth = $c->getDepth();
- $base->access_path = $c->getAccessPath();
- $base->reference = $c->isRef();
- return $this->parser?->parse($var, $base);
- }
- }
-
- return null;
- }
- }
-}
=====================================
lib/smarty_tiki/Modifier/NumStyle.php
=====================================
@@ -7,6 +7,8 @@
namespace SmartyTiki\Modifier;
+use SmartyTiki\Utils\StyleType;
+
/**
* Converts a positive integer into a selected format.
* Obe may choose a CSS list-style-type value. Some language specific options have not been implemented.
@@ -70,68 +72,3 @@ class NumStyle
}
}
}
-
-/**
- * Class StyleType
- *
- * functions for converting numbers to different formats defined by css List-Style-Type
- *
- *
- */
-class StyleType
-{
- /**
- * Takes a positive integer and returns the equivalent alpha value.
- *
- * eg. The below returns a lower case alphabetic value for 90.
- * toAlpha(90,range('a','z')
- *
- * eg. The below returns a lower case greek letters for 128.
- * toAlpha(128,array('α', 'β', 'γ', 'δ', 'ε', 'ζ', 'η', 'θ', 'ι', 'κ', 'λ', 'μ', 'ν', 'ξ', 'ο', 'π', 'ρ', 'σ', 'τ', 'υ', 'φ', 'χ', 'ψ', 'ω'));
- *
- * @param $number int The number to be turned into characters
- *
- * @param $alphabet array set of letters
- *
- * @return string alpha representation of $number
- */
- public function toAlpha($number, $alphabet)
- {
-
- $count = count($alphabet);
- if ($number <= $count) {
- return $alphabet[$number - 1];
- }
- $alpha = '';
- while ($number > 0) {
- $modulo = ($number - 1) % $count;
- $alpha = $alphabet[$modulo] . $alpha;
- $number = floor((($number - $modulo) / $count));
- }
- return $alpha;
- }
-
-
- /**
- *
- * Turns a positive integer into a uppercase roman numeral.
- * @param $number int The value to be converted into a roman numeral
- * @param $table array An array of roman numerals, (zero normally specified)
- *
- * @return string|int Roman numeral of $number
- */
- public function numerals($number, $table = ['M' => 1000, 'CM' => 900, 'D' => 500, 'CD' => 400, 'C' => 100, 'XC' => 90, 'L' => 50, 'XL' => 40, 'X' => 10, 'IX' => 9, 'V' => 5, 'IV' => 4, 'I' => 1])
- {
- $return = '';
- while ($number > 0) {
- foreach ($table as $rom => $value) {
- if ($number >= $value) {
- $number -= $value;
- $return .= $rom;
- break;
- }
- }
- }
- return $return;
- }
-}
=====================================
lib/smarty_tiki/Utils/SmartyKint.php
=====================================
@@ -0,0 +1,51 @@
+<?php
+
+// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project
+//
+// All Rights Reserved. See copyright.txt for details and a complete list of authors.
+// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
+namespace SmartyTiki\Utils;
+
+use Kint\Parser\Parser;
+use Kint\Parser\PluginBeginInterface;
+use Kint\Value\AbstractValue;
+use Kint\Value\Context\BaseContext;
+use Kint\Value\Context\ContextInterface;
+
+// https://kint-php.github.io/kint/writing-plugins/
+class SmartyKint implements PluginBeginInterface
+{
+ protected $parser;
+
+ public function setParser(Parser $p): void
+ {
+ $this->parser = $p;
+ }
+
+ public function getTypes(): array
+ {
+ return ['integer', 'string', 'array', 'object'];
+ }
+
+ public function getTriggers(): int
+ {
+ return Parser::TRIGGER_BEGIN;
+ }
+ public function parseBegin(&$var, ContextInterface $c): ?AbstractValue
+ {
+ // TODO: Implement parseBegin() method.
+ $accessPath = $c->getAccessPath();
+ if ($accessPath !== null) {
+ $replace = preg_replace('/.*\[\'([^\']+)\']->value/', '$$1', $accessPath);
+ if ($accessPath !== $replace) {
+ $base = new BaseContext($replace);
+ $base->depth = $c->getDepth();
+ $base->access_path = $c->getAccessPath();
+ $base->reference = $c->isRef();
+ return $this->parser?->parse($var, $base);
+ }
+ }
+
+ return null;
+ }
+}
=====================================
lib/smarty_tiki/Utils/StyleType.php
=====================================
@@ -0,0 +1,72 @@
+<?php
+
+// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project
+//
+// All Rights Reserved. See copyright.txt for details and a complete list of authors.
+// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
+namespace SmartyTiki\Utils;
+
+/**
+ * Class StyleType
+ *
+ * functions for converting numbers to different formats defined by css List-Style-Type
+ *
+ *
+ */
+class StyleType
+{
+ /**
+ * Takes a positive integer and returns the equivalent alpha value.
+ *
+ * eg. The below returns a lower case alphabetic value for 90.
+ * toAlpha(90,range('a','z')
+ *
+ * eg. The below returns a lower case greek letters for 128.
+ * toAlpha(128,array('α', 'β', 'γ', 'δ', 'ε', 'ζ', 'η', 'θ', 'ι', 'κ', 'λ', 'μ', 'ν', 'ξ', 'ο', 'π', 'ρ', 'σ', 'τ', 'υ', 'φ', 'χ', 'ψ', 'ω'));
+ *
+ * @param $number int The number to be turned into characters
+ *
+ * @param $alphabet array set of letters
+ *
+ * @return string alpha representation of $number
+ */
+ public function toAlpha($number, $alphabet)
+ {
+
+ $count = count($alphabet);
+ if ($number <= $count) {
+ return $alphabet[$number - 1];
+ }
+ $alpha = '';
+ while ($number > 0) {
+ $modulo = ($number - 1) % $count;
+ $alpha = $alphabet[$modulo] . $alpha;
+ $number = floor((($number - $modulo) / $count));
+ }
+ return $alpha;
+ }
+
+
+ /**
+ *
+ * Turns a positive integer into a uppercase roman numeral.
+ * @param $number int The value to be converted into a roman numeral
+ * @param $table array An array of roman numerals, (zero normally specified)
+ *
+ * @return string|int Roman numeral of $number
+ */
+ public function numerals($number, $table = ['M' => 1000, 'CM' => 900, 'D' => 500, 'CD' => 400, 'C' => 100, 'XC' => 90, 'L' => 50, 'XL' => 40, 'X' => 10, 'IX' => 9, 'V' => 5, 'IV' => 4, 'I' => 1])
+ {
+ $return = '';
+ while ($number > 0) {
+ foreach ($table as $rom => $value) {
+ if ($number >= $value) {
+ $number -= $value;
+ $return .= $rom;
+ break;
+ }
+ }
+ }
+ return $return;
+ }
+}
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/f564db8a62bb5e6980374658d9b661dc686e9f64
--
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/f564db8a62bb5e6980374658d9b661dc686e9f64
You're receiving this email because of your account on gitlab.com.
_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs