Changeset 1074021
- Timestamp:
- 01/23/2015 12:05:13 PM (11 years ago)
- File:
-
- 1 edited
-
enzymes/trunk/src/Enzymes3.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
enzymes/trunk/src/Enzymes3.php
r1073979 r1074021 368 368 // We are shutting down, so $error is really the last (fatal) error. 369 369 $error = error_get_last(); 370 echo "\n"; 371 $this->console_log($this->decorate(__('ENZYMES FATAL ERROR'), 372 sprintf(__('Fatal error: %1$s on line %2$s'), $error['message'], $error['line']))); 373 echo "\n"; 370 $this->console_log($this->decorate(__('ENZYMES SHUTDOWN ERROR'), 371 sprintf(__('%1$s: %2$s on line %3$s.'), Ando_ErrorFactory::to_str($error['type']), $error['message'], $error['line']))); 374 372 } 375 373 … … 390 388 $this->last_eval_error = compact('type', 'message', 'file', 'line', 'context'); 391 389 return true; // True to consider the error handled and suppress bubbling. 392 }393 394 /**395 * Check the syntax of a code snippet.396 *397 * @param $code398 *399 * @return mixed|null|string400 */401 protected402 function php_lint( $code )403 {404 $result = null;405 if ( ! function_exists('shell_exec') ) {406 return $result;407 }408 $temp = tmpfile();409 $meta = stream_get_meta_data($temp);410 $filename = $meta['uri'];411 fwrite($temp, "<?php $code");412 $result = shell_exec("php -n -l $filename"); // -n = no ini, -l = only lint413 fclose($temp);414 415 $result = trim($result);416 $result = str_replace("in $filename on", 'on', $result);417 $result = str_replace("\nErrors parsing $filename", '', $result);418 return $result;419 390 } 420 391 … … 441 412 // ------------------------------------------------------------------------------------------------------------- 442 413 try { 443 $result = @eval($code);414 $result = eval($code); 444 415 $error = $this->last_eval_error; 445 416 } catch ( Exception $e ) { … … 456 427 if ( false === $result ) { 457 428 if ( ! $error instanceof Exception ) { 458 $error = $this->php_lint($code);429 $error = true; // Assume error info is into $output. 459 430 } 460 431 } 461 // Not ice that error can be null, array, string, or an Exception descendant.432 // Note that $error can be true, array, or exception. 462 433 return array($result, $error, $output); 463 434 }
Note: See TracChangeset
for help on using the changeset viewer.