From 2e1b9285a24273f89ef032bae03a282d7bf7d4e4 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Mon, 7 Oct 2013 10:40:40 -0400 Subject: [PATCH] Remove dependency on WP_CLI --- class-wordpress-readme-parser.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/class-wordpress-readme-parser.php b/class-wordpress-readme-parser.php index 10c21fe..08e121d 100644 --- a/class-wordpress-readme-parser.php +++ b/class-wordpress-readme-parser.php @@ -38,7 +38,9 @@ function __construct( $args = array() ) { $readme_txt_rest = $matches[4]; $this->metadata = array_fill_keys( array( 'Contributors', 'Tags', 'Requires at least', 'Tested up to', 'Stable tag', 'License', 'License URI' ), null ); foreach ( explode( "\n", $matches[2] ) as $metadatum ) { - preg_match( '/^(.+?):\s+(.+)$/', $metadatum, $metadataum_matches ) || \WP_CLI::error( "Parse error in $metadatum" ); + if ( ! preg_match( '/^(.+?):\s+(.+)$/', $metadatum, $metadataum_matches ) ) { + throw new \Exception( "Parse error in $metadatum" ); + } list( $name, $value ) = array_slice( $metadataum_matches, 1, 2 ); $this->metadata[$name] = $value; } @@ -92,7 +94,9 @@ function to_markdown( $params = array() ) { 'Screenshots' => function ( $body ) { $body = trim( $body ); $new_body = ''; - preg_match_all( '/^\d+\. (.+?)$/m', $body, $screenshot_matches, PREG_SET_ORDER ) || \WP_CLI::error( 'Malformed screenshot section' ); + if ( ! preg_match_all( '/^\d+\. (.+?)$/m', $body, $screenshot_matches, PREG_SET_ORDER ) ) { + throw new Exception( 'Malformed screenshot section' ); + } foreach ( $screenshot_matches as $i => $screenshot_match ) { $img_extensions = array( 'jpg', 'gif', 'png' ); foreach ( $img_extensions as $ext ) {