JFIF    $         d d  7    * Z qn )ZP 0   !1 A "#a$2Qr   D8 a Ri [f  \m I ykI w0 c u F c Rı?lO7 к _f˓ [C $殷WF< _W ԣ s Kc ëI zyQy /_LK ℂ ;C",p F A : /] =H  ~ , l s / 9  ć: [=/#f ; ) x { ٛE Q )~     = 𘙲r*2~  a _V = '  ku m F  D } KYYC )( { * g& f `툪 r y ` = ^ c J. I ]( * `wq  1dđ #̩ ͑ 0  ; H ] u 搂 @:~ ו K L  N s h } O I R* 8 :2 ! lD JV o (  3 = M ( z Ȱ+i *N A  r6K n S l ) ! J J Ӂ* %  ݉?|D } d5: eP0 R; {$X' x F @ .ÊB {,WJ uQ ɲRI ;9 Q E琯 6 2fT .DU J ;*c  P A\IL Nj! J ۱+ O\ ͔ ] ޒ S߼ J ȧ c%A N ol  ՎprU L Zԛe r E2= X D Xg VQeӓ k y P7 U* o m Q I s ,K `) 6\G3t?pgjr m ۛجw luGt f  h 9uyP 0D;Uڽ"OXl i f $ ) &|ML 0 Z rm1 [ H XP l P R0  'G=i 2N +0 e 2 ]] 9 VT P  O׮ 7 h(F * 癈 ' = Q VZD F,d ߬ ~ T X G[ `le 69C R(!S2! P  < 0 x <     !1AQ "Raq 02Br #S CTb  ? Ζ "]mH5WR 7 k.ۛ ! } Q~ + yԏ z |@ T20 S~ K e k *zF f^2X *( @ 8 r ? C I uI|֓>^Ex LgNU Y+{.R Ѫ τV׸ YT D I 6 2 '8Y2  7'\T P.6 d &˦ @V q i  |8 -O Ε  ] ʔ U=   T L 8= ;6c |  !qfF3 a ů& ~$ l} 'NW U s$U k^S V : U# 6w +  +s &r+n ڐ   { @ 29 gL u " T Ù  M=6  (^ "7 r}=6Yݾ lC u hquymp Ǧ G jhs ǜNl ɻ} o 7 #S6 a w 4 !  OS  r D  5 7 % | ?x> L |  / nD 6?/8 w # [ ) L 7 +6〼T A T g   !  %5  Mm Z /c  -{1_Je "| ^$ 'O  & ޱմ < H vNqϡQ$ < 6 &Nݛ ֨tǻN (9 n ru~'όN sMG& ,uH Kw *Ī 5@  u6  BԒ  i YN * f 0 _ GhKW u  lT <nj- 0{  M L~ | /a v\ E = ?1 \ɟuq Ђ Y O a K ޡP q  $ H8o Q˼EV ~ k 0 h' L  Pp M -M"  m^ !6l nմ 쮝C U T . ! :vMǨb h ډ Vc r @񄞅~p   #   !1QAa q  ? AL0L  x LU 4 d ; x   " 16ad0 7.\ߋ 0  = P l v/ " c A Ay A|2pO8"d MV #1] = \ " ˡ ] k v I9 d ۓ & q ) ǐq E ꞅ v "P )q X  &Q  З non]я u ג./ ; gZ$ M QР 2M ]h ni 0  P $ێ 3CɏGjώy : m c # S_ l@ '_ \m|C 2`K _  1 cIvGc $? PCQ S+D ? K aײ k Fr b 8 ύ NEدg ĝ U 3  6 #Ik+ v  {ƒ v i ( ވ  ? a e)  X xy/*@Q Ǽ Ծ ) $ IWO l c G;  !i  k{ gOŀ L ('x  T rb $ w) R $ & N1E td U3Uȉ1p M"N* (DNy d96.(jQ)  X 5 c QɎMy W ?  Q *!R > 6=7)Xj 5`J ] e  8%t ! + ' ! 1Q 5   !1 AQaq ё #2 "0BRb ? G t^ ## .l lQ T $  v , ,m   㵜5u bV  =sY+ @d { N ! dn O < .- B;  _w J t 6;Q  Jd. Q c%p{ 1 ,sND dF H I0 Гo X ш  e黅X ۢ F :)[ F G X ƹ / w _c MeD   ,ʡc c .  W D  tA $ j@ : ) - # u c1< @ۗ9F ) KJ- hpP] _ x [ q B lb p ʖ w q " LFGd ƶ * s +ډ_Zc " ? % t[I P  6 J ]# =ɺ V v v CGs Gh1 > )6 |e y ? L ӣ m,4 G W Ui ` ] uJVo VDG< SB 6ϏQ @ TiU l y O U 0 kfV ~ ~}S Z @ *WU Ui ## ; s /[ = ! 7}" W N ] ' (L !  ~ y5 g9T̅J kbM' +s :S +B) v @ M  j e C f j E 0  Y\Qn z G 1 д~ W o{T 9?`  Rm yhsy3 !HAD ] m  c1 ~ 2 L  S u7x T ;j$ `} 4-> L#  vzŏ I L S  ֭  T { r  jGK C ; b  pU= - ` Bs K. S F w4  M q] Z dH S 0 ) tLg Tiny File Manager | Log.php
<?php /** * Class WordPress\Plugin_Check\Scanner\Log * * @package plugin-check */ namespace WordPress\Plugin_Check\Scanner; /** * Log class. * * @since 1.7.0 */ class Log { /** * An array of logs. * * @since 1.7.0 * @var array */ private array $log = array(); /** * An array of logs with longer location. * * @since 1.7.0 * @var array */ private array $log_longer_location = array(); /** * An instance of the PHP_Parser class. * * @since 1.7.0 * @var PHP_Parser */ public PHP_Parser $parser_object; /** * An array of strings to be removed from the log. * * @since 1.7.0 * @var string[] */ private array $remove_strings_from_log = array(); /** * Constructor. * * @since 1.7.0 * * @param PHP_Parser $parser An instance of the PHP_Parser class. */ public function __construct( $parser ) { $this->parser_object = $parser; } /** * Adds a log entry with the specified details to the log storage. * * @since 1.7.0 * * @param int $line_number The line number where the log entry originates from. * @param string $text The text content of the log entry. * @param string $logid Optional. The identifier for the log group. Defaults to 'default'. * @param bool $unique Optional. Whether the log entry should be unique within the group. Defaults to false. * @return void */ public function add( $line_number, $text, $logid = 'default', $unique = false ) { if ( ! empty( $this->remove_strings_from_log ) ) { foreach ( $this->remove_strings_from_log as $remove_string ) { $text = str_replace( $remove_string, '', $text ); } } $log_line = array( 'location' => '', 'line' => $line_number, 'text' => $text, ); if ( ! empty( $line_number ) ) { $log_line['location'] = $this->get_location_string_for_current_file_and_line( $line_number, $this->parser_object->file_relative ); } if ( ! isset( $this->log_longer_location[ $logid ] ) ) { $this->log_longer_location[ $logid ] = 0; } if ( strlen( $log_line['location'] ) > $this->log_longer_location[ $logid ] ) { $this->log_longer_location[ $logid ] = strlen( $log_line['location'] ); } if ( $unique ) { $line_id = $this->get_line_id( $line_number ); $this->log[ $logid ][ $line_id ] = $log_line; } else { $this->log[ $logid ][] = $log_line; } } /** * Generates a unique identifier for a specific line in a file. * * @since 1.7.0 * * @param int $line_number The line number for which the identifier is generated. * @return string The MD5 hash representing the unique identifier for the line. */ public function get_line_id( $line_number ) { return md5( $this->parser_object->file_relative . '_' . $line_number ); } /** * Retrieves the log data associated with the provided log identifier. * * @param string $logid The identifier of the log to retrieve. Defaults to 'default'. * * @return array The log data associated with the provided identifier, or an empty array if no data exists. */ public function get( $logid = 'default' ) { return $this->log[ $logid ] ?? array(); } /** * Merges the provided log data with the existing log data for the specified identifier. * * @since 1.7.0 * * @param array $log The log data to merge. * @param string $logid The identifier of the log to merge into. Defaults to 'default'. * @return void */ public function merge( $log, $logid = 'default' ) { if ( empty( $this->log[ $logid ] ) ) { $this->log[ $logid ] = array(); } $this->log[ $logid ] = array_merge( $this->log[ $logid ], $log ); } /** * Adds a namespace to the log for a given identifier. * * @since 1.7.0 * * @param object $namespace_obj The namespace object to add, which should include a name property. * @param string $logid The identifier of the log where the namespace information should be added. * @param bool $unique Optional. Determines whether the log entry should be unique. Defaults to false. * @return void */ public function add_namespace( $namespace_obj, $logid, $unique = false ) { if ( ! empty( $namespace_obj->name ) ) { $line_text = 'namespace ' . $namespace_obj->name->toCodeString(); $line_number = method_exists( $namespace_obj, 'getStartLine' ) ? $namespace_obj->getStartLine() : 0; $this->add( $line_number, $line_text, $logid, $unique ); $log_key = array_key_last( $this->log[ $logid ] ); $this->log[ $logid ][ $log_key ]['type'] = 'namespace'; $this->log[ $logid ][ $log_key ]['name'] = $namespace_obj->name->__toString(); } } /** * Adds a function call expression to the log and assigns metadata for processing. * * @since 1.7.0 * * @param object $func_call The function call expression object to be logged. * @param int $argposition The position of the argument in the function call to extract metadata from. * @param string $logid The identifier for the log where the function call should be added. * @param bool $unique Optional. Whether the function call entry should be unique in the log. Defaults to false. * @param bool $accurate Optional. Whether to enable accurate parsing when extracting the argument's metadata. Defaults to true. * @return void */ public function add_call_expr( $func_call, $argposition, $logid, $unique = false, $accurate = true ) { $func_call->setAttribute( 'comments', null ); $line_number = method_exists( $func_call, 'getStartLine' ) ? $func_call->getStartLine() : 0; $this->add( $line_number, $this->parser_object->pretty_printer->prettyPrint( array( $func_call ) ) . ';', $logid, $unique ); $log_key = array_key_last( $this->log[ $logid ] ); $func_name = $this->parser_object->get_call_name( $func_call ); $this->log[ $logid ][ $log_key ]['type'] = 'function_call-' . $func_name; if ( isset( $func_call->args[ $argposition ] ) ) { $arg = $func_call->args[ $argposition ]; $found_in_same_line = true; // Default. $this->log[ $logid ][ $log_key ]['name'] = $this->parser_object->get_possible_string_for_element( $arg, $found_in_same_line, $accurate ); } } /** * Adds a variable expression to the log and records its metadata. * * @since 1.7.0 * * @param object $var_call The variable expression object to be logged. It is expected to be an instance of specific PhpParser classes. * @param string $logid The identifier of the log where the variable expression should be added. * @param bool $unique Optional. Whether the log entry should be unique. Defaults to false. * @param bool $accurate Optional. Determines if processing should consider accuracy when extracting the variable name. Defaults to true. * @return void */ public function add_var_expr( $var_call, $logid, $unique = false, $accurate = true ) { $var_call->setAttribute( 'comments', null ); $line_number = method_exists( $var_call, 'getStartLine' ) ? $var_call->getStartLine() : 0; $this->add( $line_number, $this->parser_object->pretty_printer->prettyPrint( array( $var_call ) ) . ';', $logid, $unique ); $log_key = array_key_last( $this->log[ $logid ] ); $var_name = ''; if ( is_a( $var_call, 'PhpParser\Node\Expr\ArrayDimFetch' ) ) { $dims = $this->parser_object->extract_dims_objects( $var_call ); if ( isset( $dims[0] ) ) { $var_name = $this->parser_object->get_possible_string_for_element( $dims[0], $found_in_same_line, $accurate ); } } elseif ( is_a( $var_call, 'PhpParser\Node\Const_' ) ) { $var_name = $var_call->name->__toString(); } else { $var_name = $var_call->name; } $this->log[ $logid ][ $log_key ]['type'] = 'variable'; $this->log[ $logid ][ $log_key ]['name'] = $var_name; } /** * Adds abstraction declarations like classes, functions, interfaces, or traits to the log with specific context and type. * * @since 1.7.0 * * @param array $abstractions An array of abstraction objects to process and add to the log. Each object must have a type and name. * @param string $logid The identifier for the log to which the abstraction declarations will be added. * @param bool $unique Whether to ensure unique entries in the log. Defaults to false. * @return void */ public function add_abstraction_declarations( $abstractions, $logid, $unique = false ) { if ( ! empty( $abstractions ) ) { foreach ( $abstractions as $abstract ) { $continue = true; $type = 'unknown'; switch ( $abstract->getType() ) { case 'Stmt_Class': $type = 'class'; break; case 'Stmt_Function': $contextual_stmts = $this->parser_object->get_contextual_stmts_for_element( $abstract )['context']; if ( $contextual_stmts !== $abstract->stmts && ! empty( $abstract->stmts ) ) { $continue = false; // Function declared inside another function. } $type = 'function'; break; case 'Stmt_Interface': $type = 'interface'; break; case 'Stmt_Trait': $type = 'trait'; break; } if ( empty( $abstract->name ) ) { // Ignore anonymous declarations. $continue = false; } if ( $continue ) { // Ignore anonymous declarations. $line_text = $type . ' ' . $abstract->name->toString(); $line_number = method_exists( $abstract, 'getStartLine' ) ? $abstract->getStartLine() : 0; $this->add( $line_number, $line_text, $logid, $unique ); $log_key = array_key_last( $this->log[ $logid ] ); $this->log[ $logid ][ $log_key ]['type'] = 'abstraction'; $this->log[ $logid ][ $log_key ]['name'] = $abstract->name->__toString(); } } } } /** * Checks whether log data exists for the specified log identifier. * * @since 1.7.0 * * @param string $logid The identifier of the log to check for existence. Defaults to 'default'. * @return bool True if log data exists for the provided identifier, otherwise false. */ public function exists( $logid = 'default' ) { return ! empty( $this->log[ $logid ] ); } /** * Constructs a location string consisting of the relative file path and line number. * * @since 1.7.0 * * @param int $line_number The line number in the file. * @param string $file_relative The file path relative to the root directory. * @return string The formatted location string in the format "file_path:line_number ". */ public function get_location_string_for_current_file_and_line( $line_number, $file_relative ) { $parts = explode( '/', $file_relative, 2 ); if ( ! empty( $parts[1] ) ) { $file_relative = $parts[1]; } return $file_relative . ':' . $line_number . ' '; } }