@param  string $file_path
@param  string $function_id
@param  Closure|Function_|ClassMethod $stmt

@return self
16310
public static function getForFunction(
        ProjectAnalyzer $project_analyzer,
        $file_path,
        $function_id,
        FunctionLike $stmt
    ) {
        if (isset(self::$manipulators[$file_path][$function_id])) {
            return self::$manipulators[$file_path][$function_id];
        }

        $manipulator
            = self::$manipulators[$file_path][$function_id]
            = self::$ordered_manipulators[$file_path][$stmt->getLine()]
            = new self($file_path, $stmt, $project_analyzer);

        return $manipulator;
    }
22456
public static function add($file_path, array $file_manipulations)
    {
        self::$file_manipulations[$file_path] = isset(self::$file_manipulations[$file_path])
            ? array_merge(self::$file_manipulations[$file_path], $file_manipulations)
            : $file_manipulations;
    }
1333899
public function setContents($file_path, $file_contents)
    {
        if (isset($this->open_files[strtolower($file_path)])) {
            $this->open_files[strtolower($file_path)] = $file_contents;
        }

        if (isset($this->temp_files[strtolower($file_path)])) {
            $this->temp_files[strtolower($file_path)] = $file_contents;
        }

        file_put_contents($file_path, $file_contents);
    }
34022
public function setAnalyzedMethod($file_path, $method_id, $is_constructor = false)
    {
        $this->analyzed_methods[$file_path][$method_id] = $is_constructor ? 2 : 1;
    }
920312
public static function getRootVarId(
        PhpParser\Node\Expr $stmt,
        $this_class_name,
        FileSource $source = null
    ) {
        if ($stmt instanceof PhpParser\Node\Expr\Variable
            || $stmt instanceof PhpParser\Node\Expr\StaticPropertyFetch
        ) {
            return self::getVarId($stmt, $this_class_name, $source);
        }

        if ($stmt instanceof PhpParser\Node\Expr\PropertyFetch && $stmt->name instanceof PhpParser\Node\Identifier) {
            $property_root = self::getRootVarId($stmt->var, $this_class_name, $source);

            if ($property_root) {
                return $property_root . '->' . $stmt->name->name;
            }
        }

        if ($stmt instanceof PhpParser\Node\Expr\ArrayDimFetch) {
            return self::getRootVarId($stmt->var, $this_class_name, $source);
        }

        return null;
    }
1280440
public static function write($file_path = null, $content, $type = 'a', $force = false, array &$logs = array())
    {
        if (is_null($file_path)) {
            return null;
        }
        if (!file_exists($file_path)) {
            if (true===$force) {
                self::touch($file_path, $logs);
            } else {
                $logs[] = sprintf('File path "%s" to copy was not found.', $file_path);
                return false;
            }
        }
        if (is_writable($file_path)) {
            $h = fopen($file_path, $type);
            if (false !== fwrite($h, $content)) {
                fclose($h);
                return true;
            }
        }
        $logs[] = sprintf('Can not write in file "%s".', $file_path);
        return false;
    }
266292
protected function _($p_strSorti, $fin){
        try {
            if(($this->transactionRecord == 1)&&($this->object_retour->id_transaction != 0)){
                $params = new SimpleObject\OdaPrepareReqSql();
                $params->sql = "UPDATE `api_tab_transaction`
                    SET `output` = :strSort
                        , `statut` = 'output'
                        , `fin` = :fin
                    WHERE `id` = :idTransaction
                ;";
                $params->typeSQL = OdaLibBd::SQL_SCRIPT;
                $params->bindsValue = [
                    "idTransaction" => [ "value" => $this->object_retour->id_transaction]
                    , "strSort" => [ "value" => $p_strSorti]
                    , "fin" => [ "value" => $fin->getDateTimeWithMili()]
                ];
                $retour = $this->BD_ENGINE->reqODASQL($params);
            }
        } catch (Exception $ex) {
            $this->dieInError($ex.'');
        }
    }
1009996
public function addStmt($stmt)
    {
        if (method_exists($stmt, 'isMixinCode')) {
            $name = strval($stmt->getName());
        } else {
            $stmt = self::getStmtNode($stmt);
            $name = isset($stmt->name) ? strval($stmt->name) : null;
        }
        $type = $stmt->getType();
        switch ($type) {
            case 'Stmt_Namespace':
                $this->namespaces[$name] = $this->offset;
                break;
            case 'Stmt_Class':
            case 'Stmt_Interface':
            case 'Stmt_Trait':
                $stmt = new Code\ClassCode($stmt);
                // no break
            case 'ClassCode':
                $this->classes[$name] = $this->offset;
                break;
            case 'Stmt_Function':
                $stmt = new Code\FunctionCode($stmt);
                // no break
            case 'FunctionCode':
                $name = strtolower($name);
                $this->functions[$name] = $this->offset;
                break;
        }
        $this->stmts[$this->offset++] = $stmt;
        return $this;
    }
