Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6864095646 | ||
|
|
35572de44c | ||
|
|
916cad2d8d | ||
|
|
2bdb8c67da | ||
|
|
d035dbe215 | ||
|
|
d70baec3ec | ||
|
|
a993080fe6 | ||
|
|
36dbd2aaf0 | ||
|
|
99646663d6 | ||
|
|
17eaad7a92 | ||
|
|
08a24caf8c | ||
|
|
5b31f29ffd | ||
|
|
add15ab277 | ||
|
|
03d1720e84 | ||
|
|
103525ac92 | ||
|
|
d4127c7a91 | ||
|
|
65fd804bd5 | ||
|
|
e6c172f762 | ||
|
|
cf1b0157fa | ||
|
|
752271b258 | ||
|
|
7399146214 | ||
|
|
beeff70d98 | ||
|
|
430919bcdf | ||
|
|
9f3f2483f5 | ||
|
|
638bf00b89 | ||
|
|
09b7a76bd6 | ||
|
|
321cdce5e2 | ||
|
|
15a9081f3b | ||
|
|
5481353386 | ||
|
|
9c7bd34d54 | ||
|
|
a797c4f406 | ||
|
|
a815ba515c | ||
|
|
595b696a03 | ||
|
|
de563bb5d4 | ||
|
|
8875774ddb | ||
|
|
ccf3ff3738 | ||
|
|
cc7670f3c3 | ||
|
|
f62eff890a | ||
|
|
b0584dea0a | ||
|
|
dc88dcce1e | ||
|
|
f4f659c95a | ||
|
|
6be80cc832 | ||
|
|
4930979989 | ||
|
|
168a226859 | ||
|
|
588b597f99 | ||
|
|
54ba716ba8 | ||
|
|
e2f85f44d2 | ||
|
|
a2ae665dd2 | ||
|
|
f8f5e436e5 | ||
|
|
6cab9bbd6b | ||
|
|
1e9a600096 | ||
|
|
cc1cdc577a | ||
|
|
d3e352d9f3 | ||
|
|
e6bb7fadaa | ||
|
|
bd42c7b6a1 | ||
|
|
bbc7ff1ada | ||
|
|
7bffa1f49e | ||
|
|
ba72763486 | ||
|
|
739ed7dd90 | ||
|
|
59a17105ae | ||
|
|
e5079ce186 | ||
|
|
657fccb2de | ||
|
|
cc8c8a4756 | ||
|
|
2700d83208 | ||
|
|
8be22411f7 | ||
|
|
a678997c44 | ||
|
|
b4c49f3c67 | ||
|
|
4d93d2542d | ||
|
|
e1176b7f67 | ||
|
|
828d70cdd1 | ||
|
|
15ff72afb0 | ||
|
|
ad246ad1bc | ||
|
|
c1a389dc17 | ||
|
|
d724958dec | ||
|
|
950031bbaf |
No files matched your search
@@ -0,0 +1,71 @@
|
|||||||
|
name: Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types: [ published ]
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- '*'
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
upload-asset:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: composer:2
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
run: |
|
||||||
|
git init .
|
||||||
|
git remote add origin "https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@$(echo "${{ github.server_url }}" | sed -E 's|https?://||')/${{ github.repository }}.git"
|
||||||
|
git fetch --depth 1 origin "${{ github.ref }}"
|
||||||
|
git checkout FETCH_HEAD
|
||||||
|
|
||||||
|
- name: Build release zip
|
||||||
|
run: |
|
||||||
|
mkdir -p release/laps
|
||||||
|
git archive HEAD | tar -x -C release/laps
|
||||||
|
cd release/laps
|
||||||
|
composer config platform.php 7.4
|
||||||
|
composer remove composer/installers --no-update
|
||||||
|
composer update --no-dev --optimize-autoloader
|
||||||
|
cd ..
|
||||||
|
zip -q -r laps.zip laps
|
||||||
|
rm -rf laps
|
||||||
|
|
||||||
|
- name: Upload zip to Gitea Release
|
||||||
|
env:
|
||||||
|
GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
API_URL: ${{ github.api_url }}
|
||||||
|
SERVER_URL: ${{ github.server_url }}
|
||||||
|
REPO: ${{ github.repository }}
|
||||||
|
TAG: ${{ github.ref_name }}
|
||||||
|
run: |
|
||||||
|
if [ -z "$API_URL" ]; then
|
||||||
|
API_URL="${SERVER_URL}/api/v1"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Target API: $API_URL/repos/$REPO"
|
||||||
|
|
||||||
|
RELEASE_JSON=$(curl -s -H "Authorization: token $GITEA_TOKEN" "$API_URL/repos/$REPO/releases/tags/$TAG")
|
||||||
|
RELEASE_ID=$(echo "$RELEASE_JSON" | php -r '$d = json_decode(file_get_contents("php://stdin")); echo $d->id ?? "";')
|
||||||
|
|
||||||
|
if [ -z "$RELEASE_ID" ]; then
|
||||||
|
echo "Creating release for tag $TAG..."
|
||||||
|
CREATE_RES=$(curl -s -X POST \
|
||||||
|
-H "Authorization: token $GITEA_TOKEN" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d "{\"tag_name\":\"$TAG\",\"name\":\"$TAG\",\"body\":\"Release $TAG\"}" \
|
||||||
|
"$API_URL/repos/$REPO/releases")
|
||||||
|
RELEASE_ID=$(echo "$CREATE_RES" | php -r '$d = json_decode(file_get_contents("php://stdin")); echo $d->id ?? "";')
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Uploading laps.zip to release ID $RELEASE_ID..."
|
||||||
|
curl -s -f -X POST \
|
||||||
|
-H "Authorization: token $GITEA_TOKEN" \
|
||||||
|
-H "Content-Type: multipart/form-data" \
|
||||||
|
-F "attachment=@release/laps.zip" \
|
||||||
|
"$API_URL/repos/$REPO/releases/$RELEASE_ID/assets?name=laps.zip"
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
name: Tests
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ master ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ master ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
tests:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: composer:2
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
run: |
|
||||||
|
git init .
|
||||||
|
git remote add origin "https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@$(echo "${{ github.server_url }}" | sed -E 's|https?://||')/${{ github.repository }}.git"
|
||||||
|
git fetch --depth 1 origin "${{ github.ref }}"
|
||||||
|
git checkout FETCH_HEAD
|
||||||
|
|
||||||
|
- name: Install Composer dependencies
|
||||||
|
run: composer install --no-interaction --prefer-dist
|
||||||
|
|
||||||
|
- name: Run PHPUnit
|
||||||
|
run: vendor/bin/phpunit
|
||||||
@@ -1,2 +1,3 @@
|
|||||||
/vendor
|
/vendor
|
||||||
/release
|
/release
|
||||||
|
.phpunit.result.cache
|
||||||
@@ -6,6 +6,100 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
|
## 3.4.0 - 2026-09-26
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- set minimum required PHP version to 7.4
|
||||||
|
- added `Requires at least: 6.2` to plugin header (supports ClassicPress 2.x and WordPress 6.2+)
|
||||||
|
- checked user permissions (`laps_can_see`) before enqueueing assets in `Asset_Manager`
|
||||||
|
|
||||||
|
## 3.3.7 - 2022-06-16
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- PHP warning, when accessing OPcache status with `opcache.restrict_api`
|
||||||
|
|
||||||
|
## 3.3.6 - 2022-02-08
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- updated dependencies (Mustache.php, Pimple)
|
||||||
|
- minimum required PHP version 7.2.5 (was de-facto required by dependencies before)
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- deprecation notices on PHP 8.1
|
||||||
|
|
||||||
|
## 3.3.5 - 2021-09-28
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- reduced maximum Server Timing headers size to 2K (half of possible nginx defaults)
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- allowed Composer install on PHP 8
|
||||||
|
|
||||||
|
## 3.3.4 - 2020-11-16
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- non-ASCII characters in Server Timing headers
|
||||||
|
|
||||||
|
## 3.3.3 - 2020-03-11
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- wrong plugin version in header
|
||||||
|
|
||||||
|
## 3.3.2 - 2020-03-11
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- `Bootable_Provider_Interface` to extend `ServiceProviderInterface`, so that it can be mocked in PHPUnit 9
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Mustache.php version to resolve issues on PHP 7.4
|
||||||
|
- type crash when URL passed to network request filters is invalid
|
||||||
|
- large server timing headers breaking proxies
|
||||||
|
|
||||||
|
## 3.3.1 - 2019-07-02
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- crash from broken plugin loaded hook input from global
|
||||||
|
|
||||||
|
## 3.3 - 2019-03-27
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- plotting of early SQL queries (WP 5.1+)
|
||||||
|
- tracking load of individual plugin load (WP 5.1+)
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- unit tests for PHPUnit 8
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- error when formatting empty hook.
|
||||||
|
|
||||||
|
## 3.2 - 2019-01-30
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- Beaver Builder events
|
||||||
|
- error message on unsupported PHP version
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- handling of reoccurring hook events
|
||||||
|
- tracking of load events when network–activated
|
||||||
|
|
||||||
|
### Deprecated
|
||||||
|
- dedicated classes for extension events
|
||||||
|
|
||||||
|
## 3.1 - 2019-01-22
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- WooCommerce events
|
||||||
|
- PHP version and OPcache status information
|
||||||
|
- error message on incomplete install
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- headers error from new line in Server Timing
|
||||||
|
|
||||||
|
## 3.0.1 - 2019-01-09
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- fatal error when HTTP request is pre–filtered
|
||||||
|
|
||||||
## 3.0 - 2018-12-28
|
## 3.0 - 2018-12-28
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
@@ -1,47 +1,62 @@
|
|||||||

|

|
||||||
|
|
||||||
# Laps — light WordPress profiler
|
# Laps — könnyűsúlyú WordPress profilozó
|
||||||
|
|
||||||
_Make a site, make it fast._
|
> *Készíts egy weboldalt, és tedd gyorssá.*
|
||||||
|
|
||||||
[](https://scrutinizer-ci.com/g/Rarst/laps/?branch=master)
|
A Laps egy gyors és könnyű WordPress bővítmény, amely valós idejű betöltési és teljesítményadatokat jelenít meg közvetlenül az admin eszköztáron (toolbar).
|
||||||
[](https://scrutinizer-ci.com/g/Rarst/laps/build-status/master)
|
|
||||||
[](https://scrutinizer-ci.com/g/Rarst/laps/?branch=master)
|
|
||||||
[](https://packagist.org/packages/rarst/laps)
|
|
||||||
[](https://packagist.org/packages/rarst/laps)
|
|
||||||
[](https://packagist.org/packages/rarst/laps)
|
|
||||||
[](https://github.com/php-pds/skeleton)
|
|
||||||
[](https://www.rarst.net/download/laps)
|
|
||||||
|
|
||||||
Laps is a plugin that **shows performance information** about WordPress page load.
|
## Főbb funkciók
|
||||||
|
|
||||||
It provides a visual summary in toolbar that is quick and easy to inspect.
|
### Oldalprofilozás
|
||||||
|
A Laps automatikusan méri és megjeleníti a kulcsfontosságú eseményeket:
|
||||||
|
- PHP, WordPress mag, bővítmények és sablonok betöltési ideje, fő ciklus (loop), oldalsávok (sidebars)
|
||||||
|
- Adatbázis-lekérdezések és hívási láncok részletes listázása (ha a `SAVEQUERIES` konstans értéke `true`)
|
||||||
|
- Külső hálózati kérések (HTTP API hívások más oldalakra)
|
||||||
|
|
||||||
## Page profiling
|
### API mérés (Ajax & REST API)
|
||||||
|
Ajax és REST API kérések esetén a Laps a **Server Timing API** segítségével küldi el a mérési adatokat, amelyek közvetlenül megtekinthetők a böngésző fejlesztői eszköztárában (pl. Chrome DevTools Network fülön).
|
||||||
Laps automatically tracks many events, such as:
|
|
||||||
- PHP, core, plugins, and themes load, main posts loop, sidebars
|
|
||||||
- database queries (with [`SAVEQUERIES` constant](http://codex.wordpress.org/Editing_wp-config.php#Save_queries_for_analysis) enabled)
|
|
||||||
- network requests to other sites
|
|
||||||
|
|
||||||
## API profiling
|
|
||||||
|
|
||||||
For Ajax and REST API — Laps outputs performance information by Server Timing API, for use with clients such as Chrome Dev Tools.
|
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
### API authentication
|
### Jogosultságok
|
||||||
|
A teljesítményadatok és a kapcsolódó stílusok/scriptek alapértelmezetten csak a megfelelő adminisztrátori jogosultsággal rendelkező felhasználóknak jelennek meg. A megjelenítés testreszabható a `laps_can_see` szűrővel (filter).
|
||||||
|
|
||||||
API requests need to be authenticated as admin for performance data to be sent. For Ajax requests cookies are sufficient. REST API requests also [need nonce passed](https://developer.wordpress.org/rest-api/using-the-rest-api/authentication/#cookie-authentication).
|
## Telepítés
|
||||||
|
|
||||||
`laps_can_see` check can be filtered to relax required permissions on the plugin’s side.
|
1. Töltsd le a legfrissebb `laps.zip` archívumot a **Releases** oldalról.
|
||||||
|
2. A WordPress admin felületén válaszd a **Bővítmények → Új hozzáadása → Bővítmény feltöltése** menüpontot.
|
||||||
|
3. Töltsd fel a `laps.zip` fájlt, majd aktiváld.
|
||||||
|
|
||||||
## Installation
|
## Követelmények
|
||||||
|
- **WordPress / ClassicPress:** WordPress 6.2+ vagy ClassicPress 2.0+ (pl. 2.7.3)
|
||||||
|
- **PHP:** 7.4 vagy újabb
|
||||||
|
|
||||||
| [Composer](https://getcomposer.org/) (recommended) | Release archive |
|
---
|
||||||
| -------------------------------------------------- | -------- |
|
|
||||||
| `composer require rarst/laps` | [](https://www.rarst.net/download/laps) |
|
## English
|
||||||
|
|
||||||
|
# Laps — Light WordPress Profiler
|
||||||
|
|
||||||
|
> *Make a site, make it fast.*
|
||||||
|
|
||||||
|
Laps is a lightweight plugin that displays real-time page load and performance information directly in the admin toolbar.
|
||||||
|
|
||||||
|
### Features
|
||||||
|
- **Page profiling:** Automatically tracks PHP baseline, core initialization, plugin and theme load times, the main query loop, and sidebars.
|
||||||
|
- **Database queries:** Detailed query logs and execution times (when `SAVEQUERIES` is defined and set to `true`).
|
||||||
|
- **HTTP requests:** Tracks external network requests made via the WordPress HTTP API.
|
||||||
|
- **API profiling:** Emits Server Timing API headers for Ajax and REST API requests, inspectable directly in browser DevTools.
|
||||||
|
- **Access control:** Metrics and frontend/admin assets are only exposed to users with administrative capabilities (customizable via the `laps_can_see` filter).
|
||||||
|
|
||||||
|
### Installation
|
||||||
|
1. Download the latest `laps.zip` from the **Releases** page.
|
||||||
|
2. In the WordPress Admin, go to **Plugins → Add New → Upload Plugin**.
|
||||||
|
3. Upload `laps.zip` and activate.
|
||||||
|
|
||||||
|
### Requirements
|
||||||
|
- **WordPress / ClassicPress:** WordPress 6.2+ or ClassicPress 2.0+ (e.g. 2.7.3)
|
||||||
|
- **PHP:** 7.4 or higher
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
MIT
|
MIT
|
||||||
+89
-16
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
declare( strict_types=1 );
|
||||||
|
|
||||||
require __DIR__ . '/vendor/autoload.php';
|
require __DIR__ . '/vendor/autoload.php';
|
||||||
|
|
||||||
@@ -15,13 +16,13 @@ class RoboFile extends \Robo\Tasks {
|
|||||||
public function watch() {
|
public function watch() {
|
||||||
|
|
||||||
$this->taskWatch()
|
$this->taskWatch()
|
||||||
->monitor( [ 'public/css/variables.less', 'public/css/laps.less' ], function () {
|
->monitor( [ 'public/css/variables.less', 'public/css/laps.less' ], function () {
|
||||||
$this->makeCss();
|
$this->makeCss();
|
||||||
} )
|
} )
|
||||||
->monitor( 'public/js/source.js', function () {
|
->monitor( 'public/js/source.js', function () {
|
||||||
$this->makeJs();
|
$this->makeJs();
|
||||||
} )
|
} )
|
||||||
->run();
|
->run();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,7 +43,7 @@ class RoboFile extends \Robo\Tasks {
|
|||||||
$this->taskExec( 'lessc public/css/laps.less public/css/laps.css --source-map=public/css/laps.css.map' )->run();
|
$this->taskExec( 'lessc public/css/laps.less public/css/laps.css --source-map=public/css/laps.css.map' )->run();
|
||||||
|
|
||||||
$this->taskMinify( 'public/css/laps.css' )
|
$this->taskMinify( 'public/css/laps.css' )
|
||||||
->run();
|
->run();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -54,11 +55,11 @@ class RoboFile extends \Robo\Tasks {
|
|||||||
'vendor/twbs/bootstrap/js/tooltip.js',
|
'vendor/twbs/bootstrap/js/tooltip.js',
|
||||||
'public/js/source.js',
|
'public/js/source.js',
|
||||||
] )
|
] )
|
||||||
->to( 'public/js/laps.js' )
|
->to( 'public/js/laps.js' )
|
||||||
->run();
|
->run();
|
||||||
|
|
||||||
$this->taskMinify( 'public/js/laps.js' )
|
$this->taskMinify( 'public/js/laps.js' )
|
||||||
->run();
|
->run();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -68,14 +69,65 @@ class RoboFile extends \Robo\Tasks {
|
|||||||
$dir = __DIR__ . '/src/mustache/cache';
|
$dir = __DIR__ . '/src/mustache/cache';
|
||||||
$this->_cleanDir( $dir );
|
$this->_cleanDir( $dir );
|
||||||
$mustache = new \Mustache_Engine(
|
$mustache = new \Mustache_Engine(
|
||||||
array(
|
[
|
||||||
'loader' => new \Mustache_Loader_FilesystemLoader( __DIR__ . '/src/mustache' ),
|
'loader' => new \Mustache_Loader_FilesystemLoader( __DIR__ . '/src/mustache' ),
|
||||||
'cache' => $dir,
|
'cache' => $dir,
|
||||||
)
|
]
|
||||||
);
|
);
|
||||||
$mustache->loadTemplate( 'laps' );
|
$mustache->loadTemplate( 'laps' );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates release zip
|
||||||
|
*
|
||||||
|
* @param string $php PHP version to target.
|
||||||
|
*/
|
||||||
|
public function makeArchive( $php = '7.4' ): void {
|
||||||
|
|
||||||
|
$composer = json_decode( file_get_contents( __DIR__ . '/composer.json' ) );
|
||||||
|
$package = $composer->name;
|
||||||
|
|
||||||
|
[ $vendor, $name ] = explode( '/', $package );
|
||||||
|
|
||||||
|
if ( empty( $vendor ) || empty( $name ) ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->_mkdir( 'release' );
|
||||||
|
|
||||||
|
$version = $this->latestTag();
|
||||||
|
|
||||||
|
$this->taskExec( "composer create-project {$package} {$name} {$version}" )
|
||||||
|
->dir( __DIR__ . '/release' )
|
||||||
|
->arg( '--prefer-dist' )
|
||||||
|
->arg( '--no-install' )
|
||||||
|
->run();
|
||||||
|
|
||||||
|
if ( $php ) {
|
||||||
|
$this->taskExec( "composer config platform.php {$php}" )
|
||||||
|
->dir( __DIR__ . "/release/{$name}" )
|
||||||
|
->run();
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->taskExec( 'composer remove composer/installers --no-update' )
|
||||||
|
->dir( __DIR__ . "/release/{$name}" )
|
||||||
|
->run();
|
||||||
|
|
||||||
|
$this->taskExec( 'composer update --no-dev --optimize-autoloader' )
|
||||||
|
->dir( __DIR__ . "/release/{$name}" )
|
||||||
|
->run();
|
||||||
|
|
||||||
|
$zipFile = "release/{$name}.zip";
|
||||||
|
|
||||||
|
$this->_remove( $zipFile );
|
||||||
|
|
||||||
|
$this->taskPack( $zipFile )
|
||||||
|
->addDir( $name, "release/{$name}" )
|
||||||
|
->run();
|
||||||
|
|
||||||
|
$this->_deleteDir( "release/{$name}" );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates version in header and makes git version tag.
|
* Updates version in header and makes git version tag.
|
||||||
*
|
*
|
||||||
@@ -83,12 +135,13 @@ class RoboFile extends \Robo\Tasks {
|
|||||||
*/
|
*/
|
||||||
public function tag( $version ) {
|
public function tag( $version ) {
|
||||||
|
|
||||||
$this->versionSet( $version );
|
$this->makeVersion( $version );
|
||||||
|
|
||||||
$this->taskGitStack()
|
$this->taskGitStack()
|
||||||
->stopOnFail()
|
->stopOnFail()
|
||||||
|
->add( 'CHANGELOG.md' )
|
||||||
->add( 'laps.php' )
|
->add( 'laps.php' )
|
||||||
->commit( "Updated header version to {$version}" )
|
->commit( "Released version $version" )
|
||||||
->tag( $version )
|
->tag( $version )
|
||||||
->run();
|
->run();
|
||||||
}
|
}
|
||||||
@@ -98,11 +151,31 @@ class RoboFile extends \Robo\Tasks {
|
|||||||
*
|
*
|
||||||
* @param string $version Version string.
|
* @param string $version Version string.
|
||||||
*/
|
*/
|
||||||
public function versionSet( $version ) {
|
public function makeVersion( $version ) {
|
||||||
|
|
||||||
|
$this->taskReplaceInFile( 'CHANGELOG.md' )
|
||||||
|
->from( '## Unreleased' )
|
||||||
|
->to( '## Unreleased' . PHP_EOL . PHP_EOL . "## $version - " . date_format( date_create(), 'Y-m-d' ) )
|
||||||
|
->run();
|
||||||
|
|
||||||
$this->taskReplaceInFile( 'laps.php' )
|
$this->taskReplaceInFile( 'laps.php' )
|
||||||
->regex( '|^Version:.*$|m' )
|
->regex( '|^Version:.*$|m' )
|
||||||
->to( 'Version: ' . $version )
|
->to( 'Version: ' . $version )
|
||||||
->run();
|
->run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function upload() {
|
||||||
|
$version = $this->latestTag();
|
||||||
|
$zipFile = __DIR__ . '/release/laps.zip';
|
||||||
|
|
||||||
|
$this->makeArchive();
|
||||||
|
$this->_exec("gh release create $version $zipFile");
|
||||||
|
$this->_remove( $zipFile );
|
||||||
|
}
|
||||||
|
|
||||||
|
private function latestTag(): string {
|
||||||
|
$commit = escapeshellarg( exec( 'git rev-list --tags --max-count=1' ) );
|
||||||
|
|
||||||
|
return escapeshellarg( exec( "git describe --tags {$commit}" ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+15
-11
@@ -8,7 +8,7 @@
|
|||||||
"authors" : [
|
"authors" : [
|
||||||
{
|
{
|
||||||
"name" : "Andrey Savchenko",
|
"name" : "Andrey Savchenko",
|
||||||
"homepage": "http://www.Rarst.net/"
|
"homepage": "https://www.Rarst.net/"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"support" : {
|
"support" : {
|
||||||
@@ -25,16 +25,17 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"require" : {
|
"require" : {
|
||||||
"php" : "^7.1.3",
|
"php" : "^7.4 || ^8",
|
||||||
"composer/installers": "^1.6",
|
"composer/installers": "^1.6 || ^2",
|
||||||
"symfony/stopwatch" : "^4.2.1",
|
"symfony/stopwatch" : "^4.2.1",
|
||||||
"mustache/mustache" : "^2.12",
|
"mustache/mustache" : "^2.14.1",
|
||||||
"pimple/pimple" : "^3.2.3"
|
"pimple/pimple" : "^3.5"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"twbs/bootstrap": "^3.4",
|
"twbs/bootstrap": "^3.4",
|
||||||
"brain/monkey" : "^2.2",
|
"brain/monkey" : "^2.2",
|
||||||
"pds/skeleton": "^1.0"
|
"pds/skeleton": "^1.0",
|
||||||
|
"phpunit/phpunit": "^8.5 || ^9.5"
|
||||||
},
|
},
|
||||||
"extra" : {
|
"extra" : {
|
||||||
"light-ignore-plugin": {
|
"light-ignore-plugin": {
|
||||||
@@ -47,12 +48,15 @@
|
|||||||
],
|
],
|
||||||
"symfony/stopwatch": [
|
"symfony/stopwatch": [
|
||||||
"Tests"
|
"Tests"
|
||||||
],
|
|
||||||
"twbs/bootstrap" : [
|
|
||||||
"docs",
|
|
||||||
"grunt",
|
|
||||||
"js/tests"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"config": {
|
||||||
|
"allow-plugins": {
|
||||||
|
"composer/installers": true
|
||||||
|
},
|
||||||
|
"platform": {
|
||||||
|
"php": "7.4"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Generated
-704
@@ -1,704 +0,0 @@
|
|||||||
{
|
|
||||||
"_readme": [
|
|
||||||
"This file locks the dependencies of your project to a known state",
|
|
||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
|
||||||
"This file is @generated automatically"
|
|
||||||
],
|
|
||||||
"content-hash": "185526a596d05cc666426641f175a314",
|
|
||||||
"packages": [
|
|
||||||
{
|
|
||||||
"name": "composer/installers",
|
|
||||||
"version": "v1.6.0",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/composer/installers.git",
|
|
||||||
"reference": "cfcca6b1b60bc4974324efb5783c13dca6932b5b"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/composer/installers/zipball/cfcca6b1b60bc4974324efb5783c13dca6932b5b",
|
|
||||||
"reference": "cfcca6b1b60bc4974324efb5783c13dca6932b5b",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"composer-plugin-api": "^1.0"
|
|
||||||
},
|
|
||||||
"replace": {
|
|
||||||
"roundcube/plugin-installer": "*",
|
|
||||||
"shama/baton": "*"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"composer/composer": "1.0.*@dev",
|
|
||||||
"phpunit/phpunit": "^4.8.36"
|
|
||||||
},
|
|
||||||
"type": "composer-plugin",
|
|
||||||
"extra": {
|
|
||||||
"class": "Composer\\Installers\\Plugin",
|
|
||||||
"branch-alias": {
|
|
||||||
"dev-master": "1.0-dev"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"Composer\\Installers\\": "src/Composer/Installers"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"MIT"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Kyle Robinson Young",
|
|
||||||
"email": "kyle@dontkry.com",
|
|
||||||
"homepage": "https://github.com/shama"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "A multi-framework Composer library installer",
|
|
||||||
"homepage": "https://composer.github.io/installers/",
|
|
||||||
"keywords": [
|
|
||||||
"Craft",
|
|
||||||
"Dolibarr",
|
|
||||||
"Eliasis",
|
|
||||||
"Hurad",
|
|
||||||
"ImageCMS",
|
|
||||||
"Kanboard",
|
|
||||||
"Lan Management System",
|
|
||||||
"MODX Evo",
|
|
||||||
"Mautic",
|
|
||||||
"Maya",
|
|
||||||
"OXID",
|
|
||||||
"Plentymarkets",
|
|
||||||
"Porto",
|
|
||||||
"RadPHP",
|
|
||||||
"SMF",
|
|
||||||
"Thelia",
|
|
||||||
"WolfCMS",
|
|
||||||
"agl",
|
|
||||||
"aimeos",
|
|
||||||
"annotatecms",
|
|
||||||
"attogram",
|
|
||||||
"bitrix",
|
|
||||||
"cakephp",
|
|
||||||
"chef",
|
|
||||||
"cockpit",
|
|
||||||
"codeigniter",
|
|
||||||
"concrete5",
|
|
||||||
"croogo",
|
|
||||||
"dokuwiki",
|
|
||||||
"drupal",
|
|
||||||
"eZ Platform",
|
|
||||||
"elgg",
|
|
||||||
"expressionengine",
|
|
||||||
"fuelphp",
|
|
||||||
"grav",
|
|
||||||
"installer",
|
|
||||||
"itop",
|
|
||||||
"joomla",
|
|
||||||
"kohana",
|
|
||||||
"laravel",
|
|
||||||
"lavalite",
|
|
||||||
"lithium",
|
|
||||||
"magento",
|
|
||||||
"majima",
|
|
||||||
"mako",
|
|
||||||
"mediawiki",
|
|
||||||
"modulework",
|
|
||||||
"modx",
|
|
||||||
"moodle",
|
|
||||||
"osclass",
|
|
||||||
"phpbb",
|
|
||||||
"piwik",
|
|
||||||
"ppi",
|
|
||||||
"puppet",
|
|
||||||
"pxcms",
|
|
||||||
"reindex",
|
|
||||||
"roundcube",
|
|
||||||
"shopware",
|
|
||||||
"silverstripe",
|
|
||||||
"sydes",
|
|
||||||
"symfony",
|
|
||||||
"typo3",
|
|
||||||
"wordpress",
|
|
||||||
"yawik",
|
|
||||||
"zend",
|
|
||||||
"zikula"
|
|
||||||
],
|
|
||||||
"time": "2018-08-27T06:10:37+00:00"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "mustache/mustache",
|
|
||||||
"version": "v2.12.0",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/bobthecow/mustache.php.git",
|
|
||||||
"reference": "fe8fe72e9d580591854de404cc59a1b83ca4d19e"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/bobthecow/mustache.php/zipball/fe8fe72e9d580591854de404cc59a1b83ca4d19e",
|
|
||||||
"reference": "fe8fe72e9d580591854de404cc59a1b83ca4d19e",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": ">=5.2.4"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"friendsofphp/php-cs-fixer": "~1.11",
|
|
||||||
"phpunit/phpunit": "~3.7|~4.0|~5.0"
|
|
||||||
},
|
|
||||||
"type": "library",
|
|
||||||
"autoload": {
|
|
||||||
"psr-0": {
|
|
||||||
"Mustache": "src/"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"MIT"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Justin Hileman",
|
|
||||||
"email": "justin@justinhileman.info",
|
|
||||||
"homepage": "http://justinhileman.com"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "A Mustache implementation in PHP.",
|
|
||||||
"homepage": "https://github.com/bobthecow/mustache.php",
|
|
||||||
"keywords": [
|
|
||||||
"mustache",
|
|
||||||
"templating"
|
|
||||||
],
|
|
||||||
"time": "2017-07-11T12:54:05+00:00"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "pimple/pimple",
|
|
||||||
"version": "v3.2.3",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/silexphp/Pimple.git",
|
|
||||||
"reference": "9e403941ef9d65d20cba7d54e29fe906db42cf32"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/silexphp/Pimple/zipball/9e403941ef9d65d20cba7d54e29fe906db42cf32",
|
|
||||||
"reference": "9e403941ef9d65d20cba7d54e29fe906db42cf32",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": ">=5.3.0",
|
|
||||||
"psr/container": "^1.0"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"symfony/phpunit-bridge": "^3.2"
|
|
||||||
},
|
|
||||||
"type": "library",
|
|
||||||
"extra": {
|
|
||||||
"branch-alias": {
|
|
||||||
"dev-master": "3.2.x-dev"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"autoload": {
|
|
||||||
"psr-0": {
|
|
||||||
"Pimple": "src/"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"MIT"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Fabien Potencier",
|
|
||||||
"email": "fabien@symfony.com"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Pimple, a simple Dependency Injection Container",
|
|
||||||
"homepage": "http://pimple.sensiolabs.org",
|
|
||||||
"keywords": [
|
|
||||||
"container",
|
|
||||||
"dependency injection"
|
|
||||||
],
|
|
||||||
"time": "2018-01-21T07:42:36+00:00"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "psr/container",
|
|
||||||
"version": "1.0.0",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/php-fig/container.git",
|
|
||||||
"reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f",
|
|
||||||
"reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": ">=5.3.0"
|
|
||||||
},
|
|
||||||
"type": "library",
|
|
||||||
"extra": {
|
|
||||||
"branch-alias": {
|
|
||||||
"dev-master": "1.0.x-dev"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"Psr\\Container\\": "src/"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"MIT"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "PHP-FIG",
|
|
||||||
"homepage": "http://www.php-fig.org/"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Common Container Interface (PHP FIG PSR-11)",
|
|
||||||
"homepage": "https://github.com/php-fig/container",
|
|
||||||
"keywords": [
|
|
||||||
"PSR-11",
|
|
||||||
"container",
|
|
||||||
"container-interface",
|
|
||||||
"container-interop",
|
|
||||||
"psr"
|
|
||||||
],
|
|
||||||
"time": "2017-02-14T16:28:37+00:00"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "symfony/contracts",
|
|
||||||
"version": "v1.0.2",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/symfony/contracts.git",
|
|
||||||
"reference": "1aa7ab2429c3d594dd70689604b5cf7421254cdf"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/symfony/contracts/zipball/1aa7ab2429c3d594dd70689604b5cf7421254cdf",
|
|
||||||
"reference": "1aa7ab2429c3d594dd70689604b5cf7421254cdf",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": "^7.1.3"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"psr/cache": "^1.0",
|
|
||||||
"psr/container": "^1.0"
|
|
||||||
},
|
|
||||||
"suggest": {
|
|
||||||
"psr/cache": "When using the Cache contracts",
|
|
||||||
"psr/container": "When using the Service contracts",
|
|
||||||
"symfony/cache-contracts-implementation": "",
|
|
||||||
"symfony/service-contracts-implementation": "",
|
|
||||||
"symfony/translation-contracts-implementation": ""
|
|
||||||
},
|
|
||||||
"type": "library",
|
|
||||||
"extra": {
|
|
||||||
"branch-alias": {
|
|
||||||
"dev-master": "1.0-dev"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"Symfony\\Contracts\\": ""
|
|
||||||
},
|
|
||||||
"exclude-from-classmap": [
|
|
||||||
"**/Tests/"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"MIT"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Nicolas Grekas",
|
|
||||||
"email": "p@tchwork.com"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Symfony Community",
|
|
||||||
"homepage": "https://symfony.com/contributors"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "A set of abstractions extracted out of the Symfony components",
|
|
||||||
"homepage": "https://symfony.com",
|
|
||||||
"keywords": [
|
|
||||||
"abstractions",
|
|
||||||
"contracts",
|
|
||||||
"decoupling",
|
|
||||||
"interfaces",
|
|
||||||
"interoperability",
|
|
||||||
"standards"
|
|
||||||
],
|
|
||||||
"time": "2018-12-05T08:06:11+00:00"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "symfony/stopwatch",
|
|
||||||
"version": "v4.2.1",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/symfony/stopwatch.git",
|
|
||||||
"reference": "ec076716412274e51f8a7ea675d9515e5c311123"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/symfony/stopwatch/zipball/ec076716412274e51f8a7ea675d9515e5c311123",
|
|
||||||
"reference": "ec076716412274e51f8a7ea675d9515e5c311123",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": "^7.1.3",
|
|
||||||
"symfony/contracts": "^1.0"
|
|
||||||
},
|
|
||||||
"type": "library",
|
|
||||||
"extra": {
|
|
||||||
"branch-alias": {
|
|
||||||
"dev-master": "4.2-dev"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"Symfony\\Component\\Stopwatch\\": ""
|
|
||||||
},
|
|
||||||
"exclude-from-classmap": [
|
|
||||||
"/Tests/"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"MIT"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Fabien Potencier",
|
|
||||||
"email": "fabien@symfony.com"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Symfony Community",
|
|
||||||
"homepage": "https://symfony.com/contributors"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Symfony Stopwatch Component",
|
|
||||||
"homepage": "https://symfony.com",
|
|
||||||
"time": "2018-11-11T19:52:12+00:00"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"packages-dev": [
|
|
||||||
{
|
|
||||||
"name": "antecedent/patchwork",
|
|
||||||
"version": "2.1.8",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/antecedent/patchwork.git",
|
|
||||||
"reference": "3bb81ace3914c220aa273d1c0603d5e1b454c0d7"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/antecedent/patchwork/zipball/3bb81ace3914c220aa273d1c0603d5e1b454c0d7",
|
|
||||||
"reference": "3bb81ace3914c220aa273d1c0603d5e1b454c0d7",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": ">=5.4.0"
|
|
||||||
},
|
|
||||||
"type": "library",
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"MIT"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Ignas Rudaitis",
|
|
||||||
"email": "ignas.rudaitis@gmail.com"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Method redefinition (monkey-patching) functionality for PHP.",
|
|
||||||
"homepage": "http://patchwork2.org/",
|
|
||||||
"keywords": [
|
|
||||||
"aop",
|
|
||||||
"aspect",
|
|
||||||
"interception",
|
|
||||||
"monkeypatching",
|
|
||||||
"redefinition",
|
|
||||||
"runkit",
|
|
||||||
"testing"
|
|
||||||
],
|
|
||||||
"time": "2018-02-19T18:52:50+00:00"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "brain/monkey",
|
|
||||||
"version": "2.2.0",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/Brain-WP/BrainMonkey.git",
|
|
||||||
"reference": "ed9e0698bc1292f33698719da8ca1aa2e18acc51"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/Brain-WP/BrainMonkey/zipball/ed9e0698bc1292f33698719da8ca1aa2e18acc51",
|
|
||||||
"reference": "ed9e0698bc1292f33698719da8ca1aa2e18acc51",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"antecedent/patchwork": "^2.0",
|
|
||||||
"mockery/mockery": ">=0.9 <2",
|
|
||||||
"php": ">=5.6.0"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"phpunit/phpunit": "~5.7.9"
|
|
||||||
},
|
|
||||||
"type": "library",
|
|
||||||
"extra": {
|
|
||||||
"branch-alias": {
|
|
||||||
"dev-version/1": "1.x-dev",
|
|
||||||
"dev-master": "2.0.x-dev"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"Brain\\Monkey\\": "src/"
|
|
||||||
},
|
|
||||||
"files": [
|
|
||||||
"inc/api.php"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"MIT"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Giuseppe Mazzapica",
|
|
||||||
"email": "giuseppe.mazzapica@gmail.com",
|
|
||||||
"homepage": "https://gmazzap.me",
|
|
||||||
"role": "Developer"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Mocking utility for PHP functions and WordPress plugin API",
|
|
||||||
"keywords": [
|
|
||||||
"Monkey Patching",
|
|
||||||
"interception",
|
|
||||||
"mock",
|
|
||||||
"mock functions",
|
|
||||||
"mockery",
|
|
||||||
"patchwork",
|
|
||||||
"redefinition",
|
|
||||||
"runkit",
|
|
||||||
"test",
|
|
||||||
"testing"
|
|
||||||
],
|
|
||||||
"time": "2017-12-01T16:32:09+00:00"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "hamcrest/hamcrest-php",
|
|
||||||
"version": "v2.0.0",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/hamcrest/hamcrest-php.git",
|
|
||||||
"reference": "776503d3a8e85d4f9a1148614f95b7a608b046ad"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/hamcrest/hamcrest-php/zipball/776503d3a8e85d4f9a1148614f95b7a608b046ad",
|
|
||||||
"reference": "776503d3a8e85d4f9a1148614f95b7a608b046ad",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": "^5.3|^7.0"
|
|
||||||
},
|
|
||||||
"replace": {
|
|
||||||
"cordoval/hamcrest-php": "*",
|
|
||||||
"davedevelopment/hamcrest-php": "*",
|
|
||||||
"kodova/hamcrest-php": "*"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"phpunit/php-file-iterator": "1.3.3",
|
|
||||||
"phpunit/phpunit": "~4.0",
|
|
||||||
"satooshi/php-coveralls": "^1.0"
|
|
||||||
},
|
|
||||||
"type": "library",
|
|
||||||
"extra": {
|
|
||||||
"branch-alias": {
|
|
||||||
"dev-master": "2.0-dev"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"autoload": {
|
|
||||||
"classmap": [
|
|
||||||
"hamcrest"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"BSD"
|
|
||||||
],
|
|
||||||
"description": "This is the PHP port of Hamcrest Matchers",
|
|
||||||
"keywords": [
|
|
||||||
"test"
|
|
||||||
],
|
|
||||||
"time": "2016-01-20T08:20:44+00:00"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "mockery/mockery",
|
|
||||||
"version": "1.2.0",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/mockery/mockery.git",
|
|
||||||
"reference": "100633629bf76d57430b86b7098cd6beb996a35a"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/mockery/mockery/zipball/100633629bf76d57430b86b7098cd6beb996a35a",
|
|
||||||
"reference": "100633629bf76d57430b86b7098cd6beb996a35a",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"hamcrest/hamcrest-php": "~2.0",
|
|
||||||
"lib-pcre": ">=7.0",
|
|
||||||
"php": ">=5.6.0"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"phpunit/phpunit": "~5.7.10|~6.5|~7.0"
|
|
||||||
},
|
|
||||||
"type": "library",
|
|
||||||
"extra": {
|
|
||||||
"branch-alias": {
|
|
||||||
"dev-master": "1.0.x-dev"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"autoload": {
|
|
||||||
"psr-0": {
|
|
||||||
"Mockery": "library/"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"BSD-3-Clause"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Pádraic Brady",
|
|
||||||
"email": "padraic.brady@gmail.com",
|
|
||||||
"homepage": "http://blog.astrumfutura.com"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Dave Marshall",
|
|
||||||
"email": "dave.marshall@atstsolutions.co.uk",
|
|
||||||
"homepage": "http://davedevelopment.co.uk"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Mockery is a simple yet flexible PHP mock object framework",
|
|
||||||
"homepage": "https://github.com/mockery/mockery",
|
|
||||||
"keywords": [
|
|
||||||
"BDD",
|
|
||||||
"TDD",
|
|
||||||
"library",
|
|
||||||
"mock",
|
|
||||||
"mock objects",
|
|
||||||
"mockery",
|
|
||||||
"stub",
|
|
||||||
"test",
|
|
||||||
"test double",
|
|
||||||
"testing"
|
|
||||||
],
|
|
||||||
"time": "2018-10-02T21:52:37+00:00"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "pds/skeleton",
|
|
||||||
"version": "1.0.0",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/php-pds/skeleton.git",
|
|
||||||
"reference": "95e476e5d629eadacbd721c5a9553e537514a231"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/php-pds/skeleton/zipball/95e476e5d629eadacbd721c5a9553e537514a231",
|
|
||||||
"reference": "95e476e5d629eadacbd721c5a9553e537514a231",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"bin": [
|
|
||||||
"bin/pds-skeleton"
|
|
||||||
],
|
|
||||||
"type": "standard",
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"Pds\\Skeleton\\": "src/"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"CC-BY-SA-4.0"
|
|
||||||
],
|
|
||||||
"description": "Standard for PHP package skeletons.",
|
|
||||||
"homepage": "https://github.com/php-pds/skeleton",
|
|
||||||
"time": "2017-01-25T23:30:41+00:00"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "twbs/bootstrap",
|
|
||||||
"version": "v3.4.0",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/twbs/bootstrap.git",
|
|
||||||
"reference": "4c547f2175b9a05aa43551f6927da83fe249ce42"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/twbs/bootstrap/zipball/4c547f2175b9a05aa43551f6927da83fe249ce42",
|
|
||||||
"reference": "4c547f2175b9a05aa43551f6927da83fe249ce42",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"replace": {
|
|
||||||
"twitter/bootstrap": "self.version"
|
|
||||||
},
|
|
||||||
"type": "library",
|
|
||||||
"extra": {
|
|
||||||
"branch-alias": {
|
|
||||||
"dev-master": "3.4.x-dev"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"MIT"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Jacob Thornton",
|
|
||||||
"email": "jacobthornton@gmail.com"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Mark Otto",
|
|
||||||
"email": "markdotto@gmail.com"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "The most popular front-end framework for developing responsive, mobile first projects on the web.",
|
|
||||||
"homepage": "https://getbootstrap.com/",
|
|
||||||
"keywords": [
|
|
||||||
"JS",
|
|
||||||
"css",
|
|
||||||
"framework",
|
|
||||||
"front-end",
|
|
||||||
"less",
|
|
||||||
"mobile-first",
|
|
||||||
"responsive",
|
|
||||||
"web"
|
|
||||||
],
|
|
||||||
"time": "2018-12-13T23:45:51+00:00"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"aliases": [],
|
|
||||||
"minimum-stability": "stable",
|
|
||||||
"stability-flags": [],
|
|
||||||
"prefer-stable": false,
|
|
||||||
"prefer-lowest": false,
|
|
||||||
"platform": {
|
|
||||||
"php": "^7.1.3"
|
|
||||||
},
|
|
||||||
"platform-dev": []
|
|
||||||
}
|
|
||||||
@@ -5,10 +5,11 @@ Plugin Name: Laps
|
|||||||
Plugin URI: https://github.com/Rarst/laps
|
Plugin URI: https://github.com/Rarst/laps
|
||||||
Description: Light WordPress profiler.
|
Description: Light WordPress profiler.
|
||||||
Author: Andrey “Rarst” Savchenko
|
Author: Andrey “Rarst” Savchenko
|
||||||
Version: 3.0
|
Version: 3.4.0
|
||||||
Author URI: https://www.rarst.net/
|
Author URI: https://www.rarst.net/
|
||||||
Text Domain: laps
|
Requires at least: 6.2
|
||||||
Domain Path: /lang
|
Requires PHP: 7.4
|
||||||
|
Update URI: false
|
||||||
License: MIT
|
License: MIT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -16,6 +17,14 @@ if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) {
|
|||||||
require __DIR__ . '/vendor/autoload.php';
|
require __DIR__ . '/vendor/autoload.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( ! class_exists( '\Rarst\Laps\Plugin' ) ) {
|
||||||
|
trigger_error( 'Laps not fully installed! Please install with Composer or download full release archive.', E_USER_ERROR );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( PHP_VERSION_ID < 70400 ) {
|
||||||
|
trigger_error( 'Laps requires PHP version >=7.4.', E_USER_ERROR );
|
||||||
|
}
|
||||||
|
|
||||||
$laps = new \Rarst\Laps\Plugin();
|
$laps = new \Rarst\Laps\Plugin();
|
||||||
|
|
||||||
$laps->run();
|
$laps->run();
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<psalm
|
<psalm
|
||||||
totallyTyped="true"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns="https://getpsalm.org/schema/config"
|
xmlns="https://getpsalm.org/schema/config"
|
||||||
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
|
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
|
||||||
|
errorLevel="2"
|
||||||
>
|
>
|
||||||
<projectFiles>
|
<projectFiles>
|
||||||
<directory name="src"/>
|
<directory name="src"/>
|
||||||
@@ -16,28 +16,8 @@
|
|||||||
<issueHandlers>
|
<issueHandlers>
|
||||||
<LessSpecificReturnType errorLevel="info"/>
|
<LessSpecificReturnType errorLevel="info"/>
|
||||||
<UndefinedFunction errorLevel="suppress"/>
|
<UndefinedFunction errorLevel="suppress"/>
|
||||||
<UndefinedClass>
|
<UndefinedClass errorLevel="suppress"/>
|
||||||
<errorLevel type="suppress">
|
<UndefinedDocblockClass errorLevel="suppress"/>
|
||||||
<referencedClass name="WP_Admin_Bar"/>
|
<UndefinedConstant errorLevel="suppress"/>
|
||||||
<referencedClass name="WP_Error"/>
|
|
||||||
<referencedClass name="WP_Hook"/>
|
|
||||||
</errorLevel>
|
|
||||||
</UndefinedClass>
|
|
||||||
<MixedArgument>
|
|
||||||
<errorLevel type="suppress">
|
|
||||||
<file name="src/Provider/Record_Provider.php" />
|
|
||||||
<file name="src/Record/Collector/Hook_Collector.php" />
|
|
||||||
</errorLevel>
|
|
||||||
</MixedArgument>
|
|
||||||
<MissingClosureParamType>
|
|
||||||
<errorLevel type="suppress">
|
|
||||||
<file name="src/Record/Collector/Hook_Collector.php" />
|
|
||||||
</errorLevel>
|
|
||||||
</MissingClosureParamType>
|
|
||||||
<MissingClosureReturnType>
|
|
||||||
<errorLevel type="suppress">
|
|
||||||
<file name="src/Record/Collector/Hook_Collector.php" />
|
|
||||||
</errorLevel>
|
|
||||||
</MissingClosureReturnType>
|
|
||||||
</issueHandlers>
|
</issueHandlers>
|
||||||
</psalm>
|
</psalm>
|
||||||
@@ -9,7 +9,7 @@ namespace Rarst\Laps\Event;
|
|||||||
class Core_Events implements Hook_Event_Config_Interface {
|
class Core_Events implements Hook_Event_Config_Interface {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public function get_events(): array {
|
public function get_events(): array {
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,52 @@
|
|||||||
|
<?php
|
||||||
|
declare( strict_types=1 );
|
||||||
|
|
||||||
|
namespace Rarst\Laps\Event;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Events for third party themes and plugins.
|
||||||
|
*/
|
||||||
|
class Extension_Events implements Hook_Event_Config_Interface {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function get_events(): array {
|
||||||
|
|
||||||
|
return $this->beaver_builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Beaver Builder events.
|
||||||
|
*
|
||||||
|
* @return array[]
|
||||||
|
*/
|
||||||
|
private function beaver_builder(): array {
|
||||||
|
|
||||||
|
$plugin = class_exists( 'FLBuilderLoader' ) ? [
|
||||||
|
[
|
||||||
|
'Beaver Builder Post Content',
|
||||||
|
'plugin',
|
||||||
|
'fl_builder_before_render_content',
|
||||||
|
'fl_builder_after_render_content',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'Beaver Builder Module',
|
||||||
|
'plugin',
|
||||||
|
'fl_builder_before_render_module',
|
||||||
|
'fl_builder_after_render_module',
|
||||||
|
],
|
||||||
|
] : [];
|
||||||
|
|
||||||
|
$theme = class_exists( 'FLTheme' ) ? [
|
||||||
|
[ 'Beaver Builder Top Bar', 'theme', 'fl_before_top_bar', 'fl_after_top_bar' ],
|
||||||
|
[ 'Beaver Builder Header', 'theme', 'fl_before_header', 'fl_after_header' ],
|
||||||
|
[ 'Beaver Builder Page Content', 'theme', 'fl_before_content', 'fl_after_content' ],
|
||||||
|
[ 'Beaver Builder Post', 'theme', 'fl_before_post', 'fl_after_post' ],
|
||||||
|
[ 'Beaver Builder Footer Widgets', 'theme', 'fl_before_footer_widgets', 'fl_after_footer_widgets' ],
|
||||||
|
[ 'Beaver Builder Footer', 'theme', 'fl_before_footer', 'fl_after_footer' ],
|
||||||
|
] : [];
|
||||||
|
|
||||||
|
return array_merge( $plugin, $theme );
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,11 +7,13 @@ namespace Rarst\Laps\Event;
|
|||||||
* Events for Genesis Framework based themes
|
* Events for Genesis Framework based themes
|
||||||
*
|
*
|
||||||
* @link http://my.studiopress.com/themes/genesis/
|
* @link http://my.studiopress.com/themes/genesis/
|
||||||
|
*
|
||||||
|
* @deprecated 3.2:4.0 Events going to be moved to Extension_Events class.
|
||||||
*/
|
*/
|
||||||
class Genesis_Events implements Hook_Event_Config_Interface {
|
class Genesis_Events implements Hook_Event_Config_Interface {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public function get_events(): array {
|
public function get_events(): array {
|
||||||
|
|
||||||
|
|||||||
@@ -7,11 +7,13 @@ namespace Rarst\Laps\Event;
|
|||||||
* Events for Hybrid Core based themes
|
* Events for Hybrid Core based themes
|
||||||
*
|
*
|
||||||
* @link http://themehybrid.com/hybrid-core
|
* @link http://themehybrid.com/hybrid-core
|
||||||
|
*
|
||||||
|
* @deprecated 3.2:4.0 Events going to be moved to Extension_Events class.
|
||||||
*/
|
*/
|
||||||
class Hybrid_Events implements Hook_Event_Config_Interface {
|
class Hybrid_Events implements Hook_Event_Config_Interface {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public function get_events(): array {
|
public function get_events(): array {
|
||||||
|
|
||||||
|
|||||||
@@ -7,11 +7,13 @@ namespace Rarst\Laps\Event;
|
|||||||
* Events for Theme Hook Alliance
|
* Events for Theme Hook Alliance
|
||||||
*
|
*
|
||||||
* @link http://zamoose.github.io/themehookalliance/
|
* @link http://zamoose.github.io/themehookalliance/
|
||||||
|
*
|
||||||
|
* @deprecated 3.2:4.0 Events going to be moved to Extension_Events class.
|
||||||
*/
|
*/
|
||||||
class THA_Events implements Hook_Event_Config_Interface {
|
class THA_Events implements Hook_Event_Config_Interface {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public function get_events(): array {
|
public function get_events(): array {
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
declare( strict_types=1 );
|
||||||
|
|
||||||
|
namespace Rarst\Laps\Event;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Events for WooCommerce plugin
|
||||||
|
*
|
||||||
|
* @deprecated 3.2:4.0 Events going to be moved to Extension_Events class.
|
||||||
|
*/
|
||||||
|
class WooCommerce_Events implements Hook_Event_Config_Interface {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function get_events(): array {
|
||||||
|
|
||||||
|
return class_exists( 'WooCommerce' ) ? [
|
||||||
|
[ 'WooCommerce Init', 'plugin', 'before_woocommerce_init', 'woocommerce_init' ],
|
||||||
|
[ 'WooCommerce Shop Loop', 'plugin', 'woocommerce_before_shop_loop', 'woocommerce_after_shop_loop' ],
|
||||||
|
[ 'WooCommerce Shop Item', 'plugin', 'woocommerce_before_shop_loop_item', 'woocommerce_after_shop_loop_item' ],
|
||||||
|
[ 'WooCommerce Single Product', 'plugin', 'woocommerce_before_single_product', 'woocommerce_after_single_product' ],
|
||||||
|
[ 'WooCommerce Cart', 'plugin', 'woocommerce_before_cart', 'woocommerce_after_cart' ],
|
||||||
|
[ 'WooCommerce Checkout', 'plugin', 'woocommerce_before_checkout_form', 'woocommerce_after_checkout_form' ],
|
||||||
|
] : [];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,11 +5,13 @@ namespace Rarst\Laps\Event;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Events for Yoast plugins
|
* Events for Yoast plugins
|
||||||
|
*
|
||||||
|
* @deprecated 3.2:4.0 Events going to be moved to Extension_Events class.
|
||||||
*/
|
*/
|
||||||
class Yoast_Events implements Hook_Event_Config_Interface {
|
class Yoast_Events implements Hook_Event_Config_Interface {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public function get_events(): array {
|
public function get_events(): array {
|
||||||
|
|
||||||
|
|||||||
@@ -76,13 +76,12 @@ class Backtrace_Formatter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
|
* @psalm-suppress PossiblyFalseOperand
|
||||||
*
|
*
|
||||||
* @param string $item Backtrace item.
|
* @param string $item Backtrace item.
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*
|
|
||||||
* @psalm-suppress PossiblyFalseOperand
|
|
||||||
* @psalm-suppress MixedInferredReturnType
|
|
||||||
*/
|
*/
|
||||||
protected function shorten_include( string $item ): string {
|
protected function shorten_include( string $item ): string {
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ class Hook_Formatter {
|
|||||||
*/
|
*/
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
|
|
||||||
|
// TODO inject paths instead of reaching for global constants.
|
||||||
$this->truncate_paths = [
|
$this->truncate_paths = [
|
||||||
wp_normalize_path( WP_CONTENT_DIR ),
|
wp_normalize_path( WP_CONTENT_DIR ),
|
||||||
wp_normalize_path( ABSPATH ),
|
wp_normalize_path( ABSPATH ),
|
||||||
@@ -24,7 +25,14 @@ class Hook_Formatter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @psalm-type Callback = string|object|array
|
||||||
|
* @psalm-type AcceptedArgs = int
|
||||||
|
* @psalm-type Hook = array{function: Callback, accepted_args: AcceptedArgs}
|
||||||
|
* @psalm-type Priority = array-key
|
||||||
|
* @psalm-type Hooks = array<Priority, array<Hook>>
|
||||||
|
*
|
||||||
* @param \WP_Hook|array $hook Hook instance.
|
* @param \WP_Hook|array $hook Hook instance.
|
||||||
|
* @psalm-param \WP_Hook|Hooks $hook
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
@@ -33,8 +41,14 @@ class Hook_Formatter {
|
|||||||
$callbacks = [];
|
$callbacks = [];
|
||||||
|
|
||||||
if ( $hook instanceof \WP_Hook ) {
|
if ( $hook instanceof \WP_Hook ) {
|
||||||
|
/** @psalm-var Hooks $hook->callbacks */
|
||||||
$hook = $hook->callbacks;
|
$hook = $hook->callbacks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( empty( $hook ) ) {
|
||||||
|
return $callbacks;
|
||||||
|
}
|
||||||
|
|
||||||
ksort( $hook );
|
ksort( $hook );
|
||||||
|
|
||||||
$functions = array_merge( ...$hook );
|
$functions = array_merge( ...$hook );
|
||||||
@@ -55,27 +69,27 @@ class Hook_Formatter {
|
|||||||
/**
|
/**
|
||||||
* @param string|object|array $callback Hook callback.
|
* @param string|object|array $callback Hook callback.
|
||||||
* @param int $args Number of accepted arguments.
|
* @param int $args Number of accepted arguments.
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
*/
|
||||||
protected function get_callback_name( $callback, int $args ): string {
|
protected function get_callback_name( $callback, int $args ): string {
|
||||||
|
|
||||||
switch ( gettype( $callback ) ) {
|
switch ( gettype( $callback ) ) {
|
||||||
case 'object':
|
case 'object':
|
||||||
$callback = $this->get_class_name( $callback );
|
$name = $this->get_class_name( $callback );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'array':
|
case 'array':
|
||||||
$class = is_string( $callback[0] )
|
/** @psalm-var array{0: object|string, 1: string} $callback */
|
||||||
|
$class = is_string( $callback[0] )
|
||||||
? $callback[0] . '::'
|
? $callback[0] . '::'
|
||||||
: $this->get_class_name( $callback[0] ) . '->';
|
: $this->get_class_name( $callback[0] ) . '->';
|
||||||
$callback = $class . $callback[1];
|
$name = $class . $callback[1];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
$name = $callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
$callback .= ( 1 === $args ) ? '' : "({$args})";
|
return $name . ( ( 1 === $args ) ? '' : "({$args})" );
|
||||||
|
|
||||||
return $callback;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -85,7 +99,7 @@ class Hook_Formatter {
|
|||||||
*/
|
*/
|
||||||
protected function get_class_name( $object ): string {
|
protected function get_class_name( $object ): string {
|
||||||
|
|
||||||
if ( is_a( $object, 'CLosure' ) ) {
|
if ( $object instanceof \Closure ) {
|
||||||
$class = new \ReflectionFunction( $object );
|
$class = new \ReflectionFunction( $object );
|
||||||
|
|
||||||
return 'closure from ' . $this->shorten_path( $class->getFileName() ) . ':' . $class->getStartLine();
|
return 'closure from ' . $this->shorten_path( $class->getFileName() ) . ':' . $class->getStartLine();
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class Asset_Manager {
|
|||||||
wp_register_script( 'laps', plugins_url( "public/js/laps{$suffix}.js", dirname( __DIR__ ) ), [ 'jquery' ], '3.4.0', true );
|
wp_register_script( 'laps', plugins_url( "public/js/laps{$suffix}.js", dirname( __DIR__ ) ), [ 'jquery' ], '3.4.0', true );
|
||||||
wp_register_style( 'laps', plugins_url( "public/css/laps{$suffix}.css", dirname( __DIR__ ) ) );
|
wp_register_style( 'laps', plugins_url( "public/css/laps{$suffix}.css", dirname( __DIR__ ) ) );
|
||||||
|
|
||||||
if ( is_admin_bar_showing() ) {
|
if ( is_admin_bar_showing() && apply_filters( 'laps_can_see', current_user_can( 'manage_options' ) ) ) {
|
||||||
wp_enqueue_script( 'laps' );
|
wp_enqueue_script( 'laps' );
|
||||||
wp_enqueue_style( 'laps' );
|
wp_enqueue_style( 'laps' );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,8 +21,6 @@ class Load_Order_Manager {
|
|||||||
* Reorder active plugins so Laps is first and starts timing load early.
|
* Reorder active plugins so Laps is first and starts timing load early.
|
||||||
*
|
*
|
||||||
* @param array $plugins Filtered array of active plugins’ basenames.
|
* @param array $plugins Filtered array of active plugins’ basenames.
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
*/
|
||||||
public function pre_update_option_active_plugins( array $plugins ): array {
|
public function pre_update_option_active_plugins( array $plugins ): array {
|
||||||
|
|
||||||
|
|||||||
@@ -57,14 +57,19 @@ class Server_Timing_Manager {
|
|||||||
foreach ( $this->collector->get_records() as $record ) {
|
foreach ( $this->collector->get_records() as $record ) {
|
||||||
$duration = $record->get_duration() * 1000;
|
$duration = $record->get_duration() * 1000;
|
||||||
|
|
||||||
if ( $duration < 1 ) {
|
if ( $duration < 1 ) { // Filter out less than 1ms events as too noisy.
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$header .= sprintf( '%s;dur=%.2f;desc="%s", ', $record->get_category(), $duration, $record->get_name() );
|
$header .= sprintf( '%s;dur=%.2f;desc="%s", ', $record->get_category(), $duration, $record->get_name() );
|
||||||
|
|
||||||
|
if ( strlen( $header ) > 2000 ) { // 8+KB headers break proxies, 4+KB nginx, so we cut off at 1/2 that limit.
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
header( 'Server-Timing: ' . $header );
|
// Sanitize to visible US ASCII character range (32-126).
|
||||||
|
header( 'Server-Timing: ' . preg_replace( '/[^\x20-\x7E]/', '', $header ) );
|
||||||
|
|
||||||
return $input;
|
return $input;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,8 +36,6 @@ class Toolbar_Manager {
|
|||||||
* Render interface and add to the toolbar.
|
* Render interface and add to the toolbar.
|
||||||
*
|
*
|
||||||
* @param \WP_Admin_Bar $wp_admin_bar WordPress core toolbar object.
|
* @param \WP_Admin_Bar $wp_admin_bar WordPress core toolbar object.
|
||||||
*
|
|
||||||
* @psalm-suppress MixedArgument
|
|
||||||
*/
|
*/
|
||||||
public function admin_bar_menu( \WP_Admin_Bar $wp_admin_bar ): void {
|
public function admin_bar_menu( \WP_Admin_Bar $wp_admin_bar ): void {
|
||||||
|
|
||||||
|
|||||||
@@ -15,8 +15,6 @@ class Mustache_Cache_FrozenCache extends \Mustache_Cache_FilesystemCache {
|
|||||||
* @param string $value Value.
|
* @param string $value Value.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*
|
|
||||||
* @psalm-suppress InvalidScalarArgument
|
|
||||||
*/
|
*/
|
||||||
public function cache( $key, $value ): void {
|
public function cache( $key, $value ): void {
|
||||||
|
|
||||||
|
|||||||
+1
-5
@@ -20,9 +20,7 @@ class Plugin extends Container {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $values Configuration values to apply.
|
* @param array $values Configuration values to apply.
|
||||||
*
|
* @psalm-param array<string, mixed> $values
|
||||||
* @psalm-suppress MixedArgument
|
|
||||||
* @psalm-suppress MixedAssignment
|
|
||||||
*/
|
*/
|
||||||
public function __construct( array $values = [] ) {
|
public function __construct( array $values = [] ) {
|
||||||
|
|
||||||
@@ -63,8 +61,6 @@ class Plugin extends Container {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Start Stopwatch and timing plugin load immediately, then set up core events and needed hooks.
|
* Start Stopwatch and timing plugin load immediately, then set up core events and needed hooks.
|
||||||
*
|
|
||||||
* @psalm-suppress MixedAssignment
|
|
||||||
*/
|
*/
|
||||||
public function run(): void {
|
public function run(): void {
|
||||||
|
|
||||||
|
|||||||
@@ -3,12 +3,13 @@ declare( strict_types=1 );
|
|||||||
|
|
||||||
namespace Rarst\Laps\Provider;
|
namespace Rarst\Laps\Provider;
|
||||||
|
|
||||||
|
use Pimple\ServiceProviderInterface;
|
||||||
use Rarst\Laps\Plugin;
|
use Rarst\Laps\Plugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface for providers that need to boot up once plugin is ready to start.
|
* Interface for providers that need to boot up once plugin is ready to start.
|
||||||
*/
|
*/
|
||||||
interface Bootable_Provider_Interface {
|
interface Bootable_Provider_Interface extends ServiceProviderInterface {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Plugin $laps Container instance.
|
* @param Plugin $laps Container instance.
|
||||||
|
|||||||
@@ -6,9 +6,11 @@ namespace Rarst\Laps\Provider;
|
|||||||
use Pimple\Container;
|
use Pimple\Container;
|
||||||
use Pimple\ServiceProviderInterface;
|
use Pimple\ServiceProviderInterface;
|
||||||
use Rarst\Laps\Event\Core_Events;
|
use Rarst\Laps\Event\Core_Events;
|
||||||
|
use Rarst\Laps\Event\Extension_Events;
|
||||||
use Rarst\Laps\Event\Genesis_Events;
|
use Rarst\Laps\Event\Genesis_Events;
|
||||||
use Rarst\Laps\Event\Hybrid_Events;
|
use Rarst\Laps\Event\Hybrid_Events;
|
||||||
use Rarst\Laps\Event\THA_Events;
|
use Rarst\Laps\Event\THA_Events;
|
||||||
|
use Rarst\Laps\Event\WooCommerce_Events;
|
||||||
use Rarst\Laps\Event\Yoast_Events;
|
use Rarst\Laps\Event\Yoast_Events;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -18,16 +20,20 @@ class Hook_Event_Provider implements ServiceProviderInterface {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Container $pimple Container instance.
|
* @param Container $pimple Container instance.
|
||||||
|
*
|
||||||
|
* @psalm-suppress DeprecatedClass
|
||||||
*/
|
*/
|
||||||
public function register( Container $pimple ): void {
|
public function register( Container $pimple ): void {
|
||||||
|
|
||||||
$pimple['hook.events'] = function (): array {
|
$pimple['hook.events'] = function (): array {
|
||||||
return [
|
return [
|
||||||
'core' => new Core_Events(),
|
'core' => new Core_Events(),
|
||||||
'genesis' => new Genesis_Events(),
|
'extension' => new Extension_Events(),
|
||||||
'hybrid' => new Hybrid_Events(),
|
'genesis' => new Genesis_Events(),
|
||||||
'tha' => new THA_Events(),
|
'hybrid' => new Hybrid_Events(),
|
||||||
'yoast' => new Yoast_Events(),
|
'tha' => new THA_Events(),
|
||||||
|
'woocommerce' => new WooCommerce_Events(),
|
||||||
|
'yoast' => new Yoast_Events(),
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ use Rarst\Laps\Record\Collector\Core_Load_Collector;
|
|||||||
use Rarst\Laps\Record\Collector\Hook_Collector;
|
use Rarst\Laps\Record\Collector\Hook_Collector;
|
||||||
use Rarst\Laps\Record\Collector\Http_Collector;
|
use Rarst\Laps\Record\Collector\Http_Collector;
|
||||||
use Rarst\Laps\Record\Collector\Lazy_Proxy_Collector;
|
use Rarst\Laps\Record\Collector\Lazy_Proxy_Collector;
|
||||||
|
use Rarst\Laps\Record\Collector\Plugin_Load_Collector;
|
||||||
use Rarst\Laps\Record\Collector\Sql_Collector;
|
use Rarst\Laps\Record\Collector\Sql_Collector;
|
||||||
use Symfony\Component\Stopwatch\Stopwatch;
|
use Symfony\Component\Stopwatch\Stopwatch;
|
||||||
|
|
||||||
@@ -29,10 +30,11 @@ class Record_Provider implements ServiceProviderInterface, Bootable_Provider_Int
|
|||||||
|
|
||||||
$pimple['collectors'] = function ( Plugin $laps ): array {
|
$pimple['collectors'] = function ( Plugin $laps ): array {
|
||||||
return [
|
return [
|
||||||
'core' => new Core_Load_Collector(),
|
'core' => new Core_Load_Collector(),
|
||||||
'hook' => new Hook_Collector( $laps['stopwatch'], $laps['hook.events'] ),
|
'hook' => new Hook_Collector( $laps['stopwatch'], $laps['hook.events'] ),
|
||||||
'http' => new Http_Collector( $laps['stopwatch'] ),
|
'plugins' => new Plugin_Load_Collector(),
|
||||||
'sql' => new Sql_Collector(),
|
'http' => new Http_Collector( $laps['stopwatch'] ),
|
||||||
|
'sql' => new Sql_Collector(),
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -14,15 +14,21 @@ class Core_Load_Collector implements Record_Collector_Interface {
|
|||||||
/** @var float $timeload */
|
/** @var float $timeload */
|
||||||
protected $timeload;
|
protected $timeload;
|
||||||
|
|
||||||
|
/** @var bool Flag if Laps is network activated. */
|
||||||
|
private $network_activated;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Store core load end, plugin load start mark.
|
* Store plugin load start mark.
|
||||||
*/
|
*/
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->timeload = microtime( true );
|
$this->timeload = microtime( true );
|
||||||
|
$this->network_activated = ! did_action( 'muplugins_loaded' );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Record_Interface[]
|
* @return Record_Interface[]
|
||||||
|
*
|
||||||
|
* @psalm-suppress PossiblyUndefinedArrayOffset
|
||||||
*/
|
*/
|
||||||
public function get_records(): array {
|
public function get_records(): array {
|
||||||
|
|
||||||
@@ -30,14 +36,44 @@ class Core_Load_Collector implements Record_Collector_Interface {
|
|||||||
|
|
||||||
$request_time = filter_var( $_SERVER['REQUEST_TIME_FLOAT'], FILTER_VALIDATE_FLOAT );
|
$request_time = filter_var( $_SERVER['REQUEST_TIME_FLOAT'], FILTER_VALIDATE_FLOAT );
|
||||||
|
|
||||||
|
$php = 'PHP Load – ' . PHP_VERSION;
|
||||||
|
|
||||||
|
if ( $this->opcache_api_available() ) {
|
||||||
|
/**
|
||||||
|
* This is silenced since it might still emit warning for correct `opcache.resrict_api` configuration.
|
||||||
|
* @see https://github.com/php/php-src/issues/8799
|
||||||
|
*/
|
||||||
|
$zend_status = @opcache_get_status();
|
||||||
|
$php .= empty( $zend_status['opcache_enabled'] ) ? '' : ' – OPcache';
|
||||||
|
}
|
||||||
|
|
||||||
|
$load = $this->network_activated ? 'Core Load' : 'Core & MU Plugins Load';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var float $request_time
|
* @var float $request_time
|
||||||
* @var float $timestart
|
* @var float $timestart
|
||||||
*/
|
*/
|
||||||
return [
|
return [
|
||||||
new Record( 'PHP Load', $request_time, $timestart - $request_time, '', 'php' ),
|
new Record( $php, $request_time, $timestart - $request_time, '', 'php' ),
|
||||||
// TODO This includes network plugins on multisite, need conditional label if Laps is network–activated.
|
new Record( $load, $timestart, $this->timeload - $timestart, '', 'core' ),
|
||||||
new Record( 'Core and MU Plugins Load', $timestart, $this->timeload - $timestart, '', 'core' ),
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function opcache_api_available(): bool {
|
||||||
|
if ( ! function_exists( 'opcache_get_status' ) ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$restrict_api = ini_get( 'opcache.restrict_api' );
|
||||||
|
|
||||||
|
if ( ! $restrict_api ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The paths aren't normalized, because it is unclear if they are in PHP itself
|
||||||
|
* and this should rather be false negative to prevent warning emitted.
|
||||||
|
*/
|
||||||
|
return 0 === stripos( __FILE__, $restrict_api );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -20,12 +20,21 @@ class Hook_Collector extends Stopwatch_Collector {
|
|||||||
/** @var array $events */
|
/** @var array $events */
|
||||||
protected $events = [];
|
protected $events = [];
|
||||||
|
|
||||||
/** @var array */
|
/**
|
||||||
|
* @var array $callbacks
|
||||||
|
* @psalm-var array<string, \WP_Hook> $callbacks
|
||||||
|
*/
|
||||||
protected $callbacks = [];
|
protected $callbacks = [];
|
||||||
|
|
||||||
/** @var Hook_Formatter */
|
/** @var Hook_Formatter */
|
||||||
protected $formatter;
|
protected $formatter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array $calls Tracks number of calls for recurrent events.
|
||||||
|
* @psalm-var array<string, int> $calls
|
||||||
|
*/
|
||||||
|
private $calls = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Stopwatch $stopwatch Stopwatch instance.
|
* @param Stopwatch $stopwatch Stopwatch instance.
|
||||||
* @param Hook_Event_Config_Interface[] $event_configs Starts and stops configuration.
|
* @param Hook_Event_Config_Interface[] $event_configs Starts and stops configuration.
|
||||||
@@ -34,7 +43,12 @@ class Hook_Collector extends Stopwatch_Collector {
|
|||||||
|
|
||||||
parent::__construct( $stopwatch );
|
parent::__construct( $stopwatch );
|
||||||
|
|
||||||
$this->start( 'Plugins Load', 'plugin' );
|
if ( did_action( 'muplugins_loaded' ) ) {
|
||||||
|
$this->start( 'Plugins Load', 'plugin' );
|
||||||
|
} else {
|
||||||
|
$this->start( 'Network & MU Plugins Load', 'plugin' );
|
||||||
|
add_action( 'muplugins_loaded', [ $this, 'muplugins_loaded' ], PHP_INT_MAX );
|
||||||
|
}
|
||||||
$this->add_events( $event_configs['core']->get_events() );
|
$this->add_events( $event_configs['core']->get_events() );
|
||||||
unset( $event_configs['core'] );
|
unset( $event_configs['core'] );
|
||||||
$this->event_configs = $event_configs;
|
$this->event_configs = $event_configs;
|
||||||
@@ -44,6 +58,14 @@ class Hook_Collector extends Stopwatch_Collector {
|
|||||||
$this->formatter = new Hook_Formatter();
|
$this->formatter = new Hook_Formatter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Time the point between network/MU plugins and regular if network activated.
|
||||||
|
*/
|
||||||
|
public function muplugins_loaded(): void {
|
||||||
|
$this->stop( 'Network & MU Plugins Load' );
|
||||||
|
$this->start( 'Plugins Load', 'plugin' );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hook events by name and priority from array.
|
* Hook events by name and priority from array.
|
||||||
*
|
*
|
||||||
@@ -60,7 +82,6 @@ class Hook_Collector extends Stopwatch_Collector {
|
|||||||
foreach ( $stops as $key => $data ) {
|
foreach ( $stops as $key => $data ) {
|
||||||
|
|
||||||
if ( is_int( $key ) ) {
|
if ( is_int( $key ) ) {
|
||||||
/** @var array{0:string} $data */
|
|
||||||
$this->add_event( ...$data );
|
$this->add_event( ...$data );
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -81,6 +102,8 @@ class Hook_Collector extends Stopwatch_Collector {
|
|||||||
* @param string|null $stop Stop hook name (defaults to start name). Pass empty string to ignore.
|
* @param string|null $stop Stop hook name (defaults to start name). Pass empty string to ignore.
|
||||||
* @param int $start_priority Start hook priority (defaults to -1).
|
* @param int $start_priority Start hook priority (defaults to -1).
|
||||||
* @param int $stop_priority Stop hook priority (defaults to max int).
|
* @param int $stop_priority Stop hook priority (defaults to max int).
|
||||||
|
*
|
||||||
|
* @psalm-suppress MissingClosureParamType
|
||||||
*/
|
*/
|
||||||
private function add_event(
|
private function add_event(
|
||||||
string $event,
|
string $event,
|
||||||
@@ -96,13 +119,17 @@ class Hook_Collector extends Stopwatch_Collector {
|
|||||||
|
|
||||||
if ( '' !== $start ) {
|
if ( '' !== $start ) {
|
||||||
add_action( $start, function ( $input = null ) use ( $event, $category, $start, $stop ) {
|
add_action( $start, function ( $input = null ) use ( $event, $category, $start, $stop ) {
|
||||||
|
global $wp_filter;
|
||||||
|
|
||||||
|
$event .= $this->get_count_suffix( $event, true );
|
||||||
|
|
||||||
if ( 'Sidebar' === $event ) {
|
if ( 'Sidebar' === $event ) {
|
||||||
|
/** @var string $input */
|
||||||
$event = $input;
|
$event = $input;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $start === $stop ) {
|
if ( $start === $stop ) {
|
||||||
global $wp_filter;
|
/** @psalm-var array<string, \WP_Hook> $wp_filter */
|
||||||
$this->callbacks[ $event ] = $wp_filter[ $start ];
|
$this->callbacks[ $event ] = $wp_filter[ $start ];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,7 +142,10 @@ class Hook_Collector extends Stopwatch_Collector {
|
|||||||
if ( '' !== $stop ) {
|
if ( '' !== $stop ) {
|
||||||
add_action( $stop, function ( $input = null ) use ( $event ) {
|
add_action( $stop, function ( $input = null ) use ( $event ) {
|
||||||
|
|
||||||
|
$event .= $this->get_count_suffix( $event );
|
||||||
|
|
||||||
if ( 'Sidebar' === $event ) {
|
if ( 'Sidebar' === $event ) {
|
||||||
|
/** @var string $input */
|
||||||
$event = $input;
|
$event = $input;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,6 +156,29 @@ class Hook_Collector extends Stopwatch_Collector {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the suffix to use if event occurs multiple times.
|
||||||
|
*
|
||||||
|
* @param string $event Event name.
|
||||||
|
* @param boolean $increment Flag to increment count.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private function get_count_suffix( string $event, bool $increment = false ): string {
|
||||||
|
|
||||||
|
if ( ! isset( $this->calls[ $event ] ) ) {
|
||||||
|
$this->calls[ $event ] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $increment ) {
|
||||||
|
$this->calls[ $event ] ++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$count = (int) $this->calls[ $event ];
|
||||||
|
|
||||||
|
return $count > 1 ? " ({$count})" : '';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When theme is done possibly add vendor-specific events.
|
* When theme is done possibly add vendor-specific events.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -16,7 +16,10 @@ class Http_Collector extends Stopwatch_Collector {
|
|||||||
/** @var Backtrace_Formatter */
|
/** @var Backtrace_Formatter */
|
||||||
private $formatter;
|
private $formatter;
|
||||||
|
|
||||||
/** @var array */
|
/**
|
||||||
|
* @var array $callers
|
||||||
|
* @psalm-var array<string, string> $callers
|
||||||
|
*/
|
||||||
private $callers = [];
|
private $callers = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -35,16 +38,21 @@ class Http_Collector extends Stopwatch_Collector {
|
|||||||
/**
|
/**
|
||||||
* Capture start time of HTTP request
|
* Capture start time of HTTP request
|
||||||
*
|
*
|
||||||
* @param boolean $false Whether to preempt an HTTP request's return value. Default false.
|
* @param false|array|\WP_Error $false Whether to preempt an HTTP request's return value. Default false.
|
||||||
* @param array $args HTTP request arguments.
|
* @param array $args HTTP request arguments.
|
||||||
* @param string $url The request URL.
|
* @param string $url The request URL.
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return false|array|\WP_Error
|
||||||
|
*
|
||||||
|
* @psalm-suppress RedundantCondition
|
||||||
|
* @noinspection PhpUnusedParameterInspection
|
||||||
*/
|
*/
|
||||||
public function pre_http_request( bool $false, array $args, string $url ): bool {
|
public function pre_http_request( $false, $args, $url ) {
|
||||||
|
|
||||||
$this->start( $url, 'http' );
|
if ( $url && is_string( $url ) ) {
|
||||||
$this->callers[ $url ] = wp_debug_backtrace_summary( __CLASS__, 5, true );
|
$this->start( $url, 'http' );
|
||||||
|
$this->callers[ $url ] = wp_debug_backtrace_summary( __CLASS__, 5 );
|
||||||
|
}
|
||||||
|
|
||||||
return $false;
|
return $false;
|
||||||
}
|
}
|
||||||
@@ -58,13 +66,16 @@ class Http_Collector extends Stopwatch_Collector {
|
|||||||
* @param array $args HTTP request arguments.
|
* @param array $args HTTP request arguments.
|
||||||
* @param string $url The request URL.
|
* @param string $url The request URL.
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return array|\WP_Error
|
||||||
*
|
*
|
||||||
* @noinspection MoreThanThreeArgumentsInspection
|
* @psalm-suppress RedundantCondition
|
||||||
|
* @noinspection PhpUnusedParameterInspection
|
||||||
*/
|
*/
|
||||||
public function http_api_debug( $response, string $type, $class, array $args, string $url ) {
|
public function http_api_debug( $response, $type, $class, $args, $url ) {
|
||||||
|
|
||||||
$this->stop( $url );
|
if ( $url && is_string( $url ) ) {
|
||||||
|
$this->stop( $url );
|
||||||
|
}
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,76 @@
|
|||||||
|
<?php
|
||||||
|
declare( strict_types=1 );
|
||||||
|
|
||||||
|
namespace Rarst\Laps\Record\Collector;
|
||||||
|
|
||||||
|
use Rarst\Laps\Record\Record;
|
||||||
|
use Rarst\Laps\Record\Record_Interface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tracks load time of individual plugins.
|
||||||
|
*/
|
||||||
|
class Plugin_Load_Collector implements Record_Collector_Interface {
|
||||||
|
|
||||||
|
/** @var float */
|
||||||
|
private $last;
|
||||||
|
|
||||||
|
/** @var array */
|
||||||
|
private $entries = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets up start time and tracking callbacks.
|
||||||
|
*/
|
||||||
|
public function __construct() {
|
||||||
|
$this->last = microtime( true );
|
||||||
|
|
||||||
|
add_action( 'network_plugin_loaded', [ $this, 'plugin_loaded' ] );
|
||||||
|
add_action( 'plugin_loaded', [ $this, 'plugin_loaded' ] );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Records time for a plugin that just finished loading.
|
||||||
|
*
|
||||||
|
* @param string $plugin Plugin file path.
|
||||||
|
*
|
||||||
|
* @psalm-suppress DocblockTypeContradiction
|
||||||
|
*/
|
||||||
|
public function plugin_loaded( $plugin ): void {
|
||||||
|
|
||||||
|
$time = microtime( true );
|
||||||
|
|
||||||
|
if ( ! is_string( $plugin ) ) { // Broken hook input from global.
|
||||||
|
$this->last = $time;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->entries[] = [
|
||||||
|
'name' => $plugin,
|
||||||
|
'origin' => $this->last,
|
||||||
|
'duration' => $time - $this->last,
|
||||||
|
];
|
||||||
|
$this->last = $time;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Record_Interface[]
|
||||||
|
*/
|
||||||
|
public function get_records(): array {
|
||||||
|
return array_map( [ $this, 'create_record' ], $this->entries );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts recorded information into a Record instance.
|
||||||
|
*
|
||||||
|
* @param array $entry Data entry for the plugin.
|
||||||
|
*/
|
||||||
|
private function create_record( array $entry ): Record {
|
||||||
|
return new Record(
|
||||||
|
plugin_basename( $entry['name'] ),
|
||||||
|
$entry['origin'],
|
||||||
|
$entry['duration'],
|
||||||
|
'',
|
||||||
|
'plugin'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,6 +8,8 @@ use Rarst\Laps\Record\Record;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Processes SQL events from data logged by wpdb.
|
* Processes SQL events from data logged by wpdb.
|
||||||
|
*
|
||||||
|
* @template QueryData as array{0: string, 1: float, 2: string, 3: float}
|
||||||
*/
|
*/
|
||||||
class Sql_Collector implements Record_Collector_Interface {
|
class Sql_Collector implements Record_Collector_Interface {
|
||||||
|
|
||||||
@@ -25,7 +27,7 @@ class Sql_Collector implements Record_Collector_Interface {
|
|||||||
$this->formatter = new Backtrace_Formatter();
|
$this->formatter = new Backtrace_Formatter();
|
||||||
|
|
||||||
if ( $this->is_savequeries() ) {
|
if ( $this->is_savequeries() ) {
|
||||||
add_filter( 'query', [ $this, 'query' ], 20 ); // TODO refactor when core provides time start data in 5.0.
|
add_filter( 'query', [ $this, 'query' ], 20 ); // TODO Drop recording time if dropping support for WP <5.1.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,8 +37,6 @@ class Sql_Collector implements Record_Collector_Interface {
|
|||||||
* @param string $query SQL query.
|
* @param string $query SQL query.
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*
|
|
||||||
* @psalm-suppress MixedPropertyFetch
|
|
||||||
*/
|
*/
|
||||||
public function query( $query ): string {
|
public function query( $query ): string {
|
||||||
|
|
||||||
@@ -64,7 +64,11 @@ class Sql_Collector implements Record_Collector_Interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @var array $wpdb->queries */
|
/** @var array $wpdb->queries */
|
||||||
return array_map( [ $this, 'transform' ], array_keys( $wpdb->queries ), $wpdb->queries );
|
/** @psalm-var array<int, QueryData> $wpdb->queries */
|
||||||
|
/** @psalm-suppress PossiblyInvalidArgument */
|
||||||
|
$records = array_filter( array_map( [ $this, 'transform' ], array_keys( $wpdb->queries ), $wpdb->queries ) );
|
||||||
|
|
||||||
|
return $records;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -80,25 +84,24 @@ class Sql_Collector implements Record_Collector_Interface {
|
|||||||
*
|
*
|
||||||
* @param int $key Query key in captured data.
|
* @param int $key Query key in captured data.
|
||||||
* @param array $query_data Array of captured query data.
|
* @param array $query_data Array of captured query data.
|
||||||
* @psalm-param array{0: string, 1: float, 2: string} $query_data
|
* @psalm-param array{0: string, 1: float, 2: string, 3: float} $query_data
|
||||||
*
|
*
|
||||||
* @return Record
|
* @return Record
|
||||||
*/
|
*/
|
||||||
protected function transform( int $key, array $query_data ): Record {
|
protected function transform( int $key, array $query_data ): ?Record {
|
||||||
|
|
||||||
static $last_query_end = 0;
|
|
||||||
|
|
||||||
[ $sql, $duration, $caller ] = $query_data;
|
[ $sql, $duration, $caller ] = $query_data;
|
||||||
|
|
||||||
/** @var float $query_start */
|
/** @var float $query_start */
|
||||||
$query_start = $this->query_starts[ $key ] ?? $last_query_end;
|
$query_start = $query_data[3] ?? $this->query_starts[ $key ] ?? 0;
|
||||||
|
if ( empty( $query_start ) ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
$sql = trim( $sql );
|
$sql = trim( $sql );
|
||||||
$category = 'sql-read';
|
$category = 'sql-read';
|
||||||
if ( 0 === stripos( $sql, 'INSERT' ) || 0 === stripos( $sql, 'UPDATE' ) ) {
|
if ( 0 === stripos( $sql, 'INSERT' ) || 0 === stripos( $sql, 'UPDATE' ) ) {
|
||||||
$category = 'sql-write';
|
$category = 'sql-write';
|
||||||
}
|
}
|
||||||
$last_query_end = $query_start + $duration;
|
|
||||||
|
|
||||||
$desc_duration = round( $duration * 1000 );
|
$desc_duration = round( $duration * 1000 );
|
||||||
$backtrace = $this->formatter->format( $caller );
|
$backtrace = $this->formatter->format( $caller );
|
||||||
$description = $sql . ' – ' . $desc_duration . 'ms<hr />' . implode( '<br />', $backtrace );
|
$description = $sql . ' – ' . $desc_duration . 'ms<hr />' . implode( '<br />', $backtrace );
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ class Stopwatch_Collector implements Record_Collector_Interface {
|
|||||||
*/
|
*/
|
||||||
public function get_records(): array {
|
public function get_records(): array {
|
||||||
|
|
||||||
|
/** @psalm-var array<string, StopwatchEvent> $events */
|
||||||
$events = $this->stopwatch->getSectionEvents( '__root__' );
|
$events = $this->stopwatch->getSectionEvents( '__root__' );
|
||||||
|
|
||||||
/** @var string $name */
|
/** @var string $name */
|
||||||
@@ -60,6 +61,7 @@ class Stopwatch_Collector implements Record_Collector_Interface {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @psalm-suppress PossiblyInvalidArgument */
|
||||||
return array_map( [ $this, 'transform' ], array_keys( $events ), $events );
|
return array_map( [ $this, 'transform' ], array_keys( $events ), $events );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,11 @@ use Rarst\Laps\Record\Record_Interface;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Processes records, recursively bumping overlapping ones to children.
|
* Processes records, recursively bumping overlapping ones to children.
|
||||||
|
*
|
||||||
|
* @template-extends \ArrayIterator<array-key,Record_Interface>
|
||||||
|
* @template-implements \RecursiveIterator<array-key,Record_Interface>
|
||||||
|
*
|
||||||
|
* @psalm-suppress TooManyTemplateParams
|
||||||
*/
|
*/
|
||||||
class Recursive_Record_Iterator extends \ArrayIterator implements \RecursiveIterator {
|
class Recursive_Record_Iterator extends \ArrayIterator implements \RecursiveIterator {
|
||||||
|
|
||||||
@@ -15,7 +20,7 @@ class Recursive_Record_Iterator extends \ArrayIterator implements \RecursiveIter
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Record_Interface[] $records Records to process.
|
* @param Record_Interface[] $records Records to process.
|
||||||
* @param int $flags Configuration flags.
|
* @psalm-param 0|1|2|3 $flags Configuration flags.
|
||||||
*/
|
*/
|
||||||
public function __construct( array $records, int $flags = 0 ) {
|
public function __construct( array $records, int $flags = 0 ) {
|
||||||
|
|
||||||
@@ -67,10 +72,10 @@ class Recursive_Record_Iterator extends \ArrayIterator implements \RecursiveIter
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return static
|
* This should be `static` for possible subclassing, but problems hinting that for PHP <8, also don't subclass this.
|
||||||
*/
|
*/
|
||||||
public function getChildren() {
|
public function getChildren(): self {
|
||||||
|
|
||||||
return new static( $this->children );
|
return new self( $this->children );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,12 +5,13 @@ namespace Rarst\Laps\Record\Iterator;
|
|||||||
|
|
||||||
use Rarst\Laps\Record\Record;
|
use Rarst\Laps\Record\Record;
|
||||||
use Rarst\Laps\Record\Record_Interface;
|
use Rarst\Laps\Record\Record_Interface;
|
||||||
use Rarst\Laps\Record\Iterator\Recursive_Record_Iterator;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Processes records into sets for display by template.
|
* Processes records into sets for display by template.
|
||||||
*
|
*
|
||||||
* @psalm-suppress PropertyNotSetInConstructor
|
* @template-implements \Iterator<array>
|
||||||
|
*
|
||||||
|
* @psalm-suppress PropertyNotSetInConstructor, TooManyTemplateParams
|
||||||
*/
|
*/
|
||||||
class Timeline_Iterator implements \Iterator {
|
class Timeline_Iterator implements \Iterator {
|
||||||
|
|
||||||
@@ -29,7 +30,7 @@ class Timeline_Iterator implements \Iterator {
|
|||||||
/**
|
/**
|
||||||
* @param Recursive_Record_Iterator $iterator Record iterator.
|
* @param Recursive_Record_Iterator $iterator Record iterator.
|
||||||
*
|
*
|
||||||
* @psalm-suppress PossiblyFalsePropertyAssignmentValue
|
* @psalm-suppress PossiblyFalsePropertyAssignmentValue, PossiblyUndefinedArrayOffset
|
||||||
*/
|
*/
|
||||||
public function __construct( Recursive_Record_Iterator $iterator ) {
|
public function __construct( Recursive_Record_Iterator $iterator ) {
|
||||||
|
|
||||||
@@ -60,12 +61,14 @@ class Timeline_Iterator implements \Iterator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Key is unused and is only type hinted to possible `int` for PHP 8.1 `mixed` type compatibility.
|
||||||
|
*
|
||||||
* @codeCoverageIgnore
|
* @codeCoverageIgnore
|
||||||
*
|
*
|
||||||
* @return void
|
* @return null
|
||||||
*/
|
*/
|
||||||
public function key(): void {
|
public function key(): ?int {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ class Stopwatch_Record implements Record_Interface {
|
|||||||
public function get_description(): string {
|
public function get_description(): string {
|
||||||
|
|
||||||
$duration = round( $this->stopwatch_event->getDuration() );
|
$duration = round( $this->stopwatch_event->getDuration() );
|
||||||
$memory = $this->stopwatch_event->getMemory() / 1024 / 1024;
|
$memory = round( $this->stopwatch_event->getMemory() / 1024 / 1024, 2 );
|
||||||
$description = '' !== $this->description ? "<hr />{$this->description}" : '';
|
$description = '' !== $this->description ? "<hr />{$this->description}" : '';
|
||||||
|
|
||||||
return "{$this->name} – {$duration} ms – {$memory} MB{$description}";
|
return "{$this->name} – {$duration} ms – {$memory} MB{$description}";
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ use Rarst\Laps\Event\Core_Events;
|
|||||||
use Rarst\Laps\Event\Genesis_Events;
|
use Rarst\Laps\Event\Genesis_Events;
|
||||||
use Rarst\Laps\Event\Hybrid_Events;
|
use Rarst\Laps\Event\Hybrid_Events;
|
||||||
use Rarst\Laps\Event\THA_Events;
|
use Rarst\Laps\Event\THA_Events;
|
||||||
|
use Rarst\Laps\Event\WooCommerce_Events;
|
||||||
use Rarst\Laps\Event\Yoast_Events;
|
use Rarst\Laps\Event\Yoast_Events;
|
||||||
use Rarst\Laps\Tests\LapsTestCase;
|
use Rarst\Laps\Tests\LapsTestCase;
|
||||||
|
|
||||||
@@ -16,7 +17,7 @@ class EventTest extends LapsTestCase {
|
|||||||
|
|
||||||
$events = ( new Core_Events() )->get_events();
|
$events = ( new Core_Events() )->get_events();
|
||||||
|
|
||||||
$this->assertInternalType( 'array', $events );
|
$this->assertIsArray( $events );
|
||||||
$this->assertNotEmpty( $events );
|
$this->assertNotEmpty( $events );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -28,7 +29,7 @@ class EventTest extends LapsTestCase {
|
|||||||
Functions\expect( 'genesis' )->zeroOrMoreTimes();
|
Functions\expect( 'genesis' )->zeroOrMoreTimes();
|
||||||
$events = $genesis->get_events();
|
$events = $genesis->get_events();
|
||||||
|
|
||||||
$this->assertInternalType( 'array', $events );
|
$this->assertIsArray( $events );
|
||||||
$this->assertNotEmpty( $events );
|
$this->assertNotEmpty( $events );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,7 +46,7 @@ class EventTest extends LapsTestCase {
|
|||||||
|
|
||||||
$events = $hybrid->get_events();
|
$events = $hybrid->get_events();
|
||||||
|
|
||||||
$this->assertInternalType( 'array', $events );
|
$this->assertIsArray( $events );
|
||||||
$this->assertNotEmpty( $events );
|
$this->assertNotEmpty( $events );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,7 +59,20 @@ class EventTest extends LapsTestCase {
|
|||||||
|
|
||||||
$events = $tha->get_events();
|
$events = $tha->get_events();
|
||||||
|
|
||||||
$this->assertInternalType( 'array', $events );
|
$this->assertIsArray( $events );
|
||||||
|
$this->assertNotEmpty( $events );
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testWooCommerce() {
|
||||||
|
|
||||||
|
$woocommerce = new WooCommerce_Events();
|
||||||
|
$this->assertEmpty( $woocommerce->get_events() );
|
||||||
|
|
||||||
|
$this->getMockBuilder( 'WooCommerce' )->allowMockingUnknownTypes()->getMock();
|
||||||
|
|
||||||
|
$events = $woocommerce->get_events();
|
||||||
|
|
||||||
|
$this->assertIsArray( $events );
|
||||||
$this->assertNotEmpty( $events );
|
$this->assertNotEmpty( $events );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,7 +85,7 @@ class EventTest extends LapsTestCase {
|
|||||||
|
|
||||||
$events = $yoast->get_events();
|
$events = $yoast->get_events();
|
||||||
|
|
||||||
$this->assertInternalType( 'array', $events );
|
$this->assertIsArray( $events );
|
||||||
$this->assertNotEmpty( $events );
|
$this->assertNotEmpty( $events );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -51,8 +51,10 @@ class BacktraceTest extends LapsTestCase {
|
|||||||
|
|
||||||
$result = $formatter->format( $backtrace );
|
$result = $formatter->format( $backtrace );
|
||||||
|
|
||||||
$this->assertInternalType( 'array', $result );
|
$this->assertIsArray( $result );
|
||||||
$this->assertArraySubset( [ 'foo', 'path.php' ], array_values( $result ) );
|
$result = array_values( $result );
|
||||||
|
$this->assertEquals( 'foo', $result[0] );
|
||||||
|
$this->assertEquals( 'path.php', $result[1] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,10 +50,13 @@ class HookTest extends LapsTestCase {
|
|||||||
|
|
||||||
$result = $formatter->format( $hook );
|
$result = $formatter->format( $hook );
|
||||||
|
|
||||||
$this->assertInternalType( 'array', $result );
|
$this->assertIsArray( $result );
|
||||||
$this->assertArraySubset( [ 'function(2)', 'class::method' ], $result );
|
$this->assertEquals( 'function(2)', $result[0] );
|
||||||
|
$this->assertEquals( 'class::method', $result[1] );
|
||||||
$this->assertStringStartsWith( 'closure from', $result[2] );
|
$this->assertStringStartsWith( 'closure from', $result[2] );
|
||||||
$this->assertStringStartsWith( 'anonymous class from', $result[3] );
|
$this->assertStringStartsWith( 'anonymous class from', $result[3] );
|
||||||
|
|
||||||
|
$this->assertEquals( [], $formatter->format( [] ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -10,12 +10,12 @@ class LapsTestCase extends TestCase {
|
|||||||
|
|
||||||
use MockeryPHPUnitIntegration;
|
use MockeryPHPUnitIntegration;
|
||||||
|
|
||||||
protected function setUp() {
|
protected function setUp():void {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
Monkey\setUp();
|
Monkey\setUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function tearDown() {
|
protected function tearDown(): void {
|
||||||
Monkey\tearDown();
|
Monkey\tearDown();
|
||||||
parent::tearDown();
|
parent::tearDown();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ class AssetTest extends LapsTestCase {
|
|||||||
|
|
||||||
$manager = new Asset_Manager();
|
$manager = new Asset_Manager();
|
||||||
|
|
||||||
$this->assertTrue( has_action( 'wp_enqueue_scripts', [ $manager, 'enqueue_scripts' ] ) );
|
$this->assertTrue( (bool) has_action( 'wp_enqueue_scripts', [ $manager, 'enqueue_scripts' ] ) );
|
||||||
$this->assertTrue( has_action( 'admin_enqueue_scripts', [ $manager, 'enqueue_scripts' ] ) );
|
$this->assertTrue( (bool) has_action( 'admin_enqueue_scripts', [ $manager, 'enqueue_scripts' ] ) );
|
||||||
|
|
||||||
return $manager;
|
return $manager;
|
||||||
}
|
}
|
||||||
@@ -36,9 +36,33 @@ class AssetTest extends LapsTestCase {
|
|||||||
Functions\expect( 'wp_register_style' )->once();
|
Functions\expect( 'wp_register_style' )->once();
|
||||||
Functions\expect( 'plugins_url' )->zeroOrMoreTimes();
|
Functions\expect( 'plugins_url' )->zeroOrMoreTimes();
|
||||||
Functions\expect( 'is_admin_bar_showing' )->once()->andReturn( true );
|
Functions\expect( 'is_admin_bar_showing' )->once()->andReturn( true );
|
||||||
|
Functions\expect( 'current_user_can' )
|
||||||
|
->once()
|
||||||
|
->with( 'manage_options' )
|
||||||
|
->andReturn( true );
|
||||||
Functions\expect( 'wp_enqueue_script' )->once();
|
Functions\expect( 'wp_enqueue_script' )->once();
|
||||||
Functions\expect( 'wp_enqueue_style' )->once();
|
Functions\expect( 'wp_enqueue_style' )->once();
|
||||||
|
|
||||||
$manager->enqueue_scripts();
|
$manager->enqueue_scripts();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers ::enqueue_scripts
|
||||||
|
* @depends test__construct
|
||||||
|
*/
|
||||||
|
public function testEnqueue_scripts_hidden( Asset_Manager $manager ) {
|
||||||
|
|
||||||
|
Functions\expect( 'wp_register_script' )->once();
|
||||||
|
Functions\expect( 'wp_register_style' )->once();
|
||||||
|
Functions\expect( 'plugins_url' )->zeroOrMoreTimes();
|
||||||
|
Functions\expect( 'is_admin_bar_showing' )->once()->andReturn( true );
|
||||||
|
Functions\expect( 'current_user_can' )
|
||||||
|
->once()
|
||||||
|
->with( 'manage_options' )
|
||||||
|
->andReturn( false );
|
||||||
|
Functions\expect( 'wp_enqueue_script' )->never();
|
||||||
|
Functions\expect( 'wp_enqueue_style' )->never();
|
||||||
|
|
||||||
|
$manager->enqueue_scripts();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -20,8 +20,8 @@ class LoadOrderTest extends LapsTestCase {
|
|||||||
|
|
||||||
$manager = new Load_Order_Manager();
|
$manager = new Load_Order_Manager();
|
||||||
|
|
||||||
$this->assertTrue( has_action( 'pre_update_option_active_plugins', [ $manager, 'pre_update_option_active_plugins' ] ) );
|
$this->assertTrue( (bool) has_action( 'pre_update_option_active_plugins', [ $manager, 'pre_update_option_active_plugins' ] ) );
|
||||||
$this->assertTrue( has_action( 'pre_update_site_option_active_sitewide_plugins', [ $manager, 'pre_update_option_active_plugins' ] ) );
|
$this->assertTrue( (bool) has_action( 'pre_update_site_option_active_sitewide_plugins', [ $manager, 'pre_update_option_active_plugins' ] ) );
|
||||||
|
|
||||||
return $manager;
|
return $manager;
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ class LoadOrderTest extends LapsTestCase {
|
|||||||
|
|
||||||
$plugins = $manager->pre_update_option_active_plugins( $plugins );
|
$plugins = $manager->pre_update_option_active_plugins( $plugins );
|
||||||
|
|
||||||
$this->assertInternalType( 'array', $plugins );
|
$this->assertIsArray( $plugins );
|
||||||
$this->assertCount( 3, $plugins );
|
$this->assertCount( 3, $plugins );
|
||||||
$this->assertEquals( 'laps/laps.php', $plugins[0] );
|
$this->assertEquals( 'laps/laps.php', $plugins[0] );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class ToolbarTest extends LapsTestCase {
|
|||||||
$collector = new Lazy_Proxy_Collector( [] );
|
$collector = new Lazy_Proxy_Collector( [] );
|
||||||
$manager = new Toolbar_Manager( $collector, new \Mustache_Engine() );
|
$manager = new Toolbar_Manager( $collector, new \Mustache_Engine() );
|
||||||
|
|
||||||
$this->assertTrue( has_action( 'admin_bar_menu', [ $manager, 'admin_bar_menu' ] ) );
|
$this->assertTrue( (bool) has_action( 'admin_bar_menu', [ $manager, 'admin_bar_menu' ] ) );
|
||||||
|
|
||||||
return $manager;
|
return $manager;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
namespace Rarst\Laps\Tests;
|
namespace Rarst\Laps\Tests;
|
||||||
|
|
||||||
use Brain\Monkey\Functions;
|
use Brain\Monkey\Functions;
|
||||||
use Pimple\ServiceProviderInterface;
|
|
||||||
use Rarst\Laps\Provider\Bootable_Provider_Interface;
|
use Rarst\Laps\Provider\Bootable_Provider_Interface;
|
||||||
|
|
||||||
class PluginTest extends LapsTestCase {
|
class PluginTest extends LapsTestCase {
|
||||||
@@ -12,7 +11,7 @@ class PluginTest extends LapsTestCase {
|
|||||||
|
|
||||||
$container = new \Rarst\Laps\Plugin();
|
$container = new \Rarst\Laps\Plugin();
|
||||||
|
|
||||||
$service = $this->getMockBuilder( [ ServiceProviderInterface::class, Bootable_Provider_Interface::class ] )
|
$service = $this->getMockBuilder( Bootable_Provider_Interface::class )
|
||||||
->getMock();
|
->getMock();
|
||||||
|
|
||||||
$service->expects( $this->once() )
|
$service->expects( $this->once() )
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ class CoreTest extends LapsTestCase {
|
|||||||
|
|
||||||
$records = $collector->get_records();
|
$records = $collector->get_records();
|
||||||
|
|
||||||
$this->assertInternalType( 'array', $records );
|
$this->assertIsArray( $records );
|
||||||
$this->assertCount( 2, $records );
|
$this->assertCount( 2, $records );
|
||||||
$this->assertInstanceOf( Record_Interface::class, $records[0] );
|
$this->assertInstanceOf( Record_Interface::class, $records[0] );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,10 +18,9 @@ class HookTest extends LapsTestCase {
|
|||||||
$stopwatch = new Stopwatch();
|
$stopwatch = new Stopwatch();
|
||||||
$collector = new Hook_Collector( $stopwatch, [ 'core' => new Core_Events() ] );
|
$collector = new Hook_Collector( $stopwatch, [ 'core' => new Core_Events() ] );
|
||||||
|
|
||||||
$this->assertTrue( $stopwatch->isStarted( 'Plugins Load' ) );
|
$this->assertTrue( (bool) has_action( 'after_setup_theme', [ $collector, 'after_setup_theme' ] ) );
|
||||||
$this->assertTrue( has_action( 'after_setup_theme', [ $collector, 'after_setup_theme' ] ) );
|
|
||||||
|
|
||||||
$this->assertTrue( has_action( 'plugins_loaded', 'function ($input)' ) );
|
$this->assertTrue( (bool) has_action( 'plugins_loaded', 'function ($input)' ) );
|
||||||
|
|
||||||
$collector->after_setup_theme();
|
$collector->after_setup_theme();
|
||||||
$stopwatch->start( 'Toolbar' );
|
$stopwatch->start( 'Toolbar' );
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ class HttpTest extends LapsTestCase {
|
|||||||
$url = 'https://example.com/';
|
$url = 'https://example.com/';
|
||||||
$collector = new Http_Collector( $stopwatch );
|
$collector = new Http_Collector( $stopwatch );
|
||||||
|
|
||||||
$this->assertTrue( has_action( 'pre_http_request', [ $collector, 'pre_http_request' ] ) );
|
$this->assertTrue( (bool) has_action( 'pre_http_request', [ $collector, 'pre_http_request' ] ) );
|
||||||
$this->assertTrue( has_action( 'http_api_debug', [ $collector, 'http_api_debug' ] ) );
|
$this->assertTrue( (bool) has_action( 'http_api_debug', [ $collector, 'http_api_debug' ] ) );
|
||||||
|
|
||||||
$collector->pre_http_request( false, [], $url );
|
$collector->pre_http_request( false, [], $url );
|
||||||
|
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ class IteratorTest extends LapsTestCase {
|
|||||||
$this->assertTrue( $iterator->valid() );
|
$this->assertTrue( $iterator->valid() );
|
||||||
|
|
||||||
$records = $iterator->current();
|
$records = $iterator->current();
|
||||||
$this->assertInternalType( 'array', $records );
|
$this->assertIsArray( $records );
|
||||||
|
|
||||||
$this->assertArrayHasKey( 'description', $records[0] );
|
$this->assertArrayHasKey( 'description', $records[0] );
|
||||||
$this->assertArrayHasKey( 'category', $records[0] );
|
$this->assertArrayHasKey( 'category', $records[0] );
|
||||||
@@ -64,7 +64,7 @@ class IteratorTest extends LapsTestCase {
|
|||||||
$this->assertTrue( $iterator->valid() );
|
$this->assertTrue( $iterator->valid() );
|
||||||
|
|
||||||
$records = $iterator->current();
|
$records = $iterator->current();
|
||||||
$this->assertInternalType( 'array', $records );
|
$this->assertIsArray( $records );
|
||||||
|
|
||||||
$iterator->next();
|
$iterator->next();
|
||||||
$this->assertFalse( $iterator->valid() );
|
$this->assertFalse( $iterator->valid() );
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ class RecordTest extends LapsTestCase {
|
|||||||
$this->assertEquals( $name, $record->get_name() );
|
$this->assertEquals( $name, $record->get_name() );
|
||||||
$this->assertEquals( $origin, $record->get_origin() );
|
$this->assertEquals( $origin, $record->get_origin() );
|
||||||
$this->assertEquals( $duration, $record->get_duration() );
|
$this->assertEquals( $duration, $record->get_duration() );
|
||||||
$this->assertContains( $name, $record->get_description() );
|
$this->assertStringContainsString( $name, $record->get_description() );
|
||||||
$this->assertContains( (string) ( $duration * 1000 ), $record->get_description() );
|
$this->assertStringContainsString( (string) ( $duration * 1000 ), $record->get_description() );
|
||||||
$this->assertEmpty( $record->get_category() );
|
$this->assertEmpty( $record->get_category() );
|
||||||
|
|
||||||
$record = new Record( $name, $origin, $duration, $description, $category );
|
$record = new Record( $name, $origin, $duration, $description, $category );
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class SqlTest extends LapsTestCase {
|
|||||||
|
|
||||||
$collector = new Sql_Collector();
|
$collector = new Sql_Collector();
|
||||||
|
|
||||||
$this->assertTrue( has_filter( 'query', [ $collector, 'query' ] ) );
|
$this->assertTrue( (bool) has_filter( 'query', [ $collector, 'query' ] ) );
|
||||||
|
|
||||||
$query = 'SELECT * FROM wp_posts';
|
$query = 'SELECT * FROM wp_posts';
|
||||||
|
|
||||||
@@ -38,15 +38,15 @@ class SqlTest extends LapsTestCase {
|
|||||||
|
|
||||||
$records = $collector->get_records();
|
$records = $collector->get_records();
|
||||||
|
|
||||||
$this->assertInternalType( 'array', $records );
|
$this->assertIsArray( $records );
|
||||||
$this->assertCount( 1, $records );
|
$this->assertCount( 1, $records );
|
||||||
|
|
||||||
$record = $records[0];
|
$record = $records[0];
|
||||||
|
|
||||||
$this->assertInstanceOf( Record::class, $record );
|
$this->assertInstanceOf( Record::class, $record );
|
||||||
$this->assertEquals( $query, $record->get_name() );
|
$this->assertEquals( $query, $record->get_name() );
|
||||||
$this->assertContains( $query, $record->get_description() );
|
$this->assertStringContainsString( $query, $record->get_description() );
|
||||||
$this->assertInternalType( 'float', $record->get_origin() );
|
$this->assertIsFloat( $record->get_origin() );
|
||||||
$this->assertEquals( $duration, $record->get_duration() );
|
$this->assertEquals( $duration, $record->get_duration() );
|
||||||
$this->assertEquals( 'sql-read', $record->get_category() );
|
$this->assertEquals( 'sql-read', $record->get_category() );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class StopwatchTest extends LapsTestCase {
|
|||||||
|
|
||||||
$records = $collector->get_records();
|
$records = $collector->get_records();
|
||||||
|
|
||||||
$this->assertInternalType( 'array', $records );
|
$this->assertIsArray( $records );
|
||||||
$this->assertCount( 1, $records );
|
$this->assertCount( 1, $records );
|
||||||
$this->assertInstanceOf( Stopwatch_Record::class, $records[0] );
|
$this->assertInstanceOf( Stopwatch_Record::class, $records[0] );
|
||||||
|
|
||||||
@@ -47,6 +47,6 @@ class StopwatchTest extends LapsTestCase {
|
|||||||
$this->assertEquals( 'info', $record->get_category() );
|
$this->assertEquals( 'info', $record->get_category() );
|
||||||
$this->assertEquals( $event->getOrigin() / 1000, $record->get_origin() );
|
$this->assertEquals( $event->getOrigin() / 1000, $record->get_origin() );
|
||||||
$this->assertEquals( $event->getDuration() / 1000, $record->get_duration() );
|
$this->assertEquals( $event->getDuration() / 1000, $record->get_duration() );
|
||||||
$this->assertContains( 'Event', $record->get_description() );
|
$this->assertStringContainsString( 'Event', $record->get_description() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user