Completed
Push — master ( 19e79a...e0623f )
by Stefano
02:53
created
classes/Work.php 2 patches
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -21,9 +21,9 @@  discard block
 block discarded – undo
21 21
   protected static $workers;
22 22
   protected static $lastID = 0;
23 23
 
24
-  public static function add($id, $job=null){
25
-    self::$pool or ( self::$pool = new \SplQueue() );
26
-    if(is_callable($id) && $job===null){
24
+  public static function add($id, $job = null) {
25
+    self::$pool or (self::$pool = new \SplQueue());
26
+    if (is_callable($id) && $job === null) {
27 27
       $job = $id;
28 28
       $id = ++self::$lastID;
29 29
     }
@@ -33,12 +33,12 @@  discard block
 block discarded – undo
33 33
     return $task;
34 34
   }
35 35
 
36
-  public static function send($id,$passValue) {
36
+  public static function send($id, $passValue) {
37 37
      isset(self::$workers[$id]) && self::$workers[$id]->pass($passValue);
38 38
   }
39 39
 
40
-  public static function run(){
41
-    self::$pool or ( self::$pool = new \SplQueue() );
40
+  public static function run() {
41
+    self::$pool or (self::$pool = new \SplQueue());
42 42
     while (!self::$pool->isEmpty()) {
43 43
       $task = self::$pool->dequeue();
44 44
       $task->run();
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
    * Defer callback execution after script execution
55 55
    * @param callable $callback The deferred callback
56 56
    */ d
57
-  public static function after(callable $callback){
57
+  public static function after(callable $callback) {
58 58
     static::$inited_shutdown || static::install_shutdown();
59 59
     Event::on('core.shutdown', $callback);
60 60
   }
@@ -62,24 +62,24 @@  discard block
 block discarded – undo
62 62
   /**
63 63
    * Single shot defer handeler install
64 64
    */
65
-  protected static function install_shutdown(){
65
+  protected static function install_shutdown() {
66 66
     if (static::$inited_shutdown) return;
67 67
     
68 68
     // Disable time limit
69 69
     set_time_limit(0);
70 70
     
71 71
     // HHVM support
72
-    if(function_exists('register_postsend_function')){
73
-      register_postsend_function(function(){
72
+    if (function_exists('register_postsend_function')) {
73
+      register_postsend_function(function() {
74 74
         Event::trigger('core.shutdown');
75 75
       });
76
-    } else if(function_exists('fastcgi_finish_request')) {
77
-      register_shutdown_function(function(){
76
+    } else if (function_exists('fastcgi_finish_request')) {
77
+      register_shutdown_function(function() {
78 78
         fastcgi_finish_request();
79 79
         Event::trigger('core.shutdown');
80 80
       });       
81 81
     } else {
82
-      register_shutdown_function(function(){
82
+      register_shutdown_function(function() {
83 83
         Event::trigger('core.shutdown');
84 84
       });
85 85
     }
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
     }
122 122
 
123 123
     public function complete() {
124
-        return ! $this->coroutine->valid();
124
+        return !$this->coroutine->valid();
125 125
     }
126 126
 
127 127
 }
Please login to merge, or discard this patch.
Braces   +12 added lines, -10 removed lines patch added patch discarded remove patch
@@ -21,9 +21,9 @@  discard block
 block discarded – undo
21 21
   protected static $workers;
22 22
   protected static $lastID = 0;
23 23
 
24
-  public static function add($id, $job=null){
24
+  public static function add($id, $job=null) {
25 25
     self::$pool or ( self::$pool = new \SplQueue() );
26
-    if(is_callable($id) && $job===null){
26
+    if(is_callable($id) && $job===null) {
27 27
       $job = $id;
28 28
       $id = ++self::$lastID;
29 29
     }
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
      isset(self::$workers[$id]) && self::$workers[$id]->pass($passValue);
38 38
   }
39 39
 
40
-  public static function run(){
40
+  public static function run() {
41 41
     self::$pool or ( self::$pool = new \SplQueue() );
42 42
     while (!self::$pool->isEmpty()) {
43 43
       $task = self::$pool->dequeue();
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
    * Defer callback execution after script execution
55 55
    * @param callable $callback The deferred callback
56 56
    */ d
57
-  public static function after(callable $callback){
57
+  public static function after(callable $callback) {
58 58
     static::$inited_shutdown || static::install_shutdown();
59 59
     Event::on('core.shutdown', $callback);
60 60
   }
@@ -62,24 +62,26 @@  discard block
 block discarded – undo
62 62
   /**
63 63
    * Single shot defer handeler install
64 64
    */
65
-  protected static function install_shutdown(){
66
-    if (static::$inited_shutdown) return;
65
+  protected static function install_shutdown() {
66
+    if (static::$inited_shutdown) {
67
+      return;
68
+    }
67 69
     
68 70
     // Disable time limit
69 71
     set_time_limit(0);
70 72
     
71 73
     // HHVM support
72
-    if(function_exists('register_postsend_function')){
73
-      register_postsend_function(function(){
74
+    if(function_exists('register_postsend_function')) {
75
+      register_postsend_function(function() {
74 76
         Event::trigger('core.shutdown');
75 77
       });
76 78
     } else if(function_exists('fastcgi_finish_request')) {
77
-      register_shutdown_function(function(){
79
+      register_shutdown_function(function() {
78 80
         fastcgi_finish_request();
79 81
         Event::trigger('core.shutdown');
80 82
       });       
81 83
     } else {
82
-      register_shutdown_function(function(){
84
+      register_shutdown_function(function() {
83 85
         Event::trigger('core.shutdown');
84 86
       });
85 87
     }
Please login to merge, or discard this patch.
classes/Map.php 2 patches
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -29,11 +29,11 @@  discard block
 block discarded – undo
29 29
      * @param  mixed $default (optional) The default value. If is a callable it will executed and the return value will be used.
30 30
      * @return mixed The value of the key or the default (resolved) value if the key not existed.
31 31
      */
32
-    public function get($key, $default=null){
33
-        if ($ptr =& $this->find($key,false)){
32
+    public function get($key, $default = null) {
33
+        if ($ptr = & $this->find($key, false)) {
34 34
             return $ptr;
35 35
         } else {
36
-            if ($default !== null){
36
+            if ($default !== null) {
37 37
                 return $this->set($key, is_callable($default) ? call_user_func($default) : $default);
38 38
             } else {
39 39
                 return null;
@@ -47,11 +47,11 @@  discard block
 block discarded – undo
47 47
      * @param  mixed $value (optional) The value. If is a callable it will executed and the return value will be used.
48 48
      * @return mixed The value of the key or the default (resolved) value if the key not existed.
49 49
      */
50
-    public function set($key, $value=null){
50
+    public function set($key, $value = null) {
51 51
         if (is_array($key)) {
52 52
             return $this->merge($key);
53 53
         } else {
54
-            $ptr =& $this->find($key, true);
54
+            $ptr = & $this->find($key, true);
55 55
             return $ptr = $value;
56 56
         }
57 57
     }
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
      * @param  string $key The key path in dot notation
62 62
      * @param  boolean $compact (optional) Compact map removing empty paths.
63 63
      */
64
-    public function delete($key, $compact=true){
64
+    public function delete($key, $compact = true) {
65 65
         $this->set($key, null);
66 66
         if ($compact) $this->compact();
67 67
     }
@@ -71,18 +71,18 @@  discard block
 block discarded – undo
71 71
      * @param  string $key The key path in dot notation
72 72
      * @return boolean
73 73
      */
74
-    public function exists($key){
74
+    public function exists($key) {
75 75
         return null !== $this->find($key, false);
76 76
     }
77 77
 
78 78
     /**
79 79
      * Clear all key path in map.
80 80
      */
81
-    public function clear(){
81
+    public function clear() {
82 82
         $this->fields = [];
83 83
     }
84 84
 
85
-    public function __construct($fields=null){
85
+    public function __construct($fields = null) {
86 86
         $this->load($fields);
87 87
     }
88 88
 
@@ -90,8 +90,8 @@  discard block
 block discarded – undo
90 90
      * Load an associative array/object as the map source.
91 91
      * @param  string $fields The array to merge
92 92
      */
93
-    public function load($fields){
94
-        if ($fields) $this->fields = (array)$fields;
93
+    public function load($fields) {
94
+        if ($fields) $this->fields = (array) $fields;
95 95
     }
96 96
 
97 97
     /**
@@ -99,17 +99,17 @@  discard block
 block discarded – undo
99 99
      * @param  array   $array The array to merge
100 100
      * @param  boolean $merge_back If `true` merge the map over the $array, if `false` (default) the reverse.
101 101
      */
102
-    public function merge($array, $merge_back=false){
102
+    public function merge($array, $merge_back = false) {
103 103
         $this->fields = $merge_back
104
-            ? array_replace_recursive((array)$array, $this->fields)
105
-            : array_replace_recursive($this->fields, (array)$array);
104
+            ? array_replace_recursive((array) $array, $this->fields)
105
+            : array_replace_recursive($this->fields, (array) $array);
106 106
     }
107 107
 
108 108
     /**
109 109
      * Compact map removing empty paths
110 110
      */
111 111
 
112
-    public function compact(){
112
+    public function compact() {
113 113
 
114 114
         $array_filter_rec = function($input, $callback = null) use (&$array_filter_rec) {
115 115
             foreach ($input as &$value) {
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
             return array_filter($input, $callback);
121 121
         };
122 122
 
123
-        $this->fields = $array_filter_rec($this->fields,function($a){ return $a !== null; });
123
+        $this->fields = $array_filter_rec($this->fields, function($a) { return $a !== null;});
124 124
     }
125 125
 
126 126
     /**
@@ -130,18 +130,18 @@  discard block
 block discarded – undo
130 130
      * @param  callable  If passed this callback will be applied to the founded value.
131 131
      * @return mixed The founded value.
132 132
      */
133
-    public function & find($path, $create=false, callable $operation=null) {
134
-        $tok = strtok($path,'.');
135
-        if ( $create ) {
136
-            $value =& $this->fields;
133
+    public function & find($path, $create = false, callable $operation = null) {
134
+        $tok = strtok($path, '.');
135
+        if ($create) {
136
+            $value = & $this->fields;
137 137
         } else {
138 138
             $value = $this->fields;
139 139
         }
140
-        while ( $tok !== false ){
141
-            $value =& $value[$tok];
140
+        while ($tok !== false) {
141
+            $value = & $value[$tok];
142 142
             $tok = strtok('.');
143 143
         }
144
-        if ( is_callable($operation) ) $operation($value);
144
+        if (is_callable($operation)) $operation($value);
145 145
         return $value;
146 146
     }
147 147
 
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
      *
153 153
      * @return string        The json object
154 154
      */
155
-    public function jsonSerialize(){
155
+    public function jsonSerialize() {
156 156
       return $this->fields;
157 157
     }
158 158
 
Please login to merge, or discard this patch.
Braces   +22 added lines, -16 removed lines patch added patch discarded remove patch
@@ -29,11 +29,11 @@  discard block
 block discarded – undo
29 29
      * @param  mixed $default (optional) The default value. If is a callable it will executed and the return value will be used.
30 30
      * @return mixed The value of the key or the default (resolved) value if the key not existed.
31 31
      */
32
-    public function get($key, $default=null){
33
-        if ($ptr =& $this->find($key,false)){
32
+    public function get($key, $default=null) {
33
+        if ($ptr =& $this->find($key,false)) {
34 34
             return $ptr;
35 35
         } else {
36
-            if ($default !== null){
36
+            if ($default !== null) {
37 37
                 return $this->set($key, is_callable($default) ? call_user_func($default) : $default);
38 38
             } else {
39 39
                 return null;
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
      * @param  mixed $value (optional) The value. If is a callable it will executed and the return value will be used.
48 48
      * @return mixed The value of the key or the default (resolved) value if the key not existed.
49 49
      */
50
-    public function set($key, $value=null){
50
+    public function set($key, $value=null) {
51 51
         if (is_array($key)) {
52 52
             return $this->merge($key);
53 53
         } else {
@@ -61,9 +61,11 @@  discard block
 block discarded – undo
61 61
      * @param  string $key The key path in dot notation
62 62
      * @param  boolean $compact (optional) Compact map removing empty paths.
63 63
      */
64
-    public function delete($key, $compact=true){
64
+    public function delete($key, $compact=true) {
65 65
         $this->set($key, null);
66
-        if ($compact) $this->compact();
66
+        if ($compact) {
67
+          $this->compact();
68
+        }
67 69
     }
68 70
 
69 71
     /**
@@ -71,18 +73,18 @@  discard block
 block discarded – undo
71 73
      * @param  string $key The key path in dot notation
72 74
      * @return boolean
73 75
      */
74
-    public function exists($key){
76
+    public function exists($key) {
75 77
         return null !== $this->find($key, false);
76 78
     }
77 79
 
78 80
     /**
79 81
      * Clear all key path in map.
80 82
      */
81
-    public function clear(){
83
+    public function clear() {
82 84
         $this->fields = [];
83 85
     }
84 86
 
85
-    public function __construct($fields=null){
87
+    public function __construct($fields=null) {
86 88
         $this->load($fields);
87 89
     }
88 90
 
@@ -90,8 +92,10 @@  discard block
 block discarded – undo
90 92
      * Load an associative array/object as the map source.
91 93
      * @param  string $fields The array to merge
92 94
      */
93
-    public function load($fields){
94
-        if ($fields) $this->fields = (array)$fields;
95
+    public function load($fields) {
96
+        if ($fields) {
97
+          $this->fields = (array)$fields;
98
+        }
95 99
     }
96 100
 
97 101
     /**
@@ -99,7 +103,7 @@  discard block
 block discarded – undo
99 103
      * @param  array   $array The array to merge
100 104
      * @param  boolean $merge_back If `true` merge the map over the $array, if `false` (default) the reverse.
101 105
      */
102
-    public function merge($array, $merge_back=false){
106
+    public function merge($array, $merge_back=false) {
103 107
         $this->fields = $merge_back
104 108
             ? array_replace_recursive((array)$array, $this->fields)
105 109
             : array_replace_recursive($this->fields, (array)$array);
@@ -109,7 +113,7 @@  discard block
 block discarded – undo
109 113
      * Compact map removing empty paths
110 114
      */
111 115
 
112
-    public function compact(){
116
+    public function compact() {
113 117
 
114 118
         $array_filter_rec = function($input, $callback = null) use (&$array_filter_rec) {
115 119
             foreach ($input as &$value) {
@@ -137,11 +141,13 @@  discard block
 block discarded – undo
137 141
         } else {
138 142
             $value = $this->fields;
139 143
         }
140
-        while ( $tok !== false ){
144
+        while ( $tok !== false ) {
141 145
             $value =& $value[$tok];
142 146
             $tok = strtok('.');
143 147
         }
144
-        if ( is_callable($operation) ) $operation($value);
148
+        if ( is_callable($operation) ) {
149
+          $operation($value);
150
+        }
145 151
         return $value;
146 152
     }
147 153
 
@@ -152,7 +158,7 @@  discard block
 block discarded – undo
152 158
      *
153 159
      * @return string        The json object
154 160
      */
155
-    public function jsonSerialize(){
161
+    public function jsonSerialize() {
156 162
       return $this->fields;
157 163
     }
158 164
 
Please login to merge, or discard this patch.