@@ -2,7 +2,7 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | namespace VoidEngine; |
| 4 | 4 | |
| 5 | -function err_status (bool $status = null): bool |
|
| 5 | +function err_status(bool $status = null): bool |
|
| 6 | 6 | { |
| 7 | 7 | $oldStatus = $GLOBALS['__debug']['error_status']; |
| 8 | 8 | |
@@ -12,203 +12,203 @@ discard block |
||
| 12 | 12 | return $oldStatus; |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | -function err_no (): bool |
|
| 15 | +function err_no(): bool |
|
| 16 | 16 | { |
| 17 | - return err_status (false); |
|
| 17 | + return err_status(false); |
|
| 18 | 18 | } |
| 19 | 19 | |
| 20 | -function err_yes (): bool |
|
| 20 | +function err_yes(): bool |
|
| 21 | 21 | { |
| 22 | - return err_status (true); |
|
| 22 | + return err_status(true); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | -function run (string $path, ...$args) |
|
| 25 | +function run(string $path, ...$args) |
|
| 26 | 26 | { |
| 27 | - return (new Process)->start ($path, ...$args); |
|
| 27 | + return (new Process)->start($path, ...$args); |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | -function vbs_exec (string $code) |
|
| 30 | +function vbs_exec(string $code) |
|
| 31 | 31 | { |
| 32 | - file_put_contents ($path = getenv ('temp') .'/'. crc32 ($code) .'.vbs', $code); |
|
| 32 | + file_put_contents($path = getenv('temp').'/'.crc32($code).'.vbs', $code); |
|
| 33 | 33 | |
| 34 | - (new \COM ('WScript.Shell'))->Run ($path, 0, true); |
|
| 34 | + (new \COM('WScript.Shell'))->Run($path, 0, true); |
|
| 35 | 35 | |
| 36 | - unlink ($path); |
|
| 36 | + unlink($path); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | -function php_errors_check (string $code): ?array |
|
| 39 | +function php_errors_check(string $code): ?array |
|
| 40 | 40 | { |
| 41 | 41 | try |
| 42 | 42 | { |
| 43 | - eval ('return; '. $code); |
|
| 43 | + eval ('return; '.$code); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | catch (\Throwable $e) |
| 47 | 47 | { |
| 48 | 48 | return [ |
| 49 | - 'text' => $e->getMessage (), |
|
| 50 | - 'line' => $e->getLine () |
|
| 49 | + 'text' => $e->getMessage(), |
|
| 50 | + 'line' => $e->getLine() |
|
| 51 | 51 | ]; |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | return null; |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | -function enum (string $name): array |
|
| 57 | +function enum(string $name): array |
|
| 58 | 58 | { |
| 59 | 59 | return [ |
| 60 | - substr ($name, strrpos ($name, '.') + 1), |
|
| 61 | - ($name = substr ($name, 0, strrpos ($name, '.'))) .', '. substr ($name, 0, strrpos ($name, '.')) |
|
| 60 | + substr($name, strrpos($name, '.') + 1), |
|
| 61 | + ($name = substr($name, 0, strrpos($name, '.'))).', '.substr($name, 0, strrpos($name, '.')) |
|
| 62 | 62 | ]; |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | -function getNetArray (string $type, array $items = []): WFObject |
|
| 65 | +function getNetArray(string $type, array $items = []): WFObject |
|
| 66 | 66 | { |
| 67 | - $array = (new WFClass ('System.Array', null)) |
|
| 68 | - ->createInstance (VoidEngine::objectType ($type), $size = sizeof ($items)); |
|
| 67 | + $array = (new WFClass('System.Array', null)) |
|
| 68 | + ->createInstance(VoidEngine::objectType($type), $size = sizeof($items)); |
|
| 69 | 69 | |
| 70 | 70 | for ($i = 0; $i < $size; ++$i) |
| 71 | - $array[$i] = array_shift ($items); |
|
| 71 | + $array[$i] = array_shift($items); |
|
| 72 | 72 | |
| 73 | 73 | return $array; |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | -function dir_create (string $path, int $mode = 0777): void |
|
| 76 | +function dir_create(string $path, int $mode = 0777): void |
|
| 77 | 77 | { |
| 78 | - if (!is_dir ($path)) |
|
| 79 | - mkdir ($path, $mode, true); |
|
| 78 | + if (!is_dir($path)) |
|
| 79 | + mkdir($path, $mode, true); |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | -function dir_delete (string $path): bool |
|
| 82 | +function dir_delete(string $path): bool |
|
| 83 | 83 | { |
| 84 | - if (!is_dir ($path)) |
|
| 84 | + if (!is_dir($path)) |
|
| 85 | 85 | return false; |
| 86 | 86 | |
| 87 | - foreach (array_slice (scandir ($path), 2) as $file) |
|
| 88 | - if (is_dir ($file = $path .'/'. $file)) |
|
| 87 | + foreach (array_slice(scandir($path), 2) as $file) |
|
| 88 | + if (is_dir($file = $path.'/'.$file)) |
|
| 89 | 89 | { |
| 90 | - dir_delete ($file); |
|
| 90 | + dir_delete($file); |
|
| 91 | 91 | |
| 92 | - if (is_dir ($file)) |
|
| 93 | - rmdir ($file); |
|
| 92 | + if (is_dir($file)) |
|
| 93 | + rmdir($file); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | - else unlink ($file); |
|
| 96 | + else unlink($file); |
|
| 97 | 97 | |
| 98 | - rmdir ($path); |
|
| 98 | + rmdir($path); |
|
| 99 | 99 | |
| 100 | 100 | return true; |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | -function dir_clean (string $path): void |
|
| 103 | +function dir_clean(string $path): void |
|
| 104 | 104 | { |
| 105 | - dir_delete ($path); |
|
| 106 | - dir_create ($path); |
|
| 105 | + dir_delete($path); |
|
| 106 | + dir_create($path); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | -function dir_copy (string $from, string $to): bool |
|
| 109 | +function dir_copy(string $from, string $to): bool |
|
| 110 | 110 | { |
| 111 | - if (!is_dir ($from)) |
|
| 111 | + if (!is_dir($from)) |
|
| 112 | 112 | return false; |
| 113 | 113 | |
| 114 | - if (!is_dir ($to)) |
|
| 115 | - dir_create ($to); |
|
| 114 | + if (!is_dir($to)) |
|
| 115 | + dir_create($to); |
|
| 116 | 116 | |
| 117 | - foreach (array_slice (scandir ($from), 2) as $file) |
|
| 118 | - if (is_dir ($f = $from .'/'. $file)) |
|
| 119 | - dir_copy ($f, $to .'/'. $file); |
|
| 117 | + foreach (array_slice(scandir($from), 2) as $file) |
|
| 118 | + if (is_dir($f = $from.'/'.$file)) |
|
| 119 | + dir_copy($f, $to.'/'.$file); |
|
| 120 | 120 | |
| 121 | - else copy ($f, $to .'/'. $file); |
|
| 121 | + else copy($f, $to.'/'.$file); |
|
| 122 | 122 | |
| 123 | 123 | return true; |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | -function getARGBColor (string $color) |
|
| 126 | +function getARGBColor(string $color) |
|
| 127 | 127 | { |
| 128 | - return (new WFClass ('System.Drawing.ColorTranslator'))->fromHtml ($color); |
|
| 128 | + return (new WFClass('System.Drawing.ColorTranslator'))->fromHtml($color); |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | -function replaceSl (string $string): string |
|
| 131 | +function replaceSl(string $string): string |
|
| 132 | 132 | { |
| 133 | - return str_replace ('\\', '/', $string); |
|
| 133 | + return str_replace('\\', '/', $string); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | -function replaceSr (string $string): string |
|
| 136 | +function replaceSr(string $string): string |
|
| 137 | 137 | { |
| 138 | - return str_replace ('/', '\\', $string); |
|
| 138 | + return str_replace('/', '\\', $string); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | -function basenameNoExt (string $path): string |
|
| 141 | +function basenameNoExt(string $path): string |
|
| 142 | 142 | { |
| 143 | - return pathinfo ($path, PATHINFO_FILENAME); |
|
| 143 | + return pathinfo($path, PATHINFO_FILENAME); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | -function file_ext (string $path): string |
|
| 146 | +function file_ext(string $path): string |
|
| 147 | 147 | { |
| 148 | - return strtolower (pathinfo ($path, PATHINFO_EXTENSION)); |
|
| 148 | + return strtolower(pathinfo($path, PATHINFO_EXTENSION)); |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | -function filepathNoExt (string $path): string |
|
| 151 | +function filepathNoExt(string $path): string |
|
| 152 | 152 | { |
| 153 | - return dirname ($path) .'/'. basenameNoExt ($path); |
|
| 153 | + return dirname($path).'/'.basenameNoExt($path); |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | -function array_first (array $array) |
|
| 156 | +function array_first(array $array) |
|
| 157 | 157 | { |
| 158 | - return array_shift ($array); |
|
| 158 | + return array_shift($array); |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | -function array_end (array $array) |
|
| 161 | +function array_end(array $array) |
|
| 162 | 162 | { |
| 163 | - return array_pop ($array); |
|
| 163 | + return array_pop($array); |
|
| 164 | 164 | } |
| 165 | 165 | |
| 166 | -function substr_icount (string $haystack, string $needle, ...$params): int |
|
| 166 | +function substr_icount(string $haystack, string $needle, ...$params): int |
|
| 167 | 167 | { |
| 168 | - return substr_count (strtolower ($haystack), strtolower ($needle), ...$params); |
|
| 168 | + return substr_count(strtolower($haystack), strtolower($needle), ...$params); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | -function str_replace_assoc (string $subject, array $replacements): string |
|
| 171 | +function str_replace_assoc(string $subject, array $replacements): string |
|
| 172 | 172 | { |
| 173 | - return str_replace (array_keys ($replacements), array_values ($replacements), $subject); |
|
| 173 | + return str_replace(array_keys($replacements), array_values($replacements), $subject); |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | -function pre (...$args): void |
|
| 176 | +function pre(...$args): void |
|
| 177 | 177 | { |
| 178 | - message (sizeof ($args) < 2 ? current ($args) : $args); |
|
| 178 | + message(sizeof($args) < 2 ? current ($args) : $args); |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | -function messageBox (string $message, string $caption = '', ...$args) |
|
| 181 | +function messageBox(string $message, string $caption = '', ...$args) |
|
| 182 | 182 | { |
| 183 | - return (new MessageBox)->show ($message, $caption, ...$args); |
|
| 183 | + return (new MessageBox)->show($message, $caption, ...$args); |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | class Components |
| 187 | 187 | { |
| 188 | 188 | static array $components = []; |
| 189 | 189 | |
| 190 | - public static function addComponent (int $selector, object $object): void |
|
| 190 | + public static function addComponent(int $selector, object $object): void |
|
| 191 | 191 | { |
| 192 | 192 | self::$components[$selector] = $object; |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | - public static function getComponent (int $selector) |
|
| 195 | + public static function getComponent(int $selector) |
|
| 196 | 196 | { |
| 197 | 197 | return isset (self::$components[$selector]) ? |
| 198 | 198 | self::$components[$selector] : false; |
| 199 | 199 | } |
| 200 | 200 | |
| 201 | - public static function componentExists (int $selector): bool |
|
| 201 | + public static function componentExists(int $selector): bool |
|
| 202 | 202 | { |
| 203 | 203 | return isset (self::$components[$selector]); |
| 204 | 204 | } |
| 205 | 205 | |
| 206 | - public static function removeComponent (int $selector): void |
|
| 206 | + public static function removeComponent(int $selector): void |
|
| 207 | 207 | { |
| 208 | 208 | unset (self::$components[$selector]); |
| 209 | 209 | } |
| 210 | 210 | |
| 211 | - public static function cleanJunk (): void |
|
| 211 | + public static function cleanJunk(): void |
|
| 212 | 212 | { |
| 213 | 213 | // TODO: более строгие правила очистки мусорных объектов |
| 214 | 214 | |
@@ -216,46 +216,46 @@ discard block |
||
| 216 | 216 | { |
| 217 | 217 | try |
| 218 | 218 | { |
| 219 | - if ($object->getType ()->isSubclassOf (VoidEngine::objectType ('System.Windows.Forms.Form', 'System.Windows.Forms'))) |
|
| 219 | + if ($object->getType()->isSubclassOf(VoidEngine::objectType('System.Windows.Forms.Form', 'System.Windows.Forms'))) |
|
| 220 | 220 | continue; |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | catch (\Exception $e) {} |
| 224 | 224 | |
| 225 | - VoidEngine::destructObject ($selector); |
|
| 225 | + VoidEngine::destructObject($selector); |
|
| 226 | 226 | |
| 227 | - if (!VoidEngine::objectExists ($selector)) |
|
| 227 | + if (!VoidEngine::objectExists($selector)) |
|
| 228 | 228 | unset (self::$components[$selector]); |
| 229 | 229 | } |
| 230 | 230 | } |
| 231 | 231 | } |
| 232 | 232 | |
| 233 | -function _c (int $selector) |
|
| 233 | +function _c(int $selector) |
|
| 234 | 234 | { |
| 235 | - return Components::getComponent ($selector); |
|
| 235 | + return Components::getComponent($selector); |
|
| 236 | 236 | } |
| 237 | 237 | |
| 238 | -function c ($name, bool $returnAllSimilarObjects = false) |
|
| 238 | +function c($name, bool $returnAllSimilarObjects = false) |
|
| 239 | 239 | { |
| 240 | - if (is_int ($name) && is_object ($object = _c ($name))) |
|
| 240 | + if (is_int($name) && is_object($object = _c($name))) |
|
| 241 | 241 | return $object; |
| 242 | 242 | |
| 243 | 243 | else |
| 244 | 244 | { |
| 245 | - $path = explode ('->', $name); |
|
| 245 | + $path = explode('->', $name); |
|
| 246 | 246 | $similar = []; |
| 247 | 247 | |
| 248 | 248 | foreach (Components::$components as $object) |
| 249 | 249 | try |
| 250 | 250 | { |
| 251 | - if ($object->name == end ($path)) |
|
| 251 | + if ($object->name == end($path)) |
|
| 252 | 252 | { |
| 253 | - if (sizeof ($path) > 1) |
|
| 253 | + if (sizeof($path) > 1) |
|
| 254 | 254 | try |
| 255 | 255 | { |
| 256 | - if (is_object ($parent = _c($object->parent->selector))) |
|
| 256 | + if (is_object($parent = _c($object->parent->selector))) |
|
| 257 | 257 | { |
| 258 | - if (c(join ('->', array_slice ($path, 0, -1))) == $parent) |
|
| 258 | + if (c(join('->', array_slice($path, 0, -1))) == $parent) |
|
| 259 | 259 | { |
| 260 | 260 | if ($returnAllSimilarObjects) |
| 261 | 261 | $similar[] = $object; |
@@ -289,18 +289,18 @@ discard block |
||
| 289 | 289 | continue; |
| 290 | 290 | } |
| 291 | 291 | |
| 292 | - if (sizeof ($path) == 2) |
|
| 292 | + if (sizeof($path) == 2) |
|
| 293 | 293 | { |
| 294 | 294 | $objects = c($path[1], true); |
| 295 | 295 | |
| 296 | - if (is_array ($objects)) |
|
| 296 | + if (is_array($objects)) |
|
| 297 | 297 | { |
| 298 | 298 | foreach ($objects as $id => $object) |
| 299 | 299 | try |
| 300 | 300 | { |
| 301 | - while (is_object ($parent = _c($object->parent->selector))) |
|
| 301 | + while (is_object($parent = _c($object->parent->selector))) |
|
| 302 | 302 | { |
| 303 | - if ($parent->getType ()->isSubclassOf (VoidEngine::objectType ('System.Windows.Forms.Form', 'System.Windows.Forms')) && $parent->name == $path[0]) |
|
| 303 | + if ($parent->getType()->isSubclassOf(VoidEngine::objectType('System.Windows.Forms.Form', 'System.Windows.Forms')) && $parent->name == $path[0]) |
|
| 304 | 304 | return $objects[$id]; |
| 305 | 305 | |
| 306 | 306 | else $object = $parent; |
@@ -318,70 +318,70 @@ discard block |
||
| 318 | 318 | else return false; |
| 319 | 319 | } |
| 320 | 320 | |
| 321 | - else return $returnAllSimilarObjects && sizeof ($similar) > 0 ? |
|
| 321 | + else return $returnAllSimilarObjects && sizeof($similar) > 0 ? |
|
| 322 | 322 | $similar : false; |
| 323 | 323 | } |
| 324 | 324 | } |
| 325 | 325 | |
| 326 | -function setTimer (int $interval, callable $function): Timer |
|
| 326 | +function setTimer(int $interval, callable $function): Timer |
|
| 327 | 327 | { |
| 328 | 328 | $timer = new Timer; |
| 329 | 329 | $timer->interval = $interval; |
| 330 | 330 | |
| 331 | - $timer->tickEvent = function ($self) use ($function) |
|
| 331 | + $timer->tickEvent = function($self) use ($function) |
|
| 332 | 332 | { |
| 333 | - call_user_func ($function, $self); |
|
| 333 | + call_user_func($function, $self); |
|
| 334 | 334 | }; |
| 335 | 335 | |
| 336 | - $timer->start (); |
|
| 336 | + $timer->start(); |
|
| 337 | 337 | |
| 338 | 338 | return $timer; |
| 339 | 339 | } |
| 340 | 340 | |
| 341 | 341 | // FIXME: выполняется несколько раз, а не единожды |
| 342 | -function setTimeout (int $timeout, callable $function): Timer |
|
| 342 | +function setTimeout(int $timeout, callable $function): Timer |
|
| 343 | 343 | { |
| 344 | 344 | $timer = new Timer; |
| 345 | 345 | $timer->interval = $timeout; |
| 346 | 346 | |
| 347 | - $timer->tickEvent = function ($self) use ($function) |
|
| 347 | + $timer->tickEvent = function($self) use ($function) |
|
| 348 | 348 | { |
| 349 | - call_user_func ($function, $self); |
|
| 349 | + call_user_func($function, $self); |
|
| 350 | 350 | |
| 351 | - $self->stop (); |
|
| 351 | + $self->stop(); |
|
| 352 | 352 | }; |
| 353 | 353 | |
| 354 | - $timer->start (); |
|
| 354 | + $timer->start(); |
|
| 355 | 355 | |
| 356 | 356 | return $timer; |
| 357 | 357 | } |
| 358 | 358 | |
| 359 | 359 | class Clipboard |
| 360 | 360 | { |
| 361 | - public static function getText () |
|
| 361 | + public static function getText() |
|
| 362 | 362 | { |
| 363 | - return (new WFClass ('System.Windows.Forms.Clipboard'))->getText (); |
|
| 363 | + return (new WFClass('System.Windows.Forms.Clipboard'))->getText(); |
|
| 364 | 364 | } |
| 365 | 365 | |
| 366 | - public static function setText (string $text): void |
|
| 366 | + public static function setText(string $text): void |
|
| 367 | 367 | { |
| 368 | - (new WFClass ('System.Windows.Forms.Clipboard'))->setText ($text); |
|
| 368 | + (new WFClass('System.Windows.Forms.Clipboard'))->setText($text); |
|
| 369 | 369 | } |
| 370 | 370 | |
| 371 | - public static function getFiles (): array |
|
| 371 | + public static function getFiles(): array |
|
| 372 | 372 | { |
| 373 | - return (new WFClass ('System.Windows.Forms.Clipboard'))->getFileDropList ()->list; |
|
| 373 | + return (new WFClass('System.Windows.Forms.Clipboard'))->getFileDropList()->list; |
|
| 374 | 374 | } |
| 375 | 375 | |
| 376 | - public static function setFiles (array $files): void |
|
| 376 | + public static function setFiles(array $files): void |
|
| 377 | 377 | { |
| 378 | - $collection = new WFObject ('System.Collections.Specialized.StringCollection'); |
|
| 378 | + $collection = new WFObject('System.Collections.Specialized.StringCollection'); |
|
| 379 | 379 | |
| 380 | 380 | foreach ($files as $file) |
| 381 | - $collection->add ((string) $file); |
|
| 381 | + $collection->add((string) $file); |
|
| 382 | 382 | |
| 383 | - (new WFClass ('System.Windows.Forms.Clipboard'))->setFileDropList ($collection); |
|
| 384 | - VoidEngine::removeObjects ($collection->selector); |
|
| 383 | + (new WFClass('System.Windows.Forms.Clipboard'))->setFileDropList($collection); |
|
| 384 | + VoidEngine::removeObjects($collection->selector); |
|
| 385 | 385 | } |
| 386 | 386 | } |
| 387 | 387 | |
@@ -389,14 +389,13 @@ discard block |
||
| 389 | 389 | { |
| 390 | 390 | protected $cursor; |
| 391 | 391 | |
| 392 | - public function __construct (int $handle = null) |
|
| 392 | + public function __construct(int $handle = null) |
|
| 393 | 393 | { |
| 394 | 394 | $handle !== null ? |
| 395 | - $this->cursor = new WFObject ('System.Windows.Forms.Cursor', 'auto', $handle) : |
|
| 396 | - $this->cursor = new WFClass ('System.Windows.Forms.Cursor'); |
|
| 395 | + $this->cursor = new WFObject('System.Windows.Forms.Cursor', 'auto', $handle) : $this->cursor = new WFClass('System.Windows.Forms.Cursor'); |
|
| 397 | 396 | } |
| 398 | 397 | |
| 399 | - public function getPosition (): array |
|
| 398 | + public function getPosition(): array |
|
| 400 | 399 | { |
| 401 | 400 | $pos = $this->cursor->position; |
| 402 | 401 | |
@@ -407,22 +406,22 @@ discard block |
||
| 407 | 406 | } |
| 408 | 407 | } |
| 409 | 408 | |
| 410 | -function get_cursor_x (int $handle = null): int |
|
| 409 | +function get_cursor_x(int $handle = null): int |
|
| 411 | 410 | { |
| 412 | - return (new Cursor ($handle))->getPosition ()[0]; |
|
| 411 | + return (new Cursor($handle))->getPosition()[0]; |
|
| 413 | 412 | } |
| 414 | 413 | |
| 415 | -function get_cursor_y (int $handle = null): int |
|
| 414 | +function get_cursor_y(int $handle = null): int |
|
| 416 | 415 | { |
| 417 | - return (new Cursor ($handle))->getPosition ()[1]; |
|
| 416 | + return (new Cursor($handle))->getPosition()[1]; |
|
| 418 | 417 | } |
| 419 | 418 | |
| 420 | -function get_cursor_pos (int $handle = null): array |
|
| 419 | +function get_cursor_pos(int $handle = null): array |
|
| 421 | 420 | { |
| 422 | - return (new Cursor ($handle))->getPosition (); |
|
| 421 | + return (new Cursor($handle))->getPosition(); |
|
| 423 | 422 | } |
| 424 | 423 | |
| 425 | -set_error_handler (function ($no, $str, $file, $line) |
|
| 424 | +set_error_handler(function($no, $str, $file, $line) |
|
| 426 | 425 | { |
| 427 | 426 | // Мог ли я здесь сделать более адекватный код с использованием pow/sqrt? Да, мог |
| 428 | 427 | // Почему не сделал? Скорость важнее |
@@ -445,7 +444,7 @@ discard block |
||
| 445 | 444 | ]; |
| 446 | 445 | |
| 447 | 446 | if ($GLOBALS['__debug']['error_status']) |
| 448 | - message ([ |
|
| 447 | + message([ |
|
| 449 | 448 | 'type' => $errarr[$no], |
| 450 | 449 | 'text' => $str, |
| 451 | 450 | 'file' => $file, |
@@ -6,8 +6,9 @@ discard block |
||
| 6 | 6 | { |
| 7 | 7 | $oldStatus = $GLOBALS['__debug']['error_status']; |
| 8 | 8 | |
| 9 | - if ($status !== null) |
|
| 10 | - $GLOBALS['__debug']['error_status'] = $status; |
|
| 9 | + if ($status !== null) { |
|
| 10 | + $GLOBALS['__debug']['error_status'] = $status; |
|
| 11 | + } |
|
| 11 | 12 | |
| 12 | 13 | return $oldStatus; |
| 13 | 14 | } |
@@ -41,9 +42,7 @@ discard block |
||
| 41 | 42 | try |
| 42 | 43 | { |
| 43 | 44 | eval ('return; '. $code); |
| 44 | - } |
|
| 45 | - |
|
| 46 | - catch (\Throwable $e) |
|
| 45 | + } catch (\Throwable $e) |
|
| 47 | 46 | { |
| 48 | 47 | return [ |
| 49 | 48 | 'text' => $e->getMessage (), |
@@ -67,34 +66,39 @@ discard block |
||
| 67 | 66 | $array = (new WFClass ('System.Array', null)) |
| 68 | 67 | ->createInstance (VoidEngine::objectType ($type), $size = sizeof ($items)); |
| 69 | 68 | |
| 70 | - for ($i = 0; $i < $size; ++$i) |
|
| 71 | - $array[$i] = array_shift ($items); |
|
| 69 | + for ($i = 0; $i < $size; ++$i) { |
|
| 70 | + $array[$i] = array_shift ($items); |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | 73 | return $array; |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | function dir_create (string $path, int $mode = 0777): void |
| 77 | 77 | { |
| 78 | - if (!is_dir ($path)) |
|
| 79 | - mkdir ($path, $mode, true); |
|
| 80 | -} |
|
| 78 | + if (!is_dir ($path)) { |
|
| 79 | + mkdir ($path, $mode, true); |
|
| 80 | + } |
|
| 81 | + } |
|
| 81 | 82 | |
| 82 | 83 | function dir_delete (string $path): bool |
| 83 | 84 | { |
| 84 | - if (!is_dir ($path)) |
|
| 85 | - return false; |
|
| 85 | + if (!is_dir ($path)) { |
|
| 86 | + return false; |
|
| 87 | + } |
|
| 86 | 88 | |
| 87 | - foreach (array_slice (scandir ($path), 2) as $file) |
|
| 88 | - if (is_dir ($file = $path .'/'. $file)) |
|
| 89 | + foreach (array_slice (scandir ($path), 2) as $file) { |
|
| 90 | + if (is_dir ($file = $path .'/'. $file)) |
|
| 89 | 91 | { |
| 90 | 92 | dir_delete ($file); |
| 93 | + } |
|
| 91 | 94 | |
| 92 | - if (is_dir ($file)) |
|
| 93 | - rmdir ($file); |
|
| 95 | + if (is_dir ($file)) { |
|
| 96 | + rmdir ($file); |
|
| 97 | + } |
|
| 98 | + } else { |
|
| 99 | + unlink ($file); |
|
| 94 | 100 | } |
| 95 | 101 | |
| 96 | - else unlink ($file); |
|
| 97 | - |
|
| 98 | 102 | rmdir ($path); |
| 99 | 103 | |
| 100 | 104 | return true; |
@@ -108,17 +112,22 @@ discard block |
||
| 108 | 112 | |
| 109 | 113 | function dir_copy (string $from, string $to): bool |
| 110 | 114 | { |
| 111 | - if (!is_dir ($from)) |
|
| 112 | - return false; |
|
| 115 | + if (!is_dir ($from)) { |
|
| 116 | + return false; |
|
| 117 | + } |
|
| 113 | 118 | |
| 114 | - if (!is_dir ($to)) |
|
| 115 | - dir_create ($to); |
|
| 119 | + if (!is_dir ($to)) { |
|
| 120 | + dir_create ($to); |
|
| 121 | + } |
|
| 116 | 122 | |
| 117 | - foreach (array_slice (scandir ($from), 2) as $file) |
|
| 118 | - if (is_dir ($f = $from .'/'. $file)) |
|
| 123 | + foreach (array_slice (scandir ($from), 2) as $file) { |
|
| 124 | + if (is_dir ($f = $from .'/'. $file)) |
|
| 119 | 125 | dir_copy ($f, $to .'/'. $file); |
| 126 | + } |
|
| 120 | 127 | |
| 121 | - else copy ($f, $to .'/'. $file); |
|
| 128 | + else { |
|
| 129 | + copy ($f, $to .'/'. $file); |
|
| 130 | + } |
|
| 122 | 131 | |
| 123 | 132 | return true; |
| 124 | 133 | } |
@@ -216,16 +225,16 @@ discard block |
||
| 216 | 225 | { |
| 217 | 226 | try |
| 218 | 227 | { |
| 219 | - if ($object->getType ()->isSubclassOf (VoidEngine::objectType ('System.Windows.Forms.Form', 'System.Windows.Forms'))) |
|
| 220 | - continue; |
|
| 221 | - } |
|
| 222 | - |
|
| 223 | - catch (\Exception $e) {} |
|
| 228 | + if ($object->getType ()->isSubclassOf (VoidEngine::objectType ('System.Windows.Forms.Form', 'System.Windows.Forms'))) { |
|
| 229 | + continue; |
|
| 230 | + } |
|
| 231 | + } catch (\Exception $e) {} |
|
| 224 | 232 | |
| 225 | 233 | VoidEngine::destructObject ($selector); |
| 226 | 234 | |
| 227 | - if (!VoidEngine::objectExists ($selector)) |
|
| 228 | - unset (self::$components[$selector]); |
|
| 235 | + if (!VoidEngine::objectExists ($selector)) { |
|
| 236 | + unset (self::$components[$selector]); |
|
| 237 | + } |
|
| 229 | 238 | } |
| 230 | 239 | } |
| 231 | 240 | } |
@@ -237,16 +246,15 @@ discard block |
||
| 237 | 246 | |
| 238 | 247 | function c ($name, bool $returnAllSimilarObjects = false) |
| 239 | 248 | { |
| 240 | - if (is_int ($name) && is_object ($object = _c ($name))) |
|
| 241 | - return $object; |
|
| 242 | - |
|
| 243 | - else |
|
| 249 | + if (is_int ($name) && is_object ($object = _c ($name))) { |
|
| 250 | + return $object; |
|
| 251 | + } else |
|
| 244 | 252 | { |
| 245 | 253 | $path = explode ('->', $name); |
| 246 | 254 | $similar = []; |
| 247 | 255 | |
| 248 | - foreach (Components::$components as $object) |
|
| 249 | - try |
|
| 256 | + foreach (Components::$components as $object) { |
|
| 257 | + try |
|
| 250 | 258 | { |
| 251 | 259 | if ($object->name == end ($path)) |
| 252 | 260 | { |
@@ -259,32 +267,30 @@ discard block |
||
| 259 | 267 | { |
| 260 | 268 | if ($returnAllSimilarObjects) |
| 261 | 269 | $similar[] = $object; |
| 270 | + } |
|
| 262 | 271 | |
| 263 | - else return $object; |
|
| 272 | + else { |
|
| 273 | + return $object; |
|
| 274 | + } |
|
| 275 | + } else { |
|
| 276 | + continue; |
|
| 264 | 277 | } |
| 265 | - |
|
| 266 | - else continue; |
|
| 278 | + } else { |
|
| 279 | + continue; |
|
| 267 | 280 | } |
| 268 | - |
|
| 269 | - else continue; |
|
| 270 | - } |
|
| 271 | - |
|
| 272 | - catch (\Throwable $e) |
|
| 281 | + } catch (\Throwable $e) |
|
| 273 | 282 | { |
| 274 | 283 | continue; |
| 275 | - } |
|
| 276 | - |
|
| 277 | - else |
|
| 284 | + } else |
|
| 278 | 285 | { |
| 279 | - if ($returnAllSimilarObjects) |
|
| 280 | - $similar[] = $object; |
|
| 281 | - |
|
| 282 | - else return $object; |
|
| 286 | + if ($returnAllSimilarObjects) { |
|
| 287 | + $similar[] = $object; |
|
| 288 | + } else { |
|
| 289 | + return $object; |
|
| 290 | + } |
|
| 283 | 291 | } |
| 284 | 292 | } |
| 285 | - } |
|
| 286 | - |
|
| 287 | - catch (\Exception $e) |
|
| 293 | + } catch (\Exception $e) |
|
| 288 | 294 | { |
| 289 | 295 | continue; |
| 290 | 296 | } |
@@ -295,31 +301,32 @@ discard block |
||
| 295 | 301 | |
| 296 | 302 | if (is_array ($objects)) |
| 297 | 303 | { |
| 298 | - foreach ($objects as $id => $object) |
|
| 299 | - try |
|
| 304 | + foreach ($objects as $id => $object) { |
|
| 305 | + try |
|
| 300 | 306 | { |
| 301 | 307 | while (is_object ($parent = _c($object->parent->selector))) |
| 302 | 308 | { |
| 303 | 309 | if ($parent->getType ()->isSubclassOf (VoidEngine::objectType ('System.Windows.Forms.Form', 'System.Windows.Forms')) && $parent->name == $path[0]) |
| 304 | 310 | return $objects[$id]; |
| 311 | + } |
|
| 305 | 312 | |
| 306 | - else $object = $parent; |
|
| 313 | + else { |
|
| 314 | + $object = $parent; |
|
| 315 | + } |
|
| 307 | 316 | } |
| 308 | - } |
|
| 309 | - |
|
| 310 | - catch (\Throwable $e) |
|
| 317 | + } catch (\Throwable $e) |
|
| 311 | 318 | { |
| 312 | 319 | continue; |
| 313 | 320 | } |
| 314 | 321 | |
| 315 | 322 | return false; |
| 323 | + } else { |
|
| 324 | + return false; |
|
| 316 | 325 | } |
| 317 | - |
|
| 318 | - else return false; |
|
| 319 | - } |
|
| 320 | - |
|
| 321 | - else return $returnAllSimilarObjects && sizeof ($similar) > 0 ? |
|
| 326 | + } else { |
|
| 327 | + return $returnAllSimilarObjects && sizeof ($similar) > 0 ? |
|
| 322 | 328 | $similar : false; |
| 329 | + } |
|
| 323 | 330 | } |
| 324 | 331 | } |
| 325 | 332 | |
@@ -377,8 +384,9 @@ discard block |
||
| 377 | 384 | { |
| 378 | 385 | $collection = new WFObject ('System.Collections.Specialized.StringCollection'); |
| 379 | 386 | |
| 380 | - foreach ($files as $file) |
|
| 381 | - $collection->add ((string) $file); |
|
| 387 | + foreach ($files as $file) { |
|
| 388 | + $collection->add ((string) $file); |
|
| 389 | + } |
|
| 382 | 390 | |
| 383 | 391 | (new WFClass ('System.Windows.Forms.Clipboard'))->setFileDropList ($collection); |
| 384 | 392 | VoidEngine::removeObjects ($collection->selector); |
@@ -444,11 +452,12 @@ discard block |
||
| 444 | 452 | 16384 => 'E_USER_DEPRECATED' |
| 445 | 453 | ]; |
| 446 | 454 | |
| 447 | - if ($GLOBALS['__debug']['error_status']) |
|
| 448 | - message ([ |
|
| 455 | + if ($GLOBALS['__debug']['error_status']) { |
|
| 456 | + message ([ |
|
| 449 | 457 | 'type' => $errarr[$no], |
| 450 | 458 | 'text' => $str, |
| 451 | 459 | 'file' => $file, |
| 452 | 460 | 'line' => $line |
| 453 | 461 | ], 'PHP Script Error'); |
| 454 | -}); |
|
| 462 | + } |
|
| 463 | + }); |
|
@@ -36,10 +36,10 @@ discard block |
||
| 36 | 36 | const ENGINE_VERSION = '3.5.3 build-2019/09/13'; |
| 37 | 37 | const ENGINE_DIR = __DIR__; |
| 38 | 38 | |
| 39 | -chdir (ENGINE_DIR); |
|
| 39 | +chdir(ENGINE_DIR); |
|
| 40 | 40 | |
| 41 | 41 | $GLOBALS['__debug'] = [ |
| 42 | - 'start_time' => microtime (true), |
|
| 42 | + 'start_time' => microtime(true), |
|
| 43 | 43 | 'error_status' => true |
| 44 | 44 | ]; |
| 45 | 45 | |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | require 'common/Others.php'; |
| 50 | 50 | require 'common/Events.php'; |
| 51 | 51 | |
| 52 | -define ('VoidEngine\CORE_VERSION', $APPLICATION->productVersion); |
|
| 52 | +define('VoidEngine\CORE_VERSION', $APPLICATION->productVersion); |
|
| 53 | 53 | |
| 54 | 54 | require 'components/Component.php'; |
| 55 | 55 | require 'components/Control.php'; |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | require 'components/FastColoredTextBox.php'; |
| 99 | 99 | require 'components/Scintilla.php'; |
| 100 | 100 | |
| 101 | -if (is_dir ('extensions')) |
|
| 102 | - foreach (scandir ('extensions') as $ext) |
|
| 103 | - if (is_dir ('extensions/'. $ext) && file_exists ($ext = 'extensions/'. $ext .'/main.php')) |
|
| 101 | +if (is_dir('extensions')) |
|
| 102 | + foreach (scandir('extensions') as $ext) |
|
| 103 | + if (is_dir('extensions/'.$ext) && file_exists($ext = 'extensions/'.$ext.'/main.php')) |
|
| 104 | 104 | require $ext; |