Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions php/class-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ public function generate_file_signature( $asset_id ) {
*
* @param int $asset_id The attachment/asset ID.
*
* @return string
* @return bool
*/
public function generate_storage_signature( $asset_id ) {
return $this->get_asset_storage_folder( $asset_id ) === $this->media->get_public_id( $asset_id );
Expand Down Expand Up @@ -1199,7 +1199,7 @@ public function get_asset( $post_id, $type = 'object' ) {
*
* @param array $item The raw data for an asset.
*
* @return array
* @return array|null
*/
public function build_item( $item ) {
if ( empty( $item ) ) {
Expand Down
2 changes: 1 addition & 1 deletion php/class-cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function __construct() {

// Ensure it's safe.
if ( self::$daemon_watcher_interval > ini_get( 'max_execution_time' ) ) {
self::$daemon_watcher_interval = ini_get( 'max_execution_time' );
self::$daemon_watcher_interval = (int) ini_get( 'max_execution_time' );
}

$this->init_time = time();
Expand Down
3 changes: 1 addition & 2 deletions php/class-delivery-feature.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
namespace Cloudinary;

use Cloudinary\Component\Assets;
use Cloudinary\Settings\Setting;

/**
* Class Delivery_Feature
Expand Down Expand Up @@ -57,7 +56,7 @@ abstract class Delivery_Feature implements Assets {
/**
* Holds the settings.
*
* @var Setting
* @var Settings|\Cloudinary\Settings\Setting
*/
protected $settings;

Expand Down
2 changes: 1 addition & 1 deletion php/class-extensions.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Extensions extends Settings_Component implements Setup {
/**
* Holds the core plugin settings.
*
* @var Settings
* @var Settings|\Cloudinary\Settings\Setting
*/
protected $settings;

Expand Down
10 changes: 5 additions & 5 deletions php/class-media.php
Original file line number Diff line number Diff line change
Expand Up @@ -941,7 +941,7 @@ public function set_transformation( &$transformations, $type, $value, $index = f
* @param array $transformations The transformation set to check.
* @param string $type The type of transformation to check for.
*
* @return bool
* @return int|string|false
*/
public function get_transformation( $transformations, $type ) {
foreach ( $transformations as $index => $transformation ) {
Expand Down Expand Up @@ -1372,7 +1372,7 @@ protected function get_cache_key( $args ) {
* @param string|null $cloudinary_id Optional forced cloudinary ID.
* @param bool $overwrite_transformations Flag url is a breakpoint URL to stop re-applying default transformations.
*
* @return string The converted URL.
* @return string|null The converted URL.
*/
public function cloudinary_url( $attachment_id, $size = array(), $transformations = array(), $cloudinary_id = null, $overwrite_transformations = false ) {
static $cache = array();
Expand Down Expand Up @@ -1777,11 +1777,11 @@ public function cloudinary_id( $attachment_id ) {
/**
* Filter the requested image and return image source.
*
* @param null $image The null image value for short circuit check.
* @param array|false $image The image value for short circuit check.
* @param int $attachment_id The ID of the attachment.
* @param string|array $size The requested size of the image.
*
* @return array The image array of size and url.
* @return array|false The image array of size and url.
* @uses filter:image_downsize
*/
public function filter_downsize( $image, $attachment_id, $size ) {
Expand Down Expand Up @@ -2781,7 +2781,7 @@ public function get_breakpoint_options( $attachment_id ) {
*
* @param int $attachment_id The ID of the attachment.
*
* @return array
* @return string
*/
public function get_context_options( $attachment_id ) {
$caption = get_post( $attachment_id )->post_excerpt;
Expand Down
3 changes: 2 additions & 1 deletion php/class-settings-component.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

use Cloudinary\Component;
use Cloudinary\Settings as CoreSetting;
use Cloudinary\Settings\Setting;

/**
* Plugin Settings Component class.
Expand All @@ -18,7 +19,7 @@ abstract class Settings_Component implements Component\Settings {
/**
* Holds the settings object for this Class.
*
* @var CoreSetting
* @var CoreSetting|Setting
*/
protected $settings;

Expand Down
2 changes: 1 addition & 1 deletion php/class-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ public function remove_pending( $slug ) {
/**
* Save settings.
*
* @return bool[]|\WP_Error[]
* @return string[]
*/
public function save() {
$pending = array_keys( $this->get_pending() );
Expand Down
2 changes: 1 addition & 1 deletion php/class-sync.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Sync implements Setup, Assets {
/**
* Contains all the different sync components.
*
* @var Delete_Sync[]|Push_Sync[]|Upload_Sync[]|Media[]|Unsync[]|Download_Sync[]
* @var Delete_Sync[]|Push_Sync[]|Upload_Sync[]|Media[]|Unsync[]|Download_Sync[]|Sync_Queue[]
*/
public $managers;

Expand Down
4 changes: 2 additions & 2 deletions php/component/class-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace Cloudinary\Component;

use Cloudinary\Settings\Setting;
use Cloudinary\Settings as CoreSettings;

/**
* Defines an object that requires settings.
Expand All @@ -17,7 +17,7 @@ interface Settings {
/**
* Init Settings Object.
*
* @param Setting $setting The core setting.
* @param CoreSettings $setting The core setting.
*/
public function init_settings( $setting );
}
6 changes: 3 additions & 3 deletions php/connect/class-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class Api {
*
* @var string|null
*/
private $pending_url = array();
private $pending_url = null;

/**
* API constructor.
Expand Down Expand Up @@ -801,7 +801,7 @@ public function __call( $name, $args ) {
*
* @param array $args Array of parameters to sign.
*
* @return array|\WP_Error
* @return string
*/
public function sign( $args ) {

Expand Down Expand Up @@ -988,7 +988,7 @@ protected static function get_hostname( $upload_prefix ) {
* @param array $args The optional arguments to send.
* @param string $method The call HTTP method.
*
* @return array|\WP_Error
* @return array|string|\WP_Error
*/
private function call( $url, $args = array(), $method = 'get' ) {
$args['method'] = strtoupper( $method );
Expand Down
2 changes: 1 addition & 1 deletion php/media/class-gallery.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class Gallery extends Settings_Component {
/**
* Holds the sync settings object.
*
* @var Setting
* @var \Cloudinary\Settings|Setting
*/
public $settings;

Expand Down
4 changes: 2 additions & 2 deletions php/media/class-global-transformations.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class Global_Transformations {
/**
* Holds the media settings.
*
* @var Setting
* @var \Cloudinary\Settings
*/
protected $media_settings;

Expand Down Expand Up @@ -360,7 +360,7 @@ public function render_ordering_box( $post ) {
*
* @param int $post_id The post ID.
*
* @return array|false|int|\WP_Error|\WP_Term[]
* @return array<array{term: \WP_Term, value: mixed}>
*/
public function get_terms( $post_id ) {
// Get terms for this post on load.
Expand Down
10 changes: 10 additions & 0 deletions php/media/class-video.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,11 @@ public function filter_video_shortcode( $html, $attr ) {
// If not CLD video init, return default.
if ( ! $this->player_enabled() ) {
if ( empty( $attr['cloudinary'] ) ) {
/**
* The attachment metadata.
*
* @var array $video
*/
$video = wp_get_attachment_metadata( $attr['id'] );
$url = $this->media->cloudinary_url( $attr['id'] );
$attr[ $video['fileformat'] ] = strtok( $url, '?' );
Expand Down Expand Up @@ -400,6 +405,11 @@ protected function build_video_embed( $source, $attributes = array(), $overwrite
$params['source']['transformation'] = $transformations;
}
// Set the source_type.
/**
* The attachment metadata.
*
* @var array $video
*/
$video = wp_get_attachment_metadata( $attachment_id );
if ( ! empty( $video['fileformat'] ) && 'off' === $streaming['adaptive_streaming'] ) {
$params['source']['source_types'][] = $video['fileformat'];
Expand Down
4 changes: 2 additions & 2 deletions php/settings/class-setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class Setting {
/**
* Holds the parent.
*
* @var self
* @var string
*/
protected $parent;

Expand Down Expand Up @@ -388,7 +388,7 @@ public function get_option_name() {
/**
* Get the option parent.
*
* @return Settings
* @return Setting|null
*/
public function get_option_parent() {
$root = explode( $this->separator, $this->slug, 2 )[0];
Expand Down
14 changes: 10 additions & 4 deletions php/ui/component/class-line-stat.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ class Line_Stat extends Component {
/**
* Holds the used persentage.
*
* @var string
* @var int|float|string
*/
protected $used_percent;

/**
* Holds the limit.
*
* @var string
* @var int|float|string
*/
protected $limit;

Expand Down Expand Up @@ -76,7 +76,7 @@ class Line_Stat extends Component {
/**
* Holds the connect instance.
*
* @var Connect
* @var \Cloudinary\Connect
*/
protected $connect;

Expand Down Expand Up @@ -118,7 +118,13 @@ protected function set_texts() {
* Set the usage stats.
*/
protected function set_stats() {
$this->connect = get_plugin_instance()->get_component( 'connect' );
/**
* The connect component.
*
* @var \Cloudinary\Connect $connect
*/
$connect = get_plugin_instance()->get_component( 'connect' );
$this->connect = $connect;
$this->limit = $this->connect->get_usage_stat( $this->setting->get_param( 'stat' ), 'limit' );
$this->used_percent = $this->connect->get_usage_stat( $this->setting->get_param( 'stat' ), 'used_percent' );
}
Expand Down
2 changes: 1 addition & 1 deletion php/ui/component/class-on-off.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ protected function is_readonly() {
*
* @param string $value The value to sanitize.
*
* @return bool
* @return string
*/
public function sanitize_value( $value ) {
$allowed = array(
Expand Down
4 changes: 2 additions & 2 deletions php/ui/component/class-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ protected function wrap( $struct ) {
*
* @param array $struct The array structure.
*
* @return array
* @return array|null
*/
protected function form( $struct ) {
if ( $this->setting->has_param( 'has_tabs' ) ) {
Expand All @@ -72,7 +72,7 @@ protected function form( $struct ) {
*
* @param array $struct The array structure.
*
* @return array
* @return array|null
*/
protected function notice( $struct ) {
if ( Utils::get_active_setting() !== $this->setting ) {
Expand Down
2 changes: 1 addition & 1 deletion php/ui/component/class-sync.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ protected function status( $struct ) {
*
* @param array $struct The array structure.
*
* @return array
* @return array|null
*/
protected function action( $struct ) {

Expand Down
4 changes: 2 additions & 2 deletions php/ui/component/class-text.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,9 @@ protected function get_id() {
/**
* Sanitize the value.
*
* @param string $value The value to sanitize.
* @param mixed $value The value to sanitize.
*
* @return string
* @return mixed
*/
public function sanitize_value( $value ) {
if ( 0 === strlen( $value ) && $this->setting->has_param( 'default' ) ) {
Expand Down
2 changes: 1 addition & 1 deletion php/url/class-url-object.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ abstract public function url( $size = null );
/**
* Get the ID.
*
* @return int|null
* @return int|string|null
*/
abstract public function get_id();
}
2 changes: 1 addition & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ parameters:
-
identifier: return.void
message: '#^Action callback returns .+ but should not return anything\.$#'
level: 2
level: 3
paths:
- php
- cloudinary.php
Expand Down
Loading