Skip to content

Commit

Permalink
Merge pull request ampproject#7814 from ampproject/fix/phpstan-errors
Browse files Browse the repository at this point in the history
Fix static-analysis and PHPUnit tests errors
  • Loading branch information
thelovekesh authored Jun 7, 2024
2 parents f819f2c + 5986229 commit 22012c5
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 10 deletions.
2 changes: 0 additions & 2 deletions includes/sanitizers/class-amp-comments-sanitizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ class AMP_Comments_Sanitizer extends AMP_Base_Sanitizer {
* @param AMP_Base_Sanitizer[] $sanitizers Sanitizers.
*/
public function init( $sanitizers ) {
parent::init( $sanitizers );

if (
array_key_exists( AMP_Style_Sanitizer::class, $sanitizers )
&&
Expand Down
2 changes: 0 additions & 2 deletions includes/sanitizers/class-amp-script-sanitizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ class AMP_Script_Sanitizer extends AMP_Base_Sanitizer {
* @param AMP_Base_Sanitizer[] $sanitizers Sanitizers.
*/
public function init( $sanitizers ) {
parent::init( $sanitizers );

$this->sanitizers = $sanitizers;
}

Expand Down
2 changes: 0 additions & 2 deletions includes/sanitizers/class-amp-style-sanitizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -891,8 +891,6 @@ private function is_class_allowed_in_amp_date_picker( $class ) {
* @param AMP_Base_Sanitizer[] $sanitizers Sanitizers.
*/
public function init( $sanitizers ) {
parent::init( $sanitizers );

$this->sanitizers = $sanitizers;
}

Expand Down
28 changes: 24 additions & 4 deletions src/ReaderThemeSupportFeatures.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,13 @@ final class ReaderThemeSupportFeatures implements Service, Registerable {
*/
const KEY_CUSTOM_SPACING_SIZE = 'customSpacingSize';

/**
* Key for `defaultSpacingSizes` boolean in theme.json (v3).
*
* @var string
*/
const KEY_DEFAULT_SPACING_SIZES = 'defaultSpacingSizes';

/**
* Action fired when the cached primary_theme_support should be updated.
*
Expand Down Expand Up @@ -496,10 +503,23 @@ private function print_editor_gradient_presets_styles( array $gradient_presets )
* Print spacing sizes custom properties.
*/
private function print_spacing_sizes_custom_properties() {
$custom_properties = [];
$spacing_sizes = wp_get_global_settings( [ self::KEY_SPACING, self::KEY_SPACING_SIZES ], self::KEY_THEME );
$is_wp_generating_spacing_sizes = 0 !== wp_get_global_settings( [ self::KEY_SPACING, self::KEY_SPACING_SCALE ], self::KEY_THEME )[ self::KEY_STEPS ];
$custom_spacing_size = wp_get_global_settings( [ self::KEY_SPACING, self::KEY_CUSTOM_SPACING_SIZE ], self::KEY_THEME );
$custom_properties = [];
$spacing = wp_get_global_settings( [ self::KEY_SPACING ], self::KEY_THEME );
$spacing_sizes = $spacing[ self::KEY_SPACING_SIZES ] ?? [];
$custom_spacing_size = $spacing[ self::KEY_CUSTOM_SPACING_SIZE ] ?? false;
$spacing_scale = $spacing[ self::KEY_SPACING_SCALE ] ?? [];

/**
* By default check for `defaultSpacingSizes` boolean introduced in theme.json (v3)
* and if it's false, then check for `steps` in `spacingScale` which is v2 default.
*
* @see <https://github.com/WordPress/gutenberg/pull/58409#issuecomment-2078077477>.
*/
$is_wp_generating_spacing_sizes = $spacing[ self::KEY_DEFAULT_SPACING_SIZES ] ?? false;

if ( array_key_exists( self::KEY_STEPS, $spacing_scale ) ) {
$is_wp_generating_spacing_sizes = 0 !== $spacing_scale[ self::KEY_STEPS ];
}

if ( ! $is_wp_generating_spacing_sizes && $custom_spacing_size ) {
if ( isset( $spacing_sizes[ self::KEY_THEME ] ) ) {
Expand Down

0 comments on commit 22012c5

Please sign in to comment.