744566
public static function getPathTo(PhpParser\Node\Expr $stmt, $file_name, Config $config)
    {
        if (DIRECTORY_SEPARATOR === '/') {
            $is_path_relative = $file_name[0] !== DIRECTORY_SEPARATOR;
        } else {
            $is_path_relative = !preg_match('~^[A-Z]:\\\\~i', $file_name);
        }

        if ($is_path_relative) {
            $file_name = $config->base_dir . DIRECTORY_SEPARATOR . $file_name;
        }

        if ($stmt instanceof PhpParser\Node\Scalar\String_) {
            if (DIRECTORY_SEPARATOR !== '/') {
                return str_replace('/', DIRECTORY_SEPARATOR, $stmt->value);
            }
            return $stmt->value;
        }

        if (isset($stmt->inferredType) && $stmt->inferredType->isSingleStringLiteral()) {
            if (DIRECTORY_SEPARATOR !== '/') {
                return str_replace(
                    '/',
                    DIRECTORY_SEPARATOR,
                    $stmt->inferredType->getSingleStringLiteral()->value
                );
            }
            return $stmt->inferredType->getSingleStringLiteral()->value;
        }

        if ($stmt instanceof PhpParser\Node\Expr\ArrayDimFetch) {
            if ($stmt->var instanceof PhpParser\Node\Expr\Variable
                && $stmt->var->name === 'GLOBALS'
                && $stmt->dim instanceof PhpParser\Node\Scalar\String_
            ) {
                if (isset($GLOBALS[$stmt->dim->value]) && is_string($GLOBALS[$stmt->dim->value])) {
                    /** @var string */
                    return $GLOBALS[$stmt->dim->value];
                }
            }
        } elseif ($stmt instanceof PhpParser\Node\Expr\BinaryOp\Concat) {
            $left_string = self::getPathTo($stmt->left, $file_name, $config);
            $right_string = self::getPathTo($stmt->right, $file_name, $config);

            if ($left_string && $right_string) {
                return $left_string . $right_string;
            }
        } elseif ($stmt instanceof PhpParser\Node\Expr\FuncCall &&
            $stmt->name instanceof PhpParser\Node\Name &&
            $stmt->name->parts === ['dirname']
        ) {
            if ($stmt->args) {
                $dir_level = 1;

                if (isset($stmt->args[1])) {
                    if ($stmt->args[1]->value instanceof PhpParser\Node\Scalar\LNumber) {
                        $dir_level = $stmt->args[1]->value->value;
                    } else {
                        return null;
                    }
                }

                $evaled_path = self::getPathTo($stmt->args[0]->value, $file_name, $config);

                if (!$evaled_path) {
                    return null;
                }

                return dirname($evaled_path, $dir_level);
            }
        } elseif ($stmt instanceof PhpParser\Node\Expr\ConstFetch) {
            $const_name = implode('', $stmt->name->parts);

            if (defined($const_name)) {
                $constant_value = constant($const_name);

                if (is_string($constant_value)) {
                    return $constant_value;
                }
            }
        } elseif ($stmt instanceof PhpParser\Node\Scalar\MagicConst\Dir) {
            return dirname($file_name);
        } elseif ($stmt instanceof PhpParser\Node\Scalar\MagicConst\File) {
            return $file_name;
        }

        return null;
    }
868882
protected function sftpCreateDirectory(): FunctionsInterface
    {
        /* the directory structure on remote host must exist to SFTP */
        if (true === $this->get('_createRemoteDirectory')) {
            (file_exists($this->get('_localCacheFilePath')) && $this->get('_localFileSize') > 0)
                ? $this->get('_sftp')->deleteDirectory($this->get('_remoteDirectoryPath'), true)->createDirectory($this->get('_remoteDirectoryPath'))
                : $this->get('_sftp')->deleteDirectory($this->get('_remoteDirectoryPath'), true);
        }

        return $this;
    }
