1 parent
739ed7dd90
commit
ba72763486
3 files changed
+11
No files matched your search
@@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
### Changed
|
||||
- unit tests for PHPUnit 8
|
||||
|
||||
### Fixed
|
||||
- error when formatting empty hook.
|
||||
|
||||
## 3.2 - 2019-01-30
|
||||
|
||||
### Added
|
||||
|
||||
@@ -16,6 +16,7 @@ class Hook_Formatter {
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
// TODO inject paths instead of reaching for global constants.
|
||||
$this->truncate_paths = [
|
||||
wp_normalize_path( WP_CONTENT_DIR ),
|
||||
wp_normalize_path( ABSPATH ),
|
||||
@@ -35,6 +36,11 @@ class Hook_Formatter {
|
||||
if ( $hook instanceof \WP_Hook ) {
|
||||
$hook = $hook->callbacks;
|
||||
}
|
||||
|
||||
if ( empty( $hook ) ) {
|
||||
return $callbacks;
|
||||
}
|
||||
|
||||
ksort( $hook );
|
||||
|
||||
$functions = array_merge( ...$hook );
|
||||
|
||||
@@ -55,6 +55,8 @@ class HookTest extends LapsTestCase {
|
||||
$this->assertEquals( 'class::method', $result[1] );
|
||||
$this->assertStringStartsWith( 'closure from', $result[2] );
|
||||
$this->assertStringStartsWith( 'anonymous class from', $result[3] );
|
||||
|
||||
$this->assertEquals( [], $formatter->format( [] ) );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user