Completed
Pull Request — master (#101)
by MusikAnimal
02:29
created
src/AppBundle/Twig/AppExtension.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 
36 36
     /**
37 37
      * Get all functions that this class provides.
38
-     * @return array
38
+     * @return \Twig_SimpleFunction[]
39 39
      */
40 40
     public function getFunctions()
41 41
     {
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 
78 78
     /**
79 79
      * Get the duration of the current HTTP request in seconds.
80
-     * @return string
80
+     * @return double
81 81
      */
82 82
     public function requestTime()
83 83
     {
@@ -529,7 +529,7 @@  discard block
 block discarded – undo
529 529
 
530 530
     /**
531 531
      * Get all filters for this extension.
532
-     * @return array
532
+     * @return \Twig_SimpleFilter[]
533 533
      */
534 534
     public function getFilters()
535 535
     {
Please login to merge, or discard this patch.
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -41,32 +41,32 @@  discard block
 block discarded – undo
41 41
     {
42 42
         $options = ['is_safe' => ['html']];
43 43
         return [
44
-            new \Twig_SimpleFunction('request_time', [ $this, 'requestTime' ], $options),
45
-            new \Twig_SimpleFunction('memory_usage', [ $this, 'requestMemory' ], $options),
46
-            new \Twig_SimpleFunction('year', [ $this, 'generateYear' ], $options),
47
-            new \Twig_SimpleFunction('msgPrintExists', [ $this, 'intuitionMessagePrintExists' ], $options),
48
-            new \Twig_SimpleFunction('msgExists', [ $this, 'intuitionMessageExists' ], $options),
49
-            new \Twig_SimpleFunction('msg', [ $this, 'intuitionMessage' ], $options),
50
-            new \Twig_SimpleFunction('lang', [ $this, 'getLang' ], $options),
51
-            new \Twig_SimpleFunction('langName', [ $this, 'getLangName' ], $options),
52
-            new \Twig_SimpleFunction('allLangs', [ $this, 'getAllLangs' ]),
53
-            new \Twig_SimpleFunction('isRTL', [ $this, 'intuitionIsRTL' ]),
54
-            new \Twig_SimpleFunction('isRTLLang', [ $this, 'intuitionIsRTLLang' ]),
55
-            new \Twig_SimpleFunction('shortHash', [ $this, 'gitShortHash' ]),
56
-            new \Twig_SimpleFunction('hash', [ $this, 'gitHash' ]),
57
-            new \Twig_SimpleFunction('releaseDate', [ $this, 'gitDate' ]),
58
-            new \Twig_SimpleFunction('enabled', [ $this, 'tabEnabled' ]),
59
-            new \Twig_SimpleFunction('tools', [ $this, 'allTools' ]),
60
-            new \Twig_SimpleFunction('color', [ $this, 'getColorList' ]),
61
-            new \Twig_SimpleFunction('chartColor', [ $this, 'chartColor' ]),
62
-            new \Twig_SimpleFunction('isSingleWiki', [ $this, 'isSingleWiki' ]),
63
-            new \Twig_SimpleFunction('getReplagThreshold', [ $this, 'getReplagThreshold' ]),
64
-            new \Twig_SimpleFunction('loadStylesheetsFromCDN', [ $this, 'loadStylesheetsFromCDN' ]),
65
-            new \Twig_SimpleFunction('isWMFLabs', [ $this, 'isWMFLabs' ]),
66
-            new \Twig_SimpleFunction('replag', [ $this, 'replag' ]),
67
-            new \Twig_SimpleFunction('link', [ $this, 'link' ]),
68
-            new \Twig_SimpleFunction('quote', [ $this, 'quote' ]),
69
-            new \Twig_SimpleFunction('bugReportURL', [ $this, 'bugReportURL' ]),
44
+            new \Twig_SimpleFunction('request_time', [$this, 'requestTime'], $options),
45
+            new \Twig_SimpleFunction('memory_usage', [$this, 'requestMemory'], $options),
46
+            new \Twig_SimpleFunction('year', [$this, 'generateYear'], $options),
47
+            new \Twig_SimpleFunction('msgPrintExists', [$this, 'intuitionMessagePrintExists'], $options),
48
+            new \Twig_SimpleFunction('msgExists', [$this, 'intuitionMessageExists'], $options),
49
+            new \Twig_SimpleFunction('msg', [$this, 'intuitionMessage'], $options),
50
+            new \Twig_SimpleFunction('lang', [$this, 'getLang'], $options),
51
+            new \Twig_SimpleFunction('langName', [$this, 'getLangName'], $options),
52
+            new \Twig_SimpleFunction('allLangs', [$this, 'getAllLangs']),
53
+            new \Twig_SimpleFunction('isRTL', [$this, 'intuitionIsRTL']),
54
+            new \Twig_SimpleFunction('isRTLLang', [$this, 'intuitionIsRTLLang']),
55
+            new \Twig_SimpleFunction('shortHash', [$this, 'gitShortHash']),
56
+            new \Twig_SimpleFunction('hash', [$this, 'gitHash']),
57
+            new \Twig_SimpleFunction('releaseDate', [$this, 'gitDate']),
58
+            new \Twig_SimpleFunction('enabled', [$this, 'tabEnabled']),
59
+            new \Twig_SimpleFunction('tools', [$this, 'allTools']),
60
+            new \Twig_SimpleFunction('color', [$this, 'getColorList']),
61
+            new \Twig_SimpleFunction('chartColor', [$this, 'chartColor']),
62
+            new \Twig_SimpleFunction('isSingleWiki', [$this, 'isSingleWiki']),
63
+            new \Twig_SimpleFunction('getReplagThreshold', [$this, 'getReplagThreshold']),
64
+            new \Twig_SimpleFunction('loadStylesheetsFromCDN', [$this, 'loadStylesheetsFromCDN']),
65
+            new \Twig_SimpleFunction('isWMFLabs', [$this, 'isWMFLabs']),
66
+            new \Twig_SimpleFunction('replag', [$this, 'replag']),
67
+            new \Twig_SimpleFunction('link', [$this, 'link']),
68
+            new \Twig_SimpleFunction('quote', [$this, 'quote']),
69
+            new \Twig_SimpleFunction('bugReportURL', [$this, 'bugReportURL']),
70 70
             new \Twig_SimpleFunction('logged_in_user', [$this, 'functionLoggedInUser']),
71 71
             new \Twig_SimpleFunction('isUserAnon', [$this, 'isUserAnon']),
72 72
             new \Twig_SimpleFunction('nsName', [$this, 'nsName']),
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
     public function requestTime()
83 83
     {
84 84
         if (!isset($this->requestTime)) {
85
-            $this->requestTime = microtime(true) - $_SERVER['REQUEST_TIME_FLOAT'];
85
+            $this->requestTime = microtime(true)-$_SERVER['REQUEST_TIME_FLOAT'];
86 86
         }
87 87
 
88 88
         return $this->requestTime;
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
      */
156 156
     public function intuitionMessage($message = "", $vars = [])
157 157
     {
158
-        return $this->getIntuition()->msg($message, [ "domain" => "xtools", "variables" => $vars ]);
158
+        return $this->getIntuition()->msg($message, ["domain" => "xtools", "variables" => $vars]);
159 159
     }
160 160
 
161 161
     /**
@@ -184,10 +184,10 @@  discard block
 block discarded – undo
184 184
      */
185 185
     public function getAllLangs()
186 186
     {
187
-        $messageFiles = glob($this->container->getParameter("kernel.root_dir") . '/../i18n/*.json');
187
+        $messageFiles = glob($this->container->getParameter("kernel.root_dir").'/../i18n/*.json');
188 188
 
189 189
         $languages = array_values(array_unique(array_map(
190
-            function ($filename) {
190
+            function($filename) {
191 191
                 return basename($filename, '.json');
192 192
             },
193 193
             $messageFiles
@@ -534,9 +534,9 @@  discard block
 block discarded – undo
534 534
     public function getFilters()
535 535
     {
536 536
         return [
537
-            new \Twig_SimpleFilter('capitalize_first', [ $this, 'capitalizeFirst' ]),
538
-            new \Twig_SimpleFilter('percent_format', [ $this, 'percentFormat' ]),
539
-            new \Twig_SimpleFilter('diff_format', [ $this, 'diffFormat' ], [ 'is_safe' => [ 'html' ] ]),
537
+            new \Twig_SimpleFilter('capitalize_first', [$this, 'capitalizeFirst']),
538
+            new \Twig_SimpleFilter('percent_format', [$this, 'percentFormat']),
539
+            new \Twig_SimpleFilter('diff_format', [$this, 'diffFormat'], ['is_safe' => ['html']]),
540 540
             new \Twig_SimpleFilter('num_format', [$this, 'numberFormat']),
541 541
             new \Twig_SimpleFilter('date_format', [$this, 'dateFormat']),
542 542
         ];
@@ -562,7 +562,7 @@  discard block
 block discarded – undo
562 562
         $formatted = number_format($number, $decimals, $decimal, $thousands);
563 563
 
564 564
         // Remove trailing .0's (e.g. 45.00 -> 45).
565
-        return rtrim($formatted, $decimal . str_repeat('0', $decimals));
565
+        return rtrim($formatted, $decimal.str_repeat('0', $decimals));
566 566
     }
567 567
 
568 568
     public function dateFormat($datetime)
@@ -601,10 +601,10 @@  discard block
 block discarded – undo
601 601
         if (!$denominator) {
602 602
             $quotient = $numerator;
603 603
         } else {
604
-            $quotient = ( $numerator / $denominator ) * 100;
604
+            $quotient = ($numerator / $denominator) * 100;
605 605
         }
606 606
 
607
-        return $this->numberFormat($quotient, $precision) . '%';
607
+        return $this->numberFormat($quotient, $precision).'%';
608 608
     }
609 609
 
610 610
     /**
@@ -679,20 +679,20 @@  discard block
 block discarded – undo
679 679
 
680 680
         if ($seconds >= 86400) {
681 681
             // Over a day
682
-            $val = (int) floor($seconds / 86400);
682
+            $val = (int)floor($seconds / 86400);
683 683
             $key = 'days';
684 684
         } elseif ($seconds >= 3600) {
685 685
             // Over an hour, less than a day
686
-            $val = (int) floor($seconds / 3600);
686
+            $val = (int)floor($seconds / 3600);
687 687
             $key = 'hours';
688 688
         } elseif ($seconds >= 60) {
689 689
             // Over a minute, less than an hour
690
-            $val = (int) floor($seconds / 60);
690
+            $val = (int)floor($seconds / 60);
691 691
             $key = 'minutes';
692 692
         }
693 693
 
694 694
         if ($translate) {
695
-            return $this->numberFormat($val) . ' ' . $this->intuitionMessage("num-$key", [$val]);
695
+            return $this->numberFormat($val).' '.$this->intuitionMessage("num-$key", [$val]);
696 696
         } else {
697 697
             return [$this->numberFormat($val), "num-$key"];
698 698
         }
Please login to merge, or discard this patch.