Skip to content

Commit ff1fd05

Browse files
committed
fix typing & syntax
1 parent 3248037 commit ff1fd05

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

phpstan.neon

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,7 @@ parameters:
4444
- message: "#^Cannot access property \\$\\S+ on mixed\\.$#"
4545
path: views/addons-page.php
4646
count: 7
47+
- message: "#^Cannot access offset \\S+ on mixed\\.$#"
48+
path: src/SitemapParser.php
49+
count: 3
4750
- '/^Parameter #2 \$callable of static method WP_CLI::add_command\(\) expects callable\(\): mixed, \S+ given\.$/'

src/SitemapParser.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public function parseRecursive( $url ) {
123123
$sitemaps = $this->sitemaps;
124124
$urls = $this->urls;
125125
try {
126-
$this->parse( $todo[0] );
126+
$this->parse( strval( $todo[0] ) );
127127
} catch ( WP2StaticException $e ) {
128128
WsLog::w( $e->getMessage() );
129129
// Keep crawling
@@ -141,7 +141,7 @@ public function parseRecursive( $url ) {
141141
*/
142142
public function addToQueue( array $url_array ) : void {
143143
foreach ( $url_array as $url ) {
144-
$url = $this->urlEncode( $url );
144+
$url = $this->urlEncode( strval( $url ) );
145145
if ( $this->urlValidate( $url ) ) {
146146
$this->queue[] = $url;
147147
}
@@ -239,6 +239,11 @@ protected function getContent() {
239239
$this->config['guzzle']['headers']['User-Agent'] = $this->user_agent;
240240
}
241241
$client = new WP2StaticGuzzleHttp\Client( [ 'verify' => false ] );
242+
243+
if ( ! is_array( $this->config['guzzle'] ) ) {
244+
WsLog::w( 'Guzzle config is not in expected array format' );
245+
return null;
246+
}
242247
$res = $client->request( 'GET', $this->current_url, $this->config['guzzle'] );
243248
if ( $res->getStatusCode() === 200 ) {
244249
return $res->getBody()->getContents();
@@ -319,7 +324,7 @@ protected function addArray( $type, array $array ) {
319324
if ( ! isset( $array['loc'] ) ) {
320325
return false;
321326
}
322-
$array['loc'] = $this->urlEncode( trim( $array['loc'] ) );
327+
$array['loc'] = $this->urlEncode( trim( strval( $array['loc'] ) ) );
323328
if ( $this->urlValidate( $array['loc'] ) ) {
324329
switch ( $type ) {
325330
case self::XML_TAG_SITEMAP:

src/StaticSite.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ public static function getPaths() : array {
7676
);
7777

7878
foreach ( $iterator as $filename => $file_object ) {
79+
/**
80+
* @var string $filename
81+
*/
7982
$base_name = basename( $filename );
8083
if ( $base_name != '.' && $base_name != '..' ) {
8184
$real_filepath = realpath( $filename );

src/URLDetector.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,9 @@ public static function detectURLs( bool $quiet = false ) : array {
167167
$arrays_to_merge[] = DetectAuthorPaginationURLs::detect( SiteInfo::getUrl( 'site' ) );
168168
}
169169

170+
/**
171+
* @var string[] $url_queue
172+
*/
170173
$url_queue = call_user_func_array( 'array_merge', $arrays_to_merge );
171174

172175
$url_queue = FilesHelper::cleanDetectedURLs( $url_queue );

0 commit comments

Comments
 (0)