


Xdebug Document (5) Code Coverage Analysis, xdebug Document_PHP Tutorial
Xdebug Document (5) Code coverage analysis, xdebug document
Code coverage analysis can let you know which line (or section) of the script is being executed when requested.
Related settings
xdebug.coverage_enable
Type: boolean, Default value: 1, starts with
Xdebug >= 2.2
If set to 0, Xdebug will not set up built-in structures to allow code analysis. This can speed up xdebug faster, but code coverage analysis will not work.
Related functions
boolean xdebug_code_coverage_started()
Returns a Boolean value to see if code coverage analysis has started.
Example:
<?<span>php </span><span>var_dump</span><span>(xdebug_code_coverage_started()); xdebug_start_code_coverage(); </span><span>var_dump</span><span>(xdebug_code_coverage_started()); </span>?>
Returns:
bool(false)
bool(true)
array xdebug_get_code_coverage()
Returns a structure containing which line of the script (including referenced files) is being executed. The following shows an example of code coverage specifying a certain file:
Example:
<?<span>php xdebug_start_code_coverage(); </span><span>function</span> a(<span>$a</span><span>) { </span><span>echo</span> <span>$a</span> * 2.5<span>; } </span><span>function</span> b(<span>$count</span><span>) { </span><span>for</span> (<span>$i</span> = 0; <span>$i</span> < <span>$count</span>; <span>$i</span>++<span>) { a(</span><span>$i</span> + 0.17<span>); } } b(</span>6<span>); b(</span>10<span>); </span><span>var_dump</span><span>(xdebug_get_code_coverage()); </span>?>
Returns:
array
'/home/httpd/html/test/xdebug/docs/xdebug_get_code_coverage.php' =>
array
5 => int 1
6 => int 1
7 => int 1
9 => int 1
10 => int 1
11 => int 1
12 => int 1
13 => int 1
15 => int 1
16 => int 1
18 => int 1
void xdebug_start_code_coverage( [int options] )
Start code coverage analysis
This function starts collecting code coverage information. This information is formed by a two-dimensional array. The first-dimensional index is the execution file name and the second-dimensional index is the line number. The element value indicates whether the line was executed or it has unreachable lines.
Value returned for each row:
- 1: This line has already been executed
- -1: This line has not been executed
- -2: This line has no executable code
The -1 value will only be returned when XDEBUG_CC_UNUSED is turned on, and the -2 value will be returned only when XDEBUG_CC_UNUSED and XDEBUG_CC_DEAD_CODE are turned on at the same time.
The function has two options with enumeration values:
XDEBUG_CC_UNUSED
Enable code detection and indicate which lines of code are executable. Without this item, the returned array only contains the actual executed line numbers.
XDEBUG_CC_DEAD_CODE
Start additional analysis to show which code can be executed.
If these options are enabled, code coverage analysis will be significantly slowed down.
The following examples show how to use the options:
Example:
<?<span>php xdebug_start_code_coverage( XDEBUG_CC_UNUSED </span>|<span> XDEBUG_CC_DEAD_CODE ); </span>?>
void xdebug_stop_code_coverage( [int cleanup=true] )
Stop code coverage analysis
This function stops collecting information and the information will be cleared in memory. If you pass the "false" parameter, the code coverage information will not be cleared and you can use xdebug_start_code_coverage() again to resume information collection.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



It is 395 words, which is 495. This article will show you how to add red lines in Word documents. Redlining a document refers to making modifications to the document so that users can clearly see the changes. This feature is very important when multiple people are editing a document together. What redline means Marking a document Redlining means using red lines or callouts to indicate changes, edits, or revisions to a document. The term was inspired by the practice of using a red pen to mark printed documents. Redline comments are widely used in different scenarios, such as clearly showing recommended changes to authors, editors, and reviewers when editing a document. Propose changes and modifications in legal agreements or contracts Provide constructive criticism and suggestions on papers, presentations, etc. How to give W

What to do with blue screen code 0x0000001? The blue screen error is a warning mechanism when there is a problem with the computer system or hardware. Code 0x0000001 usually indicates a hardware or driver failure. When users suddenly encounter a blue screen error while using their computer, they may feel panicked and at a loss. Fortunately, most blue screen errors can be troubleshooted and dealt with with a few simple steps. This article will introduce readers to some methods to solve the blue screen error code 0x0000001. First, when encountering a blue screen error, we can try to restart

When you encounter a blank page issue when opening a Word document on a Windows 11/10 computer, you may need to perform repairs to resolve the situation. There are various sources of this problem, one of the most common being a corrupted document itself. Furthermore, corruption of Office files may also lead to similar situations. Therefore, the fixes provided in this article may be helpful to you. You can try to use some tools to repair the damaged Word document, or try to convert the document to another format and reopen it. In addition, checking whether the Office software in the system needs to be updated is also a way to solve this problem. By following these simple steps, you may be able to fix Word document blank when opening Word document on Win

If you need to program any device remotely, this article will help you. We will share the top GE universal remote codes for programming any device. What is a GE remote control? GEUniversalRemote is a remote control that can be used to control multiple devices such as smart TVs, LG, Vizio, Sony, Blu-ray, DVD, DVR, Roku, AppleTV, streaming media players and more. GEUniversal remote controls come in various models with different features and functions. GEUniversalRemote can control up to four devices. Top Universal Remote Codes to Program on Any Device GE remotes come with a set of codes that allow them to work with different devices. you may

As a programmer, I get excited about tools that simplify the coding experience. With the help of artificial intelligence tools, we can generate demo code and make necessary modifications as per the requirement. The newly introduced Copilot tool in Visual Studio Code allows us to create AI-generated code with natural language chat interactions. By explaining functionality, we can better understand the meaning of existing code. How to use Copilot to generate code? To get started, we first need to get the latest PowerPlatformTools extension. To achieve this, you need to go to the extension page, search for "PowerPlatformTool" and click the Install button

Word documents are one of the most frequently used applications in our daily work and study. When working with documents, you may sometimes encounter a situation where you need to merge two pages into one. This article will introduce in detail how to merge two pages into one page in a Word document to help readers handle document layout more efficiently. In Word documents, the operation of merging two pages into one is usually used to save paper and printing costs, or to make the document more compact and neat. The following are the specific steps to merge two pages into one: Step 1: Open the Word that needs to be operated

Working with files in the Linux operating system requires the use of various commands and techniques that enable developers to efficiently create and execute files, code, programs, scripts, and other things. In the Linux environment, files with the extension ".a" have great importance as static libraries. These libraries play an important role in software development, allowing developers to efficiently manage and share common functionality across multiple programs. For effective software development in a Linux environment, it is crucial to understand how to create and run ".a" files. This article will introduce how to comprehensively install and configure the Linux ".a" file. Let's explore the definition, purpose, structure, and methods of creating and executing the Linux ".a" file. What is L

Since the launch of ChatGLM-6B on March 14, 2023, the GLM series models have received widespread attention and recognition. Especially after ChatGLM3-6B was open sourced, developers are full of expectations for the fourth-generation model launched by Zhipu AI. This expectation has finally been fully satisfied with the release of GLM-4-9B. The birth of GLM-4-9B In order to give small models (10B and below) more powerful capabilities, the GLM technical team launched this new fourth-generation GLM series open source model: GLM-4-9B after nearly half a year of exploration. This model greatly compresses the model size while ensuring accuracy, and has faster inference speed and higher efficiency. The GLM technical team’s exploration has not