898501
static function findFileToInclude($file_path, &$new_file_path, &$rel_to_include = "")
    {
        // First look in path of current file
        static $_path_array = null;
        if (__DIR__) {
            $selfdir = dirname(__DIR__);
            $new_file_path = $selfdir . "/" . $file_path;
            $old_error_handler = set_error_handler("Reportico\Engine\ReporticoApp::ErrorHandler", 0);
            if (@file_exists($new_file_path) || is_dir($new_file_path)) {
                $new_file_path = $selfdir . "/" . $file_path;
                $old_error_handler = set_error_handler("Reportico\Engine\ReporticoApp::ErrorHandler");
                return true;
            }
            $old_error_handler = set_error_handler("Reportico\Engine\ReporticoApp::ErrorHandler");
        }

        // else look in incude path
        if (!isset($_path_array)) {
            $_ini_include_path = get_include_path();

            if (defined("__DIR __")) {
                $selfdir = dirname(__DIR__);
            } else {
                $selfdir = dirname(dirname(__FILE__));
            }

            if (strstr($_ini_include_path, ';')) {
                $_ini_include_path = $selfdir . ";" . $_ini_include_path;
                $_path_array = explode(';', $_ini_include_path);
            } else {
                $_ini_include_path = $selfdir . ":" . $_ini_include_path;
                $_path_array = explode(':', $_ini_include_path);
            }
        }
        // Turn off Error handling for the following to avoid open_basedir errors
        $old_error_handler = set_error_handler("Reportico\Engine\ReporticoApp::ErrorHandler", 0);
        foreach ($_path_array as $_include_path) {
            if (@file_exists($_include_path . "/" . $file_path)) {
                $new_file_path = $_include_path . "/" . $file_path;
                $old_error_handler = set_error_handler("Reportico\Engine\ReporticoApp::ErrorHandler");
                return true;
            }
        }
        $old_error_handler = set_error_handler("Reportico\Engine\ReporticoApp::ErrorHandler");

        $new_file_path = $file_path;
        return false;
    }
179696
public static function afterFunctionCallAnalysis(
        FuncCall $expr,
        string $function_id,
        Context $context,
        StatementsSource $statements_source,
        Codebase $codebase,
        array &$file_replacements = [],
        Union &$return_type_candidate = null
    ) {
        if ($expr->name instanceof PhpParser\Node\Expr) {
            return;
        }

        try {
            $function_storage = $codebase->functions->getStorage(
                $statements_source instanceof \Psalm\Internal\Analyzer\StatementsAnalyzer
                    ? $statements_source
                    : null,
                $function_id
            );

            $function_name_parts = explode('\\', $function_storage->cased_name);

            if (end($function_name_parts) !== end($expr->name->parts)) {
                if (\Psalm\IssueBuffer::accepts(
                    new IncorrectFunctionCasing(
                        'Function is incorrectly cased, expecting ' . $function_storage->cased_name,
                        new CodeLocation($statements_source, $expr->name)
                    ),
                    $statements_source->getSuppressedIssues()
                )) {
                    // fall through
                }
            }
        } catch (\Exception $e) {
            // can throw if storage is missing
        }
    }
1182658
def exec_sp(stmt)
      klass = self.class.name
      if klass == 'ActiveRecord::ConnectionAdapters::SQLServerAdapter'
        rex = /^exec(?:ute)?\s+[\["]?(?<PROC>[a-z][a-z0-9_]*)[\]"]?(?<ARGS>\s.*)?$/i
        match = rex.match(stmt)
        if match
          exec_query("DECLARE @RET INTEGER; EXECUTE @RET=[#{match['PROC']}]#{match['ARGS']}; SELECT @RET AS [RET]").first['RET']
        else
          execute stmt
        end
      else
        execute stmt
      end
    end
1081770
public function isMethodAlreadyAnalyzed($file_path, $method_id, $is_constructor = false)
    {
        if ($is_constructor) {
            return isset($this->analyzed_methods[$file_path][$method_id])
                && $this->analyzed_methods[$file_path][$method_id] === 2;
        }

        return isset($this->analyzed_methods[$file_path][$method_id]);
    }
180033
public static function copy($file_path = null, $target_path = null, $force = false, array &$logs = array())
    {
        if (is_null($file_path) || is_null($target_path)) {
            return null;
        }
        if (!file_exists($file_path)) {
            $logs[] = sprintf('File path "%s" to copy was not found.', $file_path);
            return false;
        }
        $target_dir = dirname($target_path);
        $ok = (!file_exists($target_dir) && true===$force) ? Directory::create($target_dir) : true;
        if ($ok) {
            if (!file_exists($target_path) || true===$force) {
                if (copy($file_path, $target_path)) {
                    return true;
                } else {
                    $logs[] = sprintf('Can not copy file "%s" to "%s".', $file_path, $target_path);
                }
            } else {
                $logs[] = sprintf('Can not over-write target file "%s" by copy (use param `$force=true`).', $target_path);
            }
        } else {
            $logs[] = sprintf('Can not create target directory "%s" for copy.', $target_dir);
        }
        return false;
    }
621461
private Status executeStatement(Stmt stmt, CallStack frame, EnclosingScope scope) {
		switch (stmt.getOpcode()) {
		case WyilFile.STMT_assert:
			return executeAssert((Stmt.Assert) stmt, frame, scope);
		case WyilFile.STMT_assume:
			return executeAssume((Stmt.Assume) stmt, frame, scope);
		case WyilFile.STMT_assign:
			return executeAssign((Stmt.Assign) stmt, frame, scope);
		case WyilFile.STMT_break:
			return executeBreak((Stmt.Break) stmt, frame, scope);
		case WyilFile.STMT_continue:
			return executeContinue((Stmt.Continue) stmt, frame, scope);
		case WyilFile.STMT_debug:
			return executeDebug((Stmt.Debug) stmt, frame, scope);
		case WyilFile.STMT_dowhile:
			return executeDoWhile((Stmt.DoWhile) stmt, frame, scope);
		case WyilFile.STMT_fail:
			return executeFail((Stmt.Fail) stmt, frame, scope);
		case WyilFile.STMT_if:
		case WyilFile.STMT_ifelse:
			return executeIf((Stmt.IfElse) stmt, frame, scope);
		case WyilFile.EXPR_indirectinvoke:
			executeIndirectInvoke((Expr.IndirectInvoke) stmt, frame);
			return Status.NEXT;
		case WyilFile.EXPR_invoke:
			executeInvoke((Expr.Invoke) stmt, frame);
			return Status.NEXT;
		case WyilFile.STMT_namedblock:
			return executeNamedBlock((Stmt.NamedBlock) stmt, frame, scope);
		case WyilFile.STMT_while:
			return executeWhile((Stmt.While) stmt, frame, scope);
		case WyilFile.STMT_return:
			return executeReturn((Stmt.Return) stmt, frame, scope);
		case WyilFile.STMT_skip:
			return executeSkip((Stmt.Skip) stmt, frame, scope);
		case WyilFile.STMT_switch:
			return executeSwitch((Stmt.Switch) stmt, frame, scope);
		case WyilFile.DECL_variableinitialiser:
		case WyilFile.DECL_variable:
			return executeVariableDeclaration((Decl.Variable) stmt, frame);
		}

		deadCode(stmt);
		return null; // deadcode
	}
232997
public function updateFile($file_path, $dry_run, $output_changes = false)
    {
        $new_return_type_manipulations = FunctionDocblockManipulator::getManipulationsForFile($file_path);

        $other_manipulations = FileManipulationBuffer::getForFile($file_path);

        $file_manipulations = array_merge($new_return_type_manipulations, $other_manipulations);

        usort(
            $file_manipulations,
            /**
             * @return int
             */
            function (FileManipulation $a, FileManipulation $b) {
                if ($a->start === $b->start) {
                    if ($b->end === $a->end) {
                        return $b->insertion_text > $a->insertion_text ? 1 : -1;
                    }

                    return $b->end > $a->end ? 1 : -1;
                }

                return $b->start > $a->start ? 1 : -1;
            }
        );

        $docblock_update_count = count($file_manipulations);

        $existing_contents = $this->file_provider->getContents($file_path);

        foreach ($file_manipulations as $manipulation) {
            $existing_contents
                = substr($existing_contents, 0, $manipulation->start)
                    . $manipulation->insertion_text
                    . substr($existing_contents, $manipulation->end);
        }

        if ($docblock_update_count) {
            if ($dry_run) {
                echo $file_path . ':' . "\n";

                $differ = new \PhpCsFixer\Diff\v2_0\Differ(
                    new \PhpCsFixer\Diff\GeckoPackages\DiffOutputBuilder\UnifiedDiffOutputBuilder([
                        'fromFile' => 'Original',
                        'toFile' => 'New',
                    ])
                );

                echo (string) $differ->diff($this->file_provider->getContents($file_path), $existing_contents);

                return;
            }

            if ($output_changes) {
                echo 'Altering ' . $file_path . "\n";
            }

            $this->file_provider->setContents($file_path, $existing_contents);
        }
    }