From 6b5a33ea94a9eb883bb745fa0031ebc0e2cae0d6 Mon Sep 17 00:00:00 2001 From: Constantine Nathanson <35217733+const-cloudinary@users.noreply.github.com> Date: Sun, 29 Dec 2024 22:00:40 +0200 Subject: [PATCH] Add PHP types --- .github/pull_request_template.md | 2 +- .github/workflows/test.yaml | 2 +- phpstan.neon | 6 + src/Transformation/Action.php | 5 +- .../Adjustment/Addon/ViesusCorrect.php | 12 +- src/Transformation/Adjustment/Adjust.php | 44 +- .../Adjustment/CommonAdjustmentTrait.php | 30 +- src/Transformation/Adjustment/FillLight.php | 7 +- .../Adjustment/ImageAdjustmentTrait.php | 136 +- src/Transformation/Adjustment/Improve.php | 19 +- src/Transformation/Adjustment/ImproveMode.php | 10 +- .../Adjustment/OpacityQualifierTrait.php | 3 +- .../Adjustment/ReplaceColor.php | 23 +- src/Transformation/Animated/Animated.php | 3 +- .../Animated/AnimatedEditTrait.php | 9 +- .../Background/AutoBackground.php | 28 +- .../Background/AutoBackgroundMode.php | 16 +- .../Background/AutoBackgroundTrait.php | 8 +- .../Background/AutoGradientBackground.php | 30 +- .../AutoGradientBackgroundTrait.php | 10 +- src/Transformation/Background/Background.php | 29 +- .../Background/BackgroundColorTrait.php | 7 +- .../Background/BackgroundQualifierTrait.php | 3 +- .../Background/BackgroundTrait.php | 4 +- .../Background/BlurredBackground.php | 16 +- .../Background/GenerativeFillBackground.php | 22 +- src/Transformation/BaseAction.php | 47 +- src/Transformation/BaseComponent.php | 17 +- src/Transformation/Border/Border.php | 34 +- src/Transformation/Border/BorderQualifier.php | 19 +- .../Border/BorderQualifierTrait.php | 3 +- .../Border/BorderStyleTrait.php | 7 +- src/Transformation/Border/BorderValue.php | 22 +- src/Transformation/CommonTransformation.php | 32 +- .../CommonTransformationInterface.php | 56 +- .../CommonTransformationTrait.php | 41 +- src/Transformation/ComponentInterface.php | 4 +- .../Condition/ConditionQualifierTrait.php | 7 +- src/Transformation/Condition/Conditional.php | 34 +- .../Condition/EndIfCondition.php | 2 +- src/Transformation/Condition/IfCondition.php | 4 +- src/Transformation/Condition/IfElse.php | 2 +- .../CustomFunction/CustomFunction.php | 29 +- .../CustomFunctionQualifierTrait.php | 14 +- .../CustomFunction/CustomFunctionTrait.php | 24 +- .../CustomFunction/CustomFunctionValue.php | 10 +- .../TransformationCustomFunctionTrait.php | 3 +- .../Delivery/ColorSpace/ColorSpace.php | 30 +- .../ColorSpace/ColorSpaceQualifierTrait.php | 8 +- .../Delivery/DeliveryBuilderTrait.php | 31 +- src/Transformation/Delivery/Dpr.php | 9 +- .../Delivery/Format/AnimatedFormat.php | 6 +- .../Delivery/Format/AnimatedFormatTrait.php | 15 +- .../Delivery/Format/AudioFormatInterface.php | 18 +- .../Delivery/Format/AudioFormatTrait.php | 27 +- src/Transformation/Delivery/Format/Format.php | 17 +- .../Delivery/Format/FormatInterface.php | 2 +- .../Delivery/Format/FormatQualifier.php | 3 +- .../Delivery/Format/FormatQualifierTrait.php | 3 +- .../Delivery/Format/FormatTrait.php | 6 +- .../Delivery/Format/ImageFormatInterface.php | 68 +- .../Delivery/Format/ImageFormatTrait.php | 60 +- .../Delivery/Format/VideoFormatInterface.php | 28 +- .../Delivery/Format/VideoFormatTrait.php | 42 +- .../Delivery/Quality/ChromaSubSampling.php | 35 +- .../Delivery/Quality/JpegMini.php | 6 +- .../Delivery/Quality/Quality.php | 27 +- .../Delivery/Quality/QualityBuilderTrait.php | 11 +- .../Delivery/Quality/QualityQualifier.php | 34 +- .../Quality/QualityQualifierTrait.php | 11 +- .../Delivery/Quality/QualityTrait.php | 45 +- .../Delivery/TransformationDeliveryTrait.php | 14 +- .../Effect/Addon/AddonEffectTrait.php | 3 +- .../Addon/Lightroom/LightroomEffect.php | 28 +- .../Lightroom/LightroomEffectInterface.php | 40 +- .../Lightroom/LightroomEffectQualifier.php | 17 +- .../Addon/Lightroom/LightroomEffectTrait.php | 93 +- .../Effect/Addon/Lightroom/WhiteBalance.php | 18 +- .../Effect/Addon/Lightroom/Xmp.php | 5 +- .../Effect/Addon/Lightroom/XmpSourceValue.php | 11 +- .../Effect/Appearance/AppearanceEffect.php | 6 +- .../Effect/Appearance/Deshake.php | 2 +- .../Effect/Appearance/ShakeStrength.php | 20 +- .../Effect/Appearance/ThemeEffect.php | 10 +- .../Effect/Appearance/ThemeEffectTrait.php | 18 +- .../Effect/Appearance/ThemeQualifier.php | 12 +- .../Appearance/VideoAppearanceEffectTrait.php | 20 +- .../Effect/Argument/EffectActionTypeTrait.php | 4 +- .../Effect/Argument/EffectMode.php | 2 +- .../Effect/Argument/EffectModeTrait.php | 2 +- .../Effect/Argument/EffectName.php | 2 +- .../Effect/Argument/EffectRange.php | 24 +- .../Effect/Argument/EffectType.php | 2 +- .../Effect/Argument/EffectTypeTrait.php | 2 +- .../Effect/BlendEffectAction.php | 2 +- .../Effect/BlendEffectQualifier.php | 3 +- .../Effect/Color/AssistColorBlind.php | 14 +- .../Effect/Color/ColorEffect.php | 14 +- .../Effect/Color/ImageColorEffectTrait.php | 41 +- .../Effect/Color/SimulateColorBlind.php | 38 +- .../Effect/DurationEffectAction.php | 2 +- .../Effect/DurationEffectQualifier.php | 7 +- src/Transformation/Effect/Effect.php | 8 +- src/Transformation/Effect/EffectAction.php | 4 +- .../Effect/EffectActionTrait.php | 95 +- src/Transformation/Effect/EffectQualifier.php | 7 +- .../Effect/EffectQualifierTrait.php | 3 +- .../Effect/Generative/DetectMultipleTrait.php | 4 +- .../Effect/Generative/GenerativeEffect.php | 12 +- .../Generative/GenerativeEffectAction.php | 6 +- .../Generative/GenerativeEffectTrait.php | 57 +- .../Effect/Generative/GenerativeRecolor.php | 9 +- .../Effect/Generative/GenerativeRemove.php | 26 +- .../Effect/Generative/GenerativeReplace.php | 32 +- .../Effect/Generative/PromptTrait.php | 5 +- .../Effect/LevelEffectAction.php | 2 +- .../Effect/LevelEffectQualifier.php | 3 +- .../Effect/LimitedEffectQualifier.php | 7 +- .../Effect/ListEffectQualifier.php | 9 +- .../Effect/Misc/ArtisticFilter.php | 105 +- src/Transformation/Effect/Misc/Cartoonify.php | 38 +- src/Transformation/Effect/Misc/DropShadow.php | 24 +- .../Effect/Misc/DropShadowQualifier.php | 24 +- src/Transformation/Effect/Misc/MiscEffect.php | 18 +- .../Effect/Misc/MiscEffectTrait.php | 122 +- src/Transformation/Effect/Misc/Outline.php | 18 +- .../Effect/Misc/OutlineMode.php | 20 +- .../Effect/Misc/OutlineQualifier.php | 17 +- src/Transformation/Effect/Misc/Shadow.php | 22 +- .../Misc/StyleTransfer/StyleTransfer.php | 6 +- .../StyleTransfer/StyleTransferQualifier.php | 20 +- src/Transformation/Effect/Misc/Vectorize.php | 35 +- .../Effect/Misc/VectorizeTrait.php | 29 +- .../Effect/Misc/VectorizeValue.php | 39 +- .../Effect/Pixel/BackgroundRemoval.php | 12 +- src/Transformation/Effect/Pixel/Blur.php | 6 +- src/Transformation/Effect/Pixel/CutOut.php | 5 +- src/Transformation/Effect/Pixel/Dither.php | 101 +- .../Effect/Pixel/GradientFade.php | 22 +- .../Effect/Pixel/GradientFadeQualifier.php | 2 +- .../Effect/Pixel/ImagePixelEffectTrait.php | 59 +- .../Effect/Pixel/PixelEffect.php | 26 +- .../Effect/Pixel/PixelEffectTrait.php | 35 +- src/Transformation/Effect/Pixel/Pixelate.php | 6 +- .../Effect/Pixel/RegionEffectAction.php | 26 +- .../Effect/Pixel/RegionEffectTrait.php | 8 +- .../Effect/Pixel/RemoveBackground.php | 12 +- .../Effect/Playback/Accelerate.php | 2 +- src/Transformation/Effect/Playback/Loop.php | 2 +- .../Effect/Playback/PlaybackEffect.php | 14 +- .../Effect/Playback/PlaybackEffectTrait.php | 24 +- .../Effect/Playback/Preview.php | 21 +- src/Transformation/Effect/Playback/Volume.php | 20 +- .../Effect/SquareSizeEffectAction.php | 2 +- .../Effect/SquareSizeEffectQualifier.php | 3 +- .../Effect/StrengthEffectAction.php | 4 +- .../Effect/StrengthEffectQualifier.php | 5 +- .../Effect/ThresholdEffectAction.php | 2 +- .../Effect/ThresholdEffectQualifier.php | 3 +- .../Effect/ToleranceEffectAction.php | 2 +- .../Effect/ToleranceEffectQualifier.php | 3 +- .../Effect/ValueEffectQualifier.php | 2 +- .../Expression/BaseExpression.php | 17 +- src/Transformation/Expression/Expression.php | 3 +- .../Expression/ExpressionComponent.php | 31 +- .../Expression/ExpressionTrait.php | 3 +- .../Expression/ExpressionUtils.php | 26 +- .../Expression/Operand/Value/UVal.php | 27 +- .../Operand/Value/ValueBuilderTrait.php | 18 +- .../Operand/Variable/Predefined/PVar.php | 53 +- .../PredefinedVariableBuilderTrait.php | 48 +- .../Predefined/PredefinedVariableTrait.php | 51 +- .../Expression/Operand/Variable/User/UVar.php | 3 +- .../User/UserVariableBuilderTrait.php | 3 +- .../Operator/ArithmeticOperator.php | 46 +- .../ArithmeticOperatorBuilderTrait.php | 20 +- .../Expression/Operator/BaseOperator.php | 23 +- .../Expression/Operator/LogicalOperator.php | 12 +- .../Operator/LogicalOperatorBuilderTrait.php | 6 +- .../Expression/Operator/Operator.php | 13 +- .../Operator/RelationalOperator.php | 36 +- .../RelationalOperatorBuilderTrait.php | 18 +- .../Operator/StringRelationalOperator.php | 26 +- .../StringRelationalOperatorBuilderTrait.php | 6 +- .../Flag/CommonFlagInterface.php | 16 +- src/Transformation/Flag/CommonFlagTrait.php | 29 +- .../Flag/CommonTransformationFlagTrait.php | 24 +- src/Transformation/Flag/FlagQualifier.php | 19 +- .../Flag/FlagQualifierTrait.php | 7 +- .../Flag/ImageFlagInterface.php | 34 +- src/Transformation/Flag/ImageFlagTrait.php | 53 +- .../Flag/ImageTransformationFlagTrait.php | 3 +- .../Flag/LayerFlagInterface.php | 20 +- src/Transformation/Flag/LayerFlagTrait.php | 24 +- src/Transformation/Flag/Progressive.php | 20 +- .../Flag/VideoFlagInterface.php | 14 +- src/Transformation/Flag/VideoFlagTrait.php | 23 +- .../Flag/VideoTransformationFlagTrait.php | 23 +- .../ImageSpecificTransformationTrait.php | 99 +- .../Image/ImageTransformationInterface.php | 50 +- .../Image/LayeredImageTransformationTrait.php | 6 +- .../Image/Qualifier/DefaultImage.php | 2 +- src/Transformation/Image/Qualifier/Delay.php | 2 +- .../Image/Qualifier/Density.php | 4 +- .../Image/Qualifier/ImageQualifierTrait.php | 14 +- .../ImageQualifierTransformationTrait.php | 13 +- src/Transformation/Layer/AssetBasedSource.php | 3 +- src/Transformation/Layer/AudioOverlay.php | 25 +- src/Transformation/Layer/AudioSource.php | 12 +- .../Layer/AudioSourceQualifier.php | 7 +- src/Transformation/Layer/AudioSourceTrait.php | 5 +- .../Layer/BasePositionalSourceContainer.php | 20 +- src/Transformation/Layer/BaseSource.php | 31 +- .../Layer/BaseSourceContainer.php | 20 +- .../Layer/BaseSourceQualifier.php | 25 +- src/Transformation/Layer/BlendMode.php | 29 +- src/Transformation/Layer/FetchImageSource.php | 6 +- .../Layer/FetchSourceQualifier.php | 12 +- src/Transformation/Layer/FetchVideoSource.php | 10 +- src/Transformation/Layer/ImageOverlay.php | 36 +- src/Transformation/Layer/ImageSource.php | 8 +- .../Layer/ImageSourceQualifier.php | 23 +- src/Transformation/Layer/ImageSourceTrait.php | 25 +- .../Layer/LayerQualifierFactory.php | 9 +- .../Layer/LayerQualifierTrait.php | 6 +- src/Transformation/Layer/LayerSourceTrait.php | 10 +- .../Layer/LayerStackPosition.php | 4 +- src/Transformation/Layer/LutLayer.php | 7 +- .../Layer/LutSourceQualifier.php | 7 +- src/Transformation/Layer/MediaOverlay.php | 12 +- src/Transformation/Layer/Overlay.php | 28 +- src/Transformation/Layer/SourceValue.php | 4 +- src/Transformation/Layer/SubtitlesSource.php | 21 +- .../Layer/SubtitlesSourceQualifier.php | 30 +- src/Transformation/Layer/TextSource.php | 55 +- .../Layer/TextSourceQualifier.php | 49 +- src/Transformation/Layer/Transition.php | 5 +- src/Transformation/Layer/Underlay.php | 7 +- src/Transformation/Layer/VideoOverlay.php | 38 +- src/Transformation/Layer/VideoSource.php | 7 +- .../Layer/VideoSourceQualifier.php | 9 +- src/Transformation/Layer/VideoSourceTrait.php | 13 +- .../Named/NamedTransformation.php | 9 +- .../NamedTransformationQualifierTrait.php | 5 +- src/Transformation/Page/BasePageAction.php | 4 +- src/Transformation/Page/ClippingPath.php | 7 +- src/Transformation/Page/Extract.php | 8 +- src/Transformation/Page/Frame.php | 8 +- src/Transformation/Page/LayerName.php | 6 +- src/Transformation/Page/Page.php | 2 +- src/Transformation/Page/PageAllTrait.php | 3 +- src/Transformation/Page/PageIndexTrait.php | 3 +- .../Page/PageLayerNameTrait.php | 7 +- .../Page/PageLayerNamesTrait.php | 3 +- src/Transformation/Page/PageNameTrait.php | 7 +- src/Transformation/Page/PageNamesTrait.php | 3 +- src/Transformation/Page/PageNumberTrait.php | 5 +- src/Transformation/Page/PageQualifier.php | 4 +- .../Page/PageQualifierTrait.php | 3 +- src/Transformation/Page/PageRangeTrait.php | 7 +- src/Transformation/Page/PageValue.php | 5 +- src/Transformation/Page/PsdTools.php | 11 +- src/Transformation/Page/SmartObject.php | 2 +- src/Transformation/Page/SmartObjectName.php | 6 +- .../Page/SmartObjectQualifier.php | 2 +- .../Positioning/AbsolutePosition.php | 10 +- .../Positioning/AbsolutePositionTrait.php | 6 +- .../Positioning/CompassGravityTrait.php | 8 +- .../Positioning/CompassPosition.php | 17 +- .../Positioning/FocalGravityTrait.php | 3 +- .../Positioning/Gravity/AutoGravity.php | 22 +- .../Gravity/AutoGravityBuilderTrait.php | 10 +- .../Positioning/Gravity/AutoGravityObject.php | 11 +- .../Positioning/Gravity/Compass.php | 25 +- .../Positioning/Gravity/CompassGravity.php | 11 +- .../Gravity/CompassGravityBuilderTrait.php | 52 +- .../Positioning/Gravity/FocalGravity.php | 9 +- .../Gravity/FocalGravityBuilderTrait.php | 37 +- .../Gravity/FocalGravityInterface.php | 28 +- .../Positioning/Gravity/Gravity.php | 3 +- .../Positioning/Gravity/GravityQualifier.php | 2 +- .../Gravity/GravityQualifierTrait.php | 3 +- .../Positioning/Gravity/LiquidRescaling.php | 2 +- .../AccessoryObjectGravityBuilderTrait.php | 36 +- .../AccessoryObjectGravityInterface.php | 22 +- .../AnimalObjectGravityBuilderTrait.php | 33 +- .../AnimalObjectGravityInterface.php | 22 +- .../ApplianceObjectGravityBuilderTrait.php | 18 +- .../ApplianceObjectGravityInterface.php | 12 +- .../Gravity/ObjectGravity/AutoFocus.php | 7 +- .../ElectronicObjectGravityBuilderTrait.php | 21 +- .../ElectronicObjectGravityInterface.php | 14 +- .../FoodObjectGravityBuilderTrait.php | 33 +- .../FoodObjectGravityInterface.php | 22 +- .../FurnitureObjectGravityBuilderTrait.php | 21 +- .../FurnitureObjectGravityInterface.php | 14 +- .../IndoorObjectGravityBuilderTrait.php | 24 +- .../IndoorObjectGravityInterface.php | 16 +- .../KitchenObjectGravityBuilderTrait.php | 24 +- .../KitchenObjectGravityInterface.php | 16 +- .../Gravity/ObjectGravity/ObjectGravity.php | 11 +- .../ObjectGravityBuilderTrait.php | 3 +- .../ObjectGravityPriorityBuilderTrait.php | 17 +- .../ObjectGravityPriorityInterface.php | 6 +- .../OutdoorObjectGravityBuilderTrait.php | 18 +- .../OutdoorObjectGravityInterface.php | 12 +- .../PersonObjectGravityBuilderTrait.php | 3 +- .../PersonObjectGravityInterface.php | 2 +- .../VehicleObjectGravityBuilderTrait.php | 27 +- .../VehicleObjectGravityInterface.php | 18 +- .../Positioning/GravityTrait.php | 2 +- src/Transformation/Positioning/Offset.php | 10 +- .../Positioning/OffsetTrait.php | 19 +- .../Positioning/PixelEffectRegionTrait.php | 39 +- src/Transformation/Positioning/Point.php | 10 +- src/Transformation/Positioning/PointTrait.php | 19 +- src/Transformation/Positioning/Position.php | 29 +- .../Positioning/PositionFlagTrait.php | 6 +- .../Positioning/PositioningQualifierTrait.php | 6 +- src/Transformation/Positioning/Region.php | 32 +- .../Positioning/RegionTrait.php | 2 +- .../Qualifier/BaseExpressionQualifier.php | 2 +- .../Qualifier/BaseQualifier.php | 46 +- .../Qualifier/Color/ColorQualifier.php | 3 +- .../Qualifier/Color/ColorQualifierTrait.php | 3 +- .../Qualifier/Color/ColorToReplaceTrait.php | 2 +- .../Qualifier/Color/ColorTrait.php | 4 +- .../Qualifier/Color/TextColorTrait.php | 4 +- .../Qualifier/Dimensions/AspectRatio.php | 37 +- .../Qualifier/Dimensions/Dimensions.php | 13 +- .../Dimensions/DimensionsQualifierTrait.php | 26 +- .../Qualifier/Dimensions/DimensionsTrait.php | 19 +- .../Qualifier/Dimensions/TextFit.php | 23 +- .../Qualifier/Dimensions/TextFitTrait.php | 8 +- .../Qualifier/GenericQualifier.php | 9 +- .../Qualifier/Misc/BreakpointsJson.php | 71 +- src/Transformation/Qualifier/Qualifier.php | 3 +- .../QualifierValue/BaseNamedArgument.php | 35 +- .../QualifierValue/Canvas/PointValue.php | 25 +- .../QualifierValue/Canvas/RectangleRegion.php | 4 +- .../Qualifier/QualifierValue/Color/Color.php | 1342 +++++------ .../QualifierValue/Color/ColorTrait.php | 2016 ++++++----------- .../QualifierValue/Color/ColorValue.php | 4 +- .../QualifierValue/Color/ColorValueTrait.php | 2 +- .../QualifierValue/Color/Gradient.php | 35 +- .../Color/GradientDirection.php | 20 +- .../QualifierValue/Color/Palette.php | 6 +- .../Effect/ForegroundObject.php | 40 +- .../Effect/ForegroundObjectTrait.php | 60 +- .../QualifierValue/GenericArgument.php | 15 +- .../QualifierValue/GenericNamedArgument.php | 20 +- .../LimitedGenericNamedArgument.php | 20 +- .../ListExpressionQualifierMultiValue.php | 2 +- .../ListQualifierMultiValue.php | 2 +- .../Qualifier/QualifierValue/MatrixValue.php | 2 +- .../QualifierValue/Misc/IndexedArgument.php | 2 +- .../Misc/PositiveFloatValue.php | 3 +- .../QualifierValue/Misc/RangeArgument.php | 8 +- .../QualifierValue/QualifierMultiValue.php | 52 +- .../QualifierValue/Text/FontAntialias.php | 30 +- .../QualifierValue/Text/FontFamily.php | 8 +- .../QualifierValue/Text/FontHinting.php | 20 +- .../QualifierValue/Text/FontStyle.php | 10 +- .../QualifierValue/Text/FontWeight.php | 65 +- .../Qualifier/QualifierValue/Text/Stroke.php | 13 +- .../Qualifier/QualifierValue/Text/Text.php | 6 +- .../QualifierValue/Text/TextAlignment.php | 30 +- .../QualifierValue/Text/TextDecoration.php | 10 +- .../QualifierValue/Text/TextStyle.php | 25 +- .../QualifierValue/Text/TextStyleTrait.php | 68 +- .../QualifierValue/Text/TextTrait.php | 9 +- .../Qualifier/QualifiersAction.php | 51 +- .../Timeline/BaseOffsetQualifier.php | 10 +- .../Qualifier/Timeline/Duration.php | 2 +- .../Qualifier/Timeline/StartOffset.php | 2 +- .../Qualifier/Timeline/Timeline.php | 36 +- .../Timeline/TimelineQualifierTrait.php | 9 +- .../Qualifier/Timeline/VideoOffset.php | 15 +- .../Resize/Addon/ImaggaTrait.php | 18 +- .../Resize/BaseResizeAction.php | 31 +- src/Transformation/Resize/Crop/Crop.php | 29 +- src/Transformation/Resize/Crop/CropPad.php | 5 +- .../Resize/Crop/CropPadTrait.php | 17 +- src/Transformation/Resize/Crop/CropTrait.php | 58 +- src/Transformation/Resize/Fill/Fill.php | 8 +- src/Transformation/Resize/Fill/FillPad.php | 24 +- .../Resize/Fill/FillPadTrait.php | 17 +- src/Transformation/Resize/Fill/FillTrait.php | 32 +- .../Resize/Generic/GenericResize.php | 2 +- .../Resize/Generic/GenericResizeTrait.php | 19 +- src/Transformation/Resize/Pad/Pad.php | 5 +- src/Transformation/Resize/Pad/PadTrait.php | 58 +- .../Resize/Parameter/CropMode.php | 36 +- .../Resize/Parameter/CropModeTrait.php | 46 +- .../Resize/Parameter/ResizeModeTrait.php | 6 +- .../Resize/Parameter/ResizeQualifierTrait.php | 8 +- .../Resize/Parameter/ZoomTrait.php | 3 +- src/Transformation/Resize/ResizeFactory.php | 17 +- src/Transformation/Resize/Scale/Scale.php | 4 +- .../Resize/Scale/ScaleTrait.php | 55 +- .../Resize/TransformationResizeTrait.php | 15 +- src/Transformation/Rotation/Angle.php | 22 +- .../Rotation/AngleQualifierTrait.php | 3 +- src/Transformation/Rotation/AngleTrait.php | 12 +- src/Transformation/Rotation/Degree.php | 13 +- src/Transformation/Rotation/Rotate.php | 12 +- .../Rotation/RotationDegreeInterface.php | 3 +- src/Transformation/Rotation/RotationMode.php | 17 +- .../Rotation/RotationModeInterface.php | 3 +- .../Rotation/RotationModeTrait.php | 18 +- src/Transformation/Shape/CornerRadius.php | 12 +- .../Shape/CornerRadiusQualifierTrait.php | 3 +- .../Shape/CornerRadiusTrait.php | 9 +- src/Transformation/Shape/Corners.php | 12 +- src/Transformation/Shape/CornersTrait.php | 21 +- src/Transformation/Shape/Distort.php | 14 +- src/Transformation/Shape/ReshapeQualifier.php | 8 +- src/Transformation/Shape/ReshapeTrait.php | 37 +- src/Transformation/Shape/RoundCorners.php | 17 +- src/Transformation/Shape/Shear.php | 17 +- src/Transformation/Shape/TrimEffect.php | 11 +- .../SourceBasedEffectAction.php | 40 +- src/Transformation/Variable/Variable.php | 42 +- .../Video/Argument/Range/MinMaxRange.php | 17 +- .../Video/Argument/Range/PreviewDuration.php | 2 +- .../Video/Argument/Range/Range.php | 23 +- src/Transformation/Video/Edit/Concatenate.php | 16 +- .../Video/Edit/VideoEditBuilderTrait.php | 24 +- .../Video/Transcode/Audio/AudioCodec.php | 20 +- .../Video/Transcode/Audio/AudioFrequency.php | 78 +- .../Transcode/Audio/AudioQualifierTrait.php | 10 +- .../Video/Transcode/BitRate.php | 18 +- .../Video/Transcode/Codec/VideoCodec.php | 32 +- .../Video/Transcode/Codec/VideoCodecLevel.php | 40 +- .../Transcode/Codec/VideoCodecProfile.php | 15 +- .../Video/Transcode/Codec/VideoCodecTrait.php | 24 +- src/Transformation/Video/Transcode/Fps.php | 24 +- .../Video/Transcode/KeyframeInterval.php | 2 +- .../Video/Transcode/StreamingProfile.php | 35 +- .../ToAnimated/ToAnimatedActionTrait.php | 12 +- .../Video/Transcode/TranscodeTrait.php | 13 +- .../Video/Transcode/VideoQualifierTrait.php | 30 +- .../VideoSpecificTransformationTrait.php | 72 +- .../Video/VideoTransformationInterface.php | 39 +- src/Utils/ArrayUtils.php | 180 +- src/Utils/ClassUtils.php | 71 +- src/Utils/JsonUtils.php | 20 +- src/Utils/StringUtils.php | 73 +- src/Utils/TransformationUtils.php | 18 +- tests/TransformationTestCase.php | 12 +- .../Common/ActionFromQualifiersTest.php | 50 +- .../Unit/Transformation/Common/EffectTest.php | 6 +- .../Transformation/Common/QualifiersTest.php | 4 +- .../Unit/Transformation/Common/RotateTest.php | 4 +- .../Common/TransformationVariableTest.php | 4 +- .../Unit/Transformation/Common/UsageTest.php | 8 +- .../Expression/ExpressionTest.php | 8 +- .../Video/Audio/VideoAudioTest.php | 4 +- 458 files changed, 5079 insertions(+), 6994 deletions(-) create mode 100644 phpstan.neon diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index e198215..e2509ff 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -26,4 +26,4 @@ include, for example: - [ ] My code follows the code style of this project. - [ ] My change requires a change to the documentation. -- [ ] I ran the full test suite before pushing the changes and all of the tests pass. +- [ ] I ran the full test suite before pushing the changes and all the tests pass. diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index ab04af3..7dc97ae 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -15,7 +15,7 @@ jobs: - '8.4' steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Setup PHP, with composer and extensions uses: shivammathur/setup-php@v2 with: diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..e89ee99 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,6 @@ +parameters: + level: 1 + paths: + - src + ignoreErrors: + - '#Unsafe usage of new static\(\)#' diff --git a/src/Transformation/Action.php b/src/Transformation/Action.php index 7733d11..0adcb9e 100644 --- a/src/Transformation/Action.php +++ b/src/Transformation/Action.php @@ -20,11 +20,10 @@ class Action extends BaseAction /** * Action named constructor. * - * @param string $genericActionString + * @param string|null $genericActionString Generic action as a string. * - * @return BaseAction */ - public static function generic($genericActionString = null) + public static function generic(?string $genericActionString = null): BaseAction { return (new static())->setGenericAction($genericActionString); } diff --git a/src/Transformation/Adjustment/Addon/ViesusCorrect.php b/src/Transformation/Adjustment/Addon/ViesusCorrect.php index 32d9a45..ebbcbfc 100644 --- a/src/Transformation/Adjustment/Addon/ViesusCorrect.php +++ b/src/Transformation/Adjustment/Addon/ViesusCorrect.php @@ -28,12 +28,12 @@ class ViesusCorrect extends EffectQualifier /** * Enhances the image without correcting for red eye. */ - const NO_REDEYE = 'no_redeye'; + public const NO_REDEYE = 'no_redeye'; /** * Enhances the image and also applies saturation to the skin tones in the image. */ - const SKIN_SATURATION = 'skin_saturation'; + public const SKIN_SATURATION = 'skin_saturation'; /** * ViesusCorrect constructor. @@ -46,9 +46,8 @@ public function __construct() /** * Enhances the image without correcting for red eye. * - * @return ViesusCorrect */ - public function noRedEye() + public function noRedEye(): static { $this->getValue()->setSimpleNamedValue('no', 'redeye'); @@ -58,12 +57,11 @@ public function noRedEye() /** * Enhances the image and also applies saturation to the skin tones in the image. * - * @param int $level The enhancement level. A positive value boosts the saturation and a negative value + * @param int|null $level The enhancement level. A positive value boosts the saturation and a negative value * reduces the saturation. (Range: -100 to 100, Server default: 50). * - * @return ViesusCorrect */ - public function skinSaturation($level = null) + public function skinSaturation(?int $level = null): static { if ($level) { $this->getValue()->setSimpleNamedValue(self::SKIN_SATURATION, $level); diff --git a/src/Transformation/Adjustment/Adjust.php b/src/Transformation/Adjustment/Adjust.php index 51d6b75..a81c652 100644 --- a/src/Transformation/Adjustment/Adjust.php +++ b/src/Transformation/Adjustment/Adjust.php @@ -18,33 +18,33 @@ abstract class Adjust { // Common adjustments - const BRIGHTNESS = 'brightness'; - const CONTRAST = 'contrast'; - const SATURATION = 'saturation'; - const GAMMA = 'gamma'; + public const BRIGHTNESS = 'brightness'; + public const CONTRAST = 'contrast'; + public const SATURATION = 'saturation'; + public const GAMMA = 'gamma'; // Image adjustments - const RED = 'red'; - const GREEN = 'green'; - const BLUE = 'blue'; - const BRIGHTNESS_HSB = 'brightness_hsb'; - const HUE = 'hue'; - const TINT = 'tint'; - const REPLACE_COLOR = 'replace_color'; - const RECOLOR = 'recolor'; + public const RED = 'red'; + public const GREEN = 'green'; + public const BLUE = 'blue'; + public const BRIGHTNESS_HSB = 'brightness_hsb'; + public const HUE = 'hue'; + public const TINT = 'tint'; + public const REPLACE_COLOR = 'replace_color'; + public const RECOLOR = 'recolor'; - const AUTO_BRIGHTNESS = 'auto_brightness'; - const AUTO_COLOR = 'auto_color'; - const AUTO_CONTRAST = 'auto_contrast'; - const FILL_LIGHT = 'fill_light'; - const IMPROVE = 'improve'; - const VIBRANCE = 'vibrance'; - const VIESUS_CORRECT = 'viesus_correct'; + public const AUTO_BRIGHTNESS = 'auto_brightness'; + public const AUTO_COLOR = 'auto_color'; + public const AUTO_CONTRAST = 'auto_contrast'; + public const FILL_LIGHT = 'fill_light'; + public const IMPROVE = 'improve'; + public const VIBRANCE = 'vibrance'; + public const VIESUS_CORRECT = 'viesus_correct'; - const SHARPEN = 'sharpen'; - const UNSHARP_MASK = 'unsharp_mask'; + public const SHARPEN = 'sharpen'; + public const UNSHARP_MASK = 'unsharp_mask'; - const OPACITY_THRESHOLD = 'opacity_threshold'; + public const OPACITY_THRESHOLD = 'opacity_threshold'; use CommonAdjustmentTrait; use ImageAdjustmentTrait; diff --git a/src/Transformation/Adjustment/CommonAdjustmentTrait.php b/src/Transformation/Adjustment/CommonAdjustmentTrait.php index 66ab1dc..c5cc97b 100644 --- a/src/Transformation/Adjustment/CommonAdjustmentTrait.php +++ b/src/Transformation/Adjustment/CommonAdjustmentTrait.php @@ -22,11 +22,10 @@ trait CommonAdjustmentTrait /** * Adjusts the brightness. * - * @param int $level The level of brightness (Range: -99 to 100, Server default: 80) + * @param int|null $level The level of brightness (Range: -99 to 100, Server default: 80) * - * @return LevelEffectAction */ - public static function brightness($level = null) + public static function brightness(?int $level = null): LevelEffectAction { return EffectAction::withLevel(Adjust::BRIGHTNESS, EffectRange::BRIGHTNESS, $level); } @@ -34,11 +33,10 @@ public static function brightness($level = null) /** * Adjusts the contrast. * - * @param int $level The level of contrast (Range: -100 to 100, Server default: 0) + * @param int|null $level The level of contrast (Range: -100 to 100, Server default: 0) * - * @return LevelEffectAction */ - public static function contrast($level = null) + public static function contrast(?int $level = null): LevelEffectAction { return EffectAction::withLevel(Adjust::CONTRAST, EffectRange::DEFAULT_RANGE, $level); } @@ -46,11 +44,10 @@ public static function contrast($level = null) /** * Adjusts the color saturation. * - * @param int $level The level of color saturation (Range: -100 to 100, Server default: 80). + * @param int|null $level The level of color saturation (Range: -100 to 100, Server default: 80). * - * @return LevelEffectAction */ - public static function saturation($level = null) + public static function saturation(?int $level = null): LevelEffectAction { return EffectAction::withLevel(Adjust::SATURATION, EffectRange::DEFAULT_RANGE, $level); } @@ -58,11 +55,10 @@ public static function saturation($level = null) /** * Adjusts the gamma level. * - * @param int $level The level of gamma (Range: -50 to 150, Server default: 0). + * @param int|null $level The level of gamma (Range: -50 to 150, Server default: 0). * - * @return LevelEffectAction */ - public static function gamma($level = null) + public static function gamma(?int $level = null): LevelEffectAction { return EffectAction::withLevel(Adjust::GAMMA, EffectRange::SHIFTED_RANGE, $level); } @@ -72,11 +68,10 @@ public static function gamma($level = null) * * @see https://cloudinary.com/documentation/image_transformations#applying_3d_luts_to_images * - * @param string $lutId The 3D LUT file id + * @param string|null $lutId The 3D LUT file id * - * @return LutLayer */ - public static function by3dLut($lutId = null) + public static function by3dLut(?string $lutId = null): LutLayer { return ClassUtils::verifyInstance($lutId, LutLayer::class); } @@ -87,12 +82,11 @@ public static function by3dLut($lutId = null) * This is a generic way to apply an effect. For example, you could set $name to "gamma" and $args to 50, and this * would have the same effect as calling gamma(50). * - * @param string $name The effect name. + * @param string $name The effect name. * @param mixed ...$args The qualifiers of the effect. * - * @return EffectAction */ - public static function generic($name, ...$args) + public static function generic(string $name, ...$args): EffectAction { return EffectAction::named($name, ...$args); } diff --git a/src/Transformation/Adjustment/FillLight.php b/src/Transformation/Adjustment/FillLight.php index c3e0e47..6c818c9 100644 --- a/src/Transformation/Adjustment/FillLight.php +++ b/src/Transformation/Adjustment/FillLight.php @@ -20,7 +20,7 @@ class FillLight extends BlendEffectQualifier /** * @var array $valueOrder The order of the values. */ - protected $valueOrder = [0, 'value', 'bias']; + protected array $valueOrder = [0, 'value', 'bias']; /** * FillLight constructor. @@ -40,11 +40,10 @@ public function __construct($blend = null, $bias = null) /** * Sets the bias. * - * @param int $bias The bias to apply to the fill light effect (Range: -100 to 100, Server default: 0). + * @param ?int $bias The bias to apply to the fill light effect (Range: -100 to 100, Server default: 0). * - * @return FillLight */ - public function bias($bias) + public function bias(?int $bias): static { $this->getValue()->setSimpleValue('bias', $bias); diff --git a/src/Transformation/Adjustment/ImageAdjustmentTrait.php b/src/Transformation/Adjustment/ImageAdjustmentTrait.php index dec7f94..2c51217 100644 --- a/src/Transformation/Adjustment/ImageAdjustmentTrait.php +++ b/src/Transformation/Adjustment/ImageAdjustmentTrait.php @@ -20,12 +20,11 @@ trait ImageAdjustmentTrait /** * Adjusts the brightness and blends the result with the original image. * - * @param int $blend How much to blend the adjusted brightness, where 0 means only use the original and 100 means - * only use the adjusted brightness result. (Range: 0 to 100, Server default: 100) + * @param int|null $blend How much to blend the adjusted brightness, where 0 means only use the original and 100 + * means only use the adjusted brightness result. (Range: 0 to 100, Server default: 100) * - * @return BlendEffectAction */ - public static function autoBrightness($blend = null) + public static function autoBrightness(?int $blend = null): BlendEffectAction { return EffectAction::withBlend(Adjust::AUTO_BRIGHTNESS, EffectRange::PERCENT, $blend); } @@ -33,12 +32,11 @@ public static function autoBrightness($blend = null) /** * Adjusts the color balance and blends the result with the original image. * - * @param int $blend How much to blend the adjusted color result, where 0 means only use the original and 100 means - * only use the adjusted color result. (Range: 0 to 100, Server default: 100) + * @param int|null $blend How much to blend the adjusted color result, where 0 means only use the original and 100 + * means only use the adjusted color result. (Range: 0 to 100, Server default: 100) * - * @return BlendEffectAction */ - public static function autoColor($blend = null) + public static function autoColor(?int $blend = null): BlendEffectAction { return EffectAction::withBlend(Adjust::AUTO_COLOR, EffectRange::PERCENT, $blend); } @@ -46,12 +44,11 @@ public static function autoColor($blend = null) /** * Adjusts the contrast and blends the result with the original image. * - * @param int $blend How much to blend the adjusted contrast, where 0 means only use the original and 100 means - * only use the adjusted contrast result. (Range: 0 to 100, Server default: 100) + * @param int|null $blend How much to blend the adjusted contrast, where 0 means only use the original and 100 means + * only use the adjusted contrast result. (Range: 0 to 100, Server default: 100) * - * @return BlendEffectAction */ - public static function autoContrast($blend = null) + public static function autoContrast(?int $blend = null): BlendEffectAction { return EffectAction::withBlend(Adjust::AUTO_CONTRAST, EffectRange::PERCENT, $blend); } @@ -59,14 +56,13 @@ public static function autoContrast($blend = null) /** * Adjusts the fill light and blends the result with the original image. * - * @param int $blend How much to blend the adjusted fill light, where 0 means only use the original and 100 means - * only use the adjusted fill light result. Range: 0 to 100, Server default: 100) - * @param int $bias The bias to apply to the fill light effect (Range: -100 to 100, Server default: 0). + * @param int|null $blend How much to blend the adjusted fill light, where 0 means only use the original and 100 + * means only use the adjusted fill light result. Range: 0 to 100, Server default: 100) + * @param int|null $bias The bias to apply to the fill light effect (Range: -100 to 100, Server default: 0). * * - * @return FillLight */ - public static function fillLight($blend = null, $bias = null) + public static function fillLight(?int $blend = null, ?int $bias = null): FillLight { return new FillLight($blend, $bias); } @@ -76,17 +72,16 @@ public static function fillLight($blend = null, $bias = null) * * Use the constants defined in \Cloudinary\Transformation\Improve for $mode. * - * @param int $blend How much to blend the improved result with the original image, - * where 0 means only use the original and 100 means only use the improved result. - * (Range: 0 to 100, Server default: 100) + * @param int|null $blend How much to blend the improved result with the original image, + * where 0 means only use the original and 100 means only use the improved result. + * (Range: 0 to 100, Server default: 100) * - * @param string $mode The improve mode. Use the constants defined in the Improve class. + * @param string|null $mode The `improve` mode. Use the constants defined in the Improve class. * - * @return Improve * - * @see \Cloudinary\Transformation\Improve + * @see Improve */ - public static function improve($blend = null, $mode = null) + public static function improve(?int $blend = null, ?string $mode = null): Improve { return new Improve($blend, $mode); } @@ -94,11 +89,10 @@ public static function improve($blend = null, $mode = null) /** * Applies a vibrance filter on the image. * - * @param int $strength The strength of the vibrance. (Range: -100 to 100, Server default: 20) + * @param int|null $strength The strength of the vibrance. (Range: -100 to 100, Server default: 20) * - * @return StrengthEffectAction */ - public static function vibrance($strength = null) + public static function vibrance(?int $strength = null): StrengthEffectAction { return EffectAction::withStrength(Adjust::VIBRANCE, EffectRange::DEFAULT_RANGE, $strength); } @@ -108,12 +102,11 @@ public static function vibrance($strength = null) * * For details, see the Viesus Automatic Image Enhancement add-on documentation. * - * @return ViesusCorrect * - * @see \Cloudinary\Transformation\ViesusCorrect + * @see ViesusCorrect * @see https://cloudinary.com/documentation/viesus_automatic_image_enhancement_addon */ - public static function viesusCorrect() + public static function viesusCorrect(): ViesusCorrect { return new ViesusCorrect(); } @@ -121,11 +114,10 @@ public static function viesusCorrect() /** * Adjusts the image's red channel. * - * @param int $level The level of red. (Range: -100 to 100, Server default: 0) + * @param int|null $level The level of red. (Range: -100 to 100, Server default: 0) * - * @return LevelEffectAction */ - public static function red($level = null) + public static function red(?int $level = null): LevelEffectAction { return EffectAction::withLevel(Adjust::RED, EffectRange::DEFAULT_RANGE, $level); } @@ -133,11 +125,10 @@ public static function red($level = null) /** * Adjusts the image's green channel. * - * @param int $level The level of green. (Range: -100 to 100, Server default: 0) + * @param int|null $level The level of green. (Range: -100 to 100, Server default: 0) * - * @return LevelEffectAction */ - public static function green($level = null) + public static function green(?int $level = null): LevelEffectAction { return EffectAction::withLevel(Adjust::GREEN, EffectRange::DEFAULT_RANGE, $level); } @@ -145,11 +136,10 @@ public static function green($level = null) /** * Adjusts the image's blue channel. * - * @param int $level The level of blue. (Range: -100 to 100, Server default: 0) + * @param int|null $level The level of blue. (Range: -100 to 100, Server default: 0) * - * @return LevelEffectAction */ - public static function blue($level = null) + public static function blue(?int $level = null): LevelEffectAction { return EffectAction::withLevel(Adjust::BLUE, EffectRange::DEFAULT_RANGE, $level); } @@ -157,11 +147,10 @@ public static function blue($level = null) /** * Adjusts image brightness modulation in HSB to prevent artifacts in some images. * - * @param int $level The level of modulation. (Range: -99 to 100, Server default: 80) + * @param int|null $level The level of modulation. (Range: -99 to 100, Server default: 80) * - * @return LevelEffectAction */ - public static function brightnessHSB($level = null) + public static function brightnessHSB(?int $level = null): LevelEffectAction { return EffectAction::withLevel(Adjust::BRIGHTNESS_HSB, EffectRange::BRIGHTNESS, $level); } @@ -169,11 +158,10 @@ public static function brightnessHSB($level = null) /** * Adjusts the image's hue. * - * @param int $level The level of hue. (Range: -100 to 100, Server default: 80) + * @param int|null $level The level of hue. (Range: -100 to 100, Server default: 80) * - * @return LevelEffectAction */ - public static function hue($level = null) + public static function hue(?int $level = null): LevelEffectAction { return EffectAction::withLevel(Adjust::HUE, EffectRange::DEFAULT_RANGE, $level); } @@ -184,11 +172,10 @@ public static function hue($level = null) * Optional - equalize colors before tinting, specify gradient blend positioning per color. * * @param array $qualifiers Syntax: [equalize]:[amount]:[color1]:[color1_position]:[color2]:[color2_position]:... - * [color10]:[color10_position] + * [color10]:[color10_position] * - * @return EffectAction */ - public static function tint(...$qualifiers) + public static function tint(...$qualifiers): EffectAction { return EffectAction::named(Adjust::TINT, ...$qualifiers); } @@ -200,21 +187,23 @@ public static function tint(...$qualifiers) * More highly saturated input colors usually give the best results. It is recommended to avoid input colors * approaching white, black, or gray. * - * @param string $toColor The HTML name or RGB/A hex code of the target output color. - * @param int $tolerance The tolerance threshold (a radius in the LAB color space) from the input color, - * representing the span of colors that should be replaced with a correspondingly adjusted - * version of the target output color. Larger values result in replacing more colors - * within the image. The more saturated the original input color, the more a change in - * value will impact the result (Server default: 50). - * @param string $fromColor The HTML name or RGB/A hex code of the base input color to map - * (Server default: the most prominent high-saturation color in the image). + * @param string $toColor The HTML name or RGB/A hex code of the target output color. + * @param int|null $tolerance The tolerance threshold (a radius in the LAB color space) from the input color, + * representing the span of colors that should be replaced with a correspondingly + * adjusted version of the target output color. Larger values result in replacing + * more colors within the image. The more saturated the original input color, the + * more a change in value will impact the result (Server default: 50). + * @param string|null $fromColor The HTML name or RGB/A hex code of the base input color to map + * (Server default: the most prominent high-saturation color in the image). * - * @return ReplaceColor * - * @see \Cloudinary\Transformation\ReplaceColor + * @see ReplaceColor */ - public static function replaceColor($toColor, $tolerance = null, $fromColor = null) - { + public static function replaceColor( + string $toColor, + ?int $tolerance = null, + ?string $fromColor = null + ): ReplaceColor { return new ReplaceColor($toColor, $tolerance, $fromColor); } @@ -228,9 +217,8 @@ public static function replaceColor($toColor, $tolerance = null, $fromColor = nu * * @param array $colorMatrix The matrix of colors. * - * @return EffectAction */ - public static function recolor(...$colorMatrix) + public static function recolor(...$colorMatrix): EffectAction { return EffectAction::fromEffectQualifier(new RecolorQualifier(...$colorMatrix)); } @@ -238,11 +226,10 @@ public static function recolor(...$colorMatrix) /** * Applies a sharpening filter to the image. * - * @param int $strength The strength of the filter. (Range: 1 to 2000, Server default: 100) + * @param int|null $strength The strength of the filter. (Range: 1 to 2000, Server default: 100) * - * @return StrengthEffectAction */ - public static function sharpen($strength = null) + public static function sharpen(?int $strength = null): StrengthEffectAction { return EffectAction::withStrength(Adjust::SHARPEN, EffectRange::PIXEL, $strength); } @@ -250,11 +237,10 @@ public static function sharpen($strength = null) /** * Applies an unsharp mask filter to the image. * - * @param int $strength The strength of the filter. (Range: 1 to 2000, Server default: 100) + * @param int|null $strength The strength of the filter. (Range: 1 to 2000, Server default: 100) * - * @return StrengthEffectAction */ - public static function unsharpMask($strength = null) + public static function unsharpMask(?int $strength = null): StrengthEffectAction { return EffectAction::withStrength(Adjust::UNSHARP_MASK, EffectRange::PIXEL, $strength); } @@ -268,11 +254,10 @@ public static function unsharpMask($strength = null) * pixels fully transparent. Note: This effect can be a useful solution when PhotoShop PSD files are delivered in a * format supporting partial transparency, such as PNG, and the results without this effect are not as expected. * - * @param int $level The level of the threshold. (Range: 1 to 100, Server default: 50) + * @param int|null $level The level of the threshold. (Range: 1 to 100, Server default: 50) * - * @return LevelEffectAction */ - public static function opacityThreshold($level = null) + public static function opacityThreshold(?int $level = null): LevelEffectAction { return EffectAction::withLevel(Adjust::OPACITY_THRESHOLD, EffectRange::POSITIVE_PERCENT, $level); } @@ -280,14 +265,13 @@ public static function opacityThreshold($level = null) /** * Adjusts the opacity of the image and makes it semi-transparent. * - * @param float $level The level of opacity. 100 means opaque, while 0 is completely transparent. - * (Range: 0 to 100) + * @param int|float|null $level The level of opacity. 100 means opaque, while 0 is completely transparent. + * (Range: 0 to 100) * - * @return Opacity * - * @see \Cloudinary\Transformation\Opacity + * @see Opacity */ - public static function opacity($level) + public static function opacity(int|float|null $level): Opacity { return new Opacity($level); } diff --git a/src/Transformation/Adjustment/Improve.php b/src/Transformation/Adjustment/Improve.php index 4dd2c8e..7fd2256 100644 --- a/src/Transformation/Adjustment/Improve.php +++ b/src/Transformation/Adjustment/Improve.php @@ -26,15 +26,12 @@ class Improve extends BlendEffectQualifier /** * @var array $valueOrder The order of the values. */ - protected $valueOrder = [0, 'mode', 'value']; + protected array $valueOrder = [0, 'mode', 'value']; /** * Improve constructor. - * - * @param $blend - * @param mixed $mode */ - public function __construct($blend = null, $mode = null) + public function __construct(?int $blend = null, ?string $mode = null) { parent::__construct(Adjust::IMPROVE, EffectRange::PERCENT, $blend); @@ -46,25 +43,23 @@ public function __construct($blend = null, $mode = null) * * Use this mode to get better results on images with indoor lighting and shadows. * - * @param int $blend How much to blend the improved result with the original image, where 0 means only use the + * @param int|null $blend How much to blend the improved result with the original image, where 0 means only use the * original and 100 means only use the improved result. * - * @return Improve */ - public static function indoor($blend = null) + public static function indoor(?int $blend = null): Improve { return new static($blend, ImproveMode::INDOOR); } /** - * Sets the improve effect to OUTDOOR mode. + * Sets the `improve` effect to OUTDOOR mode. * - * @param int $blend How much to blend the improved result with the original image, where 0 means only use the + * @param int|null $blend How much to blend the improved result with the original image, where 0 means only use the * original and 100 means only use the improved result. * - * @return Improve */ - public static function outdoor($blend = null) + public static function outdoor(?int $blend = null): Improve { return new static($blend, ImproveMode::OUTDOOR); } diff --git a/src/Transformation/Adjustment/ImproveMode.php b/src/Transformation/Adjustment/ImproveMode.php index 901105f..b6b9538 100644 --- a/src/Transformation/Adjustment/ImproveMode.php +++ b/src/Transformation/Adjustment/ImproveMode.php @@ -23,19 +23,18 @@ class ImproveMode /** * INDOOR mode. Use this mode to get better results on images with indoor lighting and shadows. */ - const INDOOR = 'indoor'; + public const INDOOR = 'indoor'; /** * OUTDOOR mode (Server default). */ - const OUTDOOR = 'outdoor'; + public const OUTDOOR = 'outdoor'; /** * INDOOR mode. Use this mode to get better results on images with indoor lighting and shadows. * - * @return string */ - public static function indoor() + public static function indoor(): string { return self::INDOOR; } @@ -43,9 +42,8 @@ public static function indoor() /** * OUTDOOR mode (Server default). * - * @return string */ - public static function outdoor() + public static function outdoor(): string { return self::OUTDOOR; } diff --git a/src/Transformation/Adjustment/OpacityQualifierTrait.php b/src/Transformation/Adjustment/OpacityQualifierTrait.php index 7438abb..0f6b062 100644 --- a/src/Transformation/Adjustment/OpacityQualifierTrait.php +++ b/src/Transformation/Adjustment/OpacityQualifierTrait.php @@ -23,9 +23,8 @@ trait OpacityQualifierTrait * @param int $level The level of opacity. 100 means opaque, while 0 is completely transparent * (Range: 0 to 100). * - * @return Opacity */ - public static function opacity($level) + public static function opacity(int $level): Opacity { return new Opacity($level); } diff --git a/src/Transformation/Adjustment/ReplaceColor.php b/src/Transformation/Adjustment/ReplaceColor.php index ebf3e62..b6cc52f 100644 --- a/src/Transformation/Adjustment/ReplaceColor.php +++ b/src/Transformation/Adjustment/ReplaceColor.php @@ -31,17 +31,17 @@ class ReplaceColor extends EffectQualifier /** * @var array $valueOrder The order of the values. */ - protected $valueOrder = [0, 'to_color', 'tolerance', 'from_color']; + protected array $valueOrder = [0, 'to_color', 'tolerance', 'from_color']; /** * ReplaceColor constructor. * - * @param string|ColorValue $toColor The HTML name or RGB/A hex code of the target output color. - * @param int $tolerance The tolerance threshold (a radius in the LAB color space) from the input + * @param string|ColorValue $toColor The HTML name or RGB/A hex code of the target output color. + * @param int $tolerance The tolerance threshold (a radius in the LAB color space) from the input * color. - * @param string|ColorValue $fromColor The HTML name or RGB/A hex code of the base input color to map. + * @param string|ColorValue|null $fromColor The HTML name or RGB/A hex code of the base input color to map. */ - public function __construct($toColor, $tolerance = null, $fromColor = null) + public function __construct($toColor, $tolerance = null, ColorValue|string|null $fromColor = null) { parent::__construct(Adjust::REPLACE_COLOR); @@ -55,9 +55,8 @@ public function __construct($toColor, $tolerance = null, $fromColor = null) * * @param string|ColorValue $to The HTML name or RGB/A hex code of the target output color. * - * @return ReplaceColor */ - public function toColor($to) + public function toColor(ColorValue|string $to): static { // dirty hack to omit rgb: from hex colors $to = StringUtils::truncatePrefix((string)$to, '#'); @@ -69,15 +68,14 @@ public function toColor($to) /** * Sets the tolerance threshold. * - * @param int $tolerance The tolerance threshold (a radius in the LAB color space) from the input color, + * @param ?int $tolerance The tolerance threshold (a radius in the LAB color space) from the input color, * representing the span of colors that should be replaced with a correspondingly adjusted * version of the target output color. Larger values result in replacing more colors * within the image. The more saturated the original input color, the more a change in * value will impact the result. * - * @return ReplaceColor */ - public function tolerance($tolerance) + public function tolerance(?int $tolerance): static { $this->value->setSimpleValue('tolerance', $tolerance); @@ -87,11 +85,10 @@ public function tolerance($tolerance) /** * Sets the base input color to map. * - * @param string|ColorValue $fromColor The HTML name or RGB/A hex code of the base input color to map. + * @param string|ColorValue|null $fromColor The HTML name or RGB/A hex code of the base input color to map. * - * @return ReplaceColor */ - public function fromColor($fromColor) + public function fromColor(ColorValue|string|null $fromColor): static { // dirty hack to omit rgb: from hex colors $fromColor = StringUtils::truncatePrefix((string)$fromColor, '#'); diff --git a/src/Transformation/Animated/Animated.php b/src/Transformation/Animated/Animated.php index 9dc1e7a..e396d31 100644 --- a/src/Transformation/Animated/Animated.php +++ b/src/Transformation/Animated/Animated.php @@ -24,9 +24,8 @@ abstract class Animated /** * Edits the animated image. * - * @return AnimatedEdit */ - public static function edit() + public static function edit(): AnimatedEdit { return new AnimatedEdit(); } diff --git a/src/Transformation/Animated/AnimatedEditTrait.php b/src/Transformation/Animated/AnimatedEditTrait.php index 936b359..5c8e5eb 100644 --- a/src/Transformation/Animated/AnimatedEditTrait.php +++ b/src/Transformation/Animated/AnimatedEditTrait.php @@ -23,10 +23,8 @@ trait AnimatedEditTrait * Controls the time delay between the frames of an animated image, in milliseconds. * * @param int $delay The delay in milliseconds - * - * @return AnimatedEdit */ - public function delay($delay) + public function delay(int $delay): AnimatedEdit { return $this->addQualifier(ClassUtils::forceInstance($delay, Delay::class)); } @@ -38,11 +36,10 @@ public function delay($delay) * * You can also specify the loop effect without a numeric value to instruct it to loop the GIF infinitely. * - * @param int $additionalIterations The additional number of times to play the animated GIF. + * @param int|null $additionalIterations The additional number of times to play the animated GIF. * - * @return AnimatedEdit */ - public function loop($additionalIterations = null) + public function loop(?int $additionalIterations = null): AnimatedEdit { return $this->addQualifier(ClassUtils::forceInstance($additionalIterations, Loop::class)); } diff --git a/src/Transformation/Background/AutoBackground.php b/src/Transformation/Background/AutoBackground.php index 845acb9..c19bd3c 100644 --- a/src/Transformation/Background/AutoBackground.php +++ b/src/Transformation/Background/AutoBackground.php @@ -23,31 +23,31 @@ */ class AutoBackground extends Background { - const AUTO = 'auto'; - const MODE = 'mode'; - const PALETTE = 'palette'; + public const AUTO = 'auto'; + public const MODE = 'mode'; + public const PALETTE = 'palette'; use AutoBackgroundTrait; /** * @var array $valueOrder The order of the values. */ - protected $valueOrder = [0, self::MODE, self::PALETTE]; + protected array $valueOrder = [0, self::MODE, self::PALETTE]; /** * Selects the predominant color while taking only the image border pixels into account. (Server default) */ - const BORDER = 'border'; + public const BORDER = 'border'; /** * Selects the predominant color while taking all pixels in the image into account. */ - const PREDOMINANT = 'predominant'; + public const PREDOMINANT = 'predominant'; /** * @var string $type The type of the background color. Use the constants defined in this class. */ - protected $type; + protected string $type; /** * AutoBackground constructor. @@ -64,11 +64,10 @@ public function __construct($mode) /** * Determines which color is automatically chosen for the background. * - * @param string $mode Use the constants defined in this class. + * @param AutoBackgroundMode|string|null $mode Use the constants defined in this class. * - * @return AutoBackground */ - protected function mode($mode) + protected function mode(AutoBackgroundMode|string|null $mode): static { $this->value->setSimpleValue(self::MODE, ClassUtils::forceInstance($mode, AutoBackgroundMode::class)); @@ -80,9 +79,8 @@ protected function mode($mode) * * @param string $type Use the constants defined in this class. * - * @return AutoBackground */ - public function type($type) + public function type(string $type): static { $this->value->getSimpleValue(self::MODE)->type($type); @@ -92,9 +90,8 @@ public function type($type) /** * Inverse the color. * - * @return AutoBackground */ - public function contrast() + public function contrast(): static { $this->value->getSimpleValue(self::MODE)->contrast(); @@ -106,9 +103,8 @@ public function contrast() * * @param array|Palette $colors The palette of colors * - * @return AutoBackground */ - public function palette(...$colors) + public function palette(...$colors): static { $this->value->setSimpleNamedValue(self::PALETTE, ClassUtils::verifyVarArgsInstance($colors, Palette::class)); diff --git a/src/Transformation/Background/AutoBackgroundMode.php b/src/Transformation/Background/AutoBackgroundMode.php index c51b659..7a1b5e3 100644 --- a/src/Transformation/Background/AutoBackgroundMode.php +++ b/src/Transformation/Background/AutoBackgroundMode.php @@ -21,12 +21,12 @@ */ class AutoBackgroundMode extends QualifierMultiValue { - const VALUE_DELIMITER = '_'; + protected const VALUE_DELIMITER = '_'; - const TYPE = 'type'; - const CONTRAST = 'contrast'; + public const TYPE = 'type'; + public const CONTRAST = 'contrast'; - protected $argumentOrder = [self::TYPE, self::CONTRAST]; + protected array $argumentOrder = [self::TYPE, self::CONTRAST]; /** * AutoBackgroundMode constructor. @@ -43,11 +43,10 @@ public function __construct($type) /** * Determines which color is automatically chosen for the background. * - * @param string $type Use the constants defined in this class. + * @param ?string $type Use the constants defined in this class. * - * @return AutoBackgroundMode */ - public function type($type) + public function type(?string $type): static { $this->setSimpleValue(self::TYPE, $type); @@ -57,9 +56,8 @@ public function type($type) /** * Inverse the color. * - * @return AutoBackgroundMode */ - public function contrast() + public function contrast(): AutoBackgroundMode { return $this->setSimpleValue(self::CONTRAST, self::CONTRAST); } diff --git a/src/Transformation/Background/AutoBackgroundTrait.php b/src/Transformation/Background/AutoBackgroundTrait.php index 4a2d028..4addc04 100644 --- a/src/Transformation/Background/AutoBackgroundTrait.php +++ b/src/Transformation/Background/AutoBackgroundTrait.php @@ -10,8 +10,6 @@ namespace Cloudinary\Transformation; -use Cloudinary\Transformation\Argument\ColorValue; - /** * Trait BackgroundTrait * @@ -22,9 +20,8 @@ trait AutoBackgroundTrait /** * Selects the predominant color while taking only the image border pixels into account. * - * @return AutoBackground */ - public static function border() + public static function border(): AutoBackground { return new AutoBackground(AutoBackground::BORDER); } @@ -32,9 +29,8 @@ public static function border() /** * Selects the predominant color while taking all pixels in the image into account. * - * @return AutoBackground */ - public static function predominant() + public static function predominant(): AutoBackground { return new AutoBackground(AutoBackground::PREDOMINANT); } diff --git a/src/Transformation/Background/AutoGradientBackground.php b/src/Transformation/Background/AutoGradientBackground.php index e8e0636..7620493 100644 --- a/src/Transformation/Background/AutoGradientBackground.php +++ b/src/Transformation/Background/AutoGradientBackground.php @@ -26,27 +26,29 @@ class AutoGradientBackground extends AutoBackground /** * Base the gradient fade effect on the predominant colors in the border pixels of the image. */ - const BORDER_GRADIENT = 'border_gradient'; + public const BORDER_GRADIENT = 'border_gradient'; /** * Base the gradient fade effect on the predominant colors in the image. */ - const PREDOMINANT_GRADIENT = 'predominant_gradient'; + public const PREDOMINANT_GRADIENT = 'predominant_gradient'; - const GRADIENT_COLORS = 'gradient_colors'; - const DIRECTION = 'direction'; + public const GRADIENT_COLORS = 'gradient_colors'; + public const DIRECTION = 'direction'; - protected $valueOrder = [0, self::MODE, self::GRADIENT_COLORS, self::DIRECTION, self::PALETTE]; + protected array $valueOrder = [0, self::MODE, self::GRADIENT_COLORS, self::DIRECTION, self::PALETTE]; /** * AutoGradientBackground constructor. * - * @param string $mode The auto background mode. - * @param int|string $gradientColors The number of gradient colors to select. Possible values: 2 or 4. Default: 2 - * @param string $gradientDirection The direction. Use the constants defined in the GradientDirection class. + * @param string $mode The auto background mode. + * @param int|string|null $gradientColors The number of gradient colors to select. Possible values: 2 or 4. + * Default: 2 + * @param string|null $gradientDirection The direction. Use the constants defined in the GradientDirection + * class. */ - public function __construct($mode, $gradientColors = null, $gradientDirection = null) + public function __construct($mode, int|string|null $gradientColors = null, ?string $gradientDirection = null) { parent::__construct($mode); @@ -57,11 +59,11 @@ public function __construct($mode, $gradientColors = null, $gradientDirection = /** * Sets the number of gradient colors to select. * - * @param int|string $gradientColors Possible values: 2 or 4. Default: 2 + * @param int|string|null $gradientColors Possible values: 2 or 4. Default: 2 * * @return $this */ - public function gradientColors($gradientColors) + public function gradientColors(int|string|null $gradientColors): static { $this->value->setSimpleValue(self::GRADIENT_COLORS, $gradientColors); @@ -69,15 +71,15 @@ public function gradientColors($gradientColors) } /** - * Sets the the direction to blend the colors together. + * Sets the direction to blend the colors together. * - * @param string $direction The direction. Use the constants defined in the GradientDirection class. + * @param ?string $direction The direction. Use the constants defined in the GradientDirection class. * * @return $this * * @see GradientDirection */ - public function gradientDirection($direction) + public function gradientDirection(?string $direction): static { $this->value->setSimpleValue(self::DIRECTION, $direction); diff --git a/src/Transformation/Background/AutoGradientBackgroundTrait.php b/src/Transformation/Background/AutoGradientBackgroundTrait.php index af9892d..777b2a5 100644 --- a/src/Transformation/Background/AutoGradientBackgroundTrait.php +++ b/src/Transformation/Background/AutoGradientBackgroundTrait.php @@ -23,9 +23,8 @@ trait AutoGradientBackgroundTrait * @param int|string $gradientColors The number of gradient colors to select. Possible values: 2 or 4. Default: 2 * @param string $gradientDirection The direction. Use the constants defined in the GradientDirection class. * - * @return AutoGradientBackground */ - public static function borderGradient($gradientColors = null, $gradientDirection = null) + public static function borderGradient($gradientColors = null, $gradientDirection = null): AutoGradientBackground { return new AutoGradientBackground(AutoGradientBackground::BORDER_GRADIENT, $gradientColors, $gradientDirection); } @@ -36,10 +35,11 @@ public static function borderGradient($gradientColors = null, $gradientDirection * @param int|string $gradientColors The number of gradient colors to select. Possible values: 2 or 4. Default: 2 * @param string $gradientDirection The direction. Use the constants defined in the GradientDirection class. * - * @return AutoGradientBackground */ - public static function predominantGradient($gradientColors = null, $gradientDirection = null) - { + public static function predominantGradient( + $gradientColors = null, + $gradientDirection = null + ): AutoGradientBackground { return new AutoGradientBackground( AutoGradientBackground::PREDOMINANT_GRADIENT, $gradientColors, diff --git a/src/Transformation/Background/Background.php b/src/Transformation/Background/Background.php index 7587094..e516c13 100644 --- a/src/Transformation/Background/Background.php +++ b/src/Transformation/Background/Background.php @@ -35,12 +35,11 @@ class Background extends BaseQualifier /** * @var string $name The name. */ - protected static $name = 'background'; + protected static string $name = 'background'; /** * Background constructor. * - * @param $color */ public function __construct($color) { @@ -52,10 +51,9 @@ public function __construct($color) * * @param string $color The color. Can be RGB, HEX, named color, etc. * - * @return Background * */ - public static function color($color) + public static function color(string $color): Background { return new self($color); } @@ -63,13 +61,12 @@ public static function color($color) /** * Applies blurred background (Relevant only for videos). * - * @param int $intensity The intensity of the blur. - * @param int $brightness The brightness of the background. + * @param int|null $intensity The intensity of the blur. + * @param int|null $brightness The brightness of the background. * - * @return BlurredBackground * */ - public static function blurred($intensity = null, $brightness = null) + public static function blurred(?int $intensity = null, ?int $brightness = null): BlurredBackground { return new BlurredBackground($intensity, $brightness); } @@ -77,13 +74,12 @@ public static function blurred($intensity = null, $brightness = null) /** * Applies background color automatically. * - * @param string $autoBackground The type of the background color. See AutoBackground class. + * @param string|null $autoBackground The type of the background color. See AutoBackground class. * - * @return AutoBackground * * @see AutoBackground */ - public static function auto($autoBackground = null) + public static function auto(?string $autoBackground = null): AutoBackground { return ClassUtils::forceInstance($autoBackground, AutoBackground::class); } @@ -91,13 +87,14 @@ public static function auto($autoBackground = null) /** * Applies generative AI background. * - * @param string|array $prompt Use natural language to describe what generate in the image. - * @param bool $ignoreForeground Whether to take foreground elements into account. + * @param array|string|null $prompt Use natural language to describe what generate in the image. + * @param bool|null $ignoreForeground Whether to take foreground elements into account. * - * @return GenerativeFillBackground */ - public static function generativeFill($prompt = null, $ignoreForeground = null) - { + public static function generativeFill( + array|string|null $prompt = null, + ?bool $ignoreForeground = null + ): GenerativeFillBackground { return new GenerativeFillBackground($prompt, $ignoreForeground); } } diff --git a/src/Transformation/Background/BackgroundColorTrait.php b/src/Transformation/Background/BackgroundColorTrait.php index 8c0cad5..41a66b0 100644 --- a/src/Transformation/Background/BackgroundColorTrait.php +++ b/src/Transformation/Background/BackgroundColorTrait.php @@ -23,13 +23,12 @@ trait BackgroundColorTrait /** * Sets the color of the background. * - * @param Background|ColorValue|string $color The color of the background to set. + * @param string|Background|ColorValue|null $color The color of the background to set. * - * @return static * - * @see \Cloudinary\Transformation\Background + * @see Background */ - public function backgroundColor($color) + public function backgroundColor(Background|ColorValue|string|null $color): static { $this->addQualifier(ClassUtils::verifyInstance($color, Background::class)); diff --git a/src/Transformation/Background/BackgroundQualifierTrait.php b/src/Transformation/Background/BackgroundQualifierTrait.php index 01ef0e6..34c2747 100644 --- a/src/Transformation/Background/BackgroundQualifierTrait.php +++ b/src/Transformation/Background/BackgroundQualifierTrait.php @@ -30,9 +30,8 @@ trait BackgroundQualifierTrait * @param array $value The background color. Can be set as an RGB or RGBA hex triplet or quadruplet, a 3- or * 4-digit RGB/RGBA hex, or a named color. * - * @return Background */ - public static function background(...$value) + public static function background(...$value): Background { return new Background(...$value); } diff --git a/src/Transformation/Background/BackgroundTrait.php b/src/Transformation/Background/BackgroundTrait.php index 536cc03..f52124f 100644 --- a/src/Transformation/Background/BackgroundTrait.php +++ b/src/Transformation/Background/BackgroundTrait.php @@ -26,13 +26,13 @@ trait BackgroundTrait * The image background is visible when padding is added with one of the padding crop modes, when rounding corners, * when adding overlays, and with semi-transparent PNGs and GIFs. * - * @param Background|ColorValue|string $background The background to set. + * @param Background|ColorValue|string|null $background The background to set. * * @return $this * * @see Background */ - public function background($background) + public function background(Background|ColorValue|string|null $background): static { $this->addQualifier(ClassUtils::verifyInstance($background, Background::class)); diff --git a/src/Transformation/Background/BlurredBackground.php b/src/Transformation/Background/BlurredBackground.php index c9eb1e9..c90a75d 100644 --- a/src/Transformation/Background/BlurredBackground.php +++ b/src/Transformation/Background/BlurredBackground.php @@ -24,15 +24,15 @@ class BlurredBackground extends Background /** * @var array $valueOrder The order of the values. */ - protected $valueOrder = [0, 'intensity', 'brightness']; // FIXME: first item should be named! + protected array $valueOrder = [0, 'intensity', 'brightness']; // FIXME: first item should be named! /** * BlurredBackground constructor. * - * @param int $intensity The intensity of the blur. - * @param int $brightness The brightness of the background. + * @param int|null $intensity The intensity of the blur. + * @param int|null $brightness The brightness of the background. */ - public function __construct($intensity = null, $brightness = null) + public function __construct(?int $intensity = null, ?int $brightness = null) { parent::__construct('blurred'); @@ -44,11 +44,11 @@ public function __construct($intensity = null, $brightness = null) /** * Sets the intensity of the blur. * - * @param int $intensity The intensity of the blur. + * @param ?int $intensity The intensity of the blur. * * @return $this */ - public function intensity($intensity) + public function intensity(?int $intensity): static { $this->value->setSimpleValue('intensity', $intensity); @@ -58,11 +58,11 @@ public function intensity($intensity) /** * Sets the brightness of the background. * - * @param int $brightness The brightness of the background. + * @param ?int $brightness The brightness of the background. * * @return $this */ - public function brightness($brightness) + public function brightness(?int $brightness): static { $this->value->setSimpleValue('brightness', $brightness); diff --git a/src/Transformation/Background/GenerativeFillBackground.php b/src/Transformation/Background/GenerativeFillBackground.php index acdb2ff..e2feab1 100644 --- a/src/Transformation/Background/GenerativeFillBackground.php +++ b/src/Transformation/Background/GenerativeFillBackground.php @@ -24,24 +24,24 @@ */ class GenerativeFillBackground extends Background { - const GEN_FILL = 'gen_fill'; + public const GEN_FILL = 'gen_fill'; - const IGNORE_FOREGROUND = 'ignore-foreground'; + public const IGNORE_FOREGROUND = 'ignore-foreground'; - const PROPERTIES = 'properties'; + public const PROPERTIES = 'properties'; /** * @var array $valueOrder The order of the values. */ - protected $valueOrder = [0, self::PROPERTIES]; + protected array $valueOrder = [0, self::PROPERTIES]; /** * GenerativeFillBackground constructor. * - * @param string|array $prompt Use natural language to describe what generate in the image. - * @param bool $ignoreForeground Whether to take foreground elements into account. + * @param string|array|null $prompt Use natural language to describe what generate in the image. + * @param bool|null $ignoreForeground Whether to take foreground elements into account. */ - public function __construct($prompt = null, $ignoreForeground = null) + public function __construct(string|array|null $prompt = null, ?bool $ignoreForeground = null) { parent::__construct(self::GEN_FILL); @@ -54,11 +54,11 @@ public function __construct($prompt = null, $ignoreForeground = null) /** * Use natural language to describe what you want to affect in the image. * - * @param string|array $prompt A list of prompts. + * @param array|string|null $prompt A list of prompts. * * @return $this */ - public function prompt($prompt) + public function prompt(array|string|null $prompt): static { $this->value->getSimpleValue(self::PROPERTIES)->setSimpleNamedValue( GenerativeEffectAction::PROMPT, @@ -71,11 +71,11 @@ public function prompt($prompt) /** * Whether to take foreground elements into account. * - * @param bool $ignoreForeground Whether to take foreground elements into account. + * @param ?bool $ignoreForeground Whether to take foreground elements into account. * * @return $this */ - public function ignoreForeground($ignoreForeground = true) + public function ignoreForeground(?bool $ignoreForeground = true): static { $this->value->getSimpleValue(self::PROPERTIES)->setSimpleNamedValue( self::IGNORE_FOREGROUND, diff --git a/src/Transformation/BaseAction.php b/src/Transformation/BaseAction.php index e798c25..b3209a9 100644 --- a/src/Transformation/BaseAction.php +++ b/src/Transformation/BaseAction.php @@ -26,27 +26,26 @@ abstract class BaseAction extends BaseComponent /** * @var array $qualifiers The components (qualifiers/parameters) of the action. */ - protected $qualifiers = []; + protected array $qualifiers = []; /** - * @var ?string MAIN_QUALIFIER Represents the main qualifier of the action. (some actions do not have main qualifier) + * @var ?string MAIN_QUALIFIER Represents the main qualifier of the action. (some actions don't have main qualifier) */ - const MAIN_QUALIFIER = null; + protected const MAIN_QUALIFIER = null; /** * @var array $flags The flags of the action. */ - protected $flags = []; + protected array $flags = []; /** - * @var string $genericAction The generic (raw) action. + * @var ?string $genericAction The generic (raw) action. */ - protected $genericAction; + protected ?string $genericAction = null; /** * Action constructor. * - * @param mixed ...$qualifiers */ public function __construct(...$qualifiers) { @@ -62,9 +61,9 @@ public function __construct(...$qualifiers) * * @return $this */ - public function addQualifier(?BaseComponent $qualifier = null) + public function addQualifier(?BaseComponent $qualifier = null): static { - ArrayUtils::addNonEmpty($this->qualifiers, $qualifier ? $qualifier->getFullName() : null, $qualifier); + ArrayUtils::addNonEmpty($this->qualifiers, $qualifier?->getFullName(), $qualifier); return $this; } @@ -76,7 +75,7 @@ public function addQualifier(?BaseComponent $qualifier = null) * * @return $this */ - public function addQualifiers(...$qualifiers) + public function addQualifiers(...$qualifiers): static { if (count($qualifiers) < 1) { return $this; @@ -100,11 +99,10 @@ public function addQualifiers(...$qualifiers) /** * Adds (sets) generic (raw) action. * - * @param string $action The generic action string. + * @param ?string $action The generic action string. * - * @return static */ - public function setGenericAction($action) + public function setGenericAction(?string $action): static { if (StringUtils::contains($action, '/')) { throw new InvalidArgumentException('A single generic action must be supplied'); @@ -124,7 +122,7 @@ public function setGenericAction($action) * * @return $this */ - public function setFlag(FlagQualifier $flag, $set = true) + public function setFlag(?FlagQualifier $flag, bool $set = true): static { if ($set === false) { return $this->unsetFlag($flag); @@ -142,7 +140,7 @@ public function setFlag(FlagQualifier $flag, $set = true) * * @return $this */ - public function unsetFlag(FlagQualifier $flag) + public function unsetFlag(FlagQualifier $flag): static { unset($this->flags[$flag->getFlagName()]); @@ -156,7 +154,7 @@ public function unsetFlag(FlagQualifier $flag) * * @return $this */ - public function importAction($action) + public function importAction(?BaseAction $action): static { if ($action === null) { return $this; @@ -170,10 +168,8 @@ public function importAction($action) /** * Serializes to json. - * - * @return mixed */ - public function jsonSerialize() + public function jsonSerialize(): array { $jsonArray = []; @@ -197,7 +193,7 @@ public function jsonSerialize() * * @internal */ - public function getStringQualifiers() + public function getStringQualifiers(): array { $flatQualifiers = []; foreach ($this->qualifiers as $qualifier) { @@ -226,7 +222,7 @@ public function __toString() * * @internal */ - protected function getMainQualifier() + protected function getMainQualifier(): BaseQualifier { $mainQualifierClassName = static::MAIN_QUALIFIER; $mainQualifierKey = $mainQualifierClassName::getName(); @@ -242,9 +238,8 @@ protected function getMainQualifier() * * @param array $flags The flags to serialize * - * @return string */ - protected static function serializeFlags($flags) + protected static function serializeFlags(array $flags): string { return ArrayUtils::implodeActionQualifiers(...array_values($flags)); } @@ -256,12 +251,10 @@ protected static function serializeFlags($flags) * * @return array Serialized qualifiers. */ - protected static function jsonSerializeQualifiers($qualifiers) + protected static function jsonSerializeQualifiers(array $qualifiers): array { $result = array_map( - static function ($qualifier) { - return JsonUtils::jsonSerialize($qualifier); - }, + static fn($qualifier) => JsonUtils::jsonSerialize($qualifier), array_values($qualifiers) ); diff --git a/src/Transformation/BaseComponent.php b/src/Transformation/BaseComponent.php index 5406aa6..6ba318e 100644 --- a/src/Transformation/BaseComponent.php +++ b/src/Transformation/BaseComponent.php @@ -21,28 +21,25 @@ abstract class BaseComponent implements ComponentInterface /** * @var string $name The name of the component. */ - protected static $name; + protected static string $name; /** * BaseComponent constructor. * - * @param mixed ...$args */ - public function __construct(...$args) + public function __construct() { - //static::getName(); } /** * Internal collector of the component class constants. * - * @param array $constantsList The constants that are set in the previous run of the function. + * @param array|null $constantsList The constants that are set in the previous run of the function. * - * @return array * * @internal */ - protected static function getConstants(&$constantsList = null) + protected static function getConstants(array|null &$constantsList = null): array { if (! empty($constantsList)) { return $constantsList; @@ -62,9 +59,9 @@ protected static function getConstants(&$constantsList = null) * * @internal */ - public static function getName() + public static function getName(): string { - $name = static::$name; + $name = static::$name ?? ""; if (empty($name)) { $name = StringUtils::camelCaseToSnakeCase(ClassUtils::getBaseName(static::class)); @@ -82,7 +79,7 @@ public static function getName() * * @internal */ - public function getFullName() + public function getFullName(): string { return self::getName(); } diff --git a/src/Transformation/Border/Border.php b/src/Transformation/Border/Border.php index e72b526..fa4c9d7 100644 --- a/src/Transformation/Border/Border.php +++ b/src/Transformation/Border/Border.php @@ -1,4 +1,5 @@ getMainQualifier()->width($width); @@ -49,7 +50,7 @@ public function width($width) * * @return $this */ - public function style($style) + public function style(string $style): static { $this->getMainQualifier()->style($style); @@ -59,11 +60,11 @@ public function style($style) /** * Sets the color of the border. * - * @param string $color The color of the border. + * @param mixed $color The color of the border. * * @return $this */ - public function color($color) + public function color(mixed $color): static { $this->getMainQualifier()->color($color); @@ -81,18 +82,21 @@ public function color($color) * corner according to $bottomRight.
* All qualifiers specified: Each corner is rounded accordingly. * - * @param int|string|CornerRadius $radiusOrTopLeft The radius in pixels of the top left corner or all the corners - * if no other corners are specified. - * @param int $topRight The radius in pixels of the top right corner. - * @param int $bottomRight The radius in pixels of the bottom right corner. - * @param int $bottomLeft The radius in pixels of the bottom left corner. + * @param int|string|CornerRadius|RoundCorners $radiusOrTopLeft The radius in pixels of the top left corner or all + * the corners if no other corners are specified. + * @param int|null $topRight The radius in pixels of the top right corner. + * @param int|null $bottomRight The radius in pixels of the bottom right corner. + * @param int|null $bottomLeft The radius in pixels of the bottom left corner. * - * @return static * - * @see \Cloudinary\Transformation\RoundCorners + * @see RoundCorners */ - public function roundCorners($radiusOrTopLeft, $topRight = null, $bottomRight = null, $bottomLeft = null) - { + public function roundCorners( + int|string|CornerRadius|RoundCorners $radiusOrTopLeft, + ?int $topRight = null, + ?int $bottomRight = null, + ?int $bottomLeft = null + ): static { $qualifiers = ArrayUtils::safeFilter([$radiusOrTopLeft, $topRight, $bottomRight, $bottomLeft]); return $this->addQualifier(ClassUtils::verifyVarArgsInstance($qualifiers, RoundCorners::class)); diff --git a/src/Transformation/Border/BorderQualifier.php b/src/Transformation/Border/BorderQualifier.php index 2bca160..2095df1 100644 --- a/src/Transformation/Border/BorderQualifier.php +++ b/src/Transformation/Border/BorderQualifier.php @@ -27,23 +27,23 @@ */ class BorderQualifier extends BaseQualifier { - const VALUE_CLASS = BorderValue::class; + protected const VALUE_CLASS = BorderValue::class; /** * @var string $key Serialization key. */ - protected static $key = 'bo'; + protected static string $key = 'bo'; use BorderStyleTrait; /** * Sets the width of the border. * - * @param int|string $width The width in pixels. + * @param int|string|null $width The width in pixels. * * @return $this */ - public function width($width) + public function width(int|string|null $width): static { $this->value->width($width); @@ -57,7 +57,7 @@ public function width($width) * * @return $this */ - public function style($style) + public function style(string $style): static { $this->value->style($style); @@ -67,11 +67,11 @@ public function style($style) /** * Sets the color of the border. * - * @param string $color The color of the border. + * @param mixed $color The color of the border. * * @return $this */ - public function color($color) + public function color(mixed $color): static { $this->value->color($color); @@ -81,11 +81,10 @@ public function color($color) /** * Creates a new instance using provided qualifiers array. * - * @param string|array $border The qualifiers of border. + * @param array|string $border The qualifiers of border. * - * @return BorderQualifier */ - public static function fromParams($border) + public static function fromParams(array|string $border): BorderQualifier { if (is_array($border)) { $borderWidth = ArrayUtils::get($border, 'width', 2); diff --git a/src/Transformation/Border/BorderQualifierTrait.php b/src/Transformation/Border/BorderQualifierTrait.php index d597d13..de7f294 100644 --- a/src/Transformation/Border/BorderQualifierTrait.php +++ b/src/Transformation/Border/BorderQualifierTrait.php @@ -24,9 +24,8 @@ trait BorderQualifierTrait * `solid` is supported for style. Colors can be set as an RGB or RGBA hex triplet or * quadruplet, a 3- or 4-digit RGB/RGBA hex, or a named color. * - * @return BorderQualifier */ - public static function border(...$value) + public static function border(...$value): BorderQualifier { return new BorderQualifier(...$value); } diff --git a/src/Transformation/Border/BorderStyleTrait.php b/src/Transformation/Border/BorderStyleTrait.php index 5bd1e86..72ac309 100644 --- a/src/Transformation/Border/BorderStyleTrait.php +++ b/src/Transformation/Border/BorderStyleTrait.php @@ -20,12 +20,11 @@ trait BorderStyleTrait /** * Adds a border around the image. * - * @param int $width The width in pixels. - * @param string $color The color of the border. + * @param int|null $width The width in pixels. + * @param string|null $color The color of the border. * - * @return Border */ - public static function solid($width = null, $color = null) + public static function solid(?int $width = null, ?string $color = null): Border { return (new Border())->style('solid')->width($width)->color($color); } diff --git a/src/Transformation/Border/BorderValue.php b/src/Transformation/Border/BorderValue.php index e1626e7..d0641f3 100644 --- a/src/Transformation/Border/BorderValue.php +++ b/src/Transformation/Border/BorderValue.php @@ -18,21 +18,19 @@ */ class BorderValue extends QualifierMultiValue { - const VALUE_DELIMITER = '_'; + protected const VALUE_DELIMITER = '_'; /** * @var array $argumentOrder The order of the arguments. */ - protected $argumentOrder = ['width', 'style', 'color']; + protected array $argumentOrder = ['width', 'style', 'color']; /** * BorderValue constructor. * - * @param string $color - * @param int|string $width - * @param string $style + * @param string $color */ - public function __construct($color = null, $width = null, $style = null) + public function __construct(mixed $color = null, int|string|null $width = null, ?string $style = null) { parent::__construct(); @@ -44,11 +42,11 @@ public function __construct($color = null, $width = null, $style = null) /** * Sets the style of the border. * - * @param string $style The border style. Currently only "solid" is supported. + * @param string|null $style The border style. Currently only "solid" is supported. * * @return $this */ - public function style($style) + public function style(?string $style): static { return $this->setSimpleValue('style', $style); } @@ -56,11 +54,11 @@ public function style($style) /** * Sets the width of the border. * - * @param int|string $width The width of the border in pixels. + * @param int|string|null $width The width of the border in pixels. * * @return $this */ - public function width($width) + public function width(int|string|null $width): static { return $this->setSimpleValue('width', $width && is_numeric($width) ? "{$width}px" : $width); } @@ -68,13 +66,13 @@ public function width($width) /** * Sets the color of the border. * - * @param string $color The border color. + * @param mixed $color The border color. * * @return $this * * @see Color */ - public function color($color) + public function color(mixed $color): static { return $this->setSimpleValue('$color', ClassUtils::verifyInstance($color, ColorValue::class)); } diff --git a/src/Transformation/CommonTransformation.php b/src/Transformation/CommonTransformation.php index fdb1ad0..c78a450 100644 --- a/src/Transformation/CommonTransformation.php +++ b/src/Transformation/CommonTransformation.php @@ -11,6 +11,7 @@ namespace Cloudinary\Transformation; use Cloudinary\ArrayUtils; +use Cloudinary\ClassUtils; use Cloudinary\Transformation\Qualifier\BaseQualifier; /** @@ -23,7 +24,7 @@ class CommonTransformation extends BaseComponent implements CommonTransformation /** * @var array $actions The components (actions) of the transformation. */ - protected $actions = []; + protected array $actions = []; /** * CommonTransformation constructor. @@ -52,11 +53,9 @@ public function __construct($transformation = null) /** * Transformation named constructor. * - * @param $transformation * - * @return static */ - public static function generic($transformation) + public static function generic($transformation): static { return new static($transformation); } @@ -66,9 +65,8 @@ public static function generic($transformation) * * @param array $qualifiers An array of transformation qualifiers. * - * @return static */ - public static function fromParams($qualifiers) + public static function fromParams(array $qualifiers): static { return (new static())->addActionFromQualifiers($qualifiers); } @@ -79,9 +77,8 @@ public static function fromParams($qualifiers) * @param BaseAction|BaseQualifier|mixed $action The transformation action to add. * If BaseQualifier is provided, it is wrapped with action. * - * @return static */ - public function addAction($action) + public function addAction(mixed $action): static { if ($action instanceof BaseQualifier) { $action = new Action($action); @@ -97,17 +94,12 @@ public function addAction($action) * * Appended transformation is nested. * - * @param CommonTransformation|string $transformation The transformation to add. + * @param CommonTransformation|string|null $transformation The transformation to add. * - * @return static */ - public function addTransformation($transformation) + public function addTransformation(CommonTransformation|string|null $transformation): static { - if (! $transformation instanceof self) { - $transformation = new CommonTransformation($transformation); - } - - $this->actions[] = $transformation; + $this->actions[] = ClassUtils::forceInstance($transformation, CommonTransformation::class); return $this; } @@ -123,11 +115,10 @@ public function __clone() /** * Serializes transformation to URL. * - * @param ImageTransformation|string|null $withTransformation Optional transformation to append. + * @param string|ImageTransformation|null $withTransformation Optional transformation to append. * - * @return string */ - public function toUrl($withTransformation = null) + public function toUrl(ImageTransformation|string|null $withTransformation = null): string { if ($withTransformation === null) { return ArrayUtils::implodeUrl($this->actions); @@ -156,9 +147,8 @@ public function __toString() /** * Serializes to json. * - * @return mixed */ - public function jsonSerialize() + public function jsonSerialize(): array { // TODO: Implement jsonSerialize() method. return ['name' => $this->getFullName(), 'actions' => $this->actions]; diff --git a/src/Transformation/CommonTransformationInterface.php b/src/Transformation/CommonTransformationInterface.php index a6cacb8..28458f6 100644 --- a/src/Transformation/CommonTransformationInterface.php +++ b/src/Transformation/CommonTransformationInterface.php @@ -22,57 +22,52 @@ interface CommonTransformationInterface extends ComponentInterface * * (Formerly known as fetch format). * - * @param Format|string $format The format in which to deliver the asset. + * @param string|Format $format The format in which to deliver the asset. * - * @return static * - * @see \Cloudinary\Transformation\Format + * @see Format */ - public function format($format); + public function format(Format|string $format): static; /** * Controls compression quality. * * Reducing the quality is a trade-off between visual quality and file size. * - * @param int|string|Quality $quality The quality value. (Range 1 to 100) + * @param Quality|int|float|string $quality The quality value. (Range 1 to 100) * - * @return static */ - public function quality($quality); + public function quality(Quality|int|float|string $quality): static; /** * Applies a filter or an effect on an asset. * - * @param EffectQualifier|EffectAction $effect The effect to apply. + * @param EffectAction|EffectQualifier $effect The effect to apply. * - * @return static * - * @see \Cloudinary\Transformation\EffectAction - * @see \Cloudinary\Transformation\EffectQualifier + * @see EffectAction + * @see EffectQualifier */ - public function effect($effect); + public function effect(EffectQualifier|EffectAction $effect): static; /** * Applies an adjustment effect on an asset. * - * @param EffectQualifier|EffectAction $adjustment The adjustment effect to apply. + * @param EffectAction|EffectQualifier $adjustment The adjustment effect to apply. * - * @return static * - * @see \Cloudinary\Transformation\EffectAction - * @see \Cloudinary\Transformation\EffectQualifier + * @see EffectAction + * @see EffectQualifier */ - public function adjust($adjustment); + public function adjust(EffectQualifier|EffectAction $adjustment): static; /** * Applies a pre-defined transformation of the given name. * * @param string $transformationName The name of the transformation. * - * @return static */ - public function namedTransformation($transformationName); + public function namedTransformation(string $transformationName): static; /** * Adds a generic qualifier as a separate action. @@ -80,9 +75,8 @@ public function namedTransformation($transformationName); * @param string $shortName The generic qualifier name. * @param array|mixed $value The generic qualifier value. * - * @return static */ - public function addGenericQualifier($shortName, ...$value); + public function addGenericQualifier(string $shortName, ...$value): static; /** * Adds (chains) a transformation action. @@ -90,9 +84,8 @@ public function addGenericQualifier($shortName, ...$value); * @param BaseAction|BaseQualifier|mixed $action The transformation action to add. * If BaseQualifier is provided, it is wrapped with action. * - * @return static */ - public function addAction($action); + public function addAction(mixed $action): static; /** * Adds (appends) a transformation. @@ -101,20 +94,18 @@ public function addAction($action); * * @param CommonTransformation $transformation The transformation to add. * - * @return static */ - public function addTransformation($transformation); + public function addTransformation(CommonTransformation $transformation): static; /** * Adds action defined as an array of qualifiers. * * @param array $qualifiers An associative array of qualifiers * - * @return static * * @see QualifiersAction */ - public function addActionFromQualifiers($qualifiers); + public function addActionFromQualifiers(array $qualifiers): static; /** * Defines a new user variable. @@ -122,27 +113,24 @@ public function addActionFromQualifiers($qualifiers); * @param string $name The variable name * @param mixed $value The variable value * - * @return static */ - public function addVariable($name, $value); + public function addVariable(string $name, mixed $value): static; /** * Rotates the asset by the given angle. * - * @param string|int $angle The rotation angle. + * @param int|string $angle The rotation angle. * - * @return static */ - public function rotate($angle); + public function rotate(int|string $angle): static; /** * Specifies a conditional transformation whose condition should be met before applying a transformation. * * @param Conditional $conditionalTransformation The conditional transformation. * - * @return static * * @see https://cloudinary.com/documentation/conditional_transformations */ - public function conditional($conditionalTransformation); + public function conditional(Conditional $conditionalTransformation): static; } diff --git a/src/Transformation/CommonTransformationTrait.php b/src/Transformation/CommonTransformationTrait.php index 8258218..a9c3534 100644 --- a/src/Transformation/CommonTransformationTrait.php +++ b/src/Transformation/CommonTransformationTrait.php @@ -11,6 +11,7 @@ namespace Cloudinary\Transformation; use Cloudinary\ClassUtils; +use Cloudinary\Transformation\Expression\BaseExpressionComponent; use Cloudinary\Transformation\Qualifier\GenericQualifier; use Cloudinary\Transformation\Variable\Variable; @@ -29,11 +30,9 @@ trait CommonTransformationTrait /** * Applies a filter or an effect on an asset. * - * @param EffectQualifier|EffectAction $effect * - * @return static */ - public function effect($effect) + public function effect(EffectQualifier|EffectAction $effect): static { return $this->addAction($effect); } @@ -41,11 +40,9 @@ public function effect($effect) /** * Applies adjustment effect on an asset. * - * @param EffectQualifier|EffectAction|AdjustmentInterface $adjustment * - * @return static */ - public function adjust($adjustment) + public function adjust(EffectQualifier|EffectAction|Opacity|LutLayer $adjustment): static { return $this->addAction($adjustment); } @@ -53,11 +50,9 @@ public function adjust($adjustment) /** * Applies a pre-defined named transformation of the given name. * - * @param string|NamedTransformation $transformationName * - * @return static */ - public function namedTransformation($transformationName) + public function namedTransformation(string $transformationName): static { return $this->addAction(ClassUtils::verifyInstance($transformationName, NamedTransformation::class)); } @@ -68,9 +63,8 @@ public function namedTransformation($transformationName) * @param string $shortName The generic qualifier name. * @param array|mixed $value The generic qualifier value. * - * @return static */ - public function addGenericQualifier($shortName, ...$value) + public function addGenericQualifier(string $shortName, ...$value): static { return $this->addAction(new GenericQualifier($shortName, ...$value)); } @@ -80,11 +74,10 @@ public function addGenericQualifier($shortName, ...$value) * * @param array $qualifiers An associative array of qualifiers * - * @return static * * @see QualifiersAction */ - public function addActionFromQualifiers($qualifiers) + public function addActionFromQualifiers(array $qualifiers): static { return $this->addAction(new QualifiersAction($qualifiers)); } @@ -92,11 +85,10 @@ public function addActionFromQualifiers($qualifiers) /** * Adds a flag as a separate action. * - * @param FlagQualifier|string $flag The flag to add. + * @param string|FlagQualifier $flag The flag to add. * - * @return static */ - public function addFlag($flag) + public function addFlag(FlagQualifier|string $flag): static { return $this->addAction(ClassUtils::verifyInstance($flag, FlagQualifier::class)); } @@ -104,12 +96,11 @@ public function addFlag($flag) /** * Defines an new user variable. * - * @param string|Variable $name The variable name or the Variable instance. - * @param mixed $value The variable value. + * @param Variable|string|null $name The variable name or the Variable instance. + * @param mixed|null $value The variable value. * - * @return static */ - public function addVariable($name, $value = null) + public function addVariable(Variable|string|null $name, mixed $value = null): static { return $this->addAction(ClassUtils::verifyInstance($name, Variable::class, null, $value)); } @@ -117,11 +108,10 @@ public function addVariable($name, $value = null) /** * Rotates the asset by the given angle. * - * @param string|int $angle The rotation angle. + * @param int|string|Rotate $angle The rotation angle. * - * @return static */ - public function rotate($angle) + public function rotate(int|string|Rotate $angle): static { return $this->addAction(ClassUtils::verifyInstance($angle, Rotate::class)); } @@ -129,13 +119,12 @@ public function rotate($angle) /** * Specifies a conditional transformation whose condition should be met before applying a transformation. * - * @param Conditional $conditionalTransformation The conditional transformation. + * @param Conditional|BaseExpressionComponent $conditionalTransformation The conditional transformation. * - * @return static * * @see https://cloudinary.com/documentation/conditional_transformations */ - public function conditional($conditionalTransformation) + public function conditional(Conditional|BaseExpressionComponent $conditionalTransformation): static { return $this->addTransformation(ClassUtils::verifyInstance($conditionalTransformation, Conditional::class)); } diff --git a/src/Transformation/ComponentInterface.php b/src/Transformation/ComponentInterface.php index bce23ae..bc5f98b 100644 --- a/src/Transformation/ComponentInterface.php +++ b/src/Transformation/ComponentInterface.php @@ -27,8 +27,6 @@ public function __toString(); /** * Serializes to json. * - * @return mixed */ - #[\ReturnTypeWillChange] - public function jsonSerialize(); + public function jsonSerialize(): array; } diff --git a/src/Transformation/Condition/ConditionQualifierTrait.php b/src/Transformation/Condition/ConditionQualifierTrait.php index eb734a4..38586da 100644 --- a/src/Transformation/Condition/ConditionQualifierTrait.php +++ b/src/Transformation/Condition/ConditionQualifierTrait.php @@ -20,14 +20,13 @@ trait ConditionQualifierTrait /** * Sets up a conditional transformation. * - * @param string $expression The condition to meet in order to apply the transformation. + * @param string|null $expression The condition to meet in order to apply the transformation. * - * @return IfCondition * - * @see \Cloudinary\Transformation\IfCondition + * @see IfCondition * @see https://cloudinary.com/documentation/conditional_transformations Conditional transformations */ - public static function ifCondition($expression) + public static function ifCondition(?string $expression): IfCondition { return new IfCondition($expression); } diff --git a/src/Transformation/Condition/Conditional.php b/src/Transformation/Condition/Conditional.php index 65094b5..07e9e1e 100644 --- a/src/Transformation/Condition/Conditional.php +++ b/src/Transformation/Condition/Conditional.php @@ -10,6 +10,7 @@ namespace Cloudinary\Transformation; +use Cloudinary\ClassUtils; use Cloudinary\Transformation\Expression\BaseExpressionComponent; /** @@ -23,18 +24,14 @@ class Conditional extends CommonTransformation { /** * Condition named constructor. - * - * @param BaseExpressionComponent|string $expression - * - * @param BaseAction|Transformation $action - * - * @return Conditional */ - public static function ifCondition($expression, $action) - { + public static function ifCondition( + BaseExpressionComponent|Conditional|string $expression, + BaseAction|Transformation $action + ): Conditional { $ct = new static(); - $ct->setIfCondition(new IfCondition($expression)); + $ct->setIfCondition($expression); $ct->addAction($action); return $ct; @@ -45,13 +42,12 @@ public static function ifCondition($expression, $action) * * @see https://cloudinary.com/documentation/conditional_transformations * - * @param BaseExpressionComponent|string $expression The conditional expression + * @param string|BaseExpressionComponent $expression The conditional expression * - * @return static */ - public function setIfCondition($expression) + public function setIfCondition(BaseExpressionComponent|string $expression): static { - return $this->addAction(new IfCondition($expression)); + return $this->addAction(ClassUtils::forceInstance($expression, IfCondition::class)); } /** @@ -59,11 +55,9 @@ public function setIfCondition($expression) * * @see https://cloudinary.com/documentation/conditional_transformations * - * @param Action|Transformation $action * - * @return static */ - public function otherwise($action) + public function otherwise(Transformation|Action $action): static { return $this->addAction(new IfElse())->addAction($action); } @@ -73,9 +67,8 @@ public function otherwise($action) * * @see https://cloudinary.com/documentation/conditional_transformations * - * @return static */ - protected function endIfCondition() + protected function endIfCondition(): static { return $this->addAction(new EndIfCondition()); } @@ -83,11 +76,10 @@ protected function endIfCondition() /** * Serializes transformation to URL. * - * @param ImageTransformation|string|null $withTransformation Optional transformation to append. + * @param string|ImageTransformation|null $withTransformation Optional transformation to append. * - * @return string */ - public function toUrl($withTransformation = null) + public function toUrl(ImageTransformation|string|null $withTransformation = null): string { $t = new Transformation(); diff --git a/src/Transformation/Condition/EndIfCondition.php b/src/Transformation/Condition/EndIfCondition.php index 980acf2..e1ebbce 100644 --- a/src/Transformation/Condition/EndIfCondition.php +++ b/src/Transformation/Condition/EndIfCondition.php @@ -20,7 +20,7 @@ class EndIfCondition extends BaseQualifier /** * @var string $key Serialization key. */ - protected static $key = 'if'; + protected static string $key = 'if'; /** * EndIf constructor. diff --git a/src/Transformation/Condition/IfCondition.php b/src/Transformation/Condition/IfCondition.php index c714748..ad93e7a 100644 --- a/src/Transformation/Condition/IfCondition.php +++ b/src/Transformation/Condition/IfCondition.php @@ -22,12 +22,12 @@ class IfCondition extends BaseQualifier /** * @var string $key Serialization key. */ - protected static $key = 'if'; + protected static string $key = 'if'; /** * IfCondition constructor. * - * @param BaseExpressionComponent|string $expression + * @param BaseExpressionComponent|string|null $expression */ public function __construct($expression) { diff --git a/src/Transformation/Condition/IfElse.php b/src/Transformation/Condition/IfElse.php index 5a38a40..5dc5d5e 100644 --- a/src/Transformation/Condition/IfElse.php +++ b/src/Transformation/Condition/IfElse.php @@ -20,7 +20,7 @@ class IfElse extends BaseQualifier /** * @var string $key Serialization key. */ - protected static $key = 'if'; + protected static string $key = 'if'; /** * IfElse constructor. diff --git a/src/Transformation/CustomFunction/CustomFunction.php b/src/Transformation/CustomFunction/CustomFunction.php index 270a9d6..093e1c8 100644 --- a/src/Transformation/CustomFunction/CustomFunction.php +++ b/src/Transformation/CustomFunction/CustomFunction.php @@ -22,49 +22,49 @@ */ class CustomFunction extends BaseQualifier { - const VALUE_CLASS = CustomFunctionValue::class; + protected const VALUE_CLASS = CustomFunctionValue::class; use CustomFunctionTrait; /** * @var string $name Serialisation name. */ - protected static $name = 'custom_function'; + protected static string $name = 'custom_function'; /** * @var string $key Serialization key. */ - protected static $key = 'fn'; + protected static string $key = 'fn'; /** * WASM. * * @var string */ - const WASM = 'wasm'; + public const WASM = 'wasm'; /** * Remote. * * @var string */ - const REMOTE = 'remote'; + public const REMOTE = 'remote'; /** * CustomFunction constructor. * - * @param string $source Source of this custom function - * @param string $type The type of custom function (CustomFunction::REMOTE or CustomFunction::WASM). - * @param bool $preprocess Preprocess custom function. Only remote functions are supported for preprocess + * @param string $source Source of this custom function + * @param string|null $type The type of custom function (CustomFunction::REMOTE or CustomFunction::WASM). + * @param bool|null $preprocess Preprocess custom function. Only remote functions are supported for preprocess * * @see CustomFunction::REMOTE * @see CustomFunction::WASM */ - public function __construct($source, $type = null, $preprocess = false) + public function __construct($source, ?string $type = null, ?bool $preprocess = false) { parent::__construct( - $type === self::REMOTE ? StringUtils::base64UrlEncode($source) : $source, - $type + $type === self::REMOTE ? StringUtils::base64UrlEncode($source) : $source, $type ); + $this->preprocess($preprocess); } @@ -73,14 +73,13 @@ public function __construct($source, $type = null, $preprocess = false) * * For more information about preprocessing custom functions see the documentation. * - * @param bool $preprocess Whether to defines the function as the remote preprocessing custom function. + * @param bool $preprocess Whether to define the function as the remote preprocessing custom function. * - * @return CustomFunction * - * @see \Cloudinary\Transformation\CustomFunction + * @see CustomFunction * @see https://cloudinary.com/documentation/custom_functions#preprocessing_custom_functions */ - public function preprocess($preprocess = true) + public function preprocess(bool $preprocess = true): static { $this->getValue()->setSimpleValue('preprocess', $preprocess ? 'pre' : null); diff --git a/src/Transformation/CustomFunction/CustomFunctionQualifierTrait.php b/src/Transformation/CustomFunction/CustomFunctionQualifierTrait.php index a545beb..aaa8b0e 100644 --- a/src/Transformation/CustomFunction/CustomFunctionQualifierTrait.php +++ b/src/Transformation/CustomFunction/CustomFunctionQualifierTrait.php @@ -20,17 +20,19 @@ trait CustomFunctionQualifierTrait /** * Injects a custom function into the image transformation pipeline. * - * @param string $source Source of this custom function - * @param string $type The type of custom function (CustomFunction::REMOTE or CustomFunction::WASM). - * @param bool $preprocess Preprocess custom function. Only remote functions are supported for preprocess + * @param string $source Source of this custom function + * @param string|null $type The type of custom function (CustomFunction::REMOTE or CustomFunction::WASM). + * @param bool $preprocess Preprocess custom function. Only remote functions are supported for preprocess * - * @return CustomFunction * * @see CustomFunction::REMOTE * @see CustomFunction::WASM */ - public static function customFunction($source, $type = null, $preprocess = false) - { + public static function customFunction( + string $source, + ?string $type = null, + bool $preprocess = false + ): CustomFunction { return new CustomFunction($source, $type, $preprocess); } } diff --git a/src/Transformation/CustomFunction/CustomFunctionTrait.php b/src/Transformation/CustomFunction/CustomFunctionTrait.php index 2d979ec..da42964 100644 --- a/src/Transformation/CustomFunction/CustomFunctionTrait.php +++ b/src/Transformation/CustomFunction/CustomFunctionTrait.php @@ -26,13 +26,12 @@ trait CustomFunctionTrait * * @param string $source The public ID of the wasm file. * - * @return CustomFunction * - * @see \Cloudinary\Transformation\CustomFunction + * @see CustomFunction * @see https://cloudinary.com/documentation/custom_functions#webassembly_functions * */ - public static function wasm($source) + public static function wasm(string $source): CustomFunction { return static::create($source, CustomFunction::WASM); } @@ -44,13 +43,12 @@ public static function wasm($source) * * @param string $source The URL of the remote function. * - * @return CustomFunction * - * @see \Cloudinary\Transformation\CustomFunction + * @see CustomFunction * @see https://cloudinary.com/documentation/custom_functions#remote_functions * */ - public static function remote($source) + public static function remote(string $source): CustomFunction { return static::create($source, CustomFunction::REMOTE); } @@ -60,12 +58,11 @@ public static function remote($source) * * @param array $values * - * @return CustomFunction - * @see \Cloudinary\Transformation\CustomFunction + * @see CustomFunction * * @internal */ - protected static function create(...$values) + protected static function create(...$values): CustomFunction { return new CustomFunction(...$values); } @@ -73,14 +70,13 @@ protected static function create(...$values) /** * Creates a new instance from an array of qualifiers. * - * @param array $qualifiers The qualifiers. - * @param bool $isPre Indicates whether the function is a pre-processing function. Default: false. + * @param array|string $qualifiers The qualifiers. + * @param bool $isPre Indicates whether the function is a pre-processing function. Default: false. * - * @return CustomFunction - * @see \Cloudinary\Transformation\CustomFunction + * @see CustomFunction * */ - public static function fromParams($qualifiers, $isPre = false) + public static function fromParams(array|string $qualifiers, bool $isPre = false): CustomFunction { if (! is_array($qualifiers)) { return static::create($qualifiers, null, $isPre); diff --git a/src/Transformation/CustomFunction/CustomFunctionValue.php b/src/Transformation/CustomFunction/CustomFunctionValue.php index daa21d4..a5501d0 100644 --- a/src/Transformation/CustomFunction/CustomFunctionValue.php +++ b/src/Transformation/CustomFunction/CustomFunctionValue.php @@ -18,16 +18,16 @@ class CustomFunctionValue extends QualifierMultiValue /** * @var array $argumentOrder The order of the arguments. */ - protected $argumentOrder = ['preprocess', 'type', 'source']; + protected array $argumentOrder = ['preprocess', 'type', 'source']; /** * CustomFunctionValue constructor. * - * @param mixed $source - * @param mixed $type - * @param mixed $preprocess + * @param mixed $source + * @param mixed|null $type + * @param mixed|null $preprocess */ - public function __construct($source = null, $type = null, $preprocess = null) + public function __construct($source = null, mixed $type = null, mixed $preprocess = null) { parent::__construct(); diff --git a/src/Transformation/CustomFunction/TransformationCustomFunctionTrait.php b/src/Transformation/CustomFunction/TransformationCustomFunctionTrait.php index d46d6da..576c9e6 100644 --- a/src/Transformation/CustomFunction/TransformationCustomFunctionTrait.php +++ b/src/Transformation/CustomFunction/TransformationCustomFunctionTrait.php @@ -24,9 +24,8 @@ trait TransformationCustomFunctionTrait * * @param CustomFunction $customFunction The custom function source * - * @return static */ - public function customFunction($customFunction) + public function customFunction($customFunction): static { return $this->addAction($customFunction); } diff --git a/src/Transformation/Delivery/ColorSpace/ColorSpace.php b/src/Transformation/Delivery/ColorSpace/ColorSpace.php index d746934..76fc3d8 100644 --- a/src/Transformation/Delivery/ColorSpace/ColorSpace.php +++ b/src/Transformation/Delivery/ColorSpace/ColorSpace.php @@ -22,41 +22,40 @@ class ColorSpace extends BaseQualifier /** * Render the image in the sRGB color space. */ - const SRGB = 'srgb'; + public const SRGB = 'srgb'; /** * Render the image using Facebook's truncated sRGB color space. */ - const TINY_SRGB = 'tinysrgb'; + public const TINY_SRGB = 'tinysrgb'; /** * Render the image in the CMYK color space. */ - const CMYK = 'cmyk'; + public const CMYK = 'cmyk'; /** * If the original image uses the CMYK color space, convert it to sRGB. */ - const NO_CMYK = 'no_cmyk'; + public const NO_CMYK = 'no_cmyk'; /** * Retain the CMYK color space when generating derived images. */ - const KEEP_CMYK = 'keep_cmyk'; + public const KEEP_CMYK = 'keep_cmyk'; /** * Render the image using the specified color space (ICC) file. The ICC file must be * uploaded to your cloud as a raw, authenticated file. Specify the ICC file using the icc method of the * this class. */ - const ICC = 'icc'; + public const ICC = 'icc'; /** * Render the image in the sRGB color space. * - * @return ColorSpace */ - public static function srgb() + public static function srgb(): ColorSpace { return new self(self::SRGB); } @@ -64,9 +63,8 @@ public static function srgb() /** * Render the image using Facebook's truncated sRGB color space. * - * @return ColorSpace */ - public static function tinysrgb() + public static function tinysrgb(): ColorSpace { return new self(self::TINY_SRGB); } @@ -74,9 +72,8 @@ public static function tinysrgb() /** * Render the image in the CMYK color space. * - * @return ColorSpace */ - public static function cmyk() + public static function cmyk(): ColorSpace { return new self(self::CMYK); } @@ -84,9 +81,8 @@ public static function cmyk() /** * If the original image uses the CMYK color space, convert it to sRGB. * - * @return ColorSpace */ - public static function noCmyk() + public static function noCmyk(): ColorSpace { return new self(self::NO_CMYK); } @@ -94,9 +90,8 @@ public static function noCmyk() /** * Retain the CMYK color space when generating derived images. * - * @return ColorSpace */ - public static function keepCmyk() + public static function keepCmyk(): ColorSpace { return new self(self::KEEP_CMYK); } @@ -109,10 +104,9 @@ public static function keepCmyk() * @param string $publicId The public ID (including the file extension) of the ICC profile that defines the * color space. * - * @return ColorSpace * */ - public static function icc($publicId) + public static function icc(string $publicId): ColorSpace { return new self(self::ICC, $publicId); } diff --git a/src/Transformation/Delivery/ColorSpace/ColorSpaceQualifierTrait.php b/src/Transformation/Delivery/ColorSpace/ColorSpaceQualifierTrait.php index ab9a173..7c3284e 100644 --- a/src/Transformation/Delivery/ColorSpace/ColorSpaceQualifierTrait.php +++ b/src/Transformation/Delivery/ColorSpace/ColorSpaceQualifierTrait.php @@ -24,12 +24,11 @@ trait ColorSpaceQualifierTrait * * @param string $colorSpace The color space. Use the constants defined in the ColorSpace class. * - * @return ColorSpace * - * @see \Cloudinary\Transformation\ColorSpace + * @see ColorSpace * */ - public static function colorSpace($colorSpace) + public static function colorSpace(string $colorSpace): ColorSpace { return new ColorSpace($colorSpace); } @@ -44,11 +43,10 @@ public static function colorSpace($colorSpace) * @param string $publicId The public ID (including the file extension) of the ICC profile that defines the * color space. * - * @return ColorSpace * * @see ColorSpace::icc */ - public static function colorSpaceFromIcc($publicId) + public static function colorSpaceFromIcc(string $publicId): ColorSpace { return ColorSpace::icc($publicId); } diff --git a/src/Transformation/Delivery/DeliveryBuilderTrait.php b/src/Transformation/Delivery/DeliveryBuilderTrait.php index b564b4d..f05d79d 100644 --- a/src/Transformation/Delivery/DeliveryBuilderTrait.php +++ b/src/Transformation/Delivery/DeliveryBuilderTrait.php @@ -27,9 +27,8 @@ trait DeliveryBuilderTrait * * @param string|Format|mixed $format The file format. * - * @return Format */ - public static function format($format) + public static function format(mixed $format): Format { return ClassUtils::verifyInstance($format, Format::class); } @@ -39,15 +38,14 @@ public static function format($format) * * Reducing the quality is a trade-off between visual quality and file size. * - * @param int|Quality|mixed $level The level of the quality. (Range 1 to 100) - * @param null|string $preset A set level of automatic quality. Use the constants defined in the QualityQualifier - * class. + * @param int|Quality|mixed $level The level of the quality. (Range 1 to 100) + * @param string|null $preset A set level of automatic quality. Use the constants defined in the + * QualityQualifier class. * - * @return Quality * - * @see \Cloudinary\Transformation\QualityQualifier + * @see QualityQualifier */ - public static function quality($level, $preset = null) + public static function quality(mixed $level, ?string $preset = null): Quality { return ClassUtils::verifyInstance($level, Quality::class, null, $preset); } @@ -55,11 +53,10 @@ public static function quality($level, $preset = null) /** * Deliver the image in the specified device pixel ratio. * - * @param Dpr|int|string $dpr The DPR (Device Pixel Ratio). Any positive float value. + * @param int|float|string|Dpr $dpr The DPR (Device Pixel Ratio). Any positive float value. * - * @return Dpr */ - public static function dpr($dpr) + public static function dpr(int|float|string|Dpr $dpr): Dpr { return ClassUtils::verifyInstance($dpr, Dpr::class); } @@ -68,11 +65,10 @@ public static function dpr($dpr) * Controls the density to use when delivering an image or when converting a vector file such as a PDF or EPS * document to a web image delivery format. * - * @param int|string $density The density in dpi. + * @param int|float|string $density The density in dpi. * - * @return Density */ - public static function density($density) + public static function density(int|float|string $density): Density { return ClassUtils::verifyInstance($density, Density::class); } @@ -81,13 +77,12 @@ public static function density($density) * Uses the specified public ID of a placeholder image if the requested image or social network picture does * not exist. The name of the placeholder image must include the file extension. * - * @param DefaultImage|string $defaultImage The public ID with extension of the placeholder image. + * @param string|DefaultImage $defaultImage The public ID with extension of the placeholder image. * - * @return static * - * @see \Cloudinary\Transformation\DefaultImage + * @see DefaultImage */ - public static function defaultImage($defaultImage) + public static function defaultImage(DefaultImage|string $defaultImage): DefaultImage { return ClassUtils::verifyInstance($defaultImage, DefaultImage::class); } diff --git a/src/Transformation/Delivery/Dpr.php b/src/Transformation/Delivery/Dpr.php index 7887731..f69a6c1 100644 --- a/src/Transformation/Delivery/Dpr.php +++ b/src/Transformation/Delivery/Dpr.php @@ -22,14 +22,11 @@ class Dpr extends BaseExpressionQualifier /** * @var string $key Serialization key. */ - protected static $key = 'dpr'; + protected static string $key = 'dpr'; - const AUTO = 'auto'; + public const AUTO = 'auto'; - /** - * @return static - */ - public static function auto() + public static function auto(): static { return new static(static::AUTO); } diff --git a/src/Transformation/Delivery/Format/AnimatedFormat.php b/src/Transformation/Delivery/Format/AnimatedFormat.php index 146b217..4fbca79 100644 --- a/src/Transformation/Delivery/Format/AnimatedFormat.php +++ b/src/Transformation/Delivery/Format/AnimatedFormat.php @@ -38,9 +38,8 @@ public function __construct(...$value) * * @param string $format The file format. * - * @return AnimatedFormat */ - public function format($format) + public function format(string $format): static { $this->qualifiers[FormatQualifier::getName()]->format($format); @@ -52,11 +51,10 @@ public function format($format) * * @param bool $useLossy Indicates whether to use lossy compression. * - * @return AnimatedFormat * * @see Flag::lossy */ - public function lossy($useLossy = true) + public function lossy(bool $useLossy = true): AnimatedFormat { return $this->setFlag(Flag::lossy(), $useLossy); } diff --git a/src/Transformation/Delivery/Format/AnimatedFormatTrait.php b/src/Transformation/Delivery/Format/AnimatedFormatTrait.php index 4266ace..eb9045d 100644 --- a/src/Transformation/Delivery/Format/AnimatedFormatTrait.php +++ b/src/Transformation/Delivery/Format/AnimatedFormatTrait.php @@ -20,9 +20,8 @@ trait AnimatedFormatTrait /** * Animated image format webp. * - * @return static */ - public static function webp() + public static function webp(): static { return static::createFormat(Format::WEBP)->setFlag(Flag::animatedWebP()); } @@ -30,9 +29,8 @@ public static function webp() /** * Animated image format gif. * - * @return static */ - public static function gif() + public static function gif(): static { return static::createFormat(Format::GIF); } @@ -40,9 +38,8 @@ public static function gif() /** * Animated image format png. * - * @return static */ - public static function png() + public static function png(): static { return static::createFormat(Format::PNG)->setFlag(Flag::animatedPng()); } @@ -50,9 +47,8 @@ public static function png() /** * Animated image auto format. * - * @return static */ - public static function auto() + public static function auto(): static { return static::createFormat(Format::AUTO); } @@ -62,11 +58,10 @@ public static function auto() * * @param string|array $format The format. * - * @return static * * @internal */ - protected static function createFormat(...$format) + protected static function createFormat(...$format): static { return new static(...$format); } diff --git a/src/Transformation/Delivery/Format/AudioFormatInterface.php b/src/Transformation/Delivery/Format/AudioFormatInterface.php index d5258b6..4d71891 100644 --- a/src/Transformation/Delivery/Format/AudioFormatInterface.php +++ b/src/Transformation/Delivery/Format/AudioFormatInterface.php @@ -17,13 +17,13 @@ */ interface AudioFormatInterface { - const MP3 = 'mp3'; - const AAC = 'aac'; - const M4A = 'm4a'; - const OGG = 'ogg'; - const WAV = 'wav'; - const AIFF = 'aiff'; - const FLAC = 'flac'; - const AMR = 'amr'; - const MIDI = 'midi'; + public const MP3 = 'mp3'; + public const AAC = 'aac'; + public const M4A = 'm4a'; + public const OGG = 'ogg'; + public const WAV = 'wav'; + public const AIFF = 'aiff'; + public const FLAC = 'flac'; + public const AMR = 'amr'; + public const MIDI = 'midi'; } diff --git a/src/Transformation/Delivery/Format/AudioFormatTrait.php b/src/Transformation/Delivery/Format/AudioFormatTrait.php index b56d297..cef6e52 100644 --- a/src/Transformation/Delivery/Format/AudioFormatTrait.php +++ b/src/Transformation/Delivery/Format/AudioFormatTrait.php @@ -20,9 +20,8 @@ trait AudioFormatTrait /** * Audio format mp3. * - * @return static */ - public static function audioMp3() + public static function audioMp3(): static { return static::createFormat(Format::MP3); } @@ -30,9 +29,8 @@ public static function audioMp3() /** * Audio format aac. * - * @return static */ - public static function audioAac() + public static function audioAac(): static { return static::createFormat(Format::AAC); } @@ -40,9 +38,8 @@ public static function audioAac() /** * Audio format m4a. * - * @return static */ - public static function audioM4a() + public static function audioM4a(): static { return static::createFormat(Format::M4A); } @@ -50,9 +47,8 @@ public static function audioM4a() /** * Audio format ogg. * - * @return static */ - public static function audioOgg() + public static function audioOgg(): static { return static::createFormat(Format::OGG); } @@ -60,9 +56,8 @@ public static function audioOgg() /** * Audio format wav. * - * @return static */ - public static function audioWav() + public static function audioWav(): static { return static::createFormat(Format::WAV); } @@ -70,9 +65,8 @@ public static function audioWav() /** * Audio format aiff. * - * @return static */ - public static function audioAiff() + public static function audioAiff(): static { return static::createFormat(Format::AIFF); } @@ -80,9 +74,8 @@ public static function audioAiff() /** * Audio format flac. * - * @return static */ - public static function audioFlac() + public static function audioFlac(): static { return static::createFormat(Format::FLAC); } @@ -90,9 +83,8 @@ public static function audioFlac() /** * Audio format amr. * - * @return static */ - public static function audioAmr() + public static function audioAmr(): static { return static::createFormat(Format::AMR); } @@ -100,9 +92,8 @@ public static function audioAmr() /** * Audio format midi. * - * @return static */ - public static function audioMidi() + public static function audioMidi(): static { return static::createFormat(Format::MIDI); } diff --git a/src/Transformation/Delivery/Format/Format.php b/src/Transformation/Delivery/Format/Format.php index 0a6dd60..bf84cb8 100644 --- a/src/Transformation/Delivery/Format/Format.php +++ b/src/Transformation/Delivery/Format/Format.php @@ -42,9 +42,8 @@ public function __construct(...$value) * * @param string $format The file format. * - * @return Format */ - public function format($format) + public function format(string $format): static { $this->qualifiers[FormatQualifier::getName()]->format($format); @@ -56,11 +55,10 @@ public function format($format) * * @param bool $useLossy Indicates whether to use lossy compression. * - * @return Format * * @see Flag::lossy */ - public function lossy($useLossy = true) + public function lossy(bool $useLossy = true): Format { return $this->setFlag(Flag::lossy(), $useLossy); } @@ -68,13 +66,12 @@ public function lossy($useLossy = true) /** * Applicable only for JPG file format * - * @param string $mode The mode to determine a specific progressive outcome. + * @param string|null $mode The mode to determine a specific progressive outcome. * - * @return Format * * @see Flag::progressive */ - public function progressive($mode = null) + public function progressive(?string $mode = null): Format { return $this->setFlag(Flag::progressive($mode)); } @@ -82,11 +79,10 @@ public function progressive($mode = null) /** * Ensures that images with a transparency channel will be delivered in PNG format. * - * @return Format * * @see Flag::preserveTransparency */ - public function preserveTransparency() + public function preserveTransparency(): Format { return $this->setFlag(Flag::preserveTransparency()); } @@ -94,11 +90,10 @@ public function preserveTransparency() /** * Ensures that an alpha channel is not applied to a TIFF image if it is a mask channel. * - * @return Format * * @see Flag::ignoreMaskChannels */ - public function ignoreMaskChannels() + public function ignoreMaskChannels(): Format { return $this->setFlag(Flag::ignoreMaskChannels()); } diff --git a/src/Transformation/Delivery/Format/FormatInterface.php b/src/Transformation/Delivery/Format/FormatInterface.php index 95f754f..d75dec9 100644 --- a/src/Transformation/Delivery/Format/FormatInterface.php +++ b/src/Transformation/Delivery/Format/FormatInterface.php @@ -17,5 +17,5 @@ */ interface FormatInterface extends ImageFormatInterface, VideoFormatInterface, AudioFormatInterface { - const AUTO = 'auto'; + public const AUTO = 'auto'; } diff --git a/src/Transformation/Delivery/Format/FormatQualifier.php b/src/Transformation/Delivery/Format/FormatQualifier.php index 008dc33..9fe326b 100644 --- a/src/Transformation/Delivery/Format/FormatQualifier.php +++ b/src/Transformation/Delivery/Format/FormatQualifier.php @@ -24,9 +24,8 @@ class FormatQualifier extends BaseQualifier implements FormatInterface * * @param string $format The file format. * - * @return static */ - public function format($format) + public function format(string $format): static { $this->setQualifierValue($format); diff --git a/src/Transformation/Delivery/Format/FormatQualifierTrait.php b/src/Transformation/Delivery/Format/FormatQualifierTrait.php index d96920e..1067bc5 100644 --- a/src/Transformation/Delivery/Format/FormatQualifierTrait.php +++ b/src/Transformation/Delivery/Format/FormatQualifierTrait.php @@ -24,9 +24,8 @@ trait FormatQualifierTrait * * @param string $format The file format. * - * @return FormatQualifier */ - public static function format($format) + public static function format(string $format): FormatQualifier { return ClassUtils::verifyInstance($format, FormatQualifier::class); } diff --git a/src/Transformation/Delivery/Format/FormatTrait.php b/src/Transformation/Delivery/Format/FormatTrait.php index b65c6d4..9c2c7ec 100644 --- a/src/Transformation/Delivery/Format/FormatTrait.php +++ b/src/Transformation/Delivery/Format/FormatTrait.php @@ -26,11 +26,10 @@ trait FormatTrait * * @param string|array $format The format. * - * @return static * * @internal */ - protected static function createFormat(...$format) + protected static function createFormat(...$format): static { return new static(...$format); } @@ -38,9 +37,8 @@ protected static function createFormat(...$format) /** * Auto format. * - * @return static */ - public static function auto() + public static function auto(): static { return static::createFormat(FormatInterface::AUTO); } diff --git a/src/Transformation/Delivery/Format/ImageFormatInterface.php b/src/Transformation/Delivery/Format/ImageFormatInterface.php index 681dd8d..77e6ccd 100644 --- a/src/Transformation/Delivery/Format/ImageFormatInterface.php +++ b/src/Transformation/Delivery/Format/ImageFormatInterface.php @@ -17,38 +17,38 @@ */ interface ImageFormatInterface { - const GIF = 'gif'; - const PNG = 'png'; - const JPG = 'jpg'; - const BMP = 'bmp'; - const ICO = 'ico'; - const PDF = 'pdf'; - const TIFF = 'tiff'; - const EPS = 'eps'; - const JPC = 'jpc'; - const JP2 = 'jp2'; - const PSD = 'psd'; - const WEBP = 'webp'; - const SVG = 'svg'; - const WDP = 'wdp'; - const HPX = 'hpx'; - const DJVU = 'djvu'; - const AI = 'ai'; - const FLIF = 'flif'; - const BPG = 'bpg'; - const MIFF = 'miff'; - const TGA = 'tga'; - const CR2 = 'cr2'; - const ARW = 'arw'; - const DNG = 'dng'; - const HEIC = 'heic'; - const GLTZ = 'gltz'; - const GLTF = 'gltf'; - const GLB = 'glb'; - const FBXZ = 'fbxz'; - const INDD = 'indd'; - const IDML = 'idml'; - const AVIF = 'avif'; - const OBJZ = 'objz'; - const USDZ = 'usdz'; + public const GIF = 'gif'; + public const PNG = 'png'; + public const JPG = 'jpg'; + public const BMP = 'bmp'; + public const ICO = 'ico'; + public const PDF = 'pdf'; + public const TIFF = 'tiff'; + public const EPS = 'eps'; + public const JPC = 'jpc'; + public const JP2 = 'jp2'; + public const PSD = 'psd'; + public const WEBP = 'webp'; + public const SVG = 'svg'; + public const WDP = 'wdp'; + public const HPX = 'hpx'; + public const DJVU = 'djvu'; + public const AI = 'ai'; + public const FLIF = 'flif'; + public const BPG = 'bpg'; + public const MIFF = 'miff'; + public const TGA = 'tga'; + public const CR2 = 'cr2'; + public const ARW = 'arw'; + public const DNG = 'dng'; + public const HEIC = 'heic'; + public const GLTZ = 'gltz'; + public const GLTF = 'gltf'; + public const GLB = 'glb'; + public const FBXZ = 'fbxz'; + public const INDD = 'indd'; + public const IDML = 'idml'; + public const AVIF = 'avif'; + public const OBJZ = 'objz'; + public const USDZ = 'usdz'; } diff --git a/src/Transformation/Delivery/Format/ImageFormatTrait.php b/src/Transformation/Delivery/Format/ImageFormatTrait.php index d9bf16d..7f9b6a9 100644 --- a/src/Transformation/Delivery/Format/ImageFormatTrait.php +++ b/src/Transformation/Delivery/Format/ImageFormatTrait.php @@ -20,9 +20,8 @@ trait ImageFormatTrait /** * Image format jpg. * - * @return static */ - public static function jpg() + public static function jpg(): static { return static::createFormat(Format::JPG); } @@ -30,9 +29,8 @@ public static function jpg() /** * Image format jpc. * - * @return static */ - public static function jpc() + public static function jpc(): static { return static::createFormat(Format::JPC); } @@ -40,9 +38,8 @@ public static function jpc() /** * Image format jp2. * - * @return static */ - public static function jp2() + public static function jp2(): static { return static::createFormat(Format::JP2); } @@ -50,9 +47,8 @@ public static function jp2() /** * Image format wdp. * - * @return static */ - public static function wdp() + public static function wdp(): static { return static::createFormat(Format::WDP); } @@ -60,9 +56,8 @@ public static function wdp() /** * Image format png. * - * @return static */ - public static function png() + public static function png(): static { return static::createFormat(Format::PNG); } @@ -70,9 +65,8 @@ public static function png() /** * Image format gif. * - * @return static */ - public static function gif() + public static function gif(): static { return static::createFormat(Format::GIF); } @@ -80,9 +74,8 @@ public static function gif() /** * Image format webp. * - * @return static */ - public static function webp() + public static function webp(): static { return static::createFormat(Format::WEBP); } @@ -90,9 +83,8 @@ public static function webp() /** * Image format bmp. * - * @return static */ - public static function bmp() + public static function bmp(): static { return static::createFormat(Format::BMP); } @@ -100,9 +92,8 @@ public static function bmp() /** * Image format tiff. * - * @return static */ - public static function tiff() + public static function tiff(): static { return static::createFormat(Format::TIFF); } @@ -110,9 +101,8 @@ public static function tiff() /** * Image format ico. * - * @return static */ - public static function ico() + public static function ico(): static { return static::createFormat(Format::ICO); } @@ -120,9 +110,8 @@ public static function ico() /** * Image format pdf. * - * @return static */ - public static function pdf() + public static function pdf(): static { return static::createFormat(Format::PDF); } @@ -130,9 +119,8 @@ public static function pdf() /** * Image format eps. * - * @return static */ - public static function eps() + public static function eps(): static { return static::createFormat(Format::EPS); } @@ -140,9 +128,8 @@ public static function eps() /** * Image format psd. * - * @return static */ - public static function psd() + public static function psd(): static { return static::createFormat(Format::PSD); } @@ -150,9 +137,8 @@ public static function psd() /** * Image format svg. * - * @return static */ - public static function svg() + public static function svg(): static { return static::createFormat(Format::SVG); } @@ -160,9 +146,8 @@ public static function svg() /** * Image format ai. * - * @return static */ - public static function ai() + public static function ai(): static { return static::createFormat(Format::AI); } @@ -170,9 +155,8 @@ public static function ai() /** * Image format djvu. * - * @return static */ - public static function djvu() + public static function djvu(): static { return static::createFormat(Format::DJVU); } @@ -180,9 +164,8 @@ public static function djvu() /** * Image format avif. * - * @return static */ - public static function avif() + public static function avif(): static { return static::createFormat(Format::AVIF); } @@ -190,9 +173,8 @@ public static function avif() /** * Image format flif. * - * @return static */ - public static function flif() + public static function flif(): static { return static::createFormat(Format::FLIF); } @@ -200,9 +182,8 @@ public static function flif() /** * Image format glb. * - * @return static */ - public static function glb() + public static function glb(): static { return static::createFormat(Format::GLB); } @@ -210,9 +191,8 @@ public static function glb() /** * Image format usdz. * - * @return static */ - public static function usdz() + public static function usdz(): static { return static::createFormat(Format::USDZ); } diff --git a/src/Transformation/Delivery/Format/VideoFormatInterface.php b/src/Transformation/Delivery/Format/VideoFormatInterface.php index b7dedbc..1f52459 100644 --- a/src/Transformation/Delivery/Format/VideoFormatInterface.php +++ b/src/Transformation/Delivery/Format/VideoFormatInterface.php @@ -17,18 +17,18 @@ */ interface VideoFormatInterface { - const AVI = 'avi'; - const MP4 = 'mp4'; - const WEBM = 'webm'; - const MOV = 'mov'; - const OGV = 'ogv'; - const F_3GP = '3gp'; - const F_3G2 = '3g2'; - const WMV = 'wmv'; - const MPEG = 'mpeg'; - const FLV = 'flv'; - const M3U8 = 'm3u8'; - const TS = 'ts'; - const MKV = 'mkv'; - const MPD = 'mpd'; + public const AVI = 'avi'; + public const MP4 = 'mp4'; + public const WEBM = 'webm'; + public const MOV = 'mov'; + public const OGV = 'ogv'; + public const F_3GP = '3gp'; + public const F_3G2 = '3g2'; + public const WMV = 'wmv'; + public const MPEG = 'mpeg'; + public const FLV = 'flv'; + public const M3U8 = 'm3u8'; + public const TS = 'ts'; + public const MKV = 'mkv'; + public const MPD = 'mpd'; } diff --git a/src/Transformation/Delivery/Format/VideoFormatTrait.php b/src/Transformation/Delivery/Format/VideoFormatTrait.php index a2287be..87f2e46 100644 --- a/src/Transformation/Delivery/Format/VideoFormatTrait.php +++ b/src/Transformation/Delivery/Format/VideoFormatTrait.php @@ -20,9 +20,8 @@ trait VideoFormatTrait /** * Video format mp4. * - * @return static */ - public static function videoMp4() + public static function videoMp4(): static { return static::createFormat(Format::MP4); } @@ -30,9 +29,8 @@ public static function videoMp4() /** * Video format ts. * - * @return static */ - public static function videoTs() + public static function videoTs(): static { return static::createFormat(Format::TS); } @@ -40,9 +38,8 @@ public static function videoTs() /** * Video format mov. * - * @return static */ - public static function videoMov() + public static function videoMov(): static { return static::createFormat(Format::MOV); } @@ -50,9 +47,8 @@ public static function videoMov() /** * Video format flv. * - * @return static */ - public static function videoFlv() + public static function videoFlv(): static { return static::createFormat(Format::FLV); } @@ -60,9 +56,8 @@ public static function videoFlv() /** * Video format webm. * - * @return static */ - public static function videoWebm() + public static function videoWebm(): static { return static::createFormat(Format::WEBM); } @@ -70,9 +65,8 @@ public static function videoWebm() /** * Video format ogv. * - * @return static */ - public static function videoOgv() + public static function videoOgv(): static { return static::createFormat(Format::OGV); } @@ -80,9 +74,8 @@ public static function videoOgv() /** * Video format m3u8. * - * @return static */ - public static function videoM3u8() + public static function videoM3u8(): static { return static::createFormat(Format::M3U8); } @@ -90,9 +83,8 @@ public static function videoM3u8() /** * Video format mpd. * - * @return static */ - public static function videoMpd() + public static function videoMpd(): static { return static::createFormat(Format::MPD); } @@ -100,9 +92,8 @@ public static function videoMpd() /** * Video format mkv. * - * @return static */ - public static function videoMkv() + public static function videoMkv(): static { return static::createFormat(Format::MKV); } @@ -110,9 +101,8 @@ public static function videoMkv() /** * Video format avi. * - * @return static */ - public static function videoAvi() + public static function videoAvi(): static { return static::createFormat(Format::AVI); } @@ -120,9 +110,8 @@ public static function videoAvi() /** * Video format 3gp. * - * @return static */ - public static function video3gp() + public static function video3gp(): static { return static::createFormat(Format::F_3GP); } @@ -130,9 +119,8 @@ public static function video3gp() /** * Video format 3g2. * - * @return static */ - public static function video3g2() + public static function video3g2(): static { return static::createFormat(Format::F_3G2); } @@ -140,9 +128,8 @@ public static function video3g2() /** * Video format wmv. * - * @return static */ - public static function videoWmv() + public static function videoWmv(): static { return static::createFormat(Format::WMV); } @@ -150,9 +137,8 @@ public static function videoWmv() /** * Video format mpeg. * - * @return static */ - public static function videoMpeg() + public static function videoMpeg(): static { return static::createFormat(Format::MPEG); } diff --git a/src/Transformation/Delivery/Quality/ChromaSubSampling.php b/src/Transformation/Delivery/Quality/ChromaSubSampling.php index 9b9b150..1e43364 100644 --- a/src/Transformation/Delivery/Quality/ChromaSubSampling.php +++ b/src/Transformation/Delivery/Quality/ChromaSubSampling.php @@ -15,20 +15,19 @@ */ class ChromaSubSampling { - const CHROMA_444 = '444'; - const CHROMA_422 = '422'; - const CHROMA_421 = '421'; - const CHROMA_411 = '411'; - const CHROMA_420 = '420'; - const CHROMA_410 = '410'; - const CHROMA_311 = '311'; + public const CHROMA_444 = '444'; + public const CHROMA_422 = '422'; + public const CHROMA_421 = '421'; + public const CHROMA_411 = '411'; + public const CHROMA_420 = '420'; + public const CHROMA_410 = '410'; + public const CHROMA_311 = '311'; /** * Chroma subsampling 4:4:4. * - * @return string */ - public static function chroma444() + public static function chroma444(): string { return self::CHROMA_444; } @@ -36,9 +35,8 @@ public static function chroma444() /** * Chroma subsampling 4:2:2. * - * @return string */ - public static function chroma422() + public static function chroma422(): string { return self::CHROMA_422; } @@ -46,9 +44,8 @@ public static function chroma422() /** * Chroma subsampling 4:2:1. * - * @return string */ - public static function chroma421() + public static function chroma421(): string { return self::CHROMA_421; } @@ -56,9 +53,8 @@ public static function chroma421() /** * Chroma subsampling 4:1:1. * - * @return string */ - public static function chroma411() + public static function chroma411(): string { return self::CHROMA_411; } @@ -66,9 +62,8 @@ public static function chroma411() /** * Chroma subsampling 4:2:0. * - * @return string */ - public static function chroma420() + public static function chroma420(): string { return self::CHROMA_420; } @@ -76,9 +71,8 @@ public static function chroma420() /** * Chroma subsampling 4:1:0. * - * @return string */ - public static function chroma410() + public static function chroma410(): string { return self::CHROMA_410; } @@ -86,9 +80,8 @@ public static function chroma410() /** * Chroma subsampling 3:1:1. * - * @return string */ - public static function chroma311() + public static function chroma311(): string { return self::CHROMA_311; } diff --git a/src/Transformation/Delivery/Quality/JpegMini.php b/src/Transformation/Delivery/Quality/JpegMini.php index 711a019..5dfede7 100644 --- a/src/Transformation/Delivery/Quality/JpegMini.php +++ b/src/Transformation/Delivery/Quality/JpegMini.php @@ -17,7 +17,7 @@ */ class JpegMini { - const BEST = 0; - const HIGH = 1; - const MEDIUM = 2; + public const BEST = 0; + public const HIGH = 1; + public const MEDIUM = 2; } diff --git a/src/Transformation/Delivery/Quality/Quality.php b/src/Transformation/Delivery/Quality/Quality.php index 2868125..32b2d6f 100644 --- a/src/Transformation/Delivery/Quality/Quality.php +++ b/src/Transformation/Delivery/Quality/Quality.php @@ -29,10 +29,8 @@ class Quality extends BaseAction /** * Quality constructor. * - * @param $level - * @param mixed ...$values */ - public function __construct($level, ...$values) + public function __construct(mixed $level, ...$values) { parent::__construct(new QualityQualifier($level, ...$values)); } @@ -41,11 +39,10 @@ public function __construct($level, ...$values) * When used together with automatic quality (q_auto): * allow switching to PNG8 encoding if the quality algorithm decides that it's more efficient. * - * @return Quality * * @see Flag::anyFormat */ - public function anyFormat() + public function anyFormat(): Quality { return $this->setFlag(Flag::anyFormat()); } @@ -53,27 +50,23 @@ public function anyFormat() /** * Named Quality constructor. * - * @param int|string $level The quality level. - * @param array $values Additional arguments. + * @param mixed $level The quality level. + * @param array $values Additional arguments. * - * @return Quality */ - protected static function createQuality($level, ...$values) + protected static function createQuality(mixed $level, ...$values): Quality { return new self($level, ...$values); } /** - * Sets simple value. - * - * @param string $name - * @param BaseComponent|null $value + * Sets simple value. * * @return $this * * @internal */ - protected function setSimpleValue($name, $value = null) + protected function setSimpleValue(string $name, mixed $value = null): static { $this->qualifiers[QualityQualifier::getName()]->setSimpleValue($name, $value); @@ -83,14 +76,14 @@ protected function setSimpleValue($name, $value = null) /** * Sets the simple named value of the quality qualifier. * - * @param string $name The named argument name - * @param BaseComponent|null $value The value + * @param string $name The named argument name. + * @param mixed $value The value. * * @return $this * * @internal */ - protected function setSimpleNamedValue($name, $value = null) + protected function setSimpleNamedValue(string $name, mixed $value = null): static { $this->qualifiers[QualityQualifier::getName()]->setSimpleNamedValue($name, $value); diff --git a/src/Transformation/Delivery/Quality/QualityBuilderTrait.php b/src/Transformation/Delivery/Quality/QualityBuilderTrait.php index dac3260..60da633 100644 --- a/src/Transformation/Delivery/Quality/QualityBuilderTrait.php +++ b/src/Transformation/Delivery/Quality/QualityBuilderTrait.php @@ -24,9 +24,8 @@ trait QualityBuilderTrait * * @param int $level The quality level. 1 is the lowest quality and 100 is the highest. * - * @return static */ - public function quality($level) + public function quality(int $level): static { $this->setSimpleValue('level', $level); @@ -36,15 +35,14 @@ public function quality($level) /** * Adds an optional qualifier to control chroma subsampling * - * Chroma sub-sampling is a method of encoding images by implementing less resolution for chroma information + * Chroma subsampling is a method of encoding images by implementing less resolution for chroma information * (colors) than for luma information (luminance), taking advantage of the human visual system's lower acuity for * color differences than for luminance * * @param string $chromaSubSampling Chroma sub-sampling value * - * @return static */ - public function chromaSubSampling($chromaSubSampling) + public function chromaSubSampling(string $chromaSubSampling): static { //TODO: Check valid value $this->setSimpleValue('chroma_sub_sampling', $chromaSubSampling); @@ -59,9 +57,8 @@ public function chromaSubSampling($chromaSubSampling) * * @param int $quantization The quantization level. Is a % (1-100) setting. * - * @return static */ - public function quantization($quantization) + public function quantization(int $quantization): static { //TODO: Check valid value $this->setSimpleNamedValue('qmax', $quantization); diff --git a/src/Transformation/Delivery/Quality/QualityQualifier.php b/src/Transformation/Delivery/Quality/QualityQualifier.php index 98808bd..c7f95c9 100644 --- a/src/Transformation/Delivery/Quality/QualityQualifier.php +++ b/src/Transformation/Delivery/Quality/QualityQualifier.php @@ -10,7 +10,6 @@ namespace Cloudinary\Transformation; -use Cloudinary\Transformation\BaseComponent; use Cloudinary\Transformation\Qualifier\BaseExpressionQualifier; /** @@ -25,47 +24,46 @@ class QualityQualifier extends BaseExpressionQualifier * Automatically calculate the optimal quality for an image: the smallest file size without affecting its * perceptual quality (same as GOOD). */ - const AUTO = 'auto'; + public const AUTO = 'auto'; /** * Automatically calculate the optimal quality for an image: the smallest file size without affecting its * perceptual quality. */ - const GOOD = 'good'; + public const GOOD = 'good'; /** * Automatically calculate the optimal quality for images using a less aggressive algorithm. */ - const BEST = 'best'; + public const BEST = 'best'; /** * Automatically calculate the optimal quality for images using a more aggressive algorithm. */ - const ECO = 'eco'; + public const ECO = 'eco'; /** * Automatically calculate the optimal quality for images using the most aggressive algorithm. */ - const LOW = 'low'; + public const LOW = 'low'; /** * Significantly reduces the size of photographs without affecting their perceptual quality. */ - const JPEG_MINI = 'jpegmini'; + public const JPEG_MINI = 'jpegmini'; /** * @var array $valueOrder The order of the values. */ - protected $valueOrder = [0, 'preset']; // FIXME: first item should be named! + protected array $valueOrder = [0, 'preset']; // FIXME: first item should be named! /** * Quality constructor. * - * @param mixed $strength - * @param mixed|BaseComponent $preset - * @param mixed $values + * @param mixed|null $preset + * @param mixed $values */ - public function __construct($strength, $preset = null, ...$values) + public function __construct(mixed $strength, mixed $preset = null, ...$values) { parent::__construct($strength); @@ -76,14 +74,14 @@ public function __construct($strength, $preset = null, ...$values) /** * Sets a simple unnamed value specified by name (for uniqueness) and the actual value. * - * @param string $name The name of the argument. - * @param BaseComponent|mixed $value The value of the argument. + * @param string $name The name of the argument. + * @param mixed $value The value of the argument. * * @return $this * * @internal */ - public function setSimpleValue($name, $value = null) + public function setSimpleValue(string $name, mixed $value = null): static { $this->value->setSimpleValue($name, $value); @@ -93,14 +91,14 @@ public function setSimpleValue($name, $value = null) /** * Sets the simple named value of the quality qualifier. * - * @param string $name The named argument name. - * @param BaseComponent|mixed $value The value. + * @param string $name The named argument name. + * @param mixed|null $value The value. * * @return $this * * @internal */ - public function setSimpleNamedValue($name, $value = null) + public function setSimpleNamedValue(string $name, mixed $value = null): static { $this->value->setSimpleNamedValue($name, $value); diff --git a/src/Transformation/Delivery/Quality/QualityQualifierTrait.php b/src/Transformation/Delivery/Quality/QualityQualifierTrait.php index 830eae4..01b787a 100644 --- a/src/Transformation/Delivery/Quality/QualityQualifierTrait.php +++ b/src/Transformation/Delivery/Quality/QualityQualifierTrait.php @@ -22,15 +22,14 @@ trait QualityQualifierTrait * * Reducing the quality is a trade-off between visual quality and file size. * - * @param int $level The level of the quality. (Range 1 to 100) - * @param null|string $preset A set level of automatic quality. Use the constants defined in the QualityQualifier - * class. + * @param mixed $level The level of the quality. (Range 1 to 100) + * @param string|null $preset A set level of automatic quality. Use the constants defined in the + * QualityQualifier class. * - * @return QualityQualifier * - * @see \Cloudinary\Transformation\QualityQualifier + * @see QualityQualifier */ - public static function quality($level, $preset = null) + public static function quality(mixed $level, ?string $preset = null): QualityQualifier { return new QualityQualifier($level, $preset); } diff --git a/src/Transformation/Delivery/Quality/QualityTrait.php b/src/Transformation/Delivery/Quality/QualityTrait.php index 5555a57..7f2c52d 100644 --- a/src/Transformation/Delivery/Quality/QualityTrait.php +++ b/src/Transformation/Delivery/Quality/QualityTrait.php @@ -22,9 +22,8 @@ trait QualityTrait * * @param int|string $level The quality value. (Range 1 to 100) * - * @return static */ - public static function level($level) + public static function level(int|string $level): static { return static::createQuality($level); } @@ -32,11 +31,9 @@ public static function level($level) /** * Quality auto. * - * @param $preset * - * @return static */ - public static function auto($preset = null) + public static function auto($preset = null): static { return static::createQuality(QualityQualifier::AUTO, $preset); } @@ -44,9 +41,8 @@ public static function auto($preset = null) /** * Quality good. * - * @return static */ - public static function autoGood() + public static function autoGood(): static { return static::auto(QualityQualifier::GOOD); } @@ -54,9 +50,8 @@ public static function autoGood() /** * Quality best. * - * @return static */ - public static function autoBest() + public static function autoBest(): static { return static::auto(QualityQualifier::BEST); } @@ -64,9 +59,8 @@ public static function autoBest() /** * Quality eco. * - * @return static */ - public static function autoEco() + public static function autoEco(): static { return static::auto(QualityQualifier::ECO); } @@ -74,9 +68,8 @@ public static function autoEco() /** * Quality low. * - * @return static */ - public static function autoLow() + public static function autoLow(): static { return static::auto(QualityQualifier::LOW); } @@ -84,13 +77,12 @@ public static function autoLow() /** * Quality jpegmini. * - * @param int $level The quality level. Use the constants defined in the JpegMini class. + * @param int|null $level The quality level. Use the constants defined in the JpegMini class. * - * @return static * - * @see \Cloudinary\Transformation\JpegMini + * @see JpegMini */ - public static function jpegmini($level = null) + public static function jpegmini(?int $level = null): static { return static::createQuality(QualityQualifier::JPEG_MINI, $level); } @@ -100,11 +92,10 @@ public static function jpegmini($level = null) * * Alias for jpegmini(JpegMini::BEST) * - * @return static * - * @see \Cloudinary\Transformation\JpegMini + * @see JpegMini */ - public static function jpegminiBest() + public static function jpegminiBest(): static { return static::jpegmini(JpegMini::BEST); } @@ -113,11 +104,10 @@ public static function jpegminiBest() * * Alias for jpegmini(JpegMini::HIGH) * - * @return static * - * @see \Cloudinary\Transformation\JpegMini + * @see JpegMini */ - public static function jpegminiHigh() + public static function jpegminiHigh(): static { return static::jpegmini(JpegMini::HIGH); } @@ -127,11 +117,10 @@ public static function jpegminiHigh() * * Alias for jpegmini(JpegMini::MEDIUM) * - * @return static * - * @see \Cloudinary\Transformation\JpegMini + * @see JpegMini */ - public static function jpegminiMedium() + public static function jpegminiMedium(): static { return static::jpegmini(JpegMini::MEDIUM); } @@ -139,14 +128,12 @@ public static function jpegminiMedium() /** * Creates a new instance. * - * @param $level * @param array $values * - * @return static * * @internal */ - protected static function createQuality($level, ...$values) + protected static function createQuality($level, ...$values): static { return new static($level, ...$values); } diff --git a/src/Transformation/Delivery/TransformationDeliveryTrait.php b/src/Transformation/Delivery/TransformationDeliveryTrait.php index 98fa9a2..cd7dbdb 100644 --- a/src/Transformation/Delivery/TransformationDeliveryTrait.php +++ b/src/Transformation/Delivery/TransformationDeliveryTrait.php @@ -27,9 +27,8 @@ trait TransformationDeliveryTrait * * @param mixed $delivery The delivery action to apply. * - * @return static */ - public function delivery($delivery) + public function delivery($delivery): static { return $this->addAction($delivery); } @@ -39,11 +38,9 @@ public function delivery($delivery) * * (Formerly known as fetch format) * - * @param Format|string $format * - * @return static */ - public function format($format) + public function format(Format|string $format): static { return $this->addAction(ClassUtils::verifyInstance($format, Format::class)); } @@ -54,11 +51,9 @@ public function format($format) * * Reducing the quality is a trade-off between visual quality and file size. * - * @param int|string|Quality $quality * - * @return static */ - public function quality($quality) + public function quality(Quality|int|float|string $quality): static { return $this->addAction(ClassUtils::verifyInstance($quality, Quality::class)); } @@ -68,9 +63,8 @@ public function quality($quality) * * @param float|string $dpr Any positive float value. * - * @return static */ - public function dpr($dpr) + public function dpr($dpr): static { return $this->addAction(ClassUtils::verifyInstance($dpr, Dpr::class)); } diff --git a/src/Transformation/Effect/Addon/AddonEffectTrait.php b/src/Transformation/Effect/Addon/AddonEffectTrait.php index 18e81a1..fe39ef2 100644 --- a/src/Transformation/Effect/Addon/AddonEffectTrait.php +++ b/src/Transformation/Effect/Addon/AddonEffectTrait.php @@ -21,9 +21,8 @@ trait AddonEffectTrait /** * Applies Adobe Lightroom filter. * - * @return LightroomEffect */ - public static function lightroom() + public static function lightroom(): LightroomEffect { return new LightroomEffect(new LightroomEffectQualifier()); } diff --git a/src/Transformation/Effect/Addon/Lightroom/LightroomEffect.php b/src/Transformation/Effect/Addon/Lightroom/LightroomEffect.php index da43b9d..981c80b 100644 --- a/src/Transformation/Effect/Addon/Lightroom/LightroomEffect.php +++ b/src/Transformation/Effect/Addon/Lightroom/LightroomEffect.php @@ -15,23 +15,25 @@ */ class LightroomEffect extends EffectAction implements LightroomEffectInterface { - const LIGHTROOM = 'lightroom'; + public const LIGHTROOM = 'lightroom'; - const SHARPNESS_RANGE = [0, 150]; - const SHARPEN_EDGE_MASKING_RANGE = [0, 10]; - const EXPOSURE_RANGE = [-5.0, 5.0]; - const SHARPEN_RADIUS_RANGE = [0.5, 3.0]; + public const SHARPNESS_RANGE = [0, 150]; + public const SHARPEN_EDGE_MASKING_RANGE = [0, 10]; + public const EXPOSURE_RANGE = [-5.0, 5.0]; + public const SHARPEN_RADIUS_RANGE = [0.5, 3.0]; use LightroomEffectTrait; /** - * @param $name - * @param $value - * @param $range + * Adds Lightroom Filter * - * @return static + * @param ?string $name The name of the filter. + * @param mixed $value The value of the filter. + * @param ?array $range The valid range of the value. + * + * @return $this */ - protected function addLightroomFilter($name, $value, $range = null) + protected function addLightroomFilter(?string $name, mixed $value, ?array $range = null): static { $this->qualifiers[EffectQualifier::getName()]->addLightroomFilter($name, $value, $range); @@ -41,12 +43,10 @@ protected function addLightroomFilter($name, $value, $range = null) /** * Lightroom XMP file. * - * @param string $source The XMP file source (public ID). - * @param string $value + * @param mixed $source The XMP file source (public ID). * - * @return static */ - public function xmp($source) + public function xmp(mixed $source): static { $this->qualifiers[EffectQualifier::getName()]->xmp($source); diff --git a/src/Transformation/Effect/Addon/Lightroom/LightroomEffectInterface.php b/src/Transformation/Effect/Addon/Lightroom/LightroomEffectInterface.php index 8a14633..c3df619 100644 --- a/src/Transformation/Effect/Addon/Lightroom/LightroomEffectInterface.php +++ b/src/Transformation/Effect/Addon/Lightroom/LightroomEffectInterface.php @@ -15,24 +15,24 @@ */ interface LightroomEffectInterface { - const CONTRAST = 'contrast'; - const SATURATION = 'saturation'; - const VIGNETTE_AMOUNT = 'vignetteamount'; - const VIBRANCE = 'vibrance'; - const HIGHLIGHTS = 'highlights'; - const SHADOWS = 'shadows'; - const WHITES = 'whites'; - const BLACKS = 'blacks'; - const CLARITY = 'clarity'; - const DEHAZE = 'dehaze'; - const TEXTURE = 'texture'; - const SHARPNESS = 'sharpness'; - const COLOR_NOISE_REDUCTION = 'colornoisereduction'; - const NOISE_REDUCTION = 'noisereduction'; - const SHARPEN_DETAIL = 'sharpendetail'; - const SHARPEN_EDGE_MASKING = 'sharpenedgemasking'; - const EXPOSURE = 'exposure'; - const SHARPEN_RADIUS = 'sharpenradius'; - const WHITE_BALANCE = 'whitebalance'; - const XMP = 'xmp'; + public const CONTRAST = 'contrast'; + public const SATURATION = 'saturation'; + public const VIGNETTE_AMOUNT = 'vignetteamount'; + public const VIBRANCE = 'vibrance'; + public const HIGHLIGHTS = 'highlights'; + public const SHADOWS = 'shadows'; + public const WHITES = 'whites'; + public const BLACKS = 'blacks'; + public const CLARITY = 'clarity'; + public const DEHAZE = 'dehaze'; + public const TEXTURE = 'texture'; + public const SHARPNESS = 'sharpness'; + public const COLOR_NOISE_REDUCTION = 'colornoisereduction'; + public const NOISE_REDUCTION = 'noisereduction'; + public const SHARPEN_DETAIL = 'sharpendetail'; + public const SHARPEN_EDGE_MASKING = 'sharpenedgemasking'; + public const EXPOSURE = 'exposure'; + public const SHARPEN_RADIUS = 'sharpenradius'; + public const WHITE_BALANCE = 'whitebalance'; + public const XMP = 'xmp'; } diff --git a/src/Transformation/Effect/Addon/Lightroom/LightroomEffectQualifier.php b/src/Transformation/Effect/Addon/Lightroom/LightroomEffectQualifier.php index 0963014..b488972 100644 --- a/src/Transformation/Effect/Addon/Lightroom/LightroomEffectQualifier.php +++ b/src/Transformation/Effect/Addon/Lightroom/LightroomEffectQualifier.php @@ -33,13 +33,15 @@ public function __construct() } /** - * @param $name - * @param $value - * @param $range + * Adds Lightroom Filter * - * @return static + * @param ?string $name The name of the filter. + * @param mixed $value The value of the filter. + * @param array|null $range The valid range of the value. + * + * @return $this */ - public function addLightroomFilter($name, $value, $range = null) + public function addLightroomFilter(?string $name, mixed $value, ?array $range = null): static { return $this->add(new LimitedGenericNamedArgument($name, $value, $range)); } @@ -47,11 +49,10 @@ public function addLightroomFilter($name, $value, $range = null) /** * Lightroom XMP file. * - * @param string $source The XMP file source (public ID). + * @param XmpSourceValue|string|null $source The XMP file source (public ID). * - * @return static */ - public function xmp($source) + public function xmp(XmpSourceValue|string|null $source): static { return $this->setEffectValue(ClassUtils::verifyInstance($source, XmpSourceValue::class)); } diff --git a/src/Transformation/Effect/Addon/Lightroom/LightroomEffectTrait.php b/src/Transformation/Effect/Addon/Lightroom/LightroomEffectTrait.php index e4338c1..8707e04 100644 --- a/src/Transformation/Effect/Addon/Lightroom/LightroomEffectTrait.php +++ b/src/Transformation/Effect/Addon/Lightroom/LightroomEffectTrait.php @@ -20,11 +20,9 @@ trait LightroomEffectTrait /** * Lightroom filter contrast. * - * @param int $value * - * @return static */ - public function contrast($value) + public function contrast(int $value): static { return $this->addLightroomFilter(LightroomEffect::CONTRAST, $value, EffectRange::DEFAULT_RANGE); } @@ -32,11 +30,9 @@ public function contrast($value) /** * Lightroom filter saturation. * - * @param int $value * - * @return static */ - public function saturation($value) + public function saturation(int $value): static { return $this->addLightroomFilter(LightroomEffect::SATURATION, $value, EffectRange::DEFAULT_RANGE); } @@ -44,11 +40,9 @@ public function saturation($value) /** * Lightroom filter vignetteAmount. * - * @param int $value * - * @return static */ - public function vignetteAmount($value) + public function vignetteAmount(int $value): static { return $this->addLightroomFilter(LightroomEffect::VIGNETTE_AMOUNT, $value, EffectRange::DEFAULT_RANGE); } @@ -56,11 +50,9 @@ public function vignetteAmount($value) /** * Lightroom filter vibrance. * - * @param int $value * - * @return static */ - public function vibrance($value) + public function vibrance(int $value): static { return $this->addLightroomFilter(LightroomEffect::VIBRANCE, $value, EffectRange::DEFAULT_RANGE); } @@ -68,11 +60,9 @@ public function vibrance($value) /** * Lightroom filter highlights. * - * @param int $value * - * @return static */ - public function highlights($value) + public function highlights(int $value): static { return $this->addLightroomFilter(LightroomEffect::HIGHLIGHTS, $value, EffectRange::DEFAULT_RANGE); } @@ -80,11 +70,9 @@ public function highlights($value) /** * Lightroom filter shadows. * - * @param int $value * - * @return static */ - public function shadows($value) + public function shadows(int $value): static { return $this->addLightroomFilter(LightroomEffect::SHADOWS, $value, EffectRange::DEFAULT_RANGE); } @@ -92,11 +80,9 @@ public function shadows($value) /** * Lightroom filter whites. * - * @param int $value * - * @return static */ - public function whites($value) + public function whites(int $value): static { return $this->addLightroomFilter(LightroomEffect::WHITES, $value, EffectRange::DEFAULT_RANGE); } @@ -104,11 +90,9 @@ public function whites($value) /** * Lightroom filter blacks. * - * @param int $value * - * @return static */ - public function blacks($value) + public function blacks(int $value): static { return $this->addLightroomFilter(LightroomEffect::BLACKS, $value, EffectRange::DEFAULT_RANGE); } @@ -116,11 +100,9 @@ public function blacks($value) /** * Lightroom filter clarity. * - * @param int $value * - * @return static */ - public function clarity($value) + public function clarity(int $value): static { return $this->addLightroomFilter(LightroomEffect::CLARITY, $value, EffectRange::DEFAULT_RANGE); } @@ -128,11 +110,9 @@ public function clarity($value) /** * Lightroom filter dehaze. * - * @param int $value * - * @return static */ - public function dehaze($value) + public function dehaze(int $value): static { return $this->addLightroomFilter(LightroomEffect::DEHAZE, $value, EffectRange::DEFAULT_RANGE); } @@ -140,11 +120,9 @@ public function dehaze($value) /** * Lightroom filter texture . * - * @param int $value * - * @return static */ - public function texture($value) + public function texture(int $value): static { return $this->addLightroomFilter(LightroomEffect::TEXTURE, $value, EffectRange::DEFAULT_RANGE); } @@ -152,11 +130,9 @@ public function texture($value) /** * Lightroom filter sharpness. * - * @param int $value * - * @return static */ - public function sharpness($value) + public function sharpness(int $value): static { return $this->addLightroomFilter(LightroomEffect::SHARPNESS, $value, LightroomEffect::SHARPNESS_RANGE); } @@ -164,11 +140,9 @@ public function sharpness($value) /** * Lightroom filter color noise reduction. * - * @param int $value * - * @return static */ - public function colorNoiseReduction($value) + public function colorNoiseReduction(int $value): static { return $this->addLightroomFilter(LightroomEffect::COLOR_NOISE_REDUCTION, $value, EffectRange::PERCENT); } @@ -176,11 +150,9 @@ public function colorNoiseReduction($value) /** * Lightroom filter noise reduction. * - * @param int $value * - * @return static */ - public function noiseReduction($value) + public function noiseReduction(int $value): static { return $this->addLightroomFilter(LightroomEffect::NOISE_REDUCTION, $value, EffectRange::PERCENT); } @@ -188,12 +160,10 @@ public function noiseReduction($value) /** * Lightroom filter sharpen detail. * - * @param int $value * - * @return static */ - public function sharpenDetail($value) + public function sharpenDetail(int $value): static { return $this->addLightroomFilter(LightroomEffect::SHARPEN_DETAIL, $value, EffectRange::PERCENT); } @@ -201,11 +171,9 @@ public function sharpenDetail($value) /** * Lightroom filter sharpen edge masking. * - * @param int $value * - * @return static */ - public function sharpenEdgeMasking($value) + public function sharpenEdgeMasking(int $value): static { return $this->addLightroomFilter( LightroomEffect::SHARPEN_EDGE_MASKING, @@ -217,11 +185,9 @@ public function sharpenEdgeMasking($value) /** * Lightroom filter exposure. * - * @param float $value * - * @return static */ - public function exposure($value) + public function exposure(float $value): static { return $this->addLightroomFilter(LightroomEffect::EXPOSURE, $value, LightroomEffect::EXPOSURE_RANGE); } @@ -229,11 +195,9 @@ public function exposure($value) /** * Lightroom filter sharpen radius. * - * @param float $value * - * @return static */ - public function sharpenRadius($value) + public function sharpenRadius(float $value): static { return $this->addLightroomFilter( LightroomEffect::SHARPEN_RADIUS, @@ -245,11 +209,9 @@ public function sharpenRadius($value) /** * Lightroom filter white balance. * - * @param string $value * - * @return static */ - public function whiteBalance($value) + public function whiteBalance(string $value): static { return $this->addLightroomFilter(LightroomEffect::WHITE_BALANCE, $value); } @@ -258,22 +220,21 @@ public function whiteBalance($value) /** * Generic lightroom filter. * - * @param string $name - * @param mixed $value * - * @return static */ - public function genericFilter($name, $value) + public function genericFilter(string $name, mixed $value): static { return $this->addLightroomFilter($name, $value); } /** - * @param $name - * @param $value - * @param $range + * Adds Lightroom Filter * - * @return static + * @param ?string $name The name of the filter. + * @param mixed $value The value of the filter. + * @param array|null $range The valid range of the value. + * + * @return $this */ - abstract public function addLightroomFilter($name, $value, $range = null); + abstract public function addLightroomFilter(?string $name, mixed $value, ?array $range = null): static; } diff --git a/src/Transformation/Effect/Addon/Lightroom/WhiteBalance.php b/src/Transformation/Effect/Addon/Lightroom/WhiteBalance.php index 0a077b6..1eebfbd 100644 --- a/src/Transformation/Effect/Addon/Lightroom/WhiteBalance.php +++ b/src/Transformation/Effect/Addon/Lightroom/WhiteBalance.php @@ -15,13 +15,13 @@ */ abstract class WhiteBalance { - const AS_SHOT = 'as shot'; - const AUTO = 'auto'; - const CLOUDY = 'cloudy'; - const CUSTOM = 'custom'; - const DAYLIGHT = 'daylight'; - const FLASH = 'flash'; - const FLUORESCENT = 'fluorescent'; - const SHADE = 'shade'; - const TUNGSTEN = 'tungsten'; + public const AS_SHOT = 'as shot'; + public const AUTO = 'auto'; + public const CLOUDY = 'cloudy'; + public const CUSTOM = 'custom'; + public const DAYLIGHT = 'daylight'; + public const FLASH = 'flash'; + public const FLUORESCENT = 'fluorescent'; + public const SHADE = 'shade'; + public const TUNGSTEN = 'tungsten'; } diff --git a/src/Transformation/Effect/Addon/Lightroom/Xmp.php b/src/Transformation/Effect/Addon/Lightroom/Xmp.php index c96ed63..9f950fc 100644 --- a/src/Transformation/Effect/Addon/Lightroom/Xmp.php +++ b/src/Transformation/Effect/Addon/Lightroom/Xmp.php @@ -18,11 +18,10 @@ abstract class Xmp /** * Created a new instance of the XmpSource class. * - * @param string $source The public id of the XMP file. + * @param mixed $source The public id of the XMP file. * - * @return XmpSourceValue */ - public static function source($source) + public static function source(mixed $source): XmpSourceValue { return new XmpSourceValue($source); } diff --git a/src/Transformation/Effect/Addon/Lightroom/XmpSourceValue.php b/src/Transformation/Effect/Addon/Lightroom/XmpSourceValue.php index 72ddf1f..429c0e9 100644 --- a/src/Transformation/Effect/Addon/Lightroom/XmpSourceValue.php +++ b/src/Transformation/Effect/Addon/Lightroom/XmpSourceValue.php @@ -15,9 +15,9 @@ */ class XmpSourceValue extends SourceValue { - const XMP = 'xmp'; + public const XMP = 'xmp'; - protected $argumentOrder = ['asset_type', 'delivery_type', 'source']; + protected array $argumentOrder = ['asset_type', 'delivery_type', 'source']; public function __construct(...$arguments) { @@ -26,12 +26,7 @@ public function __construct(...$arguments) $this->setSimpleValue('asset_type', self::XMP); } - /** - * @param bool $set - * - * @return XmpSourceValue - */ - public function authenticated($set = true) + public function authenticated(bool $set = true): XmpSourceValue { return $this->setSimpleValue('delivery_type', $set ? 'authenticated' : null); } diff --git a/src/Transformation/Effect/Appearance/AppearanceEffect.php b/src/Transformation/Effect/Appearance/AppearanceEffect.php index fe32bce..b802db3 100644 --- a/src/Transformation/Effect/Appearance/AppearanceEffect.php +++ b/src/Transformation/Effect/Appearance/AppearanceEffect.php @@ -16,9 +16,9 @@ abstract class AppearanceEffect { // Common effects - const DESHAKE = 'deshake'; - const FADE = 'fade'; - const NOISE = 'noise'; + public const DESHAKE = 'deshake'; + public const FADE = 'fade'; + public const NOISE = 'noise'; use VideoAppearanceEffectTrait; } diff --git a/src/Transformation/Effect/Appearance/Deshake.php b/src/Transformation/Effect/Appearance/Deshake.php index b5e2fbd..1f70124 100644 --- a/src/Transformation/Effect/Appearance/Deshake.php +++ b/src/Transformation/Effect/Appearance/Deshake.php @@ -40,7 +40,7 @@ public function __construct($shakeStrength, ...$args) * * @return $this */ - public function shakeStrength($shakeStrength) + public function shakeStrength(int $shakeStrength): static { $this->qualifiers[EffectQualifier::getName()]->setEffectValue($shakeStrength); diff --git a/src/Transformation/Effect/Appearance/ShakeStrength.php b/src/Transformation/Effect/Appearance/ShakeStrength.php index 1ba8348..9de8154 100644 --- a/src/Transformation/Effect/Appearance/ShakeStrength.php +++ b/src/Transformation/Effect/Appearance/ShakeStrength.php @@ -15,44 +15,40 @@ */ class ShakeStrength { - const PIXELS_16 = 16; - const PIXELS_32 = 32; - const PIXELS_48 = 48; - const PIXELS_64 = 64; + public const PIXELS_16 = 16; + public const PIXELS_32 = 32; + public const PIXELS_48 = 48; + public const PIXELS_64 = 64; /** * Shake strength 16. * - * @return int */ - public static function pixels16() + public static function pixels16(): int { return self::PIXELS_16; } /** * Shake strength 32. * - * @return int */ - public static function pixels32() + public static function pixels32(): int { return self::PIXELS_32; } /** * Shake strength 48. * - * @return int */ - public static function pixels48() + public static function pixels48(): int { return self::PIXELS_48; } /** * Shake strength 64. * - * @return int */ - public static function pixels64() + public static function pixels64(): int { return self::PIXELS_64; } diff --git a/src/Transformation/Effect/Appearance/ThemeEffect.php b/src/Transformation/Effect/Appearance/ThemeEffect.php index 815f364..95b196c 100644 --- a/src/Transformation/Effect/Appearance/ThemeEffect.php +++ b/src/Transformation/Effect/Appearance/ThemeEffect.php @@ -21,9 +21,9 @@ class ThemeEffect extends EffectAction /** * Theme constructor. * - * @param string $color The target background color. Specify either the name of a color (e.g. black, + * @param string $color The target background color. Specify either the name of a color (e.g. black, * lightgray), or an RGB hex value (e.g. f0ebe6). - * @param integer $photoSensitivity The sensitivity to photographic elements of an image. A value of 0 treats the + * @param int $photoSensitivity The sensitivity to photographic elements of an image. A value of 0 treats the * whole image as non-photographic. A value of 200 treats the whole image as * photographic, so no theme change is applied. Range: 0 to 200. Default: 100. */ @@ -38,9 +38,8 @@ public function __construct($color, $photoSensitivity = null) * @param string $color The target background color. Specify either the name of a color (e.g. black, lightgray), * or an RGB hex value (e.g. f0ebe6). * - * @return ThemeEffect */ - public function color($color) + public function color(string $color): static { $this->qualifiers[ThemeQualifier::getName()]->color($color); @@ -54,9 +53,8 @@ public function color($color) * image as non-photographic. A value of 200 treats the whole image as photographic, * so no theme change is applied. Range: 0 to 200. Default: 100. * - * @return ThemeEffect */ - public function photoSensitivity($photoSensitivity) + public function photoSensitivity(int $photoSensitivity): static { $this->qualifiers[ThemeQualifier::getName()]->photosensitivity($photoSensitivity); diff --git a/src/Transformation/Effect/Appearance/ThemeEffectTrait.php b/src/Transformation/Effect/Appearance/ThemeEffectTrait.php index 192c2e9..72da54a 100644 --- a/src/Transformation/Effect/Appearance/ThemeEffectTrait.php +++ b/src/Transformation/Effect/Appearance/ThemeEffectTrait.php @@ -21,18 +21,18 @@ trait ThemeEffectTrait * Changes the main background color to the one specified, as if a 'theme change' was applied * (e.g. dark mode vs light mode). * - * @param string $color The target background color. Specify either the name of a color (e.g. black, - * lightgray), or an RGB hex value (e.g. f0ebe6). - * @param integer $photoSensitivity The sensitivity to photographic elements of an image. A value of 0 treats the - * whole image as non-photographic. A value of 200 treats the whole image as - * photographic, so no theme change is applied. Range: 0 to 200. Default: 100. + * @param string $color The target background color. Specify either the name of a color (e.g. + * black, lightgray), or an RGB hex value (e.g. f0ebe6). + * @param int|null $photoSensitivity The sensitivity to photographic elements of an image. A value of 0 treats + * the whole image as non-photographic. A value of 200 treats the whole image + * as photographic, so no theme change is applied. Range: 0 to 200. Default: + * 100. * - * @return ThemeEffect * - * @see \Cloudinary\Transformation\ThemeEffect - * @see \Cloudinary\Transformation\ThemeQualifier + * @see ThemeEffect + * @see ThemeQualifier */ - public static function theme($color, $photoSensitivity = null) + public static function theme(string $color, ?int $photoSensitivity = null): ThemeEffect { return new ThemeEffect($color, $photoSensitivity); } diff --git a/src/Transformation/Effect/Appearance/ThemeQualifier.php b/src/Transformation/Effect/Appearance/ThemeQualifier.php index 8798810..c0b9a7f 100644 --- a/src/Transformation/Effect/Appearance/ThemeQualifier.php +++ b/src/Transformation/Effect/Appearance/ThemeQualifier.php @@ -24,7 +24,7 @@ class ThemeQualifier extends EffectQualifier { const NAME = 'theme'; - protected $valueOrder = [0, 'color', 'photosensitivity']; + protected array $valueOrder = [0, 'color', 'photosensitivity']; public function __construct($color, $photoSensitivity) { @@ -37,12 +37,11 @@ public function __construct($color, $photoSensitivity) /** * Sets the theme color. * - * @param string $color The target background color. Specify either the name of a color (e.g. black, lightgray), + * @param ?string $color The target background color. Specify either the name of a color (e.g. black, lightgray), * or an RGB hex value (e.g. f0ebe6). * - * @return ThemeQualifier */ - public function color($color) + public function color(?string $color): static { $color = StringUtils::truncatePrefix((string)$color, '#'); $this->value->setSimpleNamedValue('color', ClassUtils::verifyInstance($color, ColorValue::class)); @@ -53,13 +52,12 @@ public function color($color) /** * Sets the theme photosensitivity. * - * @param int $photoSensitivity The sensitivity to photographic elements of an image. A value of 0 treats the whole + * @param ?int $photoSensitivity The sensitivity to photographic elements of an image. A value of 0 treats the whole * image as non-photographic. A value of 200 treats the whole image as photographic, * so no theme change is applied. Range: 0 to 200. Default: 100. * - * @return ThemeQualifier */ - public function photoSensitivity($photoSensitivity) + public function photoSensitivity(?int $photoSensitivity): static { $this->value->setSimpleNamedValue('photosensitivity', $photoSensitivity); diff --git a/src/Transformation/Effect/Appearance/VideoAppearanceEffectTrait.php b/src/Transformation/Effect/Appearance/VideoAppearanceEffectTrait.php index 5e2fd9b..47bc1f7 100644 --- a/src/Transformation/Effect/Appearance/VideoAppearanceEffectTrait.php +++ b/src/Transformation/Effect/Appearance/VideoAppearanceEffectTrait.php @@ -23,12 +23,11 @@ trait VideoAppearanceEffectTrait * Removes small motion shifts from the video. with a maximum extent of movement in the horizontal and vertical * direction of 32 pixels * - * @param int $shakeStrength The maximum number of pixels in the horizontal and vertical direction that will be + * @param int|null $shakeStrength The maximum number of pixels in the horizontal and vertical direction that will be * addressed. (Possible values: 16, 32, 48, 64. Server default: 16) * - * @return Deshake */ - public static function deshake($shakeStrength = null) + public static function deshake(?int $shakeStrength = null): Deshake { return ClassUtils::forceInstance($shakeStrength, Deshake::class); } @@ -38,13 +37,12 @@ public static function deshake($shakeStrength = null) * * For details and examples, see 'Fade in and out' in the Video Transformations guide. * - * @param int $duration The time in ms for the fade to occur. (Server default: 1000) + * @param int|null $duration The time in ms for the fade to occur. (Server default: 1000) * - * @return DurationEffectAction * * @see https://cloudinary.com/documentation/video_manipulation_and_delivery#fade_in_and_out */ - public static function fadeIn($duration = null) + public static function fadeIn(?int $duration = null): DurationEffectAction { return EffectAction::withDuration(AppearanceEffect::FADE, $duration); } @@ -54,13 +52,12 @@ public static function fadeIn($duration = null) * * For details and examples, see 'Fade in and out' in the Video Transformations guide. * - * @param int $duration The time in ms for the fade to occur. + * @param int|null $duration The time in ms for the fade to occur. * - * @return DurationEffectAction * * @see https://cloudinary.com/documentation/video_manipulation_and_delivery#fade_in_and_out */ - public static function fadeOut($duration = null) + public static function fadeOut(?int $duration = null): DurationEffectAction { return EffectAction::withDuration(AppearanceEffect::FADE, $duration, true); } @@ -68,11 +65,10 @@ public static function fadeOut($duration = null) /** * Adds visual noise to the video, visible as a random flicker of "dots" or "snow". * - * @param int $percentage The percent of noise to apply. (Range: 0 to 100 Server default: 0) + * @param int|null $percentage The percent of noise to apply. (Range: 0 to 100 Server default: 0) * - * @return EffectAction */ - public static function noise($percentage = null) + public static function noise(?int $percentage = null): EffectAction { return EffectAction::withLevel(AppearanceEffect::NOISE, EffectRange::PERCENT, $percentage); } diff --git a/src/Transformation/Effect/Argument/EffectActionTypeTrait.php b/src/Transformation/Effect/Argument/EffectActionTypeTrait.php index 3ef267d..5670d8a 100644 --- a/src/Transformation/Effect/Argument/EffectActionTypeTrait.php +++ b/src/Transformation/Effect/Argument/EffectActionTypeTrait.php @@ -12,8 +12,6 @@ /** * Trait EffectTypeTrait - * - * @property array qualifiers The qualifiers of the action. */ trait EffectActionTypeTrait { @@ -24,7 +22,7 @@ trait EffectActionTypeTrait * * @return $this */ - public function type($type) + public function type(string $type): static { $this->qualifiers[EffectQualifier::getName()]->type($type); diff --git a/src/Transformation/Effect/Argument/EffectMode.php b/src/Transformation/Effect/Argument/EffectMode.php index ab83c24..717da43 100644 --- a/src/Transformation/Effect/Argument/EffectMode.php +++ b/src/Transformation/Effect/Argument/EffectMode.php @@ -18,5 +18,5 @@ class EffectMode extends BaseArgument /** * @var string $name The name of the argument. */ - protected static $name = 'mode'; + protected static string $name = 'mode'; } diff --git a/src/Transformation/Effect/Argument/EffectModeTrait.php b/src/Transformation/Effect/Argument/EffectModeTrait.php index aa27f3a..ffe1019 100644 --- a/src/Transformation/Effect/Argument/EffectModeTrait.php +++ b/src/Transformation/Effect/Argument/EffectModeTrait.php @@ -26,7 +26,7 @@ trait EffectModeTrait * * @return $this */ - public function mode($mode) + public function mode(mixed $mode): static { $this->value->setValue(ClassUtils::verifyInstance($mode, EffectMode::class)); diff --git a/src/Transformation/Effect/Argument/EffectName.php b/src/Transformation/Effect/Argument/EffectName.php index 4362cff..6a1f423 100644 --- a/src/Transformation/Effect/Argument/EffectName.php +++ b/src/Transformation/Effect/Argument/EffectName.php @@ -18,5 +18,5 @@ class EffectName extends BaseArgument /** * @var string $name The name of the argument */ - protected static $name = 'name'; + protected static string $name = 'name'; } diff --git a/src/Transformation/Effect/Argument/EffectRange.php b/src/Transformation/Effect/Argument/EffectRange.php index c3f9339..cf87ea9 100644 --- a/src/Transformation/Effect/Argument/EffectRange.php +++ b/src/Transformation/Effect/Argument/EffectRange.php @@ -17,16 +17,16 @@ */ class EffectRange { - const PERCENT = [0, 100]; - const POSITIVE_PERCENT = [1, 100]; - const EXTENDED_PERCENT = [-50, 100]; - const AUDIO_VOLUME = [-100, 400]; - const ANGLE = [-360, 360]; - const PIXEL = [1, 2000]; - const PIXEL_REGION = [1, 200]; - const DEFAULT_RANGE = [-100, 100]; - const SHIFTED_RANGE = [-50, 150]; - const BRIGHTNESS = [-99, 100]; - const DESHAKE = [0, 64]; //FIXME: set predefined values - const ORDERED_DITHER = [0, 18]; + public const PERCENT = [0, 100]; + public const POSITIVE_PERCENT = [1, 100]; + public const EXTENDED_PERCENT = [-50, 100]; + public const AUDIO_VOLUME = [-100, 400]; + public const ANGLE = [-360, 360]; + public const PIXEL = [1, 2000]; + public const PIXEL_REGION = [1, 200]; + public const DEFAULT_RANGE = [-100, 100]; + public const SHIFTED_RANGE = [-50, 150]; + public const BRIGHTNESS = [-99, 100]; + public const DESHAKE = [0, 64]; //FIXME: set predefined values + public const ORDERED_DITHER = [0, 18]; } diff --git a/src/Transformation/Effect/Argument/EffectType.php b/src/Transformation/Effect/Argument/EffectType.php index 42aa957..9501a91 100644 --- a/src/Transformation/Effect/Argument/EffectType.php +++ b/src/Transformation/Effect/Argument/EffectType.php @@ -18,5 +18,5 @@ class EffectType extends BaseArgument /** * @var string $name The name of the argument. */ - protected static $name = 'type'; + protected static string $name = 'type'; } diff --git a/src/Transformation/Effect/Argument/EffectTypeTrait.php b/src/Transformation/Effect/Argument/EffectTypeTrait.php index d3759d6..2a37169 100644 --- a/src/Transformation/Effect/Argument/EffectTypeTrait.php +++ b/src/Transformation/Effect/Argument/EffectTypeTrait.php @@ -26,7 +26,7 @@ trait EffectTypeTrait * * @return $this */ - public function type($type) + public function type(mixed $type): static { $this->value->setValue(ClassUtils::verifyInstance($type, EffectType::class)); diff --git a/src/Transformation/Effect/BlendEffectAction.php b/src/Transformation/Effect/BlendEffectAction.php index e4b9991..1f40f6c 100644 --- a/src/Transformation/Effect/BlendEffectAction.php +++ b/src/Transformation/Effect/BlendEffectAction.php @@ -22,7 +22,7 @@ class BlendEffectAction extends EffectAction * * @return $this */ - public function blend($blend) + public function blend(int $blend): static { $this->qualifiers[EffectQualifier::getName()]->blend($blend); diff --git a/src/Transformation/Effect/BlendEffectQualifier.php b/src/Transformation/Effect/BlendEffectQualifier.php index c18cf78..c68597f 100644 --- a/src/Transformation/Effect/BlendEffectQualifier.php +++ b/src/Transformation/Effect/BlendEffectQualifier.php @@ -24,11 +24,10 @@ class BlendEffectQualifier extends LimitedEffectQualifier * * @param int $blend The blend percentage to set. * - * @return static * * @internal */ - public function blend($blend) + public function blend(int $blend): static { $this->setEffectValue($blend); diff --git a/src/Transformation/Effect/Color/AssistColorBlind.php b/src/Transformation/Effect/Color/AssistColorBlind.php index 3a683a8..6f50ec9 100644 --- a/src/Transformation/Effect/Color/AssistColorBlind.php +++ b/src/Transformation/Effect/Color/AssistColorBlind.php @@ -17,7 +17,7 @@ */ class AssistColorBlind extends LimitedEffectQualifier { - const X_RAY = 'xray'; + public const X_RAY = 'xray'; /** * AssistColorBlind constructor. @@ -36,9 +36,8 @@ public function __construct($strength = null) * * @param int $strength The strength of the stripes. (Range: 1 to 100, Server default: 10) * - * @return AssistColorBlind */ - public function stripesStrength($strength) + public function stripesStrength(int $strength): static { return $this->setAssistType($strength); } @@ -47,9 +46,8 @@ public function stripesStrength($strength) * Replaces problematic colors with colors that look the same to people with and * without common colorblind conditions. * - * @return AssistColorBlind */ - public function xRay() + public function xRay(): static { return $this->setAssistType(self::X_RAY); } @@ -57,13 +55,9 @@ public function xRay() /** * Sets the type of the assistance. * - * @param string $type - * - * @return AssistColorBlind - * * @internal */ - protected function setAssistType($type) + protected function setAssistType(?string $type): static { $this->value->setSimpleValue('assist_type', $type); diff --git a/src/Transformation/Effect/Color/ColorEffect.php b/src/Transformation/Effect/Color/ColorEffect.php index 9ab894a..193c94b 100644 --- a/src/Transformation/Effect/Color/ColorEffect.php +++ b/src/Transformation/Effect/Color/ColorEffect.php @@ -16,14 +16,14 @@ abstract class ColorEffect { // Image effects - const BLACKWHITE = 'blackwhite'; - const COLORIZE = 'colorize'; - const GRAYSCALE = 'grayscale'; - const NEGATE = 'negate'; - const SEPIA = 'sepia'; + public const BLACKWHITE = 'blackwhite'; + public const COLORIZE = 'colorize'; + public const GRAYSCALE = 'grayscale'; + public const NEGATE = 'negate'; + public const SEPIA = 'sepia'; // Accessibility - const ASSIST_COLOR_BLIND = 'assist_colorblind'; - const SIMULATE_COLOR_BLIND = 'simulate_colorblind'; + public const ASSIST_COLOR_BLIND = 'assist_colorblind'; + public const SIMULATE_COLOR_BLIND = 'simulate_colorblind'; use ImageColorEffectTrait; } diff --git a/src/Transformation/Effect/Color/ImageColorEffectTrait.php b/src/Transformation/Effect/Color/ImageColorEffectTrait.php index 262317a..49d5955 100644 --- a/src/Transformation/Effect/Color/ImageColorEffectTrait.php +++ b/src/Transformation/Effect/Color/ImageColorEffectTrait.php @@ -20,11 +20,10 @@ trait ImageColorEffectTrait /** * Converts the image to black and white. * - * @param int $threshold The balance between black (100) and white (0). (Range: 0 to 100, Server default: 50) + * @param int|null $threshold The balance between black (100) and white (0). (Range: 0 to 100, Server default: 50) * - * @return ThresholdEffectAction */ - public static function blackWhite($threshold = null) + public static function blackWhite(?int $threshold = null): ThresholdEffectAction { return EffectAction::withThreshold(ColorEffect::BLACKWHITE, EffectRange::PERCENT, $threshold); } @@ -32,13 +31,12 @@ public static function blackWhite($threshold = null) /** * Colorizes the image. * - * @param int $level The strength of the color. (Range: 0 to 100, Server default: 100) - * @param string $color The color to use for colorization. Specify HTML name or RGB hex code. + * @param int|null $level The strength of the color. (Range: 0 to 100, Server default: 100) + * @param string|null $color The color to use for colorization. Specify HTML name or RGB hex code. * (Server default: gray) * - * @return Colorize */ - public static function colorize($level = null, $color = null) + public static function colorize(?int $level = null, ?string $color = null): Colorize { return (new Colorize(new LevelEffectQualifier(ColorEffect::COLORIZE, EffectRange::PERCENT, $level))) ->color($color); @@ -47,9 +45,8 @@ public static function colorize($level = null, $color = null) /** * Converts the image to gray-scale (multiple shades of gray). * - * @return EffectAction */ - public static function grayscale() + public static function grayscale(): EffectAction { return EffectAction::named(ColorEffect::GRAYSCALE); } @@ -57,9 +54,8 @@ public static function grayscale() /** * Negates the image colors (negative). * - * @return EffectAction */ - public static function negate() + public static function negate(): EffectAction { return EffectAction::named(ColorEffect::NEGATE); } @@ -67,11 +63,10 @@ public static function negate() /** * Changes the color scheme of the image to sepia. * - * @param int $level The level of sepia to apply. (Range: 1 to 100, Server default: 80) + * @param int|null $level The level of sepia to apply. (Range: 1 to 100, Server default: 80) * - * @return LevelEffectAction */ - public static function sepia($level = null) + public static function sepia(?int $level = null): LevelEffectAction { return EffectAction::withLevel(ColorEffect::SEPIA, EffectRange::PERCENT, $level); } @@ -82,31 +77,29 @@ public static function sepia($level = null) * * You can replace colors using the xRay() method of the \Cloudinary\Transformation\AssistColorBlind class. * - * @param int $strength The strength of the stripes. (Range: 1 to 100, Server default: 10) + * @param int|null $strength The strength of the stripes. (Range: 1 to 100, Server default: 10) * - * @return AssistColorBlind * - * @see \Cloudinary\Transformation\AssistColorBlind + * @see AssistColorBlind * */ - public static function assistColorBlind($strength = null) + public static function assistColorBlind(?int $strength = null): AssistColorBlind { return new AssistColorBlind($strength); } /** - * Simulates the way an image would appear to someone with the specified color blind condition. + * Simulates the way an image would appear to someone with the specified color-blind condition. * - * For a list of supported color blind conditions see the \Cloudinary\Transformation\SimulateColorBlind class. + * For a list of supported color-blind conditions see the \Cloudinary\Transformation\SimulateColorBlind class. * - * @param string $condition The color blind condition. Use the constants defined in the SimulateColorBlind class. + * @param string|null $condition The color-blind condition. Use the constants defined in the SimulateColorBlind class. * - * @return SimulateColorBlind * - * @see \Cloudinary\Transformation\SimulateColorBlind + * @see SimulateColorBlind * */ - public static function simulateColorBlind($condition = null) + public static function simulateColorBlind(?string $condition = null): SimulateColorBlind { return new SimulateColorBlind($condition); } diff --git a/src/Transformation/Effect/Color/SimulateColorBlind.php b/src/Transformation/Effect/Color/SimulateColorBlind.php index a904174..66f1af5 100644 --- a/src/Transformation/Effect/Color/SimulateColorBlind.php +++ b/src/Transformation/Effect/Color/SimulateColorBlind.php @@ -18,37 +18,37 @@ class SimulateColorBlind extends ValueEffectQualifier /** * Color blind condition: deuteranopia (Server default). */ - const DEUTERANOPIA = 'deuteranopia'; + public const DEUTERANOPIA = 'deuteranopia'; /** * Color blind condition: protanopia. */ - const PROTANOPIA = 'protanopia'; + public const PROTANOPIA = 'protanopia'; /** * Color blind condition: tritanopia. */ - const TRITANOPIA = 'tritanopia'; + public const TRITANOPIA = 'tritanopia'; /** * Color blind condition: tritanomaly. */ - const TRITANOMALY = 'tritanomaly'; + public const TRITANOMALY = 'tritanomaly'; /** * Color blind condition: deuteranomaly. */ - const DEUTERANOMALY = 'deuteranomaly'; + public const DEUTERANOMALY = 'deuteranomaly'; /** * Color blind condition: cone_monochromacy. */ - const CONE_MONOCHROMACY = 'cone_monochromacy'; + public const CONE_MONOCHROMACY = 'cone_monochromacy'; /** * Color blind condition: rod_monochromacy. */ - const ROD_MONOCHROMACY = 'rod_monochromacy'; + public const ROD_MONOCHROMACY = 'rod_monochromacy'; /** * SimulateColorBlind constructor. @@ -67,9 +67,8 @@ public function __construct($condition = null) * * @param string $condition The color blind condition to simulate * - * @return SimulateColorBlind */ - public function condition($condition) + public function condition(string $condition): static { $this->setEffectValue($condition); @@ -79,9 +78,8 @@ public function condition($condition) /** * Color blind condition: deuteranopia (Server default). * - * @return string */ - public static function deuteranopia() + public static function deuteranopia(): string { return self::DEUTERANOPIA; } @@ -89,9 +87,8 @@ public static function deuteranopia() /** * Color blind condition: protanopia. * - * @return string */ - public static function protanopia() + public static function protanopia(): string { return self::PROTANOPIA; } @@ -99,9 +96,8 @@ public static function protanopia() /** * Color blind condition: tritanopia * - * @return string */ - public static function tritanopia() + public static function tritanopia(): string { return self::TRITANOPIA; } @@ -109,9 +105,8 @@ public static function tritanopia() /** * Color blind condition: tritanomaly * - * @return string */ - public static function tritanomaly() + public static function tritanomaly(): string { return self::TRITANOMALY; } @@ -119,9 +114,8 @@ public static function tritanomaly() /** * Color blind condition: deuteranomaly * - * @return string */ - public static function deuteranomaly() + public static function deuteranomaly(): string { return self::DEUTERANOMALY; } @@ -129,9 +123,8 @@ public static function deuteranomaly() /** * Color blind condition: cone monochromacy * - * @return string */ - public static function coneMonochromacy() + public static function coneMonochromacy(): string { return self::CONE_MONOCHROMACY; } @@ -139,9 +132,8 @@ public static function coneMonochromacy() /** * Color blind condition: rod monochromacy * - * @return string */ - public static function rodMonochromacy() + public static function rodMonochromacy(): string { return self::ROD_MONOCHROMACY; } diff --git a/src/Transformation/Effect/DurationEffectAction.php b/src/Transformation/Effect/DurationEffectAction.php index 946d817..67d48e6 100644 --- a/src/Transformation/Effect/DurationEffectAction.php +++ b/src/Transformation/Effect/DurationEffectAction.php @@ -22,7 +22,7 @@ class DurationEffectAction extends EffectAction * * @return $this */ - public function duration($duration) + public function duration(int $duration): static { $this->qualifiers[EffectQualifier::getName()]->duration($duration); diff --git a/src/Transformation/Effect/DurationEffectQualifier.php b/src/Transformation/Effect/DurationEffectQualifier.php index 19ce419..9843898 100644 --- a/src/Transformation/Effect/DurationEffectQualifier.php +++ b/src/Transformation/Effect/DurationEffectQualifier.php @@ -22,7 +22,7 @@ class DurationEffectQualifier extends ValueEffectQualifier /** * @var bool Indicates whether to inverse the provided value. */ - protected $inverseValue = false; + protected bool $inverseValue = false; /** * DurationEffectQualifier constructor. @@ -47,13 +47,12 @@ public function __construct($name, $value = null, $inverseValue = false, ...$qua /** * Setter of the effect duration. * - * @param int $duration The duration to set. + * @param ?int $duration The duration to set. * - * @return DurationEffectQualifier * * @internal */ - public function duration($duration) + public function duration(?int $duration): static { if ($this->inverseValue && is_int($duration) && $duration > 0) { $duration = -$duration; diff --git a/src/Transformation/Effect/Effect.php b/src/Transformation/Effect/Effect.php index 9ca4b19..dda925a 100644 --- a/src/Transformation/Effect/Effect.php +++ b/src/Transformation/Effect/Effect.php @@ -35,9 +35,8 @@ abstract class Effect * @param string $name The effect name. * @param mixed ...$args Optional effect arguments. * - * @return EffectAction */ - public static function generic($name, ...$args) + public static function generic(string $name, ...$args): EffectAction { return EffectAction::named($name, ...$args); } @@ -45,11 +44,10 @@ public static function generic($name, ...$args) /** * Creates effect from an array of qualifiers. * - * @param string|array $qualifiers The effect qualifiers. + * @param array|string $qualifiers The effect qualifiers. * - * @return EffectAction */ - public static function fromParams($qualifiers) + public static function fromParams(array|string $qualifiers): EffectAction { return EffectAction::fromParams(ArrayUtils::build($qualifiers)); } diff --git a/src/Transformation/Effect/EffectAction.php b/src/Transformation/Effect/EffectAction.php index bbcdcc0..f69ee70 100644 --- a/src/Transformation/Effect/EffectAction.php +++ b/src/Transformation/Effect/EffectAction.php @@ -17,15 +17,13 @@ */ class EffectAction extends Action { - const MAIN_QUALIFIER = EffectQualifier::class; + protected const MAIN_QUALIFIER = EffectQualifier::class; use EffectActionTrait; /** * EffectAction constructor. * - * @param $effect - * @param mixed ...$args */ public function __construct($effect, ...$args) { diff --git a/src/Transformation/Effect/EffectActionTrait.php b/src/Transformation/Effect/EffectActionTrait.php index 6ef9088..264ba16 100644 --- a/src/Transformation/Effect/EffectActionTrait.php +++ b/src/Transformation/Effect/EffectActionTrait.php @@ -19,136 +19,99 @@ */ trait EffectActionTrait { - /** - * @param $name - * @param mixed ...$args - * - * @return EffectAction - */ - public static function named($name, ...$args) + public static function named($name, ...$args): EffectAction { return static::fromEffectQualifier(new EffectQualifier($name, ...$args)); } /** - * @param string $effectName - * @param mixed $value - * @param mixed ...$args + * @param mixed|null $value * - * @return EffectAction */ - public static function valued($effectName, $value = null, ...$args) + public static function valued(string $effectName, mixed $value = null, ...$args): EffectAction { return static::fromEffectQualifier(new ValueEffectQualifier($effectName, $value, ...$args)); } /** - * @param string $effectName - * @param array $range - * @param mixed $value - * @param mixed ...$args + * @param mixed|null $value * - * @return EffectAction */ - public static function limited($effectName, $range, $value = null, ...$args) + public static function limited(string $effectName, array $range, mixed $value = null, ...$args): EffectAction { return static::fromEffectQualifier(new LimitedEffectQualifier($effectName, $range, $value, ...$args)); } /** - * @param string $effectName - * @param array $range - * @param mixed $value - * @param mixed ...$args + * @param mixed|null $value * - * @return LevelEffectAction */ - public static function withLevel($effectName, $range, $value = null, ...$args) + public static function withLevel(string $effectName, array $range, mixed $value = null, ...$args): LevelEffectAction { return new LevelEffectAction(new LevelEffectQualifier($effectName, $range, $value, ...$args)); } /** - * @param string $effectName - * @param array $range - * @param mixed $value - * @param mixed ...$args + * @param mixed|null $value * - * @return StrengthEffectAction */ - public static function withStrength($effectName, $range, $value = null, ...$args) - { + public static function withStrength( + string $effectName, + array $range, + mixed $value = null, + ...$args + ): StrengthEffectAction { return new StrengthEffectAction(new StrengthEffectQualifier($effectName, $range, $value, ...$args)); } /** - * @param string $effectName - * @param array $range - * @param mixed $value - * @param mixed ...$args + * @param mixed|null $value * - * @return BlendEffectAction */ - public static function withBlend($effectName, $range, $value = null, ...$args) + public static function withBlend(string $effectName, array $range, mixed $value = null, ...$args): BlendEffectAction { return new BlendEffectAction(new BlendEffectQualifier($effectName, $range, $value, ...$args)); } /** - * @param string $effectName - * @param array $range - * @param mixed $value - * @param mixed ...$args + * @param mixed|null $value * - * @return ThresholdEffectAction */ - public static function withThreshold($effectName, $range, $value = null, ...$args) - { + public static function withThreshold( + string $effectName, + array $range, + mixed $value = null, + ...$args + ): ThresholdEffectAction { return new ThresholdEffectAction(new ThresholdEffectQualifier($effectName, $range, $value, ...$args)); } /** - * @param string $effectName - * @param mixed $value - * @param mixed ...$args + * @param mixed|null $value * - * @return DurationEffectAction */ - public static function withDuration($effectName, $value = null, ...$args) + public static function withDuration(string $effectName, mixed $value = null, ...$args): DurationEffectAction { return new DurationEffectAction(new DurationEffectQualifier($effectName, $value, ...$args)); } /** - * @param string $effectName - * @param array $value - * @param mixed ...$args + * @param array|null $value Effect value. * - * @return ToleranceEffectAction */ - public static function withTolerance($effectName, $value = null, ...$args) + public static function withTolerance(string $effectName, ?array $value = null, ...$args): ToleranceEffectAction { return new ToleranceEffectAction(new ToleranceEffectQualifier($effectName, $value, ...$args)); } - /** - * @param array $qualifiers - * - * @return EffectAction - */ - public static function fromParams(array $qualifiers) + public static function fromParams(array $qualifiers): EffectAction { $effectName = ArrayUtils::pop($qualifiers, 0); return static::fromEffectQualifier(new EffectQualifier($effectName, ...$qualifiers)); } - /** - * @param EffectQualifier $effectQualifier - * - * @return EffectAction - */ - public static function fromEffectQualifier(EffectQualifier $effectQualifier) + public static function fromEffectQualifier(EffectQualifier $effectQualifier): EffectAction { return new EffectAction($effectQualifier); } diff --git a/src/Transformation/Effect/EffectQualifier.php b/src/Transformation/Effect/EffectQualifier.php index 7775027..5f0bb13 100644 --- a/src/Transformation/Effect/EffectQualifier.php +++ b/src/Transformation/Effect/EffectQualifier.php @@ -21,12 +21,12 @@ class EffectQualifier extends BaseExpressionQualifier /** * @var string $key Serialization key, force it here for derived classes usage */ - protected static $key = 'e'; + protected static string $key = 'e'; /** * @var string $name Serialization name, force it here for derived classes usage */ - protected static $name = 'effect'; + protected static string $name = 'effect'; /** * EffectQualifier constructor. @@ -44,9 +44,8 @@ public function __construct($effectName, ...$values) * * @param string|EffectName $effectName The effect name. * - * @return EffectQualifier */ - public function setEffectName($effectName) + public function setEffectName(EffectName|string $effectName): static { $this->getValue()->setSimpleValue(0, ClassUtils::verifyInstance($effectName, EffectName::class)); diff --git a/src/Transformation/Effect/EffectQualifierTrait.php b/src/Transformation/Effect/EffectQualifierTrait.php index 3918d9a..3af202b 100644 --- a/src/Transformation/Effect/EffectQualifierTrait.php +++ b/src/Transformation/Effect/EffectQualifierTrait.php @@ -23,9 +23,8 @@ trait EffectQualifierTrait * @param string $effectName The name of the effect. * @param mixed ...$values The effect values. * - * @return EffectQualifier */ - public static function effect($effectName, ...$values) + public static function effect(string $effectName, ...$values): EffectQualifier { return new EffectQualifier($effectName, ...$values); } diff --git a/src/Transformation/Effect/Generative/DetectMultipleTrait.php b/src/Transformation/Effect/Generative/DetectMultipleTrait.php index 4f77b92..ab2a796 100644 --- a/src/Transformation/Effect/Generative/DetectMultipleTrait.php +++ b/src/Transformation/Effect/Generative/DetectMultipleTrait.php @@ -14,11 +14,11 @@ trait DetectMultipleTrait * * When used with multiple prompts, it’s always true even if not explicitly set. * - * @param bool $detectMultiple Whether to detect multiple objects. + * @param ?bool $detectMultiple Whether to detect multiple objects. * * @return $this */ - public function detectMultiple($detectMultiple = true) + public function detectMultiple(?bool $detectMultiple = true): static { $this->getMainQualifier()->getPropertiesValue()->setSimpleNamedValue( GenerativeEffectAction::MULTIPLE, diff --git a/src/Transformation/Effect/Generative/GenerativeEffect.php b/src/Transformation/Effect/Generative/GenerativeEffect.php index 3a7d4a4..ec74334 100644 --- a/src/Transformation/Effect/Generative/GenerativeEffect.php +++ b/src/Transformation/Effect/Generative/GenerativeEffect.php @@ -15,12 +15,12 @@ */ abstract class GenerativeEffect { - const GENERATIVE_RECOLOR = 'gen_recolor'; - const GENERATIVE_REMOVE = 'gen_remove'; - const GENERATIVE_REPLACE = 'gen_replace'; - const GENERATIVE_RESTORE = 'gen_restore'; - const UPSCALE = 'upscale'; - const ENHANCE = 'enhance'; + public const GENERATIVE_RECOLOR = 'gen_recolor'; + public const GENERATIVE_REMOVE = 'gen_remove'; + public const GENERATIVE_REPLACE = 'gen_replace'; + public const GENERATIVE_RESTORE = 'gen_restore'; + public const UPSCALE = 'upscale'; + public const ENHANCE = 'enhance'; use GenerativeEffectTrait; } diff --git a/src/Transformation/Effect/Generative/GenerativeEffectAction.php b/src/Transformation/Effect/Generative/GenerativeEffectAction.php index 8d44642..8c9e5cf 100644 --- a/src/Transformation/Effect/Generative/GenerativeEffectAction.php +++ b/src/Transformation/Effect/Generative/GenerativeEffectAction.php @@ -15,8 +15,8 @@ */ class GenerativeEffectAction extends EffectAction { - const MAIN_QUALIFIER = ListEffectQualifier::class; + protected const MAIN_QUALIFIER = ListEffectQualifier::class; - const MULTIPLE = 'multiple'; - const PROMPT = 'prompt'; + protected const MULTIPLE = 'multiple'; + public const PROMPT = 'prompt'; } diff --git a/src/Transformation/Effect/Generative/GenerativeEffectTrait.php b/src/Transformation/Effect/Generative/GenerativeEffectTrait.php index 0125376..c018fe2 100644 --- a/src/Transformation/Effect/Generative/GenerativeEffectTrait.php +++ b/src/Transformation/Effect/Generative/GenerativeEffectTrait.php @@ -20,9 +20,8 @@ trait GenerativeEffectTrait /** * Applies a generative restore effect to the asset. * - * @return GenerativeEffectAction */ - public static function generativeRestore() + public static function generativeRestore(): GenerativeEffectAction { return new GenerativeEffectAction(GenerativeEffect::GENERATIVE_RESTORE); } @@ -30,48 +29,52 @@ public static function generativeRestore() /** * Applies a generative recolor effect to the asset. * - * @param string|array $prompt Use natural language to describe what you want to affect in the image. + * @param array|string $prompt Use natural language to describe what you want to affect in the image. * @param string $toColor The target color. - * @param bool $detectMultiple Whether to recolor all instances of the prompt in the image. + * @param bool|null $detectMultiple Whether to recolor all instances of the prompt in the image. * - * @return GenerativeRecolor */ - public static function generativeRecolor($prompt, $toColor, $detectMultiple = null) - { + public static function generativeRecolor( + array|string $prompt, + string $toColor, + ?bool $detectMultiple = null + ): GenerativeRecolor { return new GenerativeRecolor($prompt, $toColor, $detectMultiple); } /** * Applies a generative remove effect to the asset. * - * @param string|array $prompt Use natural language to describe what you want to affect in the image. - * @param string|array $region Remove items from the specified region(s). - * @param bool $detectMultiple Whether to detect all instances of the prompt in the image. - * @param bool $removeShadow Whether to remove shadows and reflections. + * @param array|string|null $prompt Use natural language to describe what you want to affect in the image. + * @param array|string|null $region Remove items from the specified region(s). + * @param bool|null $detectMultiple Whether to detect all instances of the prompt in the image. + * @param bool|null $removeShadow Whether to remove shadows and reflections. * - * @return GenerativeRemove */ public static function generativeRemove( - $prompt = null, - $region = null, - $detectMultiple = null, - $removeShadow = null - ) { + array|string|null $prompt = null, + array|string|null $region = null, + ?bool $detectMultiple = null, + ?bool $removeShadow = null + ): GenerativeRemove { return new GenerativeRemove($prompt, $region, $detectMultiple, $removeShadow); } /** * Applies a generative replacement effect to the asset. * - * @param string $fromPrompt Use natural language to describe what you want to replace. - * @param string $toPrompt Use natural language to describe the replacement. - * @param bool $preserveGeometry Whether to maintain the shape of the object you're replacing. - * @param bool $detectMultiple Whether to detect all instances of the prompt in the image. + * @param string $fromPrompt Use natural language to describe what you want to replace. + * @param string $toPrompt Use natural language to describe the replacement. + * @param bool|null $preserveGeometry Whether to maintain the shape of the object you're replacing. + * @param bool|null $detectMultiple Whether to detect all instances of the prompt in the image. * - * @return GenerativeReplace */ - public static function generativeReplace($fromPrompt, $toPrompt, $preserveGeometry = null, $detectMultiple = null) - { + public static function generativeReplace( + string $fromPrompt, + string $toPrompt, + ?bool $preserveGeometry = null, + ?bool $detectMultiple = null + ): GenerativeReplace { return new GenerativeReplace($fromPrompt, $toPrompt, $preserveGeometry, $detectMultiple); } @@ -79,9 +82,8 @@ public static function generativeReplace($fromPrompt, $toPrompt, $preserveGeomet * Uses AI-based prediction to add fine detail while upscaling small images. * This 'super-resolution' feature scales each dimension by four, multiplying the total number of pixels by 16. * - * @return GenerativeEffectAction */ - public static function upscale() + public static function upscale(): GenerativeEffectAction { return new GenerativeEffectAction(GenerativeEffect::UPSCALE); } @@ -89,9 +91,8 @@ public static function upscale() /** * Uses AI to analyze an image and make adjustments to enhance the appeal of the image. * - * @return GenerativeEffectAction */ - public static function enhance() + public static function enhance(): GenerativeEffectAction { return new GenerativeEffectAction(GenerativeEffect::ENHANCE); } diff --git a/src/Transformation/Effect/Generative/GenerativeRecolor.php b/src/Transformation/Effect/Generative/GenerativeRecolor.php index 5ea61bd..55d11ae 100644 --- a/src/Transformation/Effect/Generative/GenerativeRecolor.php +++ b/src/Transformation/Effect/Generative/GenerativeRecolor.php @@ -21,17 +21,16 @@ class GenerativeRecolor extends GenerativeEffectAction use PromptTrait; use DetectMultipleTrait; - const TO_COLOR = 'to-color'; + protected const TO_COLOR = 'to-color'; /** * GenerativeRecolor constructor. * * @param string|array $prompt Use natural language to describe what you want to affect in the image. * @param string $toColor The target color. - * @param bool $detectMultiple Whether to detect all instances of the prompt in the image. - * @param mixed ...$args + * @param bool|null $detectMultiple Whether to detect all instances of the prompt in the image. */ - public function __construct($prompt, $toColor, $detectMultiple = null, ...$args) + public function __construct($prompt, $toColor, ?bool $detectMultiple = null, ...$args) { parent::__construct(GenerativeEffect::GENERATIVE_RECOLOR, ...$args); @@ -47,7 +46,7 @@ public function __construct($prompt, $toColor, $detectMultiple = null, ...$args) * * @return $this */ - public function toColor($toColor) + public function toColor(ColorValue|string $toColor): static { $this->getMainQualifier()->getPropertiesValue()->setSimpleNamedValue( self::TO_COLOR, diff --git a/src/Transformation/Effect/Generative/GenerativeRemove.php b/src/Transformation/Effect/Generative/GenerativeRemove.php index 1386f2c..c73c0d6 100644 --- a/src/Transformation/Effect/Generative/GenerativeRemove.php +++ b/src/Transformation/Effect/Generative/GenerativeRemove.php @@ -11,8 +11,6 @@ namespace Cloudinary\Transformation; use Cloudinary\ArrayUtils; -use Cloudinary\StringUtils; -use Cloudinary\Transformation\Argument\ColorValue; use Cloudinary\TransformationUtils; /** @@ -23,20 +21,24 @@ class GenerativeRemove extends GenerativeEffectAction use PromptTrait; use DetectMultipleTrait; - const REGION = 'region'; - const REMOVE_SHADOW = 'remove-shadow'; + protected const REGION = 'region'; + protected const REMOVE_SHADOW = 'remove-shadow'; /** * GenerativeRemove constructor. * * @param string|array $prompt Use natural language to describe what you want to affect in the image. * @param string|array $region Remove items from the specified region(s). - * @param bool $detectMultiple Whether to detect all instances of the prompt in the image. - * @param bool $removeShadow Whether to remove shadows and reflections. - * @param mixed ...$args + * @param bool|null $detectMultiple Whether to detect all instances of the prompt in the image. + * @param bool|null $removeShadow Whether to remove shadows and reflections. */ - public function __construct($prompt = null, $region = null, $detectMultiple = null, $removeShadow = null, ...$args) - { + public function __construct( + $prompt = null, + $region = null, + ?bool $detectMultiple = null, + ?bool $removeShadow = null, + ...$args + ) { parent::__construct(GenerativeEffect::GENERATIVE_REMOVE, ...$args); $this->prompt($prompt); @@ -52,7 +54,7 @@ public function __construct($prompt = null, $region = null, $detectMultiple = nu * * @return $this */ - public function region(...$region) + public function region(...$region): static { $this->getMainQualifier()->getPropertiesValue()->setSimpleNamedValue( self::REGION, @@ -67,11 +69,11 @@ public function region(...$region) /** * Whether to remove the shadow in addition to the object(s). * - * @param bool $removeShadow Whether to remove shadow. + * @param ?bool $removeShadow Whether to remove shadow. * * @return $this */ - public function removeShadow($removeShadow = true) + public function removeShadow(?bool $removeShadow = true): static { $this->getMainQualifier()->getPropertiesValue()->setSimpleNamedValue( self::REMOVE_SHADOW, diff --git a/src/Transformation/Effect/Generative/GenerativeReplace.php b/src/Transformation/Effect/Generative/GenerativeReplace.php index 759ad69..2df4807 100644 --- a/src/Transformation/Effect/Generative/GenerativeReplace.php +++ b/src/Transformation/Effect/Generative/GenerativeReplace.php @@ -17,9 +17,9 @@ */ class GenerativeReplace extends GenerativeEffectAction { - const FROM_PROMPT = 'from'; - const TO_PROMPT = 'to'; - const PRESERVE_GEOMETRY = 'preserve-geometry'; + protected const FROM_PROMPT = 'from'; + protected const TO_PROMPT = 'to'; + protected const PRESERVE_GEOMETRY = 'preserve-geometry'; use DetectMultipleTrait; @@ -27,14 +27,18 @@ class GenerativeReplace extends GenerativeEffectAction /** * GenerativeReplace constructor. * - * @param string $fromPrompt Use natural language to describe what you want to replace. - * @param string $toPrompt Use natural language to describe the replacement. - * @param bool $preserveGeometry Whether to maintain the shape of the object you're replacing. - * @param bool $detectMultiple Whether to detect all instances of the prompt in the image. - * @param mixed ...$args + * @param string $fromPrompt Use natural language to describe what you want to replace. + * @param string $toPrompt Use natural language to describe the replacement. + * @param bool|null $preserveGeometry Whether to maintain the shape of the object you're replacing. + * @param bool|null $detectMultiple Whether to detect all instances of the prompt in the image. */ - public function __construct($fromPrompt, $toPrompt, $preserveGeometry = null, $detectMultiple = null, ...$args) - { + public function __construct( + string $fromPrompt, + string $toPrompt, + ?bool $preserveGeometry = null, + ?bool $detectMultiple = null, + ...$args + ) { parent::__construct(GenerativeEffect::GENERATIVE_REPLACE, ...$args); $this->fromPrompt($fromPrompt); @@ -50,7 +54,7 @@ public function __construct($fromPrompt, $toPrompt, $preserveGeometry = null, $d * * @return $this */ - public function fromPrompt($fromPrompt) + public function fromPrompt(string $fromPrompt): static { $this->getMainQualifier()->getPropertiesValue()->setSimpleNamedValue( self::FROM_PROMPT, @@ -67,7 +71,7 @@ public function fromPrompt($fromPrompt) * * @return $this */ - public function toPrompt($toPrompt) + public function toPrompt(string $toPrompt): static { $this->getMainQualifier()->getPropertiesValue()->setSimpleNamedValue( self::TO_PROMPT, @@ -80,11 +84,11 @@ public function toPrompt($toPrompt) /** * Preserve geometry. * - * @param bool $preserveGeometry Whether to maintain the shape of the object you're replacing. + * @param ?bool $preserveGeometry Whether to maintain the shape of the object you're replacing. * * @return $this */ - public function preserveGeometry($preserveGeometry = true) + public function preserveGeometry(?bool $preserveGeometry = true): static { $this->getMainQualifier()->getPropertiesValue()->setSimpleNamedValue( self::PRESERVE_GEOMETRY, diff --git a/src/Transformation/Effect/Generative/PromptTrait.php b/src/Transformation/Effect/Generative/PromptTrait.php index 249c485..63479ce 100644 --- a/src/Transformation/Effect/Generative/PromptTrait.php +++ b/src/Transformation/Effect/Generative/PromptTrait.php @@ -3,7 +3,6 @@ namespace Cloudinary\Transformation; use Cloudinary\ArrayUtils; -use Cloudinary\TransformationUtils; /** * Trait DetectMultipleTrait @@ -13,11 +12,11 @@ trait PromptTrait /** * Use natural language to describe what you want to affect in the image. * - * @param string|array $prompt A list of prompts. + * @param array|string|null $prompt A list of prompts. * * @return $this */ - public function prompt($prompt) + public function prompt(array|string|null $prompt): static { $this->getMainQualifier()->getPropertiesValue()->setSimpleNamedValue( GenerativeEffectAction::PROMPT, diff --git a/src/Transformation/Effect/LevelEffectAction.php b/src/Transformation/Effect/LevelEffectAction.php index a076268..b6a8f14 100644 --- a/src/Transformation/Effect/LevelEffectAction.php +++ b/src/Transformation/Effect/LevelEffectAction.php @@ -22,7 +22,7 @@ class LevelEffectAction extends EffectAction * * @return $this */ - public function level($level) + public function level(int $level): static { $this->qualifiers[EffectQualifier::getName()]->level($level); diff --git a/src/Transformation/Effect/LevelEffectQualifier.php b/src/Transformation/Effect/LevelEffectQualifier.php index a517597..98d5471 100644 --- a/src/Transformation/Effect/LevelEffectQualifier.php +++ b/src/Transformation/Effect/LevelEffectQualifier.php @@ -24,11 +24,10 @@ class LevelEffectQualifier extends LimitedEffectQualifier * * @param int $level The level to set. * - * @return LimitedEffectQualifier * * @internal */ - public function level($level) + public function level(int $level): LimitedEffectQualifier { $this->setEffectValue($level); diff --git a/src/Transformation/Effect/LimitedEffectQualifier.php b/src/Transformation/Effect/LimitedEffectQualifier.php index 89272c8..6add5e3 100644 --- a/src/Transformation/Effect/LimitedEffectQualifier.php +++ b/src/Transformation/Effect/LimitedEffectQualifier.php @@ -24,7 +24,7 @@ class LimitedEffectQualifier extends ValueEffectQualifier /** * @var array $range The validation range. */ - protected $range; + protected array $range; /** * LimitedEffectQualifier constructor. @@ -53,7 +53,7 @@ public function __construct($effectName, $range, $level = null, ...$args) * * @internal */ - public function setValidRange($range) + public function setValidRange(array $range): static { $this->range = $range; @@ -65,11 +65,10 @@ public function setValidRange($range) * * @param mixed $value The value to set. * - * @return LimitedEffectQualifier * * @internal */ - public function setEffectValue($value) + public function setEffectValue(mixed $value): static { if (is_numeric($value) && ! empty($this->range) && ($value < $this->range[0] || $value > $this->range[1])) { throw new OutOfRangeException("Value must be in range: [{$this->range[0]}, {$this->range[1]}]"); diff --git a/src/Transformation/Effect/ListEffectQualifier.php b/src/Transformation/Effect/ListEffectQualifier.php index b23af1d..aca6c4a 100644 --- a/src/Transformation/Effect/ListEffectQualifier.php +++ b/src/Transformation/Effect/ListEffectQualifier.php @@ -19,9 +19,9 @@ class ListEffectQualifier extends EffectQualifier /** * @var string VALUE_CLASS The class of the qualifier value. Can be customized by derived classes. */ - const VALUE_CLASS = QualifierMultiValue::class; + protected const VALUE_CLASS = QualifierMultiValue::class; - const PROPERTIES = 'properties'; + protected const PROPERTIES = 'properties'; /** * ListEffectQualifier constructor. @@ -36,10 +36,7 @@ public function __construct($effectName, ...$values) $this->getValue()->setSimpleValue(self::PROPERTIES, new ListQualifierMultiValue(...$values)); } - /** - * @return mixed - */ - public function getPropertiesValue() + public function getPropertiesValue(): mixed { return parent::getValue()->getSimpleValue(self::PROPERTIES); } diff --git a/src/Transformation/Effect/Misc/ArtisticFilter.php b/src/Transformation/Effect/Misc/ArtisticFilter.php index dd99f8e..d6dd4b7 100644 --- a/src/Transformation/Effect/Misc/ArtisticFilter.php +++ b/src/Transformation/Effect/Misc/ArtisticFilter.php @@ -15,27 +15,27 @@ */ class ArtisticFilter extends ValueEffectQualifier { - const AL_DENTE = 'al_dente'; - const ATHENA = 'athena'; - const AUDREY = 'audrey'; - const AURORA = 'aurora'; - const DAGUERRE = 'daguerre'; - const EUCALYPTUS = 'eucalyptus'; - const FES = 'fes'; - const FROST = 'frost'; - const HAIRSPRAY = 'hairspray'; - const HOKUSAI = 'hokusai'; - const INCOGNITO = 'incognito'; - const LINEN = 'linen'; - const PEACOCK = 'peacock'; - const PRIMAVERA = 'primavera'; - const QUARTZ = 'quartz'; - const RED_ROCK = 'red_rock'; - const REFRESH = 'refresh'; - const SIZZLE = 'sizzle'; - const SONNET = 'sonnet'; - const UKULELE = 'ukulele'; - const ZORRO = 'zorro'; + public const AL_DENTE = 'al_dente'; + public const ATHENA = 'athena'; + public const AUDREY = 'audrey'; + public const AURORA = 'aurora'; + public const DAGUERRE = 'daguerre'; + public const EUCALYPTUS = 'eucalyptus'; + public const FES = 'fes'; + public const FROST = 'frost'; + public const HAIRSPRAY = 'hairspray'; + public const HOKUSAI = 'hokusai'; + public const INCOGNITO = 'incognito'; + public const LINEN = 'linen'; + public const PEACOCK = 'peacock'; + public const PRIMAVERA = 'primavera'; + public const QUARTZ = 'quartz'; + public const RED_ROCK = 'red_rock'; + public const REFRESH = 'refresh'; + public const SIZZLE = 'sizzle'; + public const SONNET = 'sonnet'; + public const UKULELE = 'ukulele'; + public const ZORRO = 'zorro'; /** * ArtisticFilter constructor. @@ -50,9 +50,8 @@ public function __construct($filter = null) /** * Artistic Filter alDente. * - * @return ArtisticFilter */ - public static function alDente() + public static function alDente(): ArtisticFilter { return new static(self::AL_DENTE); } @@ -60,9 +59,8 @@ public static function alDente() /** * Artistic filter athena. * - * @return ArtisticFilter */ - public static function athena() + public static function athena(): ArtisticFilter { return new static(self::ATHENA); } @@ -70,9 +68,8 @@ public static function athena() /** * Artistic filter audrey. * - * @return ArtisticFilter */ - public static function audrey() + public static function audrey(): ArtisticFilter { return new static(self::AUDREY); } @@ -80,9 +77,8 @@ public static function audrey() /** * Artistic filter aurora. * - * @return ArtisticFilter */ - public static function aurora() + public static function aurora(): ArtisticFilter { return new static(self::AURORA); } @@ -90,9 +86,8 @@ public static function aurora() /** * Artistic filter daguerre. * - * @return ArtisticFilter */ - public static function daguerre() + public static function daguerre(): ArtisticFilter { return new static(self::DAGUERRE); } @@ -100,9 +95,8 @@ public static function daguerre() /** * Artistic filter eucalyptus. * - * @return ArtisticFilter */ - public static function eucalyptus() + public static function eucalyptus(): ArtisticFilter { return new static(self::EUCALYPTUS); } @@ -110,9 +104,8 @@ public static function eucalyptus() /** * Artistic filter fes. * - * @return ArtisticFilter */ - public static function fes() + public static function fes(): ArtisticFilter { return new static(self::FES); } @@ -120,9 +113,8 @@ public static function fes() /** * Artistic filter frost. * - * @return ArtisticFilter */ - public static function frost() + public static function frost(): ArtisticFilter { return new static(self::FROST); } @@ -130,9 +122,8 @@ public static function frost() /** * Artistic filter hairspray. * - * @return ArtisticFilter */ - public static function hairspray() + public static function hairspray(): ArtisticFilter { return new static(self::HAIRSPRAY); } @@ -140,9 +131,8 @@ public static function hairspray() /** * Artistic filter hokusai. * - * @return ArtisticFilter */ - public static function hokusai() + public static function hokusai(): ArtisticFilter { return new static(self::HOKUSAI); } @@ -150,9 +140,8 @@ public static function hokusai() /** * Artistic filter incognito. * - * @return ArtisticFilter */ - public static function incognito() + public static function incognito(): ArtisticFilter { return new static(self::INCOGNITO); } @@ -160,9 +149,8 @@ public static function incognito() /** * Artistic filter linen. * - * @return ArtisticFilter */ - public static function linen() + public static function linen(): ArtisticFilter { return new static(self::LINEN); } @@ -170,9 +158,8 @@ public static function linen() /** * Artistic filter peacock. * - * @return ArtisticFilter */ - public static function peacock() + public static function peacock(): ArtisticFilter { return new static(self::PEACOCK); } @@ -180,9 +167,8 @@ public static function peacock() /** * Artistic filter primavera. * - * @return ArtisticFilter */ - public static function primavera() + public static function primavera(): ArtisticFilter { return new static(self::PRIMAVERA); } @@ -190,9 +176,8 @@ public static function primavera() /** * Artistic filter quartz. * - * @return ArtisticFilter */ - public static function quartz() + public static function quartz(): ArtisticFilter { return new static(self::QUARTZ); } @@ -200,9 +185,8 @@ public static function quartz() /** * Artistic filter redRock. * - * @return ArtisticFilter */ - public static function redRock() + public static function redRock(): ArtisticFilter { return new static(self::RED_ROCK); } @@ -210,9 +194,8 @@ public static function redRock() /** * Artistic filter refresh. * - * @return ArtisticFilter */ - public static function refresh() + public static function refresh(): ArtisticFilter { return new static(self::REFRESH); } @@ -220,9 +203,8 @@ public static function refresh() /** * Artistic filter sizzle. * - * @return ArtisticFilter */ - public static function sizzle() + public static function sizzle(): ArtisticFilter { return new static(self::SIZZLE); } @@ -230,9 +212,8 @@ public static function sizzle() /** * Artistic filter sonnet. * - * @return ArtisticFilter */ - public static function sonnet() + public static function sonnet(): ArtisticFilter { return new static(self::SONNET); } @@ -240,9 +221,8 @@ public static function sonnet() /** * Artistic filter ukulele. * - * @return ArtisticFilter */ - public static function ukulele() + public static function ukulele(): ArtisticFilter { return new static(self::UKULELE); } @@ -250,9 +230,8 @@ public static function ukulele() /** * Artistic filter zorro. * - * @return ArtisticFilter */ - public static function zorro() + public static function zorro(): ArtisticFilter { return new static(self::ZORRO); } diff --git a/src/Transformation/Effect/Misc/Cartoonify.php b/src/Transformation/Effect/Misc/Cartoonify.php index afdb819..479da4d 100644 --- a/src/Transformation/Effect/Misc/Cartoonify.php +++ b/src/Transformation/Effect/Misc/Cartoonify.php @@ -13,29 +13,32 @@ /** * Class Cartoonify * - * @see \Cloudinary\Transformation\MiscEffectTrait::cartoonify() + * @see MiscEffectTrait::cartoonify */ class Cartoonify extends LimitedEffectQualifier { /** * @var array $valueOrder The order of the values. */ - protected $valueOrder = [0, 'line_strength', 'color_reduction']; + protected array $valueOrder = [0, 'line_strength', 'color_reduction']; /** * Use for $colorReduction to achieve a black and white cartoon effect. */ - const BLACK_WHITE = 'bw'; + public const BLACK_WHITE = 'bw'; /** * Trim constructor. * - * @param float $lineStrength - * @param float|string $colorReduction - * @param array $args + * @param float|int|string|null $lineStrength + * @param float|int|string|null $colorReduction + * @param array $args */ - public function __construct($lineStrength = null, $colorReduction = null, ...$args) - { + public function __construct( + float|int|string|null $lineStrength = null, + float|int|string|null $colorReduction = null, + ...$args + ) { parent::__construct(MiscEffect::CARTOONIFY, EffectRange::PERCENT, ...$args); $this->lineStrength($lineStrength); @@ -45,11 +48,10 @@ public function __construct($lineStrength = null, $colorReduction = null, ...$ar /** * Sets the thickness of the lines. * - * @param float $lineStrength The thickness of the lines. (Range: 0 to 100, Server default: 50) + * @param float|int|string|null $lineStrength The thickness of the lines. (Range: 0 to 100, Server default: 50) * - * @return Cartoonify */ - public function lineStrength($lineStrength) + public function lineStrength(float|int|string|null $lineStrength): static { $this->value->setSimpleValue('line_strength', $lineStrength); @@ -59,14 +61,13 @@ public function lineStrength($lineStrength) /** * Sets the decrease in the number of colors and corresponding saturation boost of the remaining colors. * - * @param float|string $colorReduction The decrease in the number of colors and corresponding saturation boost of - * the remaining colors. (Range: 0 to 100). Higher reduction values - * result in a less realistic look. Set $colorReduction to - * Cartoonify::BLACK_WHITE for a black and white cartoon effect. + * @param float|int|string|null $colorReduction The decrease in the number of colors and corresponding saturation + * boost of the remaining colors. (Range: 0 to 100). Higher reduction + * values result in a less realistic look. Set $colorReduction to + * Cartoonify::BLACK_WHITE for a black and white cartoon effect. * - * @return Cartoonify */ - public function colorReductionLevel($colorReduction) + public function colorReductionLevel(float|int|string|null $colorReduction): static { $this->value->setSimpleValue('color_reduction', $colorReduction); @@ -76,9 +77,8 @@ public function colorReductionLevel($colorReduction) /** * Creates a black and white cartoon effect. * - * @return Cartoonify */ - public function blackWhite() + public function blackWhite(): static { return $this->colorReductionLevel(self::BLACK_WHITE); } diff --git a/src/Transformation/Effect/Misc/DropShadow.php b/src/Transformation/Effect/Misc/DropShadow.php index 1050d7b..561a08b 100644 --- a/src/Transformation/Effect/Misc/DropShadow.php +++ b/src/Transformation/Effect/Misc/DropShadow.php @@ -18,23 +18,23 @@ class DropShadow extends EffectAction /** * DropShadow constructor. * - * @param int $azimuth Value in range 0 - 360 (degrees). - * @param int $elevation Value in range 0 - 90 (degrees). - * @param int $spread Value in range 0 -100. + * @param int|null $azimuth Value in range 0 - 360 (degrees). + * @param int|null $elevation Value in range 0 - 90 (degrees). + * @param int|null $spread Value in range 0 -100. */ - public function __construct($azimuth = null, $elevation = null, $spread = null) + public function __construct(?int $azimuth = null, ?int$elevation = null, ?int $spread = null) { parent::__construct(new DropShadowQualifier($azimuth, $elevation, $spread)); } /** - * Sets the direction the light is coming from to cause the shadow effect. + * Sets the direction the light is coming from to cause the shadow effect. * - * @param int $azimuth Value in range 0 - 360 (degrees). + * @param ?int $azimuth Value in range 0 - 360 (degrees). * * @return $this */ - public function azimuth($azimuth) + public function azimuth(?int $azimuth): static { $this->getMainQualifier()->azimuth($azimuth); @@ -44,11 +44,11 @@ public function azimuth($azimuth) /** * Sets the height of the light source above the 'ground' to cause the shadow effect. * - * @param int $elevation Value in range 0 - 90 (degrees). + * @param ?int $elevation Value in range 0 - 90 (degrees). * * @return $this */ - public function elevation($elevation) + public function elevation(?int $elevation): static { $this->getMainQualifier()->elevation($elevation); @@ -56,13 +56,13 @@ public function elevation($elevation) } /** - * Sets the spread of the light source. A small number means 'point' light. A larger number means 'area' light. + * Sets the spread of the light source. A small number means 'point' light. A larger number means 'area' light. * - * @param int $spread Value in range 0 -100. + * @param ?int $spread Value in range 0 -100. * * @return $this */ - public function spread($spread) + public function spread(?int $spread): static { $this->getMainQualifier()->spread($spread); diff --git a/src/Transformation/Effect/Misc/DropShadowQualifier.php b/src/Transformation/Effect/Misc/DropShadowQualifier.php index 7f29fc2..324cdd8 100644 --- a/src/Transformation/Effect/Misc/DropShadowQualifier.php +++ b/src/Transformation/Effect/Misc/DropShadowQualifier.php @@ -18,11 +18,11 @@ class DropShadowQualifier extends EffectQualifier /** * DropShadowQualifier constructor. * - * @param int $azimuth Value in range 0 - 360 (degrees). - * @param int $elevation Value in range 0 - 90 (degrees). - * @param int $spread Value in range 0 -100. + * @param int|null $azimuth Value in range 0 - 360 (degrees). + * @param int|null $elevation Value in range 0 - 90 (degrees). + * @param int|null $spread Value in range 0 -100. */ - public function __construct($azimuth = null, $elevation = null, $spread = null) + public function __construct(?int $azimuth = null, ?int $elevation = null, ?int $spread = null) { parent::__construct(MiscEffect::DROP_SHADOW); @@ -34,13 +34,13 @@ public function __construct($azimuth = null, $elevation = null, $spread = null) } /** - * Sets the direction the light is coming from to cause the shadow effect. + * Sets the direction the light is coming from to cause the shadow effect. * - * @param int $azimuth Value in range 0 - 360 (degrees). + * @param ?int $azimuth Value in range 0 - 360 (degrees). * * @return $this */ - public function azimuth($azimuth) + public function azimuth(?int $azimuth): static { $this->value->getSimpleValue('properties')->setSimpleNamedValue('azimuth', $azimuth); @@ -50,11 +50,11 @@ public function azimuth($azimuth) /** * Sets the height of the light source above the 'ground' to cause the shadow effect. * - * @param int $elevation Value in range 0 - 90 (degrees). + * @param ?int $elevation Value in range 0 - 90 (degrees). * * @return $this */ - public function elevation($elevation) + public function elevation(?int $elevation): static { $this->value->getSimpleValue('properties')->setSimpleNamedValue('elevation', $elevation); @@ -62,13 +62,13 @@ public function elevation($elevation) } /** - * Sets the spread of the light source. A small number means 'point' light. A larger number means 'area' light. + * Sets the spread of the light source. A smaller number means 'point' light. A larger number means 'area' light. * - * @param int $spread Value in range 0 -100. + * @param ?int $spread Value in range 0 -100. * * @return $this */ - public function spread($spread) + public function spread(?int $spread): static { $this->value->getSimpleValue('properties')->setSimpleNamedValue('spread', $spread); diff --git a/src/Transformation/Effect/Misc/MiscEffect.php b/src/Transformation/Effect/Misc/MiscEffect.php index 964e82c..7158baf 100644 --- a/src/Transformation/Effect/Misc/MiscEffect.php +++ b/src/Transformation/Effect/Misc/MiscEffect.php @@ -15,13 +15,13 @@ */ abstract class MiscEffect { - const ARTISTIC_FILTER = 'art'; - const STYLE_TRANSFER = 'style_transfer'; - const CARTOONIFY = 'cartoonify'; - const OIL_PAINT = 'oil_paint'; - const RED_EYE = 'redeye'; - const ADVANCED_RED_EYE = 'adv_redeye'; - const VECTORIZE = 'vectorize'; - const OUTLINE = 'outline'; - const DROP_SHADOW = 'dropshadow'; + public const ARTISTIC_FILTER = 'art'; + public const STYLE_TRANSFER = 'style_transfer'; + public const CARTOONIFY = 'cartoonify'; + public const OIL_PAINT = 'oil_paint'; + public const RED_EYE = 'redeye'; + public const ADVANCED_RED_EYE = 'adv_redeye'; + public const VECTORIZE = 'vectorize'; + public const OUTLINE = 'outline'; + public const DROP_SHADOW = 'dropshadow'; } diff --git a/src/Transformation/Effect/Misc/MiscEffectTrait.php b/src/Transformation/Effect/Misc/MiscEffectTrait.php index 257b740..3aa77d0 100644 --- a/src/Transformation/Effect/Misc/MiscEffectTrait.php +++ b/src/Transformation/Effect/Misc/MiscEffectTrait.php @@ -25,14 +25,13 @@ trait MiscEffectTrait * * See the Image Transformations guide for examples of each of the filters. * - * @param string $filter The filter to apply. Use the constants defined in the ArtisticFilter class. + * @param string|ArtisticFilter $filter The filter to apply. Use the constants defined in the ArtisticFilter class. * - * @return mixed * - * @see \Cloudinary\Transformation\ArtisticFilter + * @see ArtisticFilter * @see https://cloudinary.com/documentation/image_transformations#available_filters */ - public static function artisticFilter($filter) + public static function artisticFilter(string|ArtisticFilter $filter): mixed { return ClassUtils::verifyInstance($filter, ArtisticFilter::class); } @@ -40,18 +39,17 @@ public static function artisticFilter($filter) /** * Applies a cartoon effect to an image. * - * @param float $lineStrength The thickness of the lines. (Range: 0 to 100, Server default: 50) - * @param float|string $colorReduction The decrease in the number of colors and corresponding saturation boost of + * @param mixed $lineStrength The thickness of the lines. (Range: 0 to 100, Server default: 50) + * @param mixed $colorReduction The decrease in the number of colors and corresponding saturation boost of * the remaining colors. (Range: 0 to 100, Server default: automatically * adjusts according to the line_strength value). Higher reduction values * result in a less realistic look. Set $colorReduction to * Cartoonify::BLACK_WHITE for a black and white cartoon effect. * - * @return Cartoonify * - * @see \Cloudinary\Transformation\Cartoonify + * @see Cartoonify */ - public static function cartoonify($lineStrength = null, $colorReduction = null) + public static function cartoonify(mixed $lineStrength = null, mixed $colorReduction = null): Cartoonify { return new Cartoonify($lineStrength, $colorReduction); } @@ -62,32 +60,35 @@ public static function cartoonify($lineStrength = null, $colorReduction = null) * * For details, see the Neural Artwork Style Transfer add-on documentation. * - * @param string $source The public ID of the source artwork. - * @param int $strength The strength of the style transfer. Higher numbers result in an output that is more - * highly influenced by the source artwork style. (Range: 0 to 100, Server default: - * 100) - * @param bool $preserveColor When true, style elements of the source artwork, such as brush style and texture, - * are transferred to the target photo, but the prominent colors from the source - * artwork are not transferred, so the result retains the original colors of the - * target photo. + * @param string $source The public ID of the source artwork. + * @param int|null $strength The strength of the style transfer. Higher numbers result in an output that is + * more highly influenced by the source artwork style. (Range: 0 to 100, Server + * default: + * 100) + * @param bool|null $preserveColor When true, style elements of the source artwork, such as brush style and + * texture, + * are transferred to the target photo, but the prominent colors from the source + * artwork are not transferred, so the result retains the original colors of the + * target photo. * - * @return EffectAction * * @see https://cloudinary.com/documentation/neural_artwork_style_transfer_addon */ - public static function styleTransfer($source, $strength = null, $preserveColor = null) - { + public static function styleTransfer( + string $source, + ?int $strength = null, + ?bool $preserveColor = null + ): StyleTransfer|EffectAction { return new StyleTransfer($source, $strength, $preserveColor); } /** * Applies an oil painting effect to the image. * - * @param int $strength The strength of the effect. (Range: 0 to 100, Server default: 30) + * @param int|null $strength The strength of the effect. (Range: 0 to 100, Server default: 30) * - * @return StrengthEffectAction */ - public static function oilPaint($strength = null) + public static function oilPaint(?int $strength = null): StrengthEffectAction { return EffectAction::withStrength(MiscEffect::OIL_PAINT, EffectRange::PERCENT, $strength); } @@ -95,9 +96,8 @@ public static function oilPaint($strength = null) /** * Removes red eyes in the image. * - * @return EffectAction */ - public static function redEye() + public static function redEye(): EffectAction { return EffectAction::named(MiscEffect::RED_EYE); } @@ -107,11 +107,10 @@ public static function redEye() * * For details, see the Advanced Facial Attribute Detection add-on documentation. * - * @return EffectAction * * @see https://cloudinary.com/documentation/advanced_facial_attributes_detection_addon */ - public static function advancedRedEye() + public static function advancedRedEye(): EffectAction { return EffectAction::named(MiscEffect::ADVANCED_RED_EYE); } @@ -127,22 +126,28 @@ public static function advancedRedEye() * graphic effect. * * Large images are scaled down to 1000 pixels in the largest dimension before vectorization. * - * @param int $colors The number of colors. (Range: 2 to 30, Server default: 10) - * @param float $detail The level of detail. Specify either a percentage of the original image (Range: 0.0 to - * 1.0) or an absolute number of pixels (Range: 0 to 1000). (Server default: 300) - * @param float $despeckle The size of speckles to suppress. Specify either a percentage of the original image - * (Range: 0.0 to 1.0) or an absolute number of pixels (Range: 0 to 100, Server default: 2) - * @param int $corners The corner threshold. Specify 100 for no smoothing (polygon corners), 0 for completely - * smooth corners. (Range: 0 to 100, Default: 25) - * @param int $paths The optimization value. Specify 100 for least optimization and the largest file. - * (Range: 0 to 100, Server default: 100). + * @param int|null $colors The number of colors. (Range: 2 to 30, Server default: 10) + * @param float|null $detail The level of detail. Specify either a percentage of the original image (Range: 0.0 + * to + * 1.0) or an absolute number of pixels (Range: 0 to 1000). (Server default: 300) + * @param float|null $despeckle The size of speckles to suppress. Specify either a percentage of the original image + * (Range: 0.0 to 1.0) or an absolute number of pixels (Range: 0 to 100, Server + * default: 2) + * @param int|null $corners The corner threshold. Specify 100 for no smoothing (polygon corners), 0 for + * completely smooth corners. (Range: 0 to 100, Default: 25) + * @param int|null $paths The optimization value. Specify 100 for least optimization and the largest file. + * (Range: 0 to 100, Server default: 100). * - * @return Vectorize * - * @see \Cloudinary\Transformation\Vectorize + * @see Vectorize */ - public static function vectorize($colors = null, $detail = null, $despeckle = null, $corners = null, $paths = null) - { + public static function vectorize( + ?int $colors = null, + ?float $detail = null, + ?float $despeckle = null, + ?int $corners = null, + ?int $paths = null + ): Vectorize { return new Vectorize($colors, $detail, $despeckle, $corners, $paths); } @@ -151,19 +156,18 @@ public static function vectorize($colors = null, $detail = null, $despeckle = nu * * For examples, see the Image Transformations guide. * - * @param string $mode The type of outline effect. Use the constants defined in the Outline class. - * (Default: OutlineMode::INNER and OutlineMode::OUTER). - * @param int $width The thickness of the outline in pixels. (Range: 1 to 100, Server default: 5) - * @param int $blurLevel The level of blur of the outline. (Range: 0 to 2000, Server default: 0) + * @param string|null $mode The type of outline effect. Use the constants defined in the Outline class. + * (Default: OutlineMode::INNER and OutlineMode::OUTER). + * @param int|null $width The thickness of the outline in pixels. (Range: 1 to 100, Server default: 5) + * @param int|null $blurLevel The level of blur of the outline. (Range: 0 to 2000, Server default: 0) * - * @return Outline * - * @see \Cloudinary\Transformation\Outline - * @see \Cloudinary\Transformation\OutlineMode + * @see Outline + * @see OutlineMode * @see https://cloudinary.com/documentation/image_transformations#outline_effects * */ - public static function outline($mode = null, $width = null, $blurLevel = null) + public static function outline(?string $mode = null, ?int $width = null, ?int $blurLevel = null): Outline { return new Outline($mode, $width, $blurLevel); } @@ -173,15 +177,14 @@ public static function outline($mode = null, $width = null, $blurLevel = null) * * The shadow is offset by the x and y values specified in the $position qualifier. * - * @param int $strength The strength of the shadow. (Range: 0 to 100, Server default: 40) - * @param PointValue $position The position of the shadow. (Server default: bottom right) - * @param string $color The color of the shadow (Server default: gray) + * @param int|null $strength The strength of the shadow. (Range: 0 to 100, Server default: 40) + * @param PointValue|null $position The position of the shadow. (Server default: bottom right) + * @param string|null $color The color of the shadow (Server default: gray) * - * @return Shadow - * @see \Cloudinary\Transformation\Shadow + * @see Shadow * */ - public static function shadow($strength = null, $position = null, $color = null) + public static function shadow(?int $strength = null, ?PointValue $position = null, ?string $color = null): Shadow { return new Shadow($strength, $position, $color); } @@ -189,15 +192,14 @@ public static function shadow($strength = null, $position = null, $color = null) /** * Adds a natural looking shadow to an image. * - * @param int $azimuth Value in range 0 - 360 (degrees). - * @param int $elevation Value in range 0 - 90 (degrees). - * @param int $spread Value in range 0 -100. + * @param int|null $azimuth Value in range 0 - 360 (degrees). + * @param int|null $elevation Value in range 0 - 90 (degrees). + * @param int|null $spread Value in range 0 -100. * - * @return DropShadow * - * @see \Cloudinary\Transformation\DropShadow + * @see DropShadow */ - public static function dropShadow($azimuth = null, $elevation = null, $spread = null) + public static function dropShadow(?int $azimuth = null, ?int $elevation = null, ?int $spread = null): DropShadow { return new DropShadow($azimuth, $elevation, $spread); } diff --git a/src/Transformation/Effect/Misc/Outline.php b/src/Transformation/Effect/Misc/Outline.php index 198ee4a..7e51606 100644 --- a/src/Transformation/Effect/Misc/Outline.php +++ b/src/Transformation/Effect/Misc/Outline.php @@ -18,9 +18,6 @@ class Outline extends ColoredEffectAction /** * Outline constructor. * - * @param $mode - * @param $width - * @param $blurLevel */ public function __construct($mode = null, $width = null, $blurLevel = null) { @@ -34,11 +31,10 @@ public function __construct($mode = null, $width = null, $blurLevel = null) /** * Sets the outline mode. * - * @param int|string $mode The outline mode. + * @param int|string|null $mode The outline mode. * - * @return Outline */ - public function mode($mode) + public function mode(int|string|null $mode): static { $this->qualifiers[OutlineQualifier::getName()]->mode($mode); @@ -48,11 +44,10 @@ public function mode($mode) /** * Sets the outline width. * - * @param int|string $width The width in pixels. + * @param int|string|null $width The width in pixels. * - * @return Outline */ - public function width($width) + public function width(int|string|null $width): static { $this->qualifiers[OutlineQualifier::getName()]->width($width); @@ -62,11 +57,10 @@ public function width($width) /** * Sets the outline blur level. * - * @param int|string $blurLevel The level of blur. + * @param int|string|null $blurLevel The level of blur. * - * @return Outline */ - public function blurLevel($blurLevel) + public function blurLevel(int|string|null $blurLevel): static { $this->qualifiers[OutlineQualifier::getName()]->blurLevel($blurLevel); diff --git a/src/Transformation/Effect/Misc/OutlineMode.php b/src/Transformation/Effect/Misc/OutlineMode.php index b408e51..30b3dcf 100644 --- a/src/Transformation/Effect/Misc/OutlineMode.php +++ b/src/Transformation/Effect/Misc/OutlineMode.php @@ -15,17 +15,16 @@ */ abstract class OutlineMode { - const INNER = 'inner'; - const INNER_FILL = 'inner_fill'; - const OUTER = 'outer'; - const FILL = 'fill'; + public const INNER = 'inner'; + public const INNER_FILL = 'inner_fill'; + public const OUTER = 'outer'; + public const FILL = 'fill'; /** * Outline mode inner. * - * @return string */ - public static function inner() + public static function inner(): string { return self::INNER; } @@ -33,9 +32,8 @@ public static function inner() /** * Outline mode inner fill. * - * @return string */ - public static function innerFill() + public static function innerFill(): string { return self::INNER_FILL; } @@ -43,9 +41,8 @@ public static function innerFill() /** * Outline mode outer. * - * @return string */ - public static function outer() + public static function outer(): string { return self::OUTER; } @@ -53,9 +50,8 @@ public static function outer() /** * Outline mode fill. * - * @return string */ - public static function fill() + public static function fill(): string { return self::FILL; } diff --git a/src/Transformation/Effect/Misc/OutlineQualifier.php b/src/Transformation/Effect/Misc/OutlineQualifier.php index 632f1c4..1946107 100644 --- a/src/Transformation/Effect/Misc/OutlineQualifier.php +++ b/src/Transformation/Effect/Misc/OutlineQualifier.php @@ -16,7 +16,7 @@ */ class OutlineQualifier extends EffectQualifier { - protected $valueOrder = [0, 'mode', 'width', 'blur_level']; + protected array $valueOrder = [0, 'mode', 'width', 'blur_level']; public function __construct(...$values) { @@ -26,11 +26,10 @@ public function __construct(...$values) /** * Sets the outline mode. * - * @param string $mode The outline mode. + * @param ?string $mode The outline mode. * - * @return OutlineQualifier */ - public function mode($mode) + public function mode(?string $mode): static { $this->value->setSimpleValue('mode', $mode); @@ -39,11 +38,10 @@ public function mode($mode) /** * Sets the outline width. * - * @param int|string $width The width in pixels. + * @param int|string|null $width The width in pixels. * - * @return OutlineQualifier */ - public function width($width) + public function width(int|string|null $width): static { $this->value->setSimpleValue('width', $width); @@ -53,11 +51,10 @@ public function width($width) /** * Sets the outline blur level. * - * @param int|string $blurLevel The level of blur. + * @param int|string|null $blurLevel The level of blur. * - * @return OutlineQualifier */ - public function blurLevel($blurLevel) + public function blurLevel(int|string|null $blurLevel): static { $this->value->setSimpleValue('blur_level', $blurLevel); diff --git a/src/Transformation/Effect/Misc/Shadow.php b/src/Transformation/Effect/Misc/Shadow.php index 2476fed..ded93c7 100644 --- a/src/Transformation/Effect/Misc/Shadow.php +++ b/src/Transformation/Effect/Misc/Shadow.php @@ -15,7 +15,7 @@ */ class Shadow extends StrengthEffectAction { - const SHADOW = 'shadow'; + public const SHADOW = 'shadow'; use ColorTrait; use OffsetTrait; @@ -23,13 +23,17 @@ class Shadow extends StrengthEffectAction /** * Shadow constructor. * - * @param int $strength - * @param float|int|string $offsetX - * @param float|int|string $offsetY - * @param string $color + * @param int|null $strength + * @param float|int|string|null $offsetX + * @param float|int|string|null $offsetY + * @param string|null $color */ - public function __construct($strength = null, $offsetX = null, $offsetY = null, $color = null) - { + public function __construct( + ?int $strength = null, + float|int|string|null $offsetX = null, + float|int|string|null $offsetY = null, + ?string $color = null + ) { parent::__construct(new StrengthEffectQualifier(self::SHADOW, EffectRange::PERCENT)); $this->strength($strength); $this->offset($offsetX, $offsetY); @@ -37,13 +41,11 @@ public function __construct($strength = null, $offsetX = null, $offsetY = null, } /** - * @param $value * - * @return static * @internal * */ - public function setOffsetValue($value) + public function setOffsetValue($value): static { $this->addQualifier($value); diff --git a/src/Transformation/Effect/Misc/StyleTransfer/StyleTransfer.php b/src/Transformation/Effect/Misc/StyleTransfer/StyleTransfer.php index b17f5ca..64c33ab 100644 --- a/src/Transformation/Effect/Misc/StyleTransfer/StyleTransfer.php +++ b/src/Transformation/Effect/Misc/StyleTransfer/StyleTransfer.php @@ -44,9 +44,8 @@ public function __construct($source, $strength = null, $preserveColor = null) * artwork are not transferred, so the result retains the original colors of the * target photo. * - * @return StyleTransfer */ - public function preserveColor($preserveColor = true) + public function preserveColor(bool $preserveColor = true): static { $this->qualifiers[StyleTransferQualifier::getName()]->preserveColor($preserveColor); @@ -60,9 +59,8 @@ public function preserveColor($preserveColor = true) * highly influenced by the source artwork style. (Range: 0 to 100, Server default: * 100) * - * @return StyleTransfer */ - public function strength($strength) + public function strength(int $strength): static { $this->qualifiers[StyleTransferQualifier::getName()]->strength($strength); diff --git a/src/Transformation/Effect/Misc/StyleTransfer/StyleTransferQualifier.php b/src/Transformation/Effect/Misc/StyleTransfer/StyleTransferQualifier.php index e14c72e..6358936 100644 --- a/src/Transformation/Effect/Misc/StyleTransfer/StyleTransferQualifier.php +++ b/src/Transformation/Effect/Misc/StyleTransfer/StyleTransferQualifier.php @@ -18,16 +18,16 @@ class StyleTransferQualifier extends LimitedEffectQualifier /** * @var array $valueOrder The order of the values. */ - protected $valueOrder = [0, 'preserve_color', 'style_strength']; + protected array $valueOrder = [0, 'preserve_color', 'style_strength']; /** * StyleTransfer constructor. * - * @param int $strength - * @param bool $preserveColor - * @param array $args + * @param ?int $strength Style Strength. + * @param ?bool $preserveColor Whether to preserve color. + * @param array $args Additional args. */ - public function __construct($strength = null, $preserveColor = null, ...$args) + public function __construct(?int $strength = null, ?bool $preserveColor = null, ...$args) { parent::__construct(MiscEffect::STYLE_TRANSFER, EffectRange::PERCENT, ...$args); @@ -37,14 +37,13 @@ public function __construct($strength = null, $preserveColor = null, ...$args) /** * Determines whether the original colors of the target photo are kept. * - * @param bool $preserveColor When true, style elements of the source artwork, such as brush style and texture, + * @param ?bool $preserveColor When true, style elements of the source artwork, such as brush style and texture, * are transferred to the target photo, but the prominent colors from the source * artwork are not transferred, so the result retains the original colors of the * target photo. * - * @return StyleTransferQualifier */ - public function preserveColor($preserveColor) + public function preserveColor(?bool $preserveColor): static { $this->value->setSimpleValue('preserve_color', $preserveColor ? 'preserve_color' : null); @@ -54,13 +53,12 @@ public function preserveColor($preserveColor) /** * Sets the strength of the style transfer. * - * @param int $strength The strength of the style transfer. Higher numbers result in an output that is more + * @param ?int $strength The strength of the style transfer. Higher numbers result in an output that is more * highly influenced by the source artwork style. (Range: 0 to 100, Server default: * 100) * - * @return StyleTransferQualifier */ - public function strength($strength) + public function strength(?int $strength): static { $this->value->setSimpleValue('style_strength', $strength); diff --git a/src/Transformation/Effect/Misc/Vectorize.php b/src/Transformation/Effect/Misc/Vectorize.php index f06317b..2fd01b6 100644 --- a/src/Transformation/Effect/Misc/Vectorize.php +++ b/src/Transformation/Effect/Misc/Vectorize.php @@ -17,25 +17,34 @@ */ class Vectorize extends EffectQualifier { - const VALUE_CLASS = VectorizeValue::class; + protected const VALUE_CLASS = VectorizeValue::class; use VectorizeTrait; /** * Vectorize constructor. * - * @param int $colors The number of colors. (Range: 2 to 30, Server default: 10) - * @param float $detail The level of detail. Specify either a percentage of the original image (Range: 0.0 to - * 1.0) or an absolute number of pixels (Range: 0 to 1000). (Server default: 300) - * @param float $despeckle The size of speckles to suppress. Specify either a percentage of the original image - * (Range: 0.0 to 1.0) or an absolute number of pixels (Range: 0 to 100, Server default: 2) - * @param int $corners The corner threshold. Specify 100 for no smoothing (polygon corners), 0 for completely - * smooth corners. (Range: 0 to 100, Default: 25) - * @param int $paths The optimization value. Specify 100 for least optimization and the largest file. - * (Range: 0 to 100, Server default: 100). + * @param ?int $colors The number of colors. (Range: 2 to 30, Server default: 10) + * @param ?float $detail The level of detail. Specify either a percentage of the original image (Range: + * 0.0 to + * 1.0) or an absolute number of pixels (Range: 0 to 1000). (Server default: 300) + * @param int|float|null $despeckle The size of speckles to suppress. Specify either a percentage of the original + * image + * (Range: 0.0 to 1.0) or an absolute number of pixels (Range: 0 to 100, Server + * default: 2) + * @param int|null $corners The corner threshold. Specify 100 for no smoothing (polygon corners), 0 for + * completely smooth corners. (Range: 0 to 100, Default: 25) + * @param int|null $paths The optimization value. Specify 100 for least optimization and the largest + * file. + * (Range: 0 to 100, Server default: 100). */ - public function __construct($colors = null, $detail = null, $despeckle = null, $corners = null, $paths = null) - { + public function __construct( + ?int $colors = null, + ?float $detail = null, + int|float|null $despeckle = null, + ?int $corners = null, + ?int $paths = null + ) { parent::__construct(null); $this->numOfColors($colors); @@ -55,7 +64,7 @@ public function __construct($colors = null, $detail = null, $despeckle = null, $ * * @internal */ - protected function setSimpleNamedValue($name, $value) + protected function setSimpleNamedValue(string $name, mixed $value): static { $this->value->setSimpleNamedValue($name, $value); diff --git a/src/Transformation/Effect/Misc/VectorizeTrait.php b/src/Transformation/Effect/Misc/VectorizeTrait.php index d09d6a9..08af029 100644 --- a/src/Transformation/Effect/Misc/VectorizeTrait.php +++ b/src/Transformation/Effect/Misc/VectorizeTrait.php @@ -20,11 +20,11 @@ trait VectorizeTrait /** * Limits the number of colors in the image. * - * @param int $numOfColors The number of colors. (Range: 2 to 30, Server default: 10) + * @param int|null $numOfColors The number of colors. (Range: 2 to 30, Server default: 10) * * @return $this */ - public function numOfColors($numOfColors = null) + public function numOfColors(?int $numOfColors = null): static { $this->setSimpleNamedValue(VectorizeValue::COLORS, $numOfColors); @@ -34,12 +34,12 @@ public function numOfColors($numOfColors = null) /** * Controls the level of detail. * - * @param float $level The level of detail. Specify either a percentage of the original image (Range: 0.0 to 1.0) - * or an absolute number of pixels (Range: 0 to 1000). (Server default: 300) + * @param ?float $level The level of detail. Specify either a percentage of the original image (Range: 0.0 to 1.0) + * or an absolute number of pixels (Range: 0 to 1000). (Server default: 300) * * @return $this */ - public function detailsLevel($level) + public function detailsLevel(?float $level): static { $this->setSimpleNamedValue(VectorizeValue::DETAIL, $level); @@ -49,12 +49,13 @@ public function detailsLevel($level) /** * Suppresses speckles up to the given size. * - * @param float $size The size of speckles to suppress. Specify either a percentage of the original image - * (Range: 0.0 to 1.0) or an absolute number of pixels (Range: 0 to 100, Server default: 2) + * @param int|float|null $size The size of speckles to suppress. Specify either a percentage of the original image + * (Range: 0.0 to 1.0) or an absolute number of pixels (Range: 0 to 100, Server + * default: 2) * * @return $this */ - public function despeckleLevel($size) + public function despeckleLevel(int|float|null $size): static { $this->setSimpleNamedValue(VectorizeValue::DESPECKLE, $size); @@ -64,12 +65,12 @@ public function despeckleLevel($size) /** * Controls the Bezier curve optimization. * - * @param int $value The optimization value. Specify 100 for least optimization and the largest file. - * (Range: 0 to 100, Server default: 100). + * @param ?int $value The optimization value. Specify 100 for least optimization and the largest file. + * (Range: 0 to 100, Server default: 100). * * @return $this */ - public function paths($value) + public function paths(?int $value): static { $this->setSimpleNamedValue(VectorizeValue::PATHS, $value); @@ -79,12 +80,12 @@ public function paths($value) /** * Controls the corner threshold. 100 for no smoothing (polygon corners), 0 for completely smooth corners. * - * @param int $threshold The corner threshold. Specify 100 for no smoothing (polygon corners), 0 for completely - * smooth corners. (Range: 0 to 100, Default: 25) + * @param ?int $threshold The corner threshold. Specify 100 for no smoothing (polygon corners), 0 for completely + * smooth corners. (Range: 0 to 100, Default: 25) * * @return $this */ - public function cornersLevel($threshold) + public function cornersLevel(?int $threshold): static { $this->setSimpleNamedValue(VectorizeValue::CORNERS, $threshold); diff --git a/src/Transformation/Effect/Misc/VectorizeValue.php b/src/Transformation/Effect/Misc/VectorizeValue.php index 0a6b2d3..13f1207 100644 --- a/src/Transformation/Effect/Misc/VectorizeValue.php +++ b/src/Transformation/Effect/Misc/VectorizeValue.php @@ -17,30 +17,35 @@ class VectorizeValue extends QualifierMultiValue { use VectorizeTrait; - const COLORS = 'colors'; - const DETAIL = 'detail'; - const DESPECKLE = 'despeckle'; - const PATHS = 'paths'; - const CORNERS = 'corners'; + public const COLORS = 'colors'; + public const DETAIL = 'detail'; + public const DESPECKLE = 'despeckle'; + public const PATHS = 'paths'; + public const CORNERS = 'corners'; - const KEY_VALUE_DELIMITER = ':'; + public const KEY_VALUE_DELIMITER = ':'; - const COLOR_RANGE = [2, 30]; - const DETAIL_RANGE = [0, 1000]; - const PATHS_RANGE = [0, 100]; - const CORNER_THRESHOLD_RANGE = [0, 100]; + public const COLOR_RANGE = [2, 30]; + public const DETAIL_RANGE = [0, 1000]; + public const PATHS_RANGE = [0, 100]; + public const CORNER_THRESHOLD_RANGE = [0, 100]; /** * VectorizeValue constructor. * - * @param int $colors - * @param float $detail - * @param float $despeckle - * @param int $paths - * @param int $corners + * @param int|null $colors + * @param float|null $detail + * @param float|null $despeckle + * @param int|null $paths + * @param int|null $corners */ - public function __construct($colors = null, $detail = null, $despeckle = null, $paths = null, $corners = null) - { + public function __construct( + ?int $colors = null, + ?float $detail = null, + ?float $despeckle = null, + ?int $paths = null, + ?int $corners = null + ) { parent::__construct(MiscEffect::VECTORIZE); $this->numOfColors($colors); diff --git a/src/Transformation/Effect/Pixel/BackgroundRemoval.php b/src/Transformation/Effect/Pixel/BackgroundRemoval.php index aa86324..1f8ce38 100644 --- a/src/Transformation/Effect/Pixel/BackgroundRemoval.php +++ b/src/Transformation/Effect/Pixel/BackgroundRemoval.php @@ -26,8 +26,8 @@ */ class BackgroundRemoval extends EffectAction { - const FINE_EDGES = 'fineedges'; - const HINTS = 'hints'; + public const FINE_EDGES = 'fineedges'; + public const HINTS = 'hints'; /** * RemoveBackground constructor. @@ -36,7 +36,7 @@ class BackgroundRemoval extends EffectAction * detail around its edges. * @param array $hints A list of foreground objects to keep. */ - public function __construct($fineEdges = null, $hints = []) + public function __construct($fineEdges = null, array $hints = []) { parent::__construct(new ListEffectQualifier(PixelEffect::BACKGROUND_REMOVAL)); @@ -49,9 +49,8 @@ public function __construct($fineEdges = null, $hints = []) * * @param bool|null $fineEdges Whether to apply fine edges mode. * - * @return BackgroundRemoval */ - public function fineEdges($fineEdges = true) + public function fineEdges(?bool $fineEdges = true): static { $value = TransformationUtils::boolToString($fineEdges, 'y', 'n'); @@ -65,9 +64,8 @@ public function fineEdges($fineEdges = true) * * @param array $foregroundObjects A list of foreground objects to keep. * - * @return BackgroundRemoval */ - public function hints(...$foregroundObjects) + public function hints(...$foregroundObjects): static { $this->getMainQualifier()->getPropertiesValue()->setSimpleNamedValue( self::HINTS, diff --git a/src/Transformation/Effect/Pixel/Blur.php b/src/Transformation/Effect/Pixel/Blur.php index 38aed21..0a2c2bf 100644 --- a/src/Transformation/Effect/Pixel/Blur.php +++ b/src/Transformation/Effect/Pixel/Blur.php @@ -15,14 +15,12 @@ */ class Blur extends StrengthEffectAction { - const REGION = PixelEffect::BLUR_REGION; - const FACES = PixelEffect::BLUR_FACES; + public const REGION = PixelEffect::BLUR_REGION; + public const FACES = PixelEffect::BLUR_FACES; /** * Pixelate constructor. * - * @param $strength - * @param mixed ...$args */ public function __construct($strength, ...$args) { diff --git a/src/Transformation/Effect/Pixel/CutOut.php b/src/Transformation/Effect/Pixel/CutOut.php index cc3b744..4a849d2 100644 --- a/src/Transformation/Effect/Pixel/CutOut.php +++ b/src/Transformation/Effect/Pixel/CutOut.php @@ -48,14 +48,13 @@ public function __construct($source) * * Note that e_cut_out comes with l_logo in the same sub-action. * - * @return array * * @see BasePositionalSourceContainer::getSubActionQualifiers */ - protected function getSubActionQualifiers() + protected function getSubActionQualifiers(): array { $sourceQualifiers = $this->source ? $this->source->getStringQualifiers() : []; - $sourceTransformation = $this->source ? $this->source->getTransformation() : null; + $sourceTransformation = $this->source?->getTransformation(); $positionQualifiers = $this->position ? $this->position->getStringQualifiers() : []; $additionalQualifiers = $this->getStringQualifiers(); diff --git a/src/Transformation/Effect/Pixel/Dither.php b/src/Transformation/Effect/Pixel/Dither.php index f73b78d..ebee98d 100644 --- a/src/Transformation/Effect/Pixel/Dither.php +++ b/src/Transformation/Effect/Pixel/Dither.php @@ -15,30 +15,29 @@ */ class Dither extends LimitedEffectQualifier { - const THRESHOLD_1X1_NON_DITHER = 0; - const CHECKERBOARD_2X1_DITHER = 1; - const ORDERED_2X2_DISPERSED = 2; - const ORDERED_3X3_DISPERSED = 3; - const ORDERED_4X4_DISPERSED = 4; - const ORDERED_8X8_DISPERSED = 5; - const HALFTONE_4X4_ANGLED = 6; - const HALFTONE_6X6_ANGLED = 7; - const HALFTONE_8X8_ANGLED = 8; - const HALFTONE_4X4_ORTHOGONAL = 9; - const HALFTONE_6X6_ORTHOGONAL = 10; - const HALFTONE_8X8_ORTHOGONAL = 11; - const HALFTONE_16X16_ORTHOGONAL = 12; - const CIRCLES_5X5_BLACK = 13; - const CIRCLES_5X5_WHITE = 14; - const CIRCLES_6X6_BLACK = 15; - const CIRCLES_6X6_WHITE = 16; - const CIRCLES_7X7_BLACK = 17; - const CIRCLES_7X7_WHITE = 18; + public const THRESHOLD_1X1_NON_DITHER = 0; + public const CHECKERBOARD_2X1_DITHER = 1; + public const ORDERED_2X2_DISPERSED = 2; + public const ORDERED_3X3_DISPERSED = 3; + public const ORDERED_4X4_DISPERSED = 4; + public const ORDERED_8X8_DISPERSED = 5; + public const HALFTONE_4X4_ANGLED = 6; + public const HALFTONE_6X6_ANGLED = 7; + public const HALFTONE_8X8_ANGLED = 8; + public const HALFTONE_4X4_ORTHOGONAL = 9; + public const HALFTONE_6X6_ORTHOGONAL = 10; + public const HALFTONE_8X8_ORTHOGONAL = 11; + public const HALFTONE_16X16_ORTHOGONAL = 12; + public const CIRCLES_5X5_BLACK = 13; + public const CIRCLES_5X5_WHITE = 14; + public const CIRCLES_6X6_BLACK = 15; + public const CIRCLES_6X6_WHITE = 16; + public const CIRCLES_7X7_BLACK = 17; + public const CIRCLES_7X7_WHITE = 18; /** * Dither constructor. * - * @param $type */ public function __construct($type) { @@ -50,11 +49,10 @@ public function __construct($type) /** * Sets the type of the dither. * - * @param int $type The type. + * @param int|null $type The type. * - * @return Dither */ - public function type($type) + public function type(?int $type): Dither { return $this->setEffectValue($type); } @@ -62,9 +60,8 @@ public function type($type) /** * Dither type threshold 1x1 non dither. * - * @return int */ - public static function threshold1x1NonDither() + public static function threshold1x1NonDither(): int { return self::THRESHOLD_1X1_NON_DITHER; } @@ -72,9 +69,8 @@ public static function threshold1x1NonDither() /** * Dither type checkerboard 2x1 dither. * - * @return int */ - public static function checkerboard2x1Dither() + public static function checkerboard2x1Dither(): int { return self::CHECKERBOARD_2X1_DITHER; } @@ -82,9 +78,8 @@ public static function checkerboard2x1Dither() /** * Dither type ordered 2x2 dispersed. * - * @return int */ - public static function ordered2x2Dispersed() + public static function ordered2x2Dispersed(): int { return self::ORDERED_2X2_DISPERSED; } @@ -92,9 +87,8 @@ public static function ordered2x2Dispersed() /** * Dither type ordered 3x3 dispersed. * - * @return int */ - public static function ordered3x3Dispersed() + public static function ordered3x3Dispersed(): int { return self::ORDERED_3X3_DISPERSED; } @@ -102,9 +96,8 @@ public static function ordered3x3Dispersed() /** * Dither type ordered 4x4 dispersed. * - * @return int */ - public static function ordered4x4Dispersed() + public static function ordered4x4Dispersed(): int { return self::ORDERED_4X4_DISPERSED; } @@ -112,9 +105,8 @@ public static function ordered4x4Dispersed() /** * Dither type ordered 8x8 dispersed. * - * @return int */ - public static function ordered8x8Dispersed() + public static function ordered8x8Dispersed(): int { return self::ORDERED_8X8_DISPERSED; } @@ -122,9 +114,8 @@ public static function ordered8x8Dispersed() /** * Dither type ordered 8x8 dispersed. * - * @return int */ - public static function halftone4x4Angled() + public static function halftone4x4Angled(): int { return self::HALFTONE_4X4_ANGLED; } @@ -132,9 +123,8 @@ public static function halftone4x4Angled() /** * Dither type halftone 6x6 angled. * - * @return int */ - public static function halftone6x6Angled() + public static function halftone6x6Angled(): int { return self::HALFTONE_6X6_ANGLED; } @@ -142,9 +132,8 @@ public static function halftone6x6Angled() /** * Dither type halftone 8x8 angled. * - * @return int */ - public static function halftone8x8Angled() + public static function halftone8x8Angled(): int { return self::HALFTONE_8X8_ANGLED; } @@ -152,9 +141,8 @@ public static function halftone8x8Angled() /** * Dither type halftone 4x4 orthogonal. * - * @return int */ - public static function halftone4x4Orthogonal() + public static function halftone4x4Orthogonal(): int { return self::HALFTONE_4X4_ORTHOGONAL; } @@ -162,9 +150,8 @@ public static function halftone4x4Orthogonal() /** * Dither type halftone 6x6 orthogonal. * - * @return int */ - public static function halftone6x6Orthogonal() + public static function halftone6x6Orthogonal(): int { return self::HALFTONE_6X6_ORTHOGONAL; } @@ -172,9 +159,8 @@ public static function halftone6x6Orthogonal() /** * Dither type halftone 8x8 orthogonal. * - * @return int */ - public static function halftone8x8Orthogonal() + public static function halftone8x8Orthogonal(): int { return self::HALFTONE_8X8_ORTHOGONAL; } @@ -182,9 +168,8 @@ public static function halftone8x8Orthogonal() /** * Dither type halftone 16x16 orthogonal. * - * @return int */ - public static function halftone16x16Orthogonal() + public static function halftone16x16Orthogonal(): int { return self::HALFTONE_16X16_ORTHOGONAL; } @@ -192,9 +177,8 @@ public static function halftone16x16Orthogonal() /** * Dither type circles 5x5 black. * - * @return int */ - public static function circles5x5Black() + public static function circles5x5Black(): int { return self::CIRCLES_5X5_BLACK; } @@ -202,9 +186,8 @@ public static function circles5x5Black() /** * Dither type circles 5x5 white. * - * @return int */ - public static function circles5x5White() + public static function circles5x5White(): int { return self::CIRCLES_5X5_WHITE; } @@ -212,9 +195,8 @@ public static function circles5x5White() /** * Dither type circles 6x6 black. * - * @return int */ - public static function circles6x6Black() + public static function circles6x6Black(): int { return self::CIRCLES_6X6_BLACK; } @@ -222,9 +204,8 @@ public static function circles6x6Black() /** * Dither type circles 6x6 white. * - * @return int */ - public static function circles6x6White() + public static function circles6x6White(): int { return self::CIRCLES_6X6_WHITE; } @@ -232,9 +213,8 @@ public static function circles6x6White() /** * Dither type circles 7x7 black. * - * @return int */ - public static function circles7x7Black() + public static function circles7x7Black(): int { return self::CIRCLES_7X7_BLACK; } @@ -242,9 +222,8 @@ public static function circles7x7Black() /** * Dither type circles 7x7 white. * - * @return int */ - public static function circles7x7White() + public static function circles7x7White(): int { return self::CIRCLES_7X7_WHITE; } diff --git a/src/Transformation/Effect/Pixel/GradientFade.php b/src/Transformation/Effect/Pixel/GradientFade.php index 5a9bd15..8bd77be 100644 --- a/src/Transformation/Effect/Pixel/GradientFade.php +++ b/src/Transformation/Effect/Pixel/GradientFade.php @@ -35,13 +35,13 @@ class GradientFade extends StrengthEffectAction /** * Instructs the gradient fade to be applied symmetrically (to opposite edges of the image). */ - const SYMMETRIC = 'symmetric'; + public const SYMMETRIC = 'symmetric'; /** * Instructs the gradient fade to be applied symmetrically (to opposite edges of the image) including * background padding. */ - const SYMMETRIC_PAD = 'symmetric_pad'; + public const SYMMETRIC_PAD = 'symmetric_pad'; /** * GradientFade constructor. @@ -57,9 +57,8 @@ public function __construct($strength = null, $type = null) /** * Instructs the gradient fade to be applied symmetrically (to opposite edges of the image). * - * @return string */ - public static function symmetric() + public static function symmetric(): string { return self::SYMMETRIC; } @@ -68,9 +67,8 @@ public static function symmetric() * Instructs the gradient fade to be applied symmetrically (to opposite edges of the image) including * background padding. * - * @return string */ - public static function symmetricPad() + public static function symmetricPad(): string { return self::SYMMETRIC_PAD; } @@ -78,11 +76,11 @@ public static function symmetricPad() /** * Sets the horizontal start point (x). * - * @param int|float|string $x The value of the x dimension. + * @param float|int|string $x The value of the x dimension. * * @return $this */ - public function horizontalStartPoint($x) + public function horizontalStartPoint(float|int|string $x): static { return $this->setPointValue(ClassUtils::verifyInstance($x, X::class)); } @@ -90,11 +88,11 @@ public function horizontalStartPoint($x) /** * Sets the vertical start point (y). * - * @param int|float|string $y The value of the y dimension. + * @param float|int|string $y The value of the y dimension. * * @return $this */ - public function verticalStartPoint($y) + public function verticalStartPoint(float|int|string $y): static { return $this->setPointValue(ClassUtils::verifyInstance($y, Y::class)); } @@ -102,13 +100,11 @@ public function verticalStartPoint($y) /** * Internal setter for the point value. * - * @param mixed $value * - * @return static * * @internal */ - protected function setPointValue($value) + protected function setPointValue(mixed $value): static { if (! isset($this->qualifiers[Point::getName()])) { $this->addQualifier(new Point()); diff --git a/src/Transformation/Effect/Pixel/GradientFadeQualifier.php b/src/Transformation/Effect/Pixel/GradientFadeQualifier.php index ead201f..89e3add 100644 --- a/src/Transformation/Effect/Pixel/GradientFadeQualifier.php +++ b/src/Transformation/Effect/Pixel/GradientFadeQualifier.php @@ -20,7 +20,7 @@ class GradientFadeQualifier extends StrengthEffectQualifier /** * @var array $valueOrder The order of the values. */ - protected $valueOrder = [0, 'type', 'strength']; + protected array $valueOrder = [0, 'type', 'strength']; /** * GradientFade constructor. diff --git a/src/Transformation/Effect/Pixel/ImagePixelEffectTrait.php b/src/Transformation/Effect/Pixel/ImagePixelEffectTrait.php index 80cdfc8..f183668 100644 --- a/src/Transformation/Effect/Pixel/ImagePixelEffectTrait.php +++ b/src/Transformation/Effect/Pixel/ImagePixelEffectTrait.php @@ -22,11 +22,10 @@ trait ImagePixelEffectTrait /** * Applies a pixelation effect to the image. * - * @param int $squareSize The width of each pixelation square in pixels. (Range: 1 to 200, Server default: 5) + * @param int|null $squareSize The width of each pixelation square in pixels. (Range: 1 to 200, Server default: 5) * - * @return Pixelate */ - public static function pixelate($squareSize = null) + public static function pixelate(?int $squareSize = null): Pixelate { return new Pixelate($squareSize); } @@ -35,12 +34,11 @@ public static function pixelate($squareSize = null) * Makes the background of the image transparent (or solid white for formats that do not support transparency). * The background is determined as all pixels that resemble the pixels on the edges of the image. * - * @param int $tolerance The tolerance used to accommodate variance in the background color. - * (Range: 0 to 100, Server default: 10) + * @param int|null $tolerance The tolerance used to accommodate variance in the background color. + * (Range: 0 to 100, Server default: 10) * - * @return MakeTransparent */ - public static function makeTransparent($tolerance = null) + public static function makeTransparent(?int $tolerance = null): MakeTransparent { return new MakeTransparent( new ToleranceEffectQualifier(PixelEffect::MAKE_TRANSPARENT, EffectRange::PERCENT, $tolerance) @@ -52,18 +50,19 @@ public static function makeTransparent($tolerance = null) * * Use when the background is a uniform color. * - * @param bool $screen When true, provides better results for images with near perfect green/blue - * background. - * @param string|Color $colorToRemove The background color as an RGB/A hex code. Overrides the algorithm's choice of - * background color. - * Default: The algorithm's choice - often the edge color of the image. + * @param bool $screen When true, provides better results for images with near perfect + * green/blue background. + * @param string|Color|null $colorToRemove The background color as an RGB/A hex code. Overrides the algorithm's + * choice of background color. Default: The algorithm's choice - often the + * edge color of the image. * - * @return RemoveBackground * - * @see \Cloudinary\Transformation\RemoveBackground + * @see RemoveBackground */ - public static function removeBackground($screen = false, $colorToRemove = null) - { + public static function removeBackground( + bool $screen = false, + Color|string|null $colorToRemove = null + ): RemoveBackground { return new RemoveBackground($screen, $colorToRemove); } @@ -75,11 +74,10 @@ public static function removeBackground($screen = false, $colorToRemove = null) * detail around its edges. * @param array $hints A list of foreground objects to keep. * - * @return BackgroundRemoval * - * @see \Cloudinary\Transformation\BackgroundRemoval + * @see BackgroundRemoval */ - public static function backgroundRemoval($fineEdges = null, $hints = []) + public static function backgroundRemoval(?bool $fineEdges = null, array $hints = []): BackgroundRemoval { return new BackgroundRemoval($fineEdges, $hints); } @@ -89,14 +87,13 @@ public static function backgroundRemoval($fineEdges = null, $hints = []) * * Use the constants defined in \Cloudinary\Transformation\OrderedDither for $level. * - * @param int $level The level of ordered dither. Use the constants defined in the OrderedDither class. + * @param int|null $level The level of ordered dither. Use the constants defined in the OrderedDither class. * - * @return Dither * - * @see \Cloudinary\Transformation\Dither + * @see Dither * */ - public static function dither($level = null) + public static function dither(?int $level = null): Dither { return new Dither($level); } @@ -106,15 +103,14 @@ public static function dither($level = null) * * You can specify other edges using the x and y methods of the \Cloudinary\Transformation\GradientFade class. * - * @param int $strength The strength of the fade effect. (Range: 0 to 100, Server default: 20) - * @param string $type The type of gradient fade: GradientFade::SYMMETRIC or GradientFade::SYMMETRIC_PAD. + * @param int|null $strength The strength of the fade effect. (Range: 0 to 100, Server default: 20) + * @param string|null $type The type of gradient fade: GradientFade::SYMMETRIC or GradientFade::SYMMETRIC_PAD. * - * @return GradientFade * - * @see \Cloudinary\Transformation\GradientFade + * @see GradientFade * */ - public static function gradientFade($strength = null, $type = null) + public static function gradientFade(?int $strength = null, ?string $type = null): GradientFade { return new GradientFade($strength, $type); } @@ -125,14 +121,13 @@ public static function gradientFade($strength = null, $type = null) * Wherever an overlay image is transparent, the original is shown, and wherever an overlay is opaque, the * resulting image is transparent. * - * @param string|mixed $source The public ID of the source. + * @param mixed|null $source The public ID of the source. * - * @return CutOut * - * @see \Cloudinary\Transformation\CutOut + * @see CutOut * */ - public static function cutOut($source = null) + public static function cutOut(mixed $source = null): CutOut { return new CutOut($source); } diff --git a/src/Transformation/Effect/Pixel/PixelEffect.php b/src/Transformation/Effect/Pixel/PixelEffect.php index 2295d11..d540c25 100644 --- a/src/Transformation/Effect/Pixel/PixelEffect.php +++ b/src/Transformation/Effect/Pixel/PixelEffect.php @@ -16,21 +16,21 @@ abstract class PixelEffect { // Common - const BLUR = 'blur'; - const VIGNETTE = 'vignette'; + public const BLUR = 'blur'; + public const VIGNETTE = 'vignette'; // Image - const BLUR_FACES = 'blur_faces'; - const BLUR_REGION = 'blur_region'; - const PIXELATE = 'pixelate'; - const PIXELATE_REGION = 'pixelate_region'; - const PIXELATE_FACES = 'pixelate_faces'; - const ORDERED_DITHER = 'ordered_dither'; - const GRADIENT_FADE = 'gradient_fade'; - const MAKE_TRANSPARENT = 'make_transparent'; - const REMOVE_BACKGROUND = 'bgremoval'; - const BACKGROUND_REMOVAL = 'background_removal'; - const CUT_OUT = 'cut_out'; + public const BLUR_FACES = 'blur_faces'; + public const BLUR_REGION = 'blur_region'; + public const PIXELATE = 'pixelate'; + public const PIXELATE_REGION = 'pixelate_region'; + public const PIXELATE_FACES = 'pixelate_faces'; + public const ORDERED_DITHER = 'ordered_dither'; + public const GRADIENT_FADE = 'gradient_fade'; + public const MAKE_TRANSPARENT = 'make_transparent'; + public const REMOVE_BACKGROUND = 'bgremoval'; + public const BACKGROUND_REMOVAL = 'background_removal'; + public const CUT_OUT = 'cut_out'; use PixelEffectTrait; use ImagePixelEffectTrait; diff --git a/src/Transformation/Effect/Pixel/PixelEffectTrait.php b/src/Transformation/Effect/Pixel/PixelEffectTrait.php index 49311cc..92c0090 100644 --- a/src/Transformation/Effect/Pixel/PixelEffectTrait.php +++ b/src/Transformation/Effect/Pixel/PixelEffectTrait.php @@ -20,11 +20,10 @@ trait PixelEffectTrait /** * Applies a blurring filter to the asset. * - * @param int $strength The strength of the blur. (Range: 1 to 2000, Server default: 100) + * @param int|null $strength The strength of the blur. (Range: 1 to 2000, Server default: 100) * - * @return Blur */ - public static function blur($strength = null) + public static function blur(?int $strength = null): Blur { return new Blur($strength); } @@ -32,11 +31,10 @@ public static function blur($strength = null) /** * Applies a blurring filter to the faces detected on the asset. * - * @param int $strength The strength of the blur. (Range: 1 to 2000, Server default: 100) + * @param int|null $strength The strength of the blur. (Range: 1 to 2000, Server default: 100) * - * @return Blur */ - public static function blurFaces($strength = null) + public static function blurFaces(?int $strength = null): Blur { return (new Blur($strength))->region(Region::faces()); } @@ -44,27 +42,30 @@ public static function blurFaces($strength = null) /** * Applies a blurring filter to the region on the asset. * - * @param int|string $strength The strength of the blur. (Range: 1 to 2000, Server default: 100) - * @param int|string $x X. - * @param int|string $y Y. - * @param int|string $width Width. - * @param int|string $height Height. + * @param int|string|null $strength The strength of the blur. (Range: 1 to 2000, Server default: 100) + * @param int|string|null $x X. + * @param int|string|null $y Y. + * @param int|string|null $width Width. + * @param int|string|null $height Height. * - * @return Blur */ - public static function blurRegion($strength = null, $x = null, $y = null, $width = null, $height = null) - { + public static function blurRegion( + int|string|null $strength = null, + int|string|null $x = null, + int|string|null $y = null, + int|string|null $width = null, + int|string|null $height = null + ): Blur { return (new Blur($strength))->region(Region::custom($x, $y, $width, $height)); } /** * Applies a vignette effect. * - * @param int $strength The strength of the vignette. (Range: 0 to 100, Server default: 20) + * @param int|null $strength The strength of the vignette. (Range: 0 to 100, Server default: 20) * - * @return StrengthEffectAction */ - public static function vignette($strength = null) + public static function vignette(?int $strength = null): StrengthEffectAction { return EffectAction::withStrength(PixelEffect::VIGNETTE, EffectRange::PERCENT, $strength); } diff --git a/src/Transformation/Effect/Pixel/Pixelate.php b/src/Transformation/Effect/Pixel/Pixelate.php index ea7b154..4f830ea 100644 --- a/src/Transformation/Effect/Pixel/Pixelate.php +++ b/src/Transformation/Effect/Pixel/Pixelate.php @@ -15,14 +15,12 @@ */ class Pixelate extends SquareSizeEffectAction { - const REGION = PixelEffect::PIXELATE_REGION; - const FACES = PixelEffect::PIXELATE_FACES; + public const REGION = PixelEffect::PIXELATE_REGION; + public const FACES = PixelEffect::PIXELATE_FACES; /** * Pixelate constructor. * - * @param $squareSize - * @param mixed ...$args */ public function __construct($squareSize, ...$args) { diff --git a/src/Transformation/Effect/Pixel/RegionEffectAction.php b/src/Transformation/Effect/Pixel/RegionEffectAction.php index 66c20fc..12441a6 100644 --- a/src/Transformation/Effect/Pixel/RegionEffectAction.php +++ b/src/Transformation/Effect/Pixel/RegionEffectAction.php @@ -10,8 +10,6 @@ namespace Cloudinary\Transformation; -use Cloudinary\Transformation\Region; - /** * Class RegionEffectAction */ @@ -22,16 +20,16 @@ class RegionEffectAction extends EffectAction /** * RegionEffectAction constructor. * - * @param string $effectName - * @param array $range - * @param mixed $strength - * @param Region $region - * @param mixed ...$args + * @param string $effectName + * @param array $range + * @param mixed|null $strength + * @param Region|null $region + * @param mixed ...$args */ - public function __construct($effectName, $range, $strength = null, $region = null, ...$args) + public function __construct($effectName, array $range, mixed $strength = null, ?Region $region = null, ...$args) { parent::__construct( - new LimitedEffectQualifier($effectName, $range, $strength), + new LimitedEffectQualifier($effectName, $range, $strength), ...$args ); @@ -41,13 +39,11 @@ public function __construct($effectName, $range, $strength = null, $region = nul /** * Internal setter for the point value. * - * @param mixed $value - * - * @return static + * @param mixed $value The value. * * @internal */ - public function setPointValue($value) + public function setPointValue(mixed $value): static { if (! isset($this->qualifiers[Region::getName()])) { $this->addQualifier(new Region()); @@ -63,11 +59,9 @@ public function setPointValue($value) * * @param Region|mixed $value The dimensions. * - * @return static - * * @internal */ - protected function setDimension($value) + protected function setDimension(mixed $value): static { if (! isset($this->qualifiers[Region::getName()])) { $this->addQualifier(new Region()); diff --git a/src/Transformation/Effect/Pixel/RegionEffectTrait.php b/src/Transformation/Effect/Pixel/RegionEffectTrait.php index 45d28ee..bc778f2 100644 --- a/src/Transformation/Effect/Pixel/RegionEffectTrait.php +++ b/src/Transformation/Effect/Pixel/RegionEffectTrait.php @@ -24,11 +24,10 @@ trait RegionEffectTrait * * @param mixed $value * - * @return static * * @internal */ - public function setPointValue($value) + public function setPointValue($value): static { if (! isset($this->qualifiers[Region::getName()])) { $this->addQualifier(new Region()); @@ -44,11 +43,10 @@ public function setPointValue($value) * * @param Region|mixed $value The dimensions. * - * @return static * * @internal */ - protected function setDimension($value) + protected function setDimension($value): static { if (! isset($this->qualifiers[Region::getName()])) { $this->addQualifier(new Region()); @@ -69,7 +67,7 @@ protected function setDimension($value) * * @internal */ - public function getStringQualifiers() + public function getStringQualifiers(): array { $actionQualifiers = $this->qualifiers; diff --git a/src/Transformation/Effect/Pixel/RemoveBackground.php b/src/Transformation/Effect/Pixel/RemoveBackground.php index 79d48f6..7d77453 100644 --- a/src/Transformation/Effect/Pixel/RemoveBackground.php +++ b/src/Transformation/Effect/Pixel/RemoveBackground.php @@ -30,8 +30,8 @@ */ class RemoveBackground extends EffectAction { - const SCREEN = 'screen'; - const COLOR_TO_REMOVE = 'color_to_remove'; + protected const SCREEN = 'screen'; + protected const COLOR_TO_REMOVE = 'color_to_remove'; /** * RemoveBackground constructor. @@ -57,9 +57,8 @@ public function __construct($screen = false, $colorToRemove = null) * * @param bool $screen Whether to use "screen" mode. * - * @return RemoveBackground */ - public function screen($screen = true) + public function screen(bool $screen = true): static { if ($screen) { $this->getMainQualifier()->getValue()->setSimpleValue(self::SCREEN, self::SCREEN); @@ -71,11 +70,10 @@ public function screen($screen = true) /** * Overrides the algorithm's choice of background color. * - * @param string|Color $colorToRemove The background color as an RGB/A hex code. + * @param string|Color|null $colorToRemove The background color as an RGB/A hex code. * - * @return RemoveBackground */ - public function colorToRemove($colorToRemove) + public function colorToRemove(Color|string|null $colorToRemove): static { if ($colorToRemove) { // dirty hack to omit rgb: from hex colors diff --git a/src/Transformation/Effect/Playback/Accelerate.php b/src/Transformation/Effect/Playback/Accelerate.php index 0e5c949..3830057 100644 --- a/src/Transformation/Effect/Playback/Accelerate.php +++ b/src/Transformation/Effect/Playback/Accelerate.php @@ -37,7 +37,7 @@ public function __construct($rate, ...$args) * * @return $this */ - public function rate($rate) + public function rate(int $rate): static { $this->qualifiers[EffectQualifier::getName()]->setEffectValue($rate); diff --git a/src/Transformation/Effect/Playback/Loop.php b/src/Transformation/Effect/Playback/Loop.php index cdfc6ce..ce81d89 100644 --- a/src/Transformation/Effect/Playback/Loop.php +++ b/src/Transformation/Effect/Playback/Loop.php @@ -33,7 +33,7 @@ public function __construct($additionalIterations, ...$args) * * @return $this */ - public function additionalIterations($additionalIterations) + public function additionalIterations(int $additionalIterations): static { $this->qualifiers[EffectQualifier::getName()]->setEffectValue($additionalIterations); diff --git a/src/Transformation/Effect/Playback/PlaybackEffect.php b/src/Transformation/Effect/Playback/PlaybackEffect.php index 812bc6b..3559a15 100644 --- a/src/Transformation/Effect/Playback/PlaybackEffect.php +++ b/src/Transformation/Effect/Playback/PlaybackEffect.php @@ -15,13 +15,13 @@ */ abstract class PlaybackEffect { - const ACCELERATE = 'accelerate'; - const LOOP = 'loop'; - const BOOMERANG = 'boomerang'; - const PREVIEW = 'preview'; - const REVERSE = 'reverse'; - const VOLUME = 'volume'; - const TRANSITION = 'transition'; + public const ACCELERATE = 'accelerate'; + public const LOOP = 'loop'; + public const BOOMERANG = 'boomerang'; + public const PREVIEW = 'preview'; + public const REVERSE = 'reverse'; + public const VOLUME = 'volume'; + public const TRANSITION = 'transition'; use PlaybackEffectTrait; } diff --git a/src/Transformation/Effect/Playback/PlaybackEffectTrait.php b/src/Transformation/Effect/Playback/PlaybackEffectTrait.php index 4279fc7..f02ec54 100644 --- a/src/Transformation/Effect/Playback/PlaybackEffectTrait.php +++ b/src/Transformation/Effect/Playback/PlaybackEffectTrait.php @@ -22,12 +22,11 @@ trait PlaybackEffectTrait /** * Changes the speed of the video playback. * - * @param int $rate The percentage change of speed. Positive numbers speed up the playback, negative numbers + * @param int|null $rate The percentage change of speed. Positive numbers speed up the playback, negative numbers * slow down the playback (Range: -50 to 100, Server default: 0). * - * @return Accelerate */ - public static function accelerate($rate = null) + public static function accelerate(?int $rate = null): Accelerate { return new Accelerate($rate); } @@ -39,11 +38,10 @@ public static function accelerate($rate = null) * to deliver a classic (short, repeating) boomerang clip. * For details and examples, see 'Create a boomerang video clip' in the Video Transformations guide. * - * @return EffectAction * * @see https://cloudinary.com/documentation/video_manipulation_and_delivery#create_a_boomerang_video_clip */ - public static function boomerang() + public static function boomerang(): EffectAction { return EffectAction::named(PlaybackEffect::BOOMERANG); } @@ -55,11 +53,10 @@ public static function boomerang() * * For animated images (GIF), see Animated::edit()->loop(). * - * @param int $additionalIterations The additional number of times to play the video. + * @param int|null $additionalIterations The additional number of times to play the video. * - * @return Loop */ - public static function loop($additionalIterations = null) + public static function loop(?int $additionalIterations = null): Loop { return new Loop($additionalIterations); } @@ -67,9 +64,8 @@ public static function loop($additionalIterations = null) /** * Plays the video or audio file in reverse. * - * @return EffectAction */ - public static function reverse() + public static function reverse(): EffectAction { return EffectAction::named(PlaybackEffect::REVERSE); } @@ -81,11 +77,10 @@ public static function reverse() * * @param int|Volume $level The percentage change of volume (Range: -100 to 400). * - * @return EffectAction * - * @see \Cloudinary\Transformation\Volume + * @see Volume */ - public static function volume($level) + public static function volume(Volume|int $level): EffectAction { return EffectAction::fromEffectQualifier(ClassUtils::verifyInstance($level, Volume::class)); } @@ -93,9 +88,8 @@ public static function volume($level) /** * Indicates that the video overlay is to be used as a transition between the base and second video. * - * @return EffectAction */ - public static function transition() + public static function transition(): EffectAction { return EffectAction::named(PlaybackEffect::TRANSITION); } diff --git a/src/Transformation/Effect/Playback/Preview.php b/src/Transformation/Effect/Playback/Preview.php index f862940..58d6a86 100644 --- a/src/Transformation/Effect/Playback/Preview.php +++ b/src/Transformation/Effect/Playback/Preview.php @@ -24,9 +24,9 @@ class Preview extends EffectAction * * @param mixed|object $duration * @param mixed $maximumSegments - * @param mixed $minimumSegmentDuration + * @param mixed|null $minimumSegmentDuration */ - public function __construct($duration = null, $maximumSegments = null, $minimumSegmentDuration = null) + public function __construct($duration = null, $maximumSegments = null, mixed $minimumSegmentDuration = null) { parent::__construct(PlaybackEffect::PREVIEW); @@ -38,21 +38,15 @@ public function __construct($duration = null, $maximumSegments = null, $minimumS /** * @param mixed|object $duration * - * @return Preview */ - public function duration($duration) + public function duration(mixed $duration): static { $this->getMainQualifier()->add(ClassUtils::verifyInstance($duration, PreviewDuration::class)); return $this; } - /** - * @param $maximumSegments - * - * @return Preview - */ - public function maximumSegments($maximumSegments) + public function maximumSegments($maximumSegments): static { if ($maximumSegments) { $this->getMainQualifier()->add(new GenericNamedArgument('max_seg', $maximumSegments)); @@ -61,12 +55,7 @@ public function maximumSegments($maximumSegments) return $this; } - /** - * @param $minimumSegmentDuration - * - * @return Preview - */ - public function minimumSegmentDuration($minimumSegmentDuration) + public function minimumSegmentDuration($minimumSegmentDuration): static { if ($minimumSegmentDuration) { $this->getMainQualifier()->add(new GenericNamedArgument('min_seg_dur', $minimumSegmentDuration)); diff --git a/src/Transformation/Effect/Playback/Volume.php b/src/Transformation/Effect/Playback/Volume.php index 6d34119..3b1e501 100644 --- a/src/Transformation/Effect/Playback/Volume.php +++ b/src/Transformation/Effect/Playback/Volume.php @@ -23,7 +23,7 @@ */ class Volume extends LimitedEffectQualifier { - const MUTE = 'mute'; + public const MUTE = 'mute'; /** * Volume constructor. @@ -40,11 +40,9 @@ public function __construct($volume = null) /** * Named Volume constructor. * - * @param mixed $volume * - * @return Volume */ - public static function volume($volume) + public static function volume(mixed $volume): Volume { return new self($volume); } @@ -54,9 +52,8 @@ public static function volume($volume) * * @param int $dBOffset The offset in dB. * - * @return Volume */ - public static function byDecibels($dBOffset) + public static function byDecibels(int $dBOffset): Volume { return new self(TransformationUtils::formatSigned($dBOffset) . 'dB'); } @@ -66,9 +63,8 @@ public static function byDecibels($dBOffset) * * @param int $level The percentage change of volume (Range: -100 to 400). * - * @return Volume */ - public static function byPercent($level) + public static function byPercent(int $level): Volume { return new self($level); } @@ -79,9 +75,8 @@ public static function byPercent($level) * You can use this on the base video to deliver a video without sound, or with a video overlay * to ensure that only the sound from the base video plays. * - * @return Volume */ - public static function mute() + public static function mute(): Volume { return new self(self::MUTE); } @@ -89,11 +84,10 @@ public static function mute() /** * Increases or decreases the volume by a percentage of the current volume. * - * @param int $value The percentage change of volume (Range: -100 to 400). + * @param int|string $value The percentage change of volume (Range: -100 to 400). * - * @return Volume */ - protected function setVolume($value) + protected function setVolume(int|string $value): static { $this->value->setSimpleValue('volume', $value); diff --git a/src/Transformation/Effect/SquareSizeEffectAction.php b/src/Transformation/Effect/SquareSizeEffectAction.php index 04a9dd1..7b45685 100644 --- a/src/Transformation/Effect/SquareSizeEffectAction.php +++ b/src/Transformation/Effect/SquareSizeEffectAction.php @@ -22,7 +22,7 @@ class SquareSizeEffectAction extends EffectAction * * @return $this */ - public function squareSize($squareSize) + public function squareSize(int $squareSize): static { $this->qualifiers[EffectQualifier::getName()]->squareSize($squareSize); diff --git a/src/Transformation/Effect/SquareSizeEffectQualifier.php b/src/Transformation/Effect/SquareSizeEffectQualifier.php index 0e75570..3a79cfb 100644 --- a/src/Transformation/Effect/SquareSizeEffectQualifier.php +++ b/src/Transformation/Effect/SquareSizeEffectQualifier.php @@ -24,11 +24,10 @@ class SquareSizeEffectQualifier extends LimitedEffectQualifier * * @param int $squareSize The square size to set. * - * @return SquareSizeEffectQualifier * * @internal */ - public function squareSize($squareSize) + public function squareSize(int $squareSize): static { $this->setEffectValue($squareSize); diff --git a/src/Transformation/Effect/StrengthEffectAction.php b/src/Transformation/Effect/StrengthEffectAction.php index bbcc8b2..fcb072e 100644 --- a/src/Transformation/Effect/StrengthEffectAction.php +++ b/src/Transformation/Effect/StrengthEffectAction.php @@ -18,11 +18,11 @@ class StrengthEffectAction extends EffectAction /** * Setter of the effect strength. * - * @param int $strength The strength to set. + * @param int|string|null $strength The strength to set. * * @return $this */ - public function strength($strength) + public function strength(int|string|null $strength): static { $this->qualifiers[EffectQualifier::getName()]->strength($strength); diff --git a/src/Transformation/Effect/StrengthEffectQualifier.php b/src/Transformation/Effect/StrengthEffectQualifier.php index acacdb1..da97cc5 100644 --- a/src/Transformation/Effect/StrengthEffectQualifier.php +++ b/src/Transformation/Effect/StrengthEffectQualifier.php @@ -22,13 +22,12 @@ class StrengthEffectQualifier extends LimitedEffectQualifier /** * Setter of the effect strength. * - * @param int $strength The strength to set. + * @param int|string|null $strength The strength to set. * - * @return StrengthEffectQualifier * * @internal */ - public function strength($strength) + public function strength(int|string|null $strength): static { $this->setEffectValue($strength); diff --git a/src/Transformation/Effect/ThresholdEffectAction.php b/src/Transformation/Effect/ThresholdEffectAction.php index bf44124..1a9dcb3 100644 --- a/src/Transformation/Effect/ThresholdEffectAction.php +++ b/src/Transformation/Effect/ThresholdEffectAction.php @@ -22,7 +22,7 @@ class ThresholdEffectAction extends EffectAction * * @return $this */ - public function threshold($threshold) + public function threshold(int $threshold): static { $this->qualifiers[EffectQualifier::getName()]->threshold($threshold); diff --git a/src/Transformation/Effect/ThresholdEffectQualifier.php b/src/Transformation/Effect/ThresholdEffectQualifier.php index 1278406..f29d591 100644 --- a/src/Transformation/Effect/ThresholdEffectQualifier.php +++ b/src/Transformation/Effect/ThresholdEffectQualifier.php @@ -24,11 +24,10 @@ class ThresholdEffectQualifier extends LimitedEffectQualifier * * @param int $threshold The threshold to set. * - * @return ThresholdEffectQualifier * * @internal */ - public function threshold($threshold) + public function threshold(int $threshold): static { $this->setEffectValue($threshold); diff --git a/src/Transformation/Effect/ToleranceEffectAction.php b/src/Transformation/Effect/ToleranceEffectAction.php index 90242fc..075deb2 100644 --- a/src/Transformation/Effect/ToleranceEffectAction.php +++ b/src/Transformation/Effect/ToleranceEffectAction.php @@ -22,7 +22,7 @@ class ToleranceEffectAction extends EffectAction * * @return $this */ - public function tolerance($tolerance) + public function tolerance(int $tolerance): static { $this->qualifiers[EffectQualifier::getName()]->tolerance($tolerance); diff --git a/src/Transformation/Effect/ToleranceEffectQualifier.php b/src/Transformation/Effect/ToleranceEffectQualifier.php index 1291023..71ea2be 100644 --- a/src/Transformation/Effect/ToleranceEffectQualifier.php +++ b/src/Transformation/Effect/ToleranceEffectQualifier.php @@ -24,11 +24,10 @@ class ToleranceEffectQualifier extends LimitedEffectQualifier * * @param int $tolerance The level of tolerance to set. * - * @return LimitedEffectQualifier * * @internal */ - public function tolerance($tolerance) + public function tolerance(int $tolerance): LimitedEffectQualifier { $this->setEffectValue($tolerance); diff --git a/src/Transformation/Effect/ValueEffectQualifier.php b/src/Transformation/Effect/ValueEffectQualifier.php index d7f1c25..18c3341 100644 --- a/src/Transformation/Effect/ValueEffectQualifier.php +++ b/src/Transformation/Effect/ValueEffectQualifier.php @@ -39,7 +39,7 @@ public function __construct($name, $value = null, ...$qualifiers) * * @internal */ - public function setEffectValue($value) + public function setEffectValue(mixed $value): static { $this->value->setSimpleValue('value', $value); diff --git a/src/Transformation/Expression/BaseExpression.php b/src/Transformation/Expression/BaseExpression.php index afbd8cb..7a2371b 100644 --- a/src/Transformation/Expression/BaseExpression.php +++ b/src/Transformation/Expression/BaseExpression.php @@ -18,14 +18,13 @@ abstract class BaseExpression extends BaseExpressionComponent { /** - * @var ExpressionComponent $exprValue The expression value. + * @var ExpressionComponent|string|null $exprValue The expression value. */ - protected $exprValue; + protected ExpressionComponent|string|null $exprValue; /** * ExpressionComponent constructor. * - * @param $exprUserVariableName */ public function __construct($exprUserVariableName) { @@ -37,11 +36,10 @@ public function __construct($exprUserVariableName) /** * Internal expression builder. * - * @param mixed $operator The operator to use for building the expression. + * @param ArithmeticOperator|string|null $operator The operator to use for building the expression. * - * @return ExpressionOperator */ - protected function buildExpression($operator) + protected function buildExpression(ArithmeticOperator|string|null $operator): ExpressionOperator { return new ExpressionOperator(new ExpressionComponent($this->exprValue, $operator)); } @@ -49,11 +47,9 @@ protected function buildExpression($operator) /** * Sets the right operand. * - * @param $rightOperand * - * @return Expression */ - protected function setRightOperand($rightOperand) + protected function setRightOperand($rightOperand): Expression { $this->exprValue->setRightOperand($rightOperand); @@ -74,9 +70,8 @@ public function __toString() /** * Serializes to JSON. * - * @return mixed */ - public function jsonSerialize() + public function jsonSerialize(): array { return $this->exprValue->jsonSerialize(); } diff --git a/src/Transformation/Expression/Expression.php b/src/Transformation/Expression/Expression.php index 9475091..1c814d7 100644 --- a/src/Transformation/Expression/Expression.php +++ b/src/Transformation/Expression/Expression.php @@ -32,9 +32,8 @@ class Expression extends BaseExpression * * @param string $expression Arithmetic expression * - * @return static */ - public static function expression($expression) + public static function expression(string $expression): static { return new static($expression); } diff --git a/src/Transformation/Expression/ExpressionComponent.php b/src/Transformation/Expression/ExpressionComponent.php index 1b76121..676cb55 100644 --- a/src/Transformation/Expression/ExpressionComponent.php +++ b/src/Transformation/Expression/ExpressionComponent.php @@ -20,32 +20,32 @@ class ExpressionComponent extends BaseExpressionComponent /** * @var string EXPRESSION_DELIMITER The delimiter between expression components. */ - const EXPRESSION_DELIMITER = '_'; + protected const EXPRESSION_DELIMITER = '_'; /** * @var mixed $leftOperand The left operand. */ - protected $leftOperand; + protected mixed $leftOperand; /** - * @var string $operator The operator + * @var BaseOperator|string|null $operator The operator */ - protected $operator; + protected BaseOperator|string|null $operator; /** * @var mixed The right operand. */ - protected $rightOperand; + protected mixed $rightOperand; /** * ExpressionComponent constructor. * - * @param $leftOperand - * @param $operator - * @param $rightOperand */ - public function __construct($leftOperand, $operator = null, $rightOperand = null) - { + public function __construct( + mixed $leftOperand, + BaseOperator|string|null $operator = null, + mixed $rightOperand = null + ) { parent::__construct(); $this->leftOperand = $leftOperand; @@ -56,9 +56,9 @@ public function __construct($leftOperand, $operator = null, $rightOperand = null /** * Sets the expression operator. * - * @param string $operator The operator + * @param BaseOperator|string|null $operator The operator */ - public function setOperator($operator) + public function setOperator(BaseOperator|string|null $operator): void { $this->operator = $operator; } @@ -66,9 +66,8 @@ public function setOperator($operator) /** * Sets the right operand. * - * @param $rightOperand */ - public function setRightOperand($rightOperand) + public function setRightOperand(mixed $rightOperand): void { $this->rightOperand = $rightOperand; } @@ -88,10 +87,8 @@ public function __toString() /** * Serializes to json. - * - * @return mixed */ - public function jsonSerialize() + public function jsonSerialize(): array { return [ 'left_operand' => $this->leftOperand, diff --git a/src/Transformation/Expression/ExpressionTrait.php b/src/Transformation/Expression/ExpressionTrait.php index 7cd1c4b..3509f62 100644 --- a/src/Transformation/Expression/ExpressionTrait.php +++ b/src/Transformation/Expression/ExpressionTrait.php @@ -22,9 +22,8 @@ trait ExpressionTrait * * @param mixed $value The expression value. * - * @return static */ - public function expression($value) + public function expression(mixed $value): Expression { return $this->setRightOperand($value); } diff --git a/src/Transformation/Expression/ExpressionUtils.php b/src/Transformation/Expression/ExpressionUtils.php index c33dbbb..8f24d47 100644 --- a/src/Transformation/Expression/ExpressionUtils.php +++ b/src/Transformation/Expression/ExpressionUtils.php @@ -22,31 +22,31 @@ class ExpressionUtils /** * @var array $OPERATORS A list of supported operators (arithmetic, logical, relational). */ - private static $OPERATORS; + private static array $OPERATORS; /** * @var array $PREDEFINED_VARIABLES A list of supported predefined variables. */ - private static $PREDEFINED_VARIABLES; + private static array $PREDEFINED_VARIABLES; /** * @var string $IF_REPLACE_RE Operators and predefined variables serialisation regular expression. * * @see ExpressionUtils::lazyInit */ - private static $IF_REPLACE_RE; + private static string $IF_REPLACE_RE; /** * Normalizes expression from user representation to URL form. * * @param mixed $expression The expression to normalize. * - * @return string The normalized expression. + * @return ?string The normalized expression. * * @uses translateIf() * */ - public static function normalize($expression) + public static function normalize(mixed $expression): ?string { if ($expression === null || self::isLiteral($expression)) { return $expression; @@ -60,15 +60,11 @@ public static function normalize($expression) $expression = preg_replace('/[ _]+/', '_', $expression); - $expression = preg_replace_callback( + return preg_replace_callback( self::$IF_REPLACE_RE, - static function (array $source) { - return self::translateIf($source); - }, + static fn(array $source) => self::translateIf($source), $expression ); - - return $expression; } /** @@ -76,7 +72,7 @@ static function (array $source) { * * @see ExpressionUtils::$IF_REPLACE_RE */ - private static function lazyInit() + private static function lazyInit(): void { if (! empty(self::$IF_REPLACE_RE)) { return; //initialized last, if initialized, all the rest is OK @@ -104,11 +100,10 @@ private static function lazyInit() * * @param array $source The source to translate. * - * @return mixed * * @see normalize() */ - protected static function translateIf($source) + protected static function translateIf(array $source): mixed { if (isset(self::$OPERATORS[$source[0]])) { return self::$OPERATORS[$source[0]]; @@ -126,9 +121,8 @@ protected static function translateIf($source) * * @param string $expression The expression * - * @return bool */ - protected static function isLiteral($expression) + protected static function isLiteral(string $expression): bool { return (boolean)preg_match('/^!.+!$/', $expression); } diff --git a/src/Transformation/Expression/Operand/Value/UVal.php b/src/Transformation/Expression/Operand/Value/UVal.php index 1f886fb..8cba085 100644 --- a/src/Transformation/Expression/Operand/Value/UVal.php +++ b/src/Transformation/Expression/Operand/Value/UVal.php @@ -32,9 +32,8 @@ class UVal extends Expression * * @param int $value The int value. * - * @return Expression */ - public static function int($value) + public static function int(int $value): Expression|UVal { return self::uVal($value); } @@ -44,9 +43,8 @@ public static function int($value) * * @param float $value The float value. * - * @return self */ - public static function float($value) + public static function float(float $value): UVal { return self::uVal($value); } @@ -56,9 +54,8 @@ public static function float($value) * * @param mixed $value The numeric value. Can be used for aspect ratio, for example "16:9", etc. * - * @return self */ - public static function numeric($value) + public static function numeric(mixed $value): UVal { return self::uVal($value); } @@ -68,9 +65,8 @@ public static function numeric($value) * * @param string $value The string value * - * @return self */ - public static function string($value) + public static function string(string $value): UVal { return self::uVal(StringUtils::ensureWrappedWith($value, self::STRING_MARKER)); } @@ -80,9 +76,8 @@ public static function string($value) * * @param array $array The array of strings. * - * @return self */ - public static function stringArray($array) + public static function stringArray(array $array): UVal { return self::string(implode(self::STRING_ARR_DELIM, $array)); } @@ -92,9 +87,8 @@ public static function stringArray($array) * * @param string $publicId The public ID of the file. * - * @return self */ - public static function assetReference($publicId) + public static function assetReference(string $publicId): UVal { $publicId = StringUtils::ensureWrappedWith($publicId, self::STRING_MARKER); @@ -106,9 +100,8 @@ public static function assetReference($publicId) * * @param string $contextKey The context key. * - * @return self */ - public static function context($contextKey) + public static function context(string $contextKey): UVal { $contextKey = StringUtils::ensureWrappedWith($contextKey, self::STRING_MARKER); @@ -120,9 +113,8 @@ public static function context($contextKey) * * @param string $metadataKey The structured metadata key. * - * @return self */ - public static function metadata($metadataKey) + public static function metadata(string $metadataKey): UVal { $metadataKey = StringUtils::ensureWrappedWith($metadataKey, self::STRING_MARKER); @@ -134,9 +126,8 @@ public static function metadata($metadataKey) * * @param mixed $value The value. * - * @return self */ - public static function uVal($value) + public static function uVal(mixed $value): UVal { return new self($value); } diff --git a/src/Transformation/Expression/Operand/Value/ValueBuilderTrait.php b/src/Transformation/Expression/Operand/Value/ValueBuilderTrait.php index 1de4b2b..31bdc46 100644 --- a/src/Transformation/Expression/Operand/Value/ValueBuilderTrait.php +++ b/src/Transformation/Expression/Operand/Value/ValueBuilderTrait.php @@ -22,9 +22,8 @@ trait ValueBuilderTrait * * @param int $value The value. * - * @return Expression */ - public function int($value) + public function int(int $value): Expression { return $this->setRightOperand(UVal::int($value)); } @@ -34,9 +33,8 @@ public function int($value) * * @param float $value The value. * - * @return Expression */ - public function float($value) + public function float(float $value): Expression { return $this->setRightOperand(UVal::float($value)); } @@ -46,9 +44,8 @@ public function float($value) * * @param int|float|mixed $value The value. * - * @return Expression */ - public function numeric($value) + public function numeric(mixed $value): Expression { return $this->setRightOperand(UVal::numeric($value)); } @@ -58,9 +55,8 @@ public function numeric($value) * * @param string $value The value. * - * @return Expression */ - public function string($value) + public function string(string $value): Expression { return $this->setRightOperand(UVal::string($value)); } @@ -70,9 +66,8 @@ public function string($value) * * @param array $value The array value. * - * @return Expression */ - public function stringArray($value) + public function stringArray(array $value): Expression { return $this->setRightOperand(UVal::stringArray($value)); } @@ -82,9 +77,8 @@ public function stringArray($value) * * @param string $publicId The public ID of the file. * - * @return Expression */ - public function assetReference($publicId) + public function assetReference(string $publicId): Expression { return $this->setRightOperand(UVal::assetReference($publicId)); } diff --git a/src/Transformation/Expression/Operand/Variable/Predefined/PVar.php b/src/Transformation/Expression/Operand/Variable/Predefined/PVar.php index 715f771..a6caacd 100644 --- a/src/Transformation/Expression/Operand/Variable/Predefined/PVar.php +++ b/src/Transformation/Expression/Operand/Variable/Predefined/PVar.php @@ -24,30 +24,30 @@ class PVar extends Expression { // Numeric variables - const WIDTH = 'w'; - const INITIAL_WIDTH = 'iw'; - const HEIGHT = 'h'; - const INITIAL_HEIGHT = 'ih'; - const ASPECT_RATIO = 'ar'; - const INITIAL_ASPECT_RATIO = 'iar'; - const TRIMMED_ASPECT_RATIO = 'tar'; - const PAGE_COUNT = 'pc'; - const DURATION = 'du'; - const INITIAL_DURATION = 'idu'; - const FACE_COUNT = 'fc'; - const ILLUSTRATION_SCORE = 'ils'; - const CURRENT_PAGE = 'cp'; - const PAGE_X = 'px'; - const PAGE_Y = 'py'; + public const WIDTH = 'w'; + public const INITIAL_WIDTH = 'iw'; + public const HEIGHT = 'h'; + public const INITIAL_HEIGHT = 'ih'; + public const ASPECT_RATIO = 'ar'; + public const INITIAL_ASPECT_RATIO = 'iar'; + public const TRIMMED_ASPECT_RATIO = 'tar'; + public const PAGE_COUNT = 'pc'; + public const DURATION = 'du'; + public const INITIAL_DURATION = 'idu'; + public const FACE_COUNT = 'fc'; + public const ILLUSTRATION_SCORE = 'ils'; + public const CURRENT_PAGE = 'cp'; + public const PAGE_X = 'px'; + public const PAGE_Y = 'py'; // String variables - const TAGS = 'tags'; - const CONTEXT = 'ctx'; + public const TAGS = 'tags'; + public const CONTEXT = 'ctx'; /** * @var array The friendly representations of the predefined variables. */ - protected static $friendlyRepresentations = [ + protected static array $friendlyRepresentations = [ 'width' => self::WIDTH, 'height' => self::HEIGHT, 'initial_width' => self::INITIAL_WIDTH, @@ -82,11 +82,11 @@ class PVar extends Expression use PredefinedVariableTrait; /** - * @var array The predefined variables. + * @var ?array The predefined variables. * * Initialized lazily. */ - protected static $predefinedVariables; + protected static ?array $predefinedVariables; /** * PVar constructor. @@ -107,7 +107,7 @@ public function __construct($name) * * @return array The predefined variables. */ - public static function getPredefinedVariables() + public static function getPredefinedVariables(): array { return self::getConstants(self::$predefinedVariables); } @@ -115,9 +115,8 @@ public static function getPredefinedVariables() /** * Gets a mapping of the friendly representations of the predefined variables. * - * @return array */ - public static function getFriendlyRepresentations() + public static function getFriendlyRepresentations(): array { return self::$friendlyRepresentations; } @@ -127,11 +126,10 @@ public static function getFriendlyRepresentations() * * @param mixed $candidate The predefined variable candidate. * - * @return bool */ - protected static function isPredefinedVariable($candidate) + protected static function isPredefinedVariable(mixed $candidate): bool { - return in_array($candidate, self::getPredefinedVariables(), false); + return in_array($candidate, self::getPredefinedVariables()); } /** @@ -139,9 +137,8 @@ protected static function isPredefinedVariable($candidate) * * @param string $predefinedVariableName The predefined variable name. * - * @return static */ - protected static function pVar($predefinedVariableName) + protected static function pVar(string $predefinedVariableName): static { return new static($predefinedVariableName); } diff --git a/src/Transformation/Expression/Operand/Variable/Predefined/PredefinedVariableBuilderTrait.php b/src/Transformation/Expression/Operand/Variable/Predefined/PredefinedVariableBuilderTrait.php index 5395d38..c45a8ab 100644 --- a/src/Transformation/Expression/Operand/Variable/Predefined/PredefinedVariableBuilderTrait.php +++ b/src/Transformation/Expression/Operand/Variable/Predefined/PredefinedVariableBuilderTrait.php @@ -20,9 +20,8 @@ trait PredefinedVariableBuilderTrait /** * The asset's current width. * - * @return Expression */ - public function width() + public function width(): Expression { return $this->setRightOperand(PVar::WIDTH); } @@ -30,9 +29,8 @@ public function width() /** * The asset's initial width. * - * @return Expression */ - public function initialWidth() + public function initialWidth(): Expression { return $this->setRightOperand(PVar::INITIAL_WIDTH); } @@ -40,9 +38,8 @@ public function initialWidth() /** * The asset's current height. * - * @return Expression */ - public function height() + public function height(): Expression { return $this->setRightOperand(PVar::HEIGHT); } @@ -50,9 +47,8 @@ public function height() /** * The asset's initial height. * - * @return Expression */ - public function initialHeight() + public function initialHeight(): Expression { return $this->setRightOperand(PVar::INITIAL_HEIGHT); } @@ -60,9 +56,8 @@ public function initialHeight() /** * The aspect ratio of the asset. The compared value can be either decimal (e.g., 1.5) or a ratio (e.g., 3:4) * - * @return Expression */ - public function aspectRatio() + public function aspectRatio(): Expression { return $this->setRightOperand(PVar::ASPECT_RATIO); } @@ -70,9 +65,8 @@ public function aspectRatio() /** * The initial aspect ratio of the asset. * - * @return Expression */ - public function initialAspectRatio() + public function initialAspectRatio(): Expression { return $this->setRightOperand(PVar::INITIAL_ASPECT_RATIO); } @@ -83,11 +77,10 @@ public function initialAspectRatio() * * The compared value can be either decimal (e.g., 1.5) or a ratio (e.g., 3:4). * - * @return Expression * * @see Effect::trim */ - public function trimmedAspectRatio() + public function trimmedAspectRatio(): Expression { return $this->setRightOperand(PVar::TRIMMED_ASPECT_RATIO); } @@ -95,9 +88,8 @@ public function trimmedAspectRatio() /** * The total number of pages in the image/document. * - * @return Expression */ - public function pageCount() + public function pageCount(): Expression { return $this->setRightOperand(PVar::PAGE_COUNT); } @@ -105,9 +97,8 @@ public function pageCount() /** * The total number of detected faces in the image. * - * @return Expression */ - public function faceCount() + public function faceCount(): Expression { return $this->setRightOperand(PVar::FACE_COUNT); } @@ -116,9 +107,8 @@ public function faceCount() * The likelihood that the image is an illustration (as opposed to a photo). * Supported values: 0 (photo) to 1 (illustration) * - * @return Expression */ - public function illustrationScore() + public function illustrationScore(): Expression { return $this->setRightOperand(PVar::ILLUSTRATION_SCORE); } @@ -126,9 +116,8 @@ public function illustrationScore() /** * The current page in the image/document. * - * @return Expression */ - public function currentPage() + public function currentPage(): Expression { return $this->setRightOperand(PVar::CURRENT_PAGE); } @@ -136,9 +125,8 @@ public function currentPage() /** * The page X. * - * @return Expression */ - public function pageX() + public function pageX(): Expression { return $this->setRightOperand(PVar::PAGE_X); } @@ -146,9 +134,8 @@ public function pageX() /** * The page Y. * - * @return Expression */ - public function pageY() + public function pageY(): Expression { return $this->setRightOperand(PVar::PAGE_Y); } @@ -161,12 +148,11 @@ public function pageY() * Note: The syntax for this characteristic is slightly different: * if_!!_in_tags, where the : delimiter denotes AND. * - * @return Expression * * @see Expression::in * @see Expression::notIn */ - public function tags() + public function tags(): Expression { return $this->setRightOperand(PVar::TAGS); } @@ -174,9 +160,8 @@ public function tags() /** * A context value assigned to an asset. * - * @return Expression */ - public function context() + public function context(): Expression { return $this->setRightOperand(PVar::CONTEXT); } @@ -186,9 +171,8 @@ public function context() * * @param string $genericPredefinedVariable The name of the predefined variable * - * @return Expression */ - public function generic($genericPredefinedVariable) + public function generic(string $genericPredefinedVariable): Expression { return $this->setRightOperand($genericPredefinedVariable); } diff --git a/src/Transformation/Expression/Operand/Variable/Predefined/PredefinedVariableTrait.php b/src/Transformation/Expression/Operand/Variable/Predefined/PredefinedVariableTrait.php index f4570e9..5eb543f 100644 --- a/src/Transformation/Expression/Operand/Variable/Predefined/PredefinedVariableTrait.php +++ b/src/Transformation/Expression/Operand/Variable/Predefined/PredefinedVariableTrait.php @@ -20,9 +20,8 @@ trait PredefinedVariableTrait /** * Predefined variable width. * - * @return static */ - public static function width() + public static function width(): static { return static::pVar(static::WIDTH); } @@ -30,9 +29,8 @@ public static function width() /** * Predefined variable initialWidth. * - * @return static */ - public static function initialWidth() + public static function initialWidth(): static { return static::pVar(static::INITIAL_WIDTH); } @@ -40,9 +38,8 @@ public static function initialWidth() /** * Predefined variable height. * - * @return static */ - public static function height() + public static function height(): static { return static::pVar(static::HEIGHT); } @@ -50,9 +47,8 @@ public static function height() /** * Predefined variable initialHeight. * - * @return static */ - public static function initialHeight() + public static function initialHeight(): static { return static::pVar(static::INITIAL_HEIGHT); } @@ -60,9 +56,8 @@ public static function initialHeight() /** * Predefined variable aspectRatio. * - * @return static */ - public static function aspectRatio() + public static function aspectRatio(): static { return static::pVar(static::ASPECT_RATIO); } @@ -70,9 +65,8 @@ public static function aspectRatio() /** * Predefined variable initialAspectRatio. * - * @return static */ - public static function initialAspectRatio() + public static function initialAspectRatio(): static { return static::pVar(static::INITIAL_ASPECT_RATIO); } @@ -80,9 +74,8 @@ public static function initialAspectRatio() /** * Predefined variable trimmedAspectRatio. * - * @return static */ - public static function trimmedAspectRatio() + public static function trimmedAspectRatio(): static { return static::pVar(static::TRIMMED_ASPECT_RATIO); } @@ -90,9 +83,8 @@ public static function trimmedAspectRatio() /** * Predefined variable pageCount. * - * @return static */ - public static function pageCount() + public static function pageCount(): static { return static::pVar(static::PAGE_COUNT); } @@ -100,9 +92,8 @@ public static function pageCount() /** * Predefined variable duration. * - * @return static */ - public static function duration() + public static function duration(): static { return static::pVar(static::DURATION); } @@ -110,9 +101,8 @@ public static function duration() /** * Predefined variable initialDuration. * - * @return static */ - public static function initialDuration() + public static function initialDuration(): static { return static::pVar(static::INITIAL_DURATION); } @@ -120,9 +110,8 @@ public static function initialDuration() /** * Predefined variable faceCount. * - * @return static */ - public static function faceCount() + public static function faceCount(): static { return static::pVar(static::FACE_COUNT); } @@ -130,9 +119,8 @@ public static function faceCount() /** * Predefined variable illustrationScore. * - * @return static */ - public static function illustrationScore() + public static function illustrationScore(): static { return static::pVar(static::ILLUSTRATION_SCORE); } @@ -140,9 +128,8 @@ public static function illustrationScore() /** * Predefined variable currentPage. * - * @return static */ - public static function currentPage() + public static function currentPage(): static { return static::pVar(static::CURRENT_PAGE); } @@ -150,9 +137,8 @@ public static function currentPage() /** * Predefined variable pageX. * - * @return static */ - public static function pageX() + public static function pageX(): static { return static::pVar(static::PAGE_X); } @@ -160,9 +146,8 @@ public static function pageX() /** * Predefined variable pageY. * - * @return static */ - public static function pageY() + public static function pageY(): static { return static::pVar(static::PAGE_Y); } @@ -170,9 +155,8 @@ public static function pageY() /** * Predefined variable tags. * - * @return static */ - public static function tags() + public static function tags(): static { return static::pVar(static::TAGS); } @@ -180,9 +164,8 @@ public static function tags() /** * Predefined variable context. * - * @return static */ - public static function context() + public static function context(): static { return static::pVar(static::CONTEXT); } diff --git a/src/Transformation/Expression/Operand/Variable/User/UVar.php b/src/Transformation/Expression/Operand/Variable/User/UVar.php index eab76bf..2fa0016 100644 --- a/src/Transformation/Expression/Operand/Variable/User/UVar.php +++ b/src/Transformation/Expression/Operand/Variable/User/UVar.php @@ -45,9 +45,8 @@ public function __construct($userVariableName) * * @param string $userVariableName The user variable name. * - * @return UVar */ - public static function uVar($userVariableName) + public static function uVar(string $userVariableName): UVar { return new self($userVariableName); } diff --git a/src/Transformation/Expression/Operand/Variable/User/UserVariableBuilderTrait.php b/src/Transformation/Expression/Operand/Variable/User/UserVariableBuilderTrait.php index 18e928b..fc6f35d 100644 --- a/src/Transformation/Expression/Operand/Variable/User/UserVariableBuilderTrait.php +++ b/src/Transformation/Expression/Operand/Variable/User/UserVariableBuilderTrait.php @@ -22,9 +22,8 @@ trait UserVariableBuilderTrait * * @param string $variableName The user variable name. * - * @return Expression */ - public function uVar($variableName) + public function uVar(string $variableName): Expression { return $this->setRightOperand(UVar::uVar($variableName)); } diff --git a/src/Transformation/Expression/Operator/ArithmeticOperator.php b/src/Transformation/Expression/Operator/ArithmeticOperator.php index 182ef3a..f19afb2 100644 --- a/src/Transformation/Expression/Operator/ArithmeticOperator.php +++ b/src/Transformation/Expression/Operator/ArithmeticOperator.php @@ -22,21 +22,21 @@ */ class ArithmeticOperator extends BaseOperator { - const ADD = 'add'; - const SUBTRACT = 'sub'; - const MULTIPLY = 'mul'; - const DIVIDE = 'div'; - const MODULO = 'mod'; - const POWER = 'pow'; + public const ADD = 'add'; + public const SUBTRACT = 'sub'; + public const MULTIPLY = 'mul'; + public const DIVIDE = 'div'; + public const MODULO = 'mod'; + public const POWER = 'pow'; /** * @var array $operators The supported arithmetic operators. */ - protected static $operators; + protected static array $operators = []; /** - * @var array $friendlyRepresentations The user friendly representations of the arithmetic operators. + * @var array $friendlyRepresentations The user-friendly representations of the arithmetic operators. */ - protected static $friendlyRepresentations = [ + protected static array $friendlyRepresentations = [ '+' => self::ADD, '-' => self::SUBTRACT, '*' => self::MULTIPLY, @@ -50,9 +50,8 @@ class ArithmeticOperator extends BaseOperator * * '+' * - * @return ArithmeticOperator */ - public static function add() + public static function add(): ArithmeticOperator { return new self(self::ADD); } @@ -62,11 +61,9 @@ public static function add() * * + * - * @return ArithmeticOperator - * * @see ArithmeticOperator::add */ - public static function plus() + public static function plus(): ArithmeticOperator { return self::add(); } @@ -76,9 +73,8 @@ public static function plus() * * - * - * @return ArithmeticOperator */ - public static function subtract() + public static function subtract(): ArithmeticOperator { return new self(self::SUBTRACT); } @@ -88,11 +84,9 @@ public static function subtract() * * - * - * @return ArithmeticOperator - * * @see ArithmeticOperator::subtract */ - public static function minus() + public static function minus(): ArithmeticOperator { return self::subtract(); } @@ -102,11 +96,10 @@ public static function minus() * * * * - * @return ArithmeticOperator */ - public static function multiply() + public static function multiply(): ArithmeticOperator { - return new static(static::MULTIPLY); + return new self(self::MULTIPLY); } /** @@ -114,9 +107,8 @@ public static function multiply() * * / * - * @return ArithmeticOperator */ - public static function divide() + public static function divide(): ArithmeticOperator { return new self(self::DIVIDE); } @@ -126,9 +118,8 @@ public static function divide() * * % * - * @return ArithmeticOperator */ - public static function modulo() + public static function modulo(): ArithmeticOperator { return new self(self::MODULO); } @@ -138,9 +129,8 @@ public static function modulo() * * ^ * - * @return ArithmeticOperator */ - public static function power() + public static function power(): ArithmeticOperator { return new self(self::POWER); } diff --git a/src/Transformation/Expression/Operator/ArithmeticOperatorBuilderTrait.php b/src/Transformation/Expression/Operator/ArithmeticOperatorBuilderTrait.php index cda0f6a..dd1bdb6 100644 --- a/src/Transformation/Expression/Operator/ArithmeticOperatorBuilderTrait.php +++ b/src/Transformation/Expression/Operator/ArithmeticOperatorBuilderTrait.php @@ -19,50 +19,40 @@ trait ArithmeticOperatorBuilderTrait { /** * Add. - * - * @return ExpressionOperator */ - public function add() + public function add(): ExpressionOperator { return $this->buildExpression(ArithmeticOperator::add()); } /** * Subtract. - * - * @return ExpressionOperator */ - public function subtract() + public function subtract(): ExpressionOperator { return $this->buildExpression(ArithmeticOperator::subtract()); } /** * Multiply. - * - * @return ExpressionOperator */ - public function multiply() + public function multiply(): ExpressionOperator { return $this->buildExpression(ArithmeticOperator::multiply()); } /** * Divide. - * - * @return ExpressionOperator */ - public function divide() + public function divide(): ExpressionOperator { return $this->buildExpression(ArithmeticOperator::divide()); } /** * Modulo. - * - * @return ExpressionOperator */ - public function modulo() + public function modulo(): ExpressionOperator { return $this->buildExpression(ArithmeticOperator::modulo()); } diff --git a/src/Transformation/Expression/Operator/BaseOperator.php b/src/Transformation/Expression/Operator/BaseOperator.php index 6b387c8..a5f0935 100644 --- a/src/Transformation/Expression/Operator/BaseOperator.php +++ b/src/Transformation/Expression/Operator/BaseOperator.php @@ -10,6 +10,7 @@ namespace Cloudinary\Transformation\Expression; +use Cloudinary\ArrayUtils; use Cloudinary\ClassUtils; use UnexpectedValueException; @@ -23,7 +24,11 @@ abstract class BaseOperator extends BaseExpressionComponent /** * @var string $operator The operator. */ - protected $operator; + protected string $operator; + + protected static array $operators = []; + + protected static array $friendlyRepresentations = []; // These static properties are defined in corresponding derived classes, otherwise they will be shared among // derived classes @@ -34,7 +39,6 @@ abstract class BaseOperator extends BaseExpressionComponent /** * BaseOperator constructor. * - * @param $operator */ public function __construct($operator) { @@ -46,9 +50,8 @@ public function __construct($operator) /** * Gets supported operators. * - * @return array */ - protected static function operators() + protected static function operators(): array { return self::getConstants(static::$operators); } @@ -56,9 +59,8 @@ protected static function operators() /** * Gets friendly representations. * - * @return array */ - protected static function friendlyRepresentations() + protected static function friendlyRepresentations(): array { return static::$friendlyRepresentations; } @@ -68,9 +70,9 @@ protected static function friendlyRepresentations() * * @param string $operator The operator to set. */ - protected function setOperator($operator) + protected function setOperator(string $operator): void { - if (in_array($operator, self::operators(), false)) { + if (in_array($operator, static::operators())) { $this->operator = $operator; return; @@ -78,7 +80,7 @@ protected function setOperator($operator) $friendlyRepresentations = static::friendlyRepresentations(); - if (isset($operator, $friendlyRepresentations)) { + if (array_key_exists($operator, $friendlyRepresentations)) { $this->operator = $friendlyRepresentations[$operator]; return; @@ -100,9 +102,8 @@ public function __toString() /** * Serializes to json. * - * @return mixed */ - public function jsonSerialize() + public function jsonSerialize(): array { return ['operator' => $this->operator]; } diff --git a/src/Transformation/Expression/Operator/LogicalOperator.php b/src/Transformation/Expression/Operator/LogicalOperator.php index 2dc7b03..9ccc0c2 100644 --- a/src/Transformation/Expression/Operator/LogicalOperator.php +++ b/src/Transformation/Expression/Operator/LogicalOperator.php @@ -28,11 +28,11 @@ class LogicalOperator extends BaseOperator /** * @var array $operators The supported logical operators. */ - protected static $operators; + protected static array $operators = []; /** - * @var array $friendlyRepresentations The user friendly representations of the logical operators. + * @var array $friendlyRepresentations The user-friendly representations of the logical operators. */ - protected static $friendlyRepresentations = [ + protected static array $friendlyRepresentations = [ '&&' => self::AND_OPERATOR, '||' => self::OR_OPERATOR, ]; @@ -40,9 +40,8 @@ class LogicalOperator extends BaseOperator /** * And. * - * @return LogicalOperator */ - public static function andOperator() + public static function andOperator(): LogicalOperator { return new static(self::AND_OPERATOR); } @@ -50,9 +49,8 @@ public static function andOperator() /** * Or. * - * @return LogicalOperator */ - public static function orOperator() + public static function orOperator(): LogicalOperator { return new static(self::OR_OPERATOR); } diff --git a/src/Transformation/Expression/Operator/LogicalOperatorBuilderTrait.php b/src/Transformation/Expression/Operator/LogicalOperatorBuilderTrait.php index d8e33b0..ea496c8 100644 --- a/src/Transformation/Expression/Operator/LogicalOperatorBuilderTrait.php +++ b/src/Transformation/Expression/Operator/LogicalOperatorBuilderTrait.php @@ -22,9 +22,8 @@ trait LogicalOperatorBuilderTrait * * '&&' * - * @return ExpressionOperator */ - public function and_() + public function and_(): ExpressionOperator { return $this->buildExpression(LogicalOperator::andOperator()); } @@ -34,9 +33,8 @@ public function and_() * * '||' * - * @return ExpressionOperator */ - public function or_() + public function or_(): ExpressionOperator { return $this->buildExpression(LogicalOperator::orOperator()); } diff --git a/src/Transformation/Expression/Operator/Operator.php b/src/Transformation/Expression/Operator/Operator.php index 84d1a81..923f53c 100644 --- a/src/Transformation/Expression/Operator/Operator.php +++ b/src/Transformation/Expression/Operator/Operator.php @@ -20,7 +20,7 @@ class Operator extends BaseOperator /** * @var array $operatorTypes The supported operator types. */ - private static $operatorTypes = [ + private static array $operatorTypes = [ ArithmeticOperator::class, LogicalOperator::class, RelationalOperator::class, @@ -30,18 +30,18 @@ class Operator extends BaseOperator /** * @var array $operators The supported operators. */ - protected static $operators = []; + protected static array $operators = []; /** - * @var array $friendlyRepresentations The user friendly representations of the operators. + * @var array $friendlyRepresentations The user-friendly representations of the operators. */ - protected static $friendlyRepresentations = []; + protected static array $friendlyRepresentations = []; /** * Gets all supported operators. * * @return array The supported operators. */ - public static function operators() + public static function operators(): array { if (! empty(self::$operators)) { return self::$operators; @@ -57,9 +57,8 @@ public static function operators() /** * Gets user friendly representations of the operators. * - * @return array */ - public static function friendlyRepresentations() + public static function friendlyRepresentations(): array { if (! empty(self::$friendlyRepresentations)) { return self::$friendlyRepresentations; diff --git a/src/Transformation/Expression/Operator/RelationalOperator.php b/src/Transformation/Expression/Operator/RelationalOperator.php index 75d13b4..0b5dec2 100644 --- a/src/Transformation/Expression/Operator/RelationalOperator.php +++ b/src/Transformation/Expression/Operator/RelationalOperator.php @@ -17,26 +17,26 @@ */ class RelationalOperator extends BaseOperator { - const EQUAL = 'eq'; - const NOT_EQUAL = 'ne'; - const LESS_THAN = 'lt'; - const GREATER_THAN = 'gt'; - const LESS_THAN_OR_EQUAL = 'lte'; - const GREATER_THAN_OR_EQUAL = 'gte'; + public const EQUAL = 'eq'; + public const NOT_EQUAL = 'ne'; + public const LESS_THAN = 'lt'; + public const GREATER_THAN = 'gt'; + public const LESS_THAN_OR_EQUAL = 'lte'; + public const GREATER_THAN_OR_EQUAL = 'gte'; /** * The supported relational operators. * * @var array $operators */ - protected static $operators; + protected static array $operators = []; /** - * The user friendly representations of the relational operators. + * The user-friendly representations of the relational operators. * * @var array $friendlyRepresentations */ - protected static $friendlyRepresentations = [ + protected static array $friendlyRepresentations = [ '=' => self::EQUAL, '!=' => self::NOT_EQUAL, '<' => self::LESS_THAN, @@ -48,9 +48,8 @@ class RelationalOperator extends BaseOperator /** * Equals. * - * @return RelationalOperator */ - public static function equal() + public static function equal(): RelationalOperator { return new static(self::EQUAL); } @@ -58,9 +57,8 @@ public static function equal() /** * Does not equal. * - * @return RelationalOperator */ - public static function notEqual() + public static function notEqual(): RelationalOperator { return new static(self::NOT_EQUAL); } @@ -68,9 +66,8 @@ public static function notEqual() /** * Less than. * - * @return RelationalOperator */ - public static function lessThan() + public static function lessThan(): RelationalOperator { return new static(static::LESS_THAN); } @@ -78,9 +75,8 @@ public static function lessThan() /** * Greater than. * - * @return RelationalOperator */ - public static function greaterThan() + public static function greaterThan(): RelationalOperator { return new static(self::GREATER_THAN); } @@ -88,9 +84,8 @@ public static function greaterThan() /** * Less than or equals. * - * @return RelationalOperator */ - public static function lessThanOrEqual() + public static function lessThanOrEqual(): RelationalOperator { return new static(self::LESS_THAN_OR_EQUAL); } @@ -98,9 +93,8 @@ public static function lessThanOrEqual() /** * Greater than or equals. * - * @return RelationalOperator */ - public static function greaterThanOrEqual() + public static function greaterThanOrEqual(): RelationalOperator { return new static(self::GREATER_THAN_OR_EQUAL); } diff --git a/src/Transformation/Expression/Operator/RelationalOperatorBuilderTrait.php b/src/Transformation/Expression/Operator/RelationalOperatorBuilderTrait.php index 4d0633c..866517b 100644 --- a/src/Transformation/Expression/Operator/RelationalOperatorBuilderTrait.php +++ b/src/Transformation/Expression/Operator/RelationalOperatorBuilderTrait.php @@ -20,9 +20,8 @@ trait RelationalOperatorBuilderTrait /** * Equals. * - * @return ExpressionOperator */ - public function equal() + public function equal(): ExpressionOperator { return $this->buildExpression(RelationalOperator::equal()); } @@ -30,9 +29,8 @@ public function equal() /** * Does not equal. * - * @return ExpressionOperator */ - public function notEqual() + public function notEqual(): ExpressionOperator { return $this->buildExpression(RelationalOperator::notEqual()); } @@ -40,9 +38,8 @@ public function notEqual() /** * Less than. * - * @return ExpressionOperator */ - public function lessThan() + public function lessThan(): ExpressionOperator { return $this->buildExpression(RelationalOperator::lessThan()); } @@ -50,9 +47,8 @@ public function lessThan() /** * Greater than. * - * @return ExpressionOperator */ - public function greaterThan() + public function greaterThan(): ExpressionOperator { return $this->buildExpression(RelationalOperator::greaterThan()); } @@ -60,9 +56,8 @@ public function greaterThan() /** * Less than or equals. * - * @return ExpressionOperator */ - public function lessThanOrEqual() + public function lessThanOrEqual(): ExpressionOperator { return $this->buildExpression(RelationalOperator::lessThanOrEqual()); } @@ -70,9 +65,8 @@ public function lessThanOrEqual() /** * Greater than or equals. * - * @return ExpressionOperator */ - public function greaterThanOrEqual() + public function greaterThanOrEqual(): ExpressionOperator { return $this->buildExpression(RelationalOperator::greaterThanOrEqual()); } diff --git a/src/Transformation/Expression/Operator/StringRelationalOperator.php b/src/Transformation/Expression/Operator/StringRelationalOperator.php index 4fd3dcc..48cf768 100644 --- a/src/Transformation/Expression/Operator/StringRelationalOperator.php +++ b/src/Transformation/Expression/Operator/StringRelationalOperator.php @@ -17,24 +17,24 @@ */ class StringRelationalOperator extends BaseOperator { - const EQUAL = 'eq'; - const NOT_EQUAL = 'ne'; - const IN = 'in'; - const NOT_IN = 'nin'; + public const EQUAL = 'eq'; + public const NOT_EQUAL = 'ne'; + public const IN = 'in'; + public const NOT_IN = 'nin'; /** * The supported string relational operators. * * @var array $operators */ - protected static $operators; + protected static array $operators = []; /** - * The user friendly representations of the string relational operators. + * The user-friendly representations of the string relational operators. * * @var array $friendlyRepresentations */ - protected static $friendlyRepresentations = [ + protected static array $friendlyRepresentations = [ '=' => self::EQUAL, '!=' => self::NOT_EQUAL, 'in' => self::IN, @@ -44,9 +44,8 @@ class StringRelationalOperator extends BaseOperator /** * String Equals. * - * @return StringRelationalOperator */ - public static function equal() + public static function equal(): StringRelationalOperator { return new static(self::EQUAL); } @@ -54,9 +53,8 @@ public static function equal() /** * String does not equal. * - * @return StringRelationalOperator */ - public static function notEqual() + public static function notEqual(): StringRelationalOperator { return new static(self::NOT_EQUAL); } @@ -64,9 +62,8 @@ public static function notEqual() /** * Is in (a list of strings). * - * @return StringRelationalOperator */ - public static function in() + public static function in(): StringRelationalOperator { return new static(self::IN); } @@ -74,9 +71,8 @@ public static function in() /** * Is not in (a list of strings). * - * @return StringRelationalOperator */ - public static function notIn() + public static function notIn(): StringRelationalOperator { return new static(self::NOT_IN); } diff --git a/src/Transformation/Expression/Operator/StringRelationalOperatorBuilderTrait.php b/src/Transformation/Expression/Operator/StringRelationalOperatorBuilderTrait.php index 22f91f7..9353a84 100644 --- a/src/Transformation/Expression/Operator/StringRelationalOperatorBuilderTrait.php +++ b/src/Transformation/Expression/Operator/StringRelationalOperatorBuilderTrait.php @@ -20,9 +20,8 @@ trait StringRelationalOperatorBuilderTrait /** * Is in (a list of strings). * - * @return ExpressionOperator */ - public function in() + public function in(): ExpressionOperator { return $this->buildExpression(StringRelationalOperator::in()); } @@ -30,9 +29,8 @@ public function in() /** * Is not in (a list of strings). * - * @return ExpressionOperator */ - public function notIn() + public function notIn(): ExpressionOperator { return $this->buildExpression(StringRelationalOperator::notIn()); } diff --git a/src/Transformation/Flag/CommonFlagInterface.php b/src/Transformation/Flag/CommonFlagInterface.php index 0c8e5c4..7599f34 100644 --- a/src/Transformation/Flag/CommonFlagInterface.php +++ b/src/Transformation/Flag/CommonFlagInterface.php @@ -17,12 +17,12 @@ */ interface CommonFlagInterface { - const ATTACHMENT = 'attachment'; - const IGNORE_ASPECT_RATIO = 'ignore_aspect_ratio'; - const FORCE_ICC = 'force_icc'; - const FORCE_STRIP = 'force_strip'; - const GET_INFO = 'getinfo'; - const IMMUTABLE_CACHE = 'immutable_cache'; - const KEEP_ATTRIBUTION = 'keep_attribution'; - const KEEP_IPTC = 'keep_iptc'; + public const ATTACHMENT = 'attachment'; + public const IGNORE_ASPECT_RATIO = 'ignore_aspect_ratio'; + public const FORCE_ICC = 'force_icc'; + public const FORCE_STRIP = 'force_strip'; + public const GET_INFO = 'getinfo'; + public const IMMUTABLE_CACHE = 'immutable_cache'; + public const KEEP_ATTRIBUTION = 'keep_attribution'; + public const KEEP_IPTC = 'keep_iptc'; } diff --git a/src/Transformation/Flag/CommonFlagTrait.php b/src/Transformation/Flag/CommonFlagTrait.php index 6c7d907..a83d843 100644 --- a/src/Transformation/Flag/CommonFlagTrait.php +++ b/src/Transformation/Flag/CommonFlagTrait.php @@ -25,11 +25,10 @@ trait CommonFlagTrait * will be used as the attachment filename (rather than the public_id) unless the discard_original_filename * qualifier was set during the file upload. * - * @param string $filename The attachment's filename + * @param string|null $filename The attachment's filename * - * @return FlagQualifier */ - public static function attachment($filename = null) + public static function attachment(?string $filename = null): FlagQualifier { return new FlagQualifier(self::ATTACHMENT, $filename); } @@ -38,9 +37,8 @@ public static function attachment($filename = null) * Allows specifying only either width or height so the value of the second axis remains as is, and is not * recalculated to maintain the aspect ratio of the original image. * - * @return FlagQualifier */ - public static function ignoreAspectRatio() + public static function ignoreAspectRatio(): FlagQualifier { return new FlagQualifier(self::IGNORE_ASPECT_RATIO); } @@ -48,9 +46,8 @@ public static function ignoreAspectRatio() /** * Adds ICC color space metadata to the image, even when the original image doesn't contain any ICC data. * - * @return FlagQualifier */ - public static function forceIcc() + public static function forceIcc(): FlagQualifier { return new FlagQualifier(self::FORCE_ICC); } @@ -58,9 +55,8 @@ public static function forceIcc() /** * Instructs Cloudinary to clear all image meta-data (IPTC, Exif and XMP) while applying an incoming transformation. * - * @return FlagQualifier */ - public static function forceStrip() + public static function forceStrip(): FlagQualifier { return new FlagQualifier(self::FORCE_STRIP); } @@ -70,9 +66,8 @@ public static function forceStrip() * * When used with g_auto, the metadata includes the proposed g_auto cropping coordinates. * - * @return FlagQualifier */ - public static function getInfo() + public static function getInfo(): FlagQualifier { return new FlagQualifier(self::GET_INFO); } @@ -83,9 +78,8 @@ public static function getInfo() * * Currently supported only by Firefox. * - * @return FlagQualifier */ - public static function immutableCache() + public static function immutableCache(): FlagQualifier { return new FlagQualifier(self::IMMUTABLE_CACHE); } @@ -94,9 +88,8 @@ public static function immutableCache() * Keeps the copyright related fields when stripping meta-data. Without this flag, Cloudinary's default behavior is * to strip all meta-data when generating new image transformations. * - * @return FlagQualifier */ - public static function keepAttribution() + public static function keepAttribution(): FlagQualifier { return new FlagQualifier(self::KEEP_ATTRIBUTION); } @@ -107,9 +100,8 @@ public static function keepAttribution() * * Note that this flag cannot be used in conjunction with the automatic quality transformation (q_auto). * - * @return FlagQualifier */ - public static function keepIptc() + public static function keepIptc(): FlagQualifier { return new FlagQualifier(self::KEEP_IPTC); } @@ -120,9 +112,8 @@ public static function keepIptc() * @param string $name The flag name. * @param mixed ...$args The flag value. * - * @return FlagQualifier */ - public static function generic($name, ...$args) + public static function generic(string $name, ...$args): FlagQualifier { return new FlagQualifier($name, ...$args); } diff --git a/src/Transformation/Flag/CommonTransformationFlagTrait.php b/src/Transformation/Flag/CommonTransformationFlagTrait.php index a74addc..ea7c94d 100644 --- a/src/Transformation/Flag/CommonTransformationFlagTrait.php +++ b/src/Transformation/Flag/CommonTransformationFlagTrait.php @@ -22,11 +22,10 @@ trait CommonTransformationFlagTrait * * @param string $filename The attachment's filename * - * @return static * * @see Flag::attachment */ - public function attachment($filename = null) + public function attachment($filename = null): static { return $this->addAction(Flag::attachment($filename)); } @@ -34,11 +33,10 @@ public function attachment($filename = null) /** * Adds ICC color space metadata to the image, even when the original image doesn't contain any ICC data. * - * @return static * * @see Flag::forceIcc */ - public function forceIcc() + public function forceIcc(): static { return $this->addAction(Flag::forceIcc()); } @@ -46,11 +44,10 @@ public function forceIcc() /** * Instructs Cloudinary to clear all image meta-data (IPTC, Exif and XMP) while applying an incoming transformation. * - * @return static * * @see Flag::forceStrip */ - public function forceStrip() + public function forceStrip(): static { return $this->addAction(Flag::forceStrip()); } @@ -58,11 +55,10 @@ public function forceStrip() /** * Returns metadata of the input asset and of the transformed output asset in JSON instead of the transformed image. * - * @return static * * @see Flag::getInfo */ - public function getInfo() + public function getInfo(): static { return $this->addAction(Flag::getInfo()); } @@ -70,11 +66,10 @@ public function getInfo() /** * Sets the cache-control to immutable for the asset. * - * @return static * * @see Flag::immutableCache */ - public function immutableCache() + public function immutableCache(): static { return $this->addAction(Flag::immutableCache()); } @@ -82,11 +77,10 @@ public function immutableCache() /** * Keeps the copyright related fields when stripping meta-data. * - * @return static * * @see Flag::keepAttribution */ - public function keepAttribution() + public function keepAttribution(): static { return $this->addAction(Flag::keepAttribution()); } @@ -94,22 +88,20 @@ public function keepAttribution() /** * Keeps all meta-data. * - * @return static * * @see Flag::keepIptc */ - public function keepIptc() + public function keepIptc(): static { return $this->addAction(Flag::keepIptc()); } /** * Instructs Cloudinary to clear all ICC color profile data included with the image. - * @return static * * @see Flag::stripProfile */ - public function stripProfile() + public function stripProfile(): static { return $this->addAction(Flag::stripProfile()); } diff --git a/src/Transformation/Flag/FlagQualifier.php b/src/Transformation/Flag/FlagQualifier.php index 0839797..311b10a 100644 --- a/src/Transformation/Flag/FlagQualifier.php +++ b/src/Transformation/Flag/FlagQualifier.php @@ -22,20 +22,20 @@ class FlagQualifier extends BaseQualifier /** * @var string The flag qualifier key */ - protected static $key = 'fl'; + protected static string $key = 'fl'; /** * @var string $flagName The name of the flag. */ - protected $flagName; + protected string $flagName; /** * FlagQualifier constructor. * - * @param string $flagName The name of the flag. - * @param string|array|mixed $value An optional value of the flag. + * @param string $flagName The name of the flag. + * @param mixed|null $value An optional value of the flag. */ - public function __construct($flagName, $value = null) + public function __construct($flagName, mixed $value = null) { parent::__construct(); @@ -46,11 +46,10 @@ public function __construct($flagName, $value = null) /** * Gets the name of the flag. * - * @return string * * @internal */ - public function getFlagName() + public function getFlagName(): string { return $this->flagName; } @@ -60,9 +59,8 @@ public function getFlagName() * * @param string $flagName The name. * - * @return FlagQualifier */ - public function setFlagName($flagName) + public function setFlagName(string $flagName): static { $this->flagName = $flagName; @@ -88,9 +86,8 @@ public function __toString() /** * Serializes to json. * - * @return mixed */ - public function jsonSerialize() + public function jsonSerialize(): array { $res = []; if ($this->flagName) { diff --git a/src/Transformation/Flag/FlagQualifierTrait.php b/src/Transformation/Flag/FlagQualifierTrait.php index 63913f6..750f772 100644 --- a/src/Transformation/Flag/FlagQualifierTrait.php +++ b/src/Transformation/Flag/FlagQualifierTrait.php @@ -20,12 +20,11 @@ trait FlagQualifierTrait /** * Sets the flag. * - * @param string $flagName The name of the flag. - * @param string|array|mixed $value An optional value of the flag. + * @param string $flagName The name of the flag. + * @param mixed|null $value An optional value of the flag. * - * @return FlagQualifier */ - public static function flag($flagName, $value = null) + public static function flag(string $flagName, mixed $value = null): FlagQualifier { return new FlagQualifier($flagName, $value); } diff --git a/src/Transformation/Flag/ImageFlagInterface.php b/src/Transformation/Flag/ImageFlagInterface.php index bdf545f..bf53cc0 100644 --- a/src/Transformation/Flag/ImageFlagInterface.php +++ b/src/Transformation/Flag/ImageFlagInterface.php @@ -15,21 +15,21 @@ */ interface ImageFlagInterface { - const ANIMATED = 'animated'; - const ANY_FORMAT = 'any_format'; - const ANIMATED_PNG = 'apng'; - const ANIMATED_WEBP = 'awebp'; - const CLIP = 'clip'; - const CLIP_EVEN_ODD = 'clip_evenodd'; - const LOSSY = 'lossy'; - const PRESERVE_TRANSPARENCY = 'preserve_transparency'; - const PNG8 = 'png8'; - const PNG24 = 'png24'; - const PNG32 = 'png32'; - const PROGRESSIVE = 'progressive'; - const RASTERIZE = 'rasterize'; - const SANITIZE = 'sanitize'; - const STRIP_PROFILE = 'strip_profile'; - const TIFF8_LZW = 'tiff8_lzw'; - const IGNORE_MASK_CHANNELS = 'ignore_mask_channels'; + public const ANIMATED = 'animated'; + public const ANY_FORMAT = 'any_format'; + public const ANIMATED_PNG = 'apng'; + public const ANIMATED_WEBP = 'awebp'; + public const CLIP = 'clip'; + public const CLIP_EVEN_ODD = 'clip_evenodd'; + public const LOSSY = 'lossy'; + public const PRESERVE_TRANSPARENCY = 'preserve_transparency'; + public const PNG8 = 'png8'; + public const PNG24 = 'png24'; + public const PNG32 = 'png32'; + public const PROGRESSIVE = 'progressive'; + public const RASTERIZE = 'rasterize'; + public const SANITIZE = 'sanitize'; + public const STRIP_PROFILE = 'strip_profile'; + public const TIFF8_LZW = 'tiff8_lzw'; + public const IGNORE_MASK_CHANNELS = 'ignore_mask_channels'; } diff --git a/src/Transformation/Flag/ImageFlagTrait.php b/src/Transformation/Flag/ImageFlagTrait.php index cd978e9..171f953 100644 --- a/src/Transformation/Flag/ImageFlagTrait.php +++ b/src/Transformation/Flag/ImageFlagTrait.php @@ -27,9 +27,8 @@ trait ImageFlagTrait * Note: When delivering a video in GIF format, it is delivered as an animated GIF by default and this flag is not * necessary. To deliver a single frame of a video in GIF format, use the page qualifier. * - * @return FlagQualifier */ - public static function animated() + public static function animated(): FlagQualifier { return new FlagQualifier(self::ANIMATED); } @@ -38,9 +37,8 @@ public static function animated() * When used together with automatic quality (q_auto): * allow switching to PNG8 encoding if the quality algorithm decides that it's more efficient. * - * @return FlagQualifier */ - public static function anyFormat() + public static function anyFormat(): FlagQualifier { return new FlagQualifier(self::ANY_FORMAT); } @@ -51,9 +49,8 @@ public static function anyFormat() * * Note that animated PNGs are not supported in all browsers and versions. * - * @return FlagQualifier */ - public static function animatedPng() + public static function animatedPng(): FlagQualifier { return new FlagQualifier(self::ANIMATED_PNG); } @@ -64,9 +61,8 @@ public static function animatedPng() * * Note that animated WebPs are not supported in all browsers and versions. * - * @return FlagQualifier */ - public static function animatedWebP() + public static function animatedWebP(): FlagQualifier { return new FlagQualifier(self::ANIMATED_WEBP); } @@ -75,9 +71,8 @@ public static function animatedWebP() * Trims pixels according to a clipping path included in the original image * (e.g., manually created using PhotoShop). * - * @return FlagQualifier */ - public static function clip() + public static function clip(): FlagQualifier { return new FlagQualifier(self::CLIP); } @@ -86,9 +81,8 @@ public static function clip() * Trims pixels according to a clipping path included in the original image (e.g., manually created using PhotoShop) * using an evenodd clipping rule. * - * @return FlagQualifier */ - public static function clipEvenOdd() + public static function clipEvenOdd(): FlagQualifier { return new FlagQualifier(self::CLIP_EVEN_ODD); } @@ -100,9 +94,8 @@ public static function clipEvenOdd() * image in PNG format (as requested) unless there is no transparency channel - in which case deliver in JPEG * format. * - * @return FlagQualifier */ - public static function lossy() + public static function lossy(): FlagQualifier { return new FlagQualifier(self::LOSSY); } @@ -111,9 +104,8 @@ public static function lossy() * When used with automatic fetch_format (f_auto): ensures that images with a transparency channel will be * delivered in PNG format. * - * @return FlagQualifier */ - public static function preserveTransparency() + public static function preserveTransparency(): FlagQualifier { return new FlagQualifier(self::PRESERVE_TRANSPARENCY); } @@ -121,9 +113,8 @@ public static function preserveTransparency() /** * Generate PNG images in the PNG8 format. * - * @return FlagQualifier */ - public static function png8() + public static function png8(): FlagQualifier { return new FlagQualifier(self::PNG8); } @@ -131,9 +122,8 @@ public static function png8() /** * Generates PNG images in the PNG24 format. * - * @return FlagQualifier */ - public static function png24() + public static function png24(): FlagQualifier { return new FlagQualifier(self::PNG24); } @@ -141,9 +131,8 @@ public static function png24() /** * Generates PNG images in the PNG32 format. * - * @return FlagQualifier */ - public static function png32() + public static function png32(): FlagQualifier { return new FlagQualifier(self::PNG32); } @@ -154,7 +143,7 @@ public static function png32() * This format allows the browser to quickly show a low-quality rendering of the image until the full-quality * image is loaded. * - * @param string $mode The mode to determine a specific progressive outcome as follows: + * @param string|null $mode The mode to determine a specific progressive outcome as follows: * * semi - A smart optimization of the decoding time, compression level and progressive * rendering (less iterations). This is the default mode when using q_auto. * * steep - Delivers a preview very quickly, and in a single later phase improves the image to @@ -162,11 +151,10 @@ public static function png32() * * none - Use this to deliver a non-progressive image. This is the default mode when setting * a specific value for quality. * - * @return FlagQualifier *@see Progressive * */ - public static function progressive($mode = null) + public static function progressive(?string $mode = null): FlagQualifier { return new FlagQualifier(self::PROGRESSIVE, $mode); } @@ -175,9 +163,8 @@ public static function progressive($mode = null) * Reduces the image to one flat pixelated layer (as opposed to the default vector based graphic) in order to enable * PDF resizing and overlay manipulations. * - * @return FlagQualifier */ - public static function rasterize() + public static function rasterize(): FlagQualifier { return new FlagQualifier(self::RASTERIZE); } @@ -185,9 +172,8 @@ public static function rasterize() /** * Instructs Cloudinary to run a sanitizer on the image (relevant only for the SVG format). * - * @return FlagQualifier */ - public static function sanitize() + public static function sanitize(): FlagQualifier { return new FlagQualifier(self::SANITIZE); } @@ -195,9 +181,8 @@ public static function sanitize() /** * Instructs Cloudinary to clear all ICC color profile data included with the image. * - * @return FlagQualifier */ - public static function stripProfile() + public static function stripProfile(): FlagQualifier { return new FlagQualifier(self::STRIP_PROFILE); } @@ -205,9 +190,8 @@ public static function stripProfile() /** * Generates TIFF images using LZW compression and in the TIFF8 format. * - * @return FlagQualifier */ - public static function tiff8Lzw() + public static function tiff8Lzw(): FlagQualifier { return new FlagQualifier(self::TIFF8_LZW); } @@ -217,9 +201,8 @@ public static function tiff8Lzw() * * @see https://cloudinary.com/documentation/transformation_reference#fl_ignore_mask_channels * - * @return FlagQualifier */ - public static function ignoreMaskChannels() + public static function ignoreMaskChannels(): FlagQualifier { return new FlagQualifier(self::IGNORE_MASK_CHANNELS); } diff --git a/src/Transformation/Flag/ImageTransformationFlagTrait.php b/src/Transformation/Flag/ImageTransformationFlagTrait.php index 1fdd49e..7486b06 100644 --- a/src/Transformation/Flag/ImageTransformationFlagTrait.php +++ b/src/Transformation/Flag/ImageTransformationFlagTrait.php @@ -20,9 +20,8 @@ trait ImageTransformationFlagTrait /** * Instruct Cloudinary to run a sanitizer on the image (relevant only for the SVG format). * - * @return static */ - public function sanitize() + public function sanitize(): static { return $this->addFlag(Flag::sanitize()); } diff --git a/src/Transformation/Flag/LayerFlagInterface.php b/src/Transformation/Flag/LayerFlagInterface.php index 854eef1..4943a91 100644 --- a/src/Transformation/Flag/LayerFlagInterface.php +++ b/src/Transformation/Flag/LayerFlagInterface.php @@ -15,14 +15,14 @@ */ interface LayerFlagInterface { - const CUTTER = 'cutter'; - const LAYER_APPLY = 'layer_apply'; - const NO_OVERFLOW = 'no_overflow'; - const REGION_RELATIVE = 'region_relative'; - const RELATIVE = 'relative'; - const REPLACE_IMAGE = 'replace_image'; - const SPLICE = 'splice'; - const TEXT_NO_TRIM = 'text_no_trim'; - const TEXT_DISALLOW_OVERFLOW = 'text_disallow_overflow'; - const TILED = 'tiled'; + public const CUTTER = 'cutter'; + public const LAYER_APPLY = 'layer_apply'; + public const NO_OVERFLOW = 'no_overflow'; + public const REGION_RELATIVE = 'region_relative'; + public const RELATIVE = 'relative'; + public const REPLACE_IMAGE = 'replace_image'; + public const SPLICE = 'splice'; + public const TEXT_NO_TRIM = 'text_no_trim'; + public const TEXT_DISALLOW_OVERFLOW = 'text_disallow_overflow'; + public const TILED = 'tiled'; } diff --git a/src/Transformation/Flag/LayerFlagTrait.php b/src/Transformation/Flag/LayerFlagTrait.php index a66eeff..f8f2d61 100644 --- a/src/Transformation/Flag/LayerFlagTrait.php +++ b/src/Transformation/Flag/LayerFlagTrait.php @@ -25,9 +25,8 @@ trait LayerFlagTrait * Wherever the overlay image is transparent, the original is shown, and wherever the overlay is opaque, the * resulting image is transparent. * - * @return FlagQualifier */ - public static function cutter() + public static function cutter(): FlagQualifier { return new FlagQualifier(self::CUTTER); } @@ -36,9 +35,8 @@ public static function cutter() * Applies all chained transformations, until a transformation component that includes this flag, on the last added * overlay or underlay instead of applying on the containing image. * - * @return FlagQualifier */ - public static function layerApply() + public static function layerApply(): FlagQualifier { return new FlagQualifier(self::LAYER_APPLY); } @@ -47,9 +45,8 @@ public static function layerApply() * Replaces the first image embedded in a PDF with the image stipulated as an overlay, * instead of adding it as another overlay. * - * @return FlagQualifier */ - public static function replaceImage() + public static function replaceImage(): FlagQualifier { return new FlagQualifier(self::REPLACE_IMAGE); } @@ -58,9 +55,8 @@ public static function replaceImage() * Splices the video stipulated as an overlay on to the end of the container video instead of adding it as an * overlay. * - * @return FlagQualifier */ - public static function splice() + public static function splice(): FlagQualifier { return new FlagQualifier(self::SPLICE); } @@ -69,9 +65,8 @@ public static function splice() * Prevents Cloudinary from extending the image canvas beyond the original dimensions when overlaying text and * other images. * - * @return FlagQualifier */ - public static function noOverflow() + public static function noOverflow(): FlagQualifier { return new FlagQualifier(self::NO_OVERFLOW); } @@ -80,9 +75,8 @@ public static function noOverflow() * By default, text overlays are trimmed tightly to the text with no excess padding. This flag adds a small amount * of padding around the text overlay string. * - * @return FlagQualifier */ - public static function textNoTrim() + public static function textNoTrim(): FlagQualifier { return new FlagQualifier(self::TEXT_NO_TRIM); } @@ -90,9 +84,8 @@ public static function textNoTrim() /** * Returns an error if the text overlay exceeds the image boundaries. * - * @return FlagQualifier */ - public static function textDisallowOverflow() + public static function textDisallowOverflow(): FlagQualifier { return new FlagQualifier(self::TEXT_DISALLOW_OVERFLOW); } @@ -100,9 +93,8 @@ public static function textDisallowOverflow() /** * Tiles the added overlay over the entire image. * - * @return FlagQualifier */ - public static function tiled() + public static function tiled(): FlagQualifier { return new FlagQualifier(self::TILED); } diff --git a/src/Transformation/Flag/Progressive.php b/src/Transformation/Flag/Progressive.php index 9471fc4..f69140c 100644 --- a/src/Transformation/Flag/Progressive.php +++ b/src/Transformation/Flag/Progressive.php @@ -18,31 +18,30 @@ class Progressive /** * Default mode. */ - const PROGRESSIVE = ''; + public const PROGRESSIVE = ''; /** * A smart optimization of the decoding time, compression level and progressive rendering (less iterations). * This is the default mode when using q_auto. */ - const SEMI = 'semi'; + public const SEMI = 'semi'; /** * Delivers a preview very quickly, and in a single later phase improves the image to the required resolution. */ - const STEEP = 'steep'; + public const STEEP = 'steep'; /** * Use this to deliver a non-progressive image. This is the default mode when setting a specific value for quality. */ - const NONE = 'none'; + public const NONE = 'none'; /** * Default mode. * - * @return string */ - public static function progressive() + public static function progressive(): string { return self::PROGRESSIVE; } @@ -51,9 +50,8 @@ public static function progressive() * A smart optimization of the decoding time, compression level and progressive rendering (less iterations). * This is the default mode when using q_auto. * - * @return string */ - public static function semi() + public static function semi(): string { return self::SEMI; } @@ -61,9 +59,8 @@ public static function semi() /** * Delivers a preview very quickly, and in a single later phase improves the image to the required resolution. * - * @return string */ - public static function steep() + public static function steep(): string { return self::STEEP; } @@ -71,9 +68,8 @@ public static function steep() /** * Use this to deliver a non-progressive image. This is the default mode when setting a specific value for quality. * - * @return string */ - public static function none() + public static function none(): string { return self::NONE; } diff --git a/src/Transformation/Flag/VideoFlagInterface.php b/src/Transformation/Flag/VideoFlagInterface.php index f65ec74..746c6ae 100644 --- a/src/Transformation/Flag/VideoFlagInterface.php +++ b/src/Transformation/Flag/VideoFlagInterface.php @@ -15,11 +15,11 @@ */ interface VideoFlagInterface { - const STREAMING_ATTACHMENT = 'streaming_attachment'; - const HLSV3 = 'hlsv3'; - const KEEP_DAR = 'keep_dar'; - const NO_STREAM = 'no_stream'; - const MONO = 'mono'; - const TRUNCATE_TS = 'truncate_ts'; - const WAVEFORM = 'waveform'; + public const STREAMING_ATTACHMENT = 'streaming_attachment'; + public const HLSV3 = 'hlsv3'; + public const KEEP_DAR = 'keep_dar'; + public const NO_STREAM = 'no_stream'; + public const MONO = 'mono'; + public const TRUNCATE_TS = 'truncate_ts'; + public const WAVEFORM = 'waveform'; } diff --git a/src/Transformation/Flag/VideoFlagTrait.php b/src/Transformation/Flag/VideoFlagTrait.php index dbb569e..8d982ae 100644 --- a/src/Transformation/Flag/VideoFlagTrait.php +++ b/src/Transformation/Flag/VideoFlagTrait.php @@ -29,13 +29,12 @@ trait VideoFlagTrait * * Most standard video players successfully play fragmented video files without issue. * - * @param string $filename The attachment's filename + * @param string|null $filename The attachment's filename * - * @return FlagQualifier * * @see Flag::attachment */ - public static function streamingAttachment($filename = null) + public static function streamingAttachment(?string $filename = null): FlagQualifier { return new FlagQualifier(self::STREAMING_ATTACHMENT, $filename); } @@ -45,11 +44,10 @@ public static function streamingAttachment($filename = null) * * Delivering in this format requires a private CDN configuration. * - * @return FlagQualifier * * @see https://cloudinary.com/documentation/video_manipulation_and_delivery#adaptive_bitrate_streaming_hls_and_mpeg_dash */ - public static function hlsv3() + public static function hlsv3(): FlagQualifier { return new FlagQualifier(self::HLSV3); } @@ -58,9 +56,8 @@ public static function hlsv3() * Keep the Display Aspect Ratio metadata of the uploaded video (if it’s different from the current video * dimensions). * - * @return FlagQualifier */ - public static function keepDar() + public static function keepDar(): FlagQualifier { return new FlagQualifier(self::KEEP_DAR); } @@ -68,9 +65,8 @@ public static function keepDar() /** * Don't stream a video that is currently being generated on the fly. Wait until the video is fully generated. * - * @return FlagQualifier */ - public static function noStream() + public static function noStream(): FlagQualifier { return new FlagQualifier(self::NO_STREAM); } @@ -78,9 +74,8 @@ public static function noStream() /** * Convert the audio channel to mono * - * @return FlagQualifier */ - public static function mono() + public static function mono(): FlagQualifier { return new FlagQualifier(self::MONO); } @@ -89,9 +84,8 @@ public static function mono() * Truncate (trim) a video file based on the start time defined in the metadata (relevant only where the metadata * includes a directive to play only a section of the video). * - * @return FlagQualifier */ - public static function truncateTS() + public static function truncateTS(): FlagQualifier { return new FlagQualifier(self::TRUNCATE_TS); } @@ -99,9 +93,8 @@ public static function truncateTS() /** * Create a waveform image (in the format specified by the file extension) from the audio or video file. * - * @return FlagQualifier */ - public static function waveform() + public static function waveform(): FlagQualifier { return new FlagQualifier(self::WAVEFORM); } diff --git a/src/Transformation/Flag/VideoTransformationFlagTrait.php b/src/Transformation/Flag/VideoTransformationFlagTrait.php index 9513218..0cefcf6 100644 --- a/src/Transformation/Flag/VideoTransformationFlagTrait.php +++ b/src/Transformation/Flag/VideoTransformationFlagTrait.php @@ -20,9 +20,8 @@ trait VideoTransformationFlagTrait /** * Don't stream a video that is currently being generated on the fly. Wait until the video is fully generated. * - * @return static */ - public function noStream() + public function noStream(): static { return $this->addAction(Flag::noStream()); } @@ -30,13 +29,12 @@ public function noStream() /** * Causes the video download to begin immediately, streaming it as a fragmented video file. * - * @param string $filename The attachment's filename + * @param string|null $filename The attachment's filename * - * @return static * * @see Flag::streamingAttachment */ - public function streamingAttachment($filename = null) + public function streamingAttachment(?string $filename = null): static { return $this->addAction(Flag::streamingAttachment($filename)); } @@ -44,11 +42,10 @@ public function streamingAttachment($filename = null) /** * Deliver an HLS adaptive bitrate streaming file as HLS v3 instead of the default version (HLS v4). * - * @return static * * @see Flag::hlsv3 */ - public function hlsv3() + public function hlsv3(): static { return $this->addAction(Flag::hlsv3()); } @@ -56,9 +53,8 @@ public function hlsv3() /** * Keep the Display Aspect Ratio metadata of the uploaded video. * - * @return static */ - public function keepDar() + public function keepDar(): static { return $this->addAction(Flag::keepDar()); } @@ -66,9 +62,8 @@ public function keepDar() /** * Convert the audio channel to mono. * - * @return static */ - public function mono() + public function mono(): static { return $this->addAction(Flag::mono()); } @@ -76,9 +71,8 @@ public function mono() /** * Truncate (trim) a video file based on the start time defined in the metadata. * - * @return static */ - public function truncateTS() + public function truncateTS(): static { return $this->addAction(Flag::truncateTS()); } @@ -86,9 +80,8 @@ public function truncateTS() /** * Create a waveform image (in the format specified by the file extension) from the audio or video file. * - * @return static */ - public function waveform() + public function waveform(): static { return $this->addAction(Flag::waveform()); } diff --git a/src/Transformation/Image/ImageSpecificTransformationTrait.php b/src/Transformation/Image/ImageSpecificTransformationTrait.php index d7af0d3..3d92c91 100644 --- a/src/Transformation/Image/ImageSpecificTransformationTrait.php +++ b/src/Transformation/Image/ImageSpecificTransformationTrait.php @@ -28,17 +28,21 @@ trait ImageSpecificTransformationTrait /** * Adds an overlay over the base image. * - * @param string $layer The public ID of the image to overlay. - * @param Position|AbsolutePosition $position The position of the overlay with respect to the base image. - * @param string $blendMode The blend mode. Use the constants defined in the BlendMode class. + * @param string|BaseSource|BasePositionalSourceContainer $layer The public ID of the image to overlay. + * @param BasePosition|null $position The position of the overlay with respect to + * the base image. + * @param string|null $blendMode The blend mode. Use the constants defined in + * the BlendMode class. * - * @return static * - * @see \Cloudinary\Transformation\ImageOverlay - * @see \Cloudinary\Transformation\BlendMode + * @see ImageOverlay + * @see BlendMode */ - public function overlay($layer, $position = null, $blendMode = null) - { + public function overlay( + string|BaseSource|BasePositionalSourceContainer $layer, + ?BasePosition $position = null, + ?string $blendMode = null + ): static { return $this->addAction( ClassUtils::verifyInstance( $layer, @@ -53,17 +57,22 @@ public function overlay($layer, $position = null, $blendMode = null) /** * Adds an underlay under the base image. * - * @param string $layer The public ID of the image to underlay. - * @param Position|AbsolutePosition $position The position of the underlay with respect to the base image. - * @param string $blendMode The blend mode. Use the constants defined in the BlendMode class. + * @param BaseSourceContainer|BaseSource|string|null $layer The public ID of the image to underlay. + * @param BasePosition|null $position The position of the underlay with respect to the + * base image. + * @param string|null $blendMode The blend mode. Use the constants defined in the + * BlendMode + * class. * - * @return static * - * @see \Cloudinary\Transformation\OverlayOverlay - * @see \Cloudinary\Transformation\BlendMode + * @see OverlayOverlay + * @see BlendMode */ - public function underlay($layer, $position = null, $blendMode = null) - { + public function underlay( + BaseSourceContainer|BaseSource|string|null $layer, + BasePosition|null $position = null, + ?string $blendMode = null + ): static { $underlay = ClassUtils::forceInstance($layer, ImageOverlay::class, null, $position, $blendMode); $underlay->setStackPosition(LayerStackPosition::UNDERLAY); @@ -75,9 +84,8 @@ public function underlay($layer, $position = null, $blendMode = null) * * @param ReshapeQualifier|EffectAction|EffectQualifier|mixed $reshape The reshape to apply. * - * @return static */ - public function reshape($reshape) + public function reshape(mixed $reshape): static { return $this->addAction($reshape); } @@ -93,18 +101,21 @@ public function reshape($reshape) * corner according to $bottomRight.
* All qualifiers specified: Each corner is rounded accordingly. * - * @param int|string|CornerRadius $radiusOrTopLeft The radius in pixels of the top left corner or all the corners - * if no other corners are specified. - * @param int $topRight The radius in pixels of the top right corner. - * @param int $bottomRight The radius in pixels of the bottom right corner. - * @param int $bottomLeft The radius in pixels of the bottom left corner. + * @param int|string|CornerRadius|RoundCorners $radiusOrTopLeft The radius in pixels of the top left corner or all + * the corners if no other corners are specified. + * @param int|null $topRight The radius in pixels of the top right corner. + * @param int|null $bottomRight The radius in pixels of the bottom right corner. + * @param int|null $bottomLeft The radius in pixels of the bottom left corner. * - * @return static * - * @see \Cloudinary\Transformation\RoundCorners + * @see RoundCorners */ - public function roundCorners($radiusOrTopLeft, $topRight = null, $bottomRight = null, $bottomLeft = null) - { + public function roundCorners( + int|string|CornerRadius|RoundCorners $radiusOrTopLeft, + ?int $topRight = null, + ?int $bottomRight = null, + ?int $bottomLeft = null + ): static { $qualifiers = ArrayUtils::safeFilter([$radiusOrTopLeft, $topRight, $bottomRight, $bottomLeft]); $roundCorners = ClassUtils::verifyVarArgsInstance($qualifiers, RoundCorners::class); @@ -118,11 +129,10 @@ public function roundCorners($radiusOrTopLeft, $topRight = null, $bottomRight = * @param Border $border A Border object in which you set the width, style and color of the border. * See the Border class. * - * @return static * - * @see \Cloudinary\Transformation\Border + * @see Border */ - public function border(Border $border) + public function border(Border $border): static { return $this->addAction($border); } @@ -130,13 +140,12 @@ public function border(Border $border) /** * Sets the color of the background. * - * @param Background|ColorValue|string $color The color of the background to set. + * @param string|Background|ColorValue $color The color of the background to set. * - * @return static * - * @see \Cloudinary\Transformation\Background + * @see Background */ - public function backgroundColor($color) + public function backgroundColor(Background|ColorValue|string $color): static { return $this->addAction(ClassUtils::verifyInstance($color, Background::class)); } @@ -144,13 +153,12 @@ public function backgroundColor($color) /** * Sets the image background. * - * @param Background|string $background The background to set. + * @param string|Background $background The background to set. * - * @return static * - * @see \Cloudinary\Transformation\Background + * @see Background */ - public function background($background) + public function background(Background|string $background): static { return $this->addAction(ClassUtils::verifyInstance($background, Background::class)); } @@ -158,13 +166,12 @@ public function background($background) /** * Controls the color space used for the delivered image. * - * @param ColorSpace|string $colorSpace Use the constants defined in the ColorSpace class. + * @param string|ColorSpace $colorSpace Use the constants defined in the ColorSpace class. * - * @return static * - * @see \Cloudinary\Transformation\ColorSpace + * @see ColorSpace */ - public function colorSpace($colorSpace) + public function colorSpace(string|ColorSpace $colorSpace): static { return $this->addAction(ClassUtils::verifyInstance($colorSpace, ColorSpace::class)); } @@ -172,12 +179,11 @@ public function colorSpace($colorSpace) /** * Prevents style class names collisions for sprite generation. * - * @param Prefix|string $prefix The style class name prefix. + * @param string $prefix The style class name prefix. * * - * @return static */ - public function prefix($prefix) + public function prefix(string $prefix): static { return $this->addAction(ClassUtils::verifyInstance($prefix, Prefix::class)); } @@ -187,9 +193,8 @@ public function prefix($prefix) * * @param AnimatedEdit $animated Animated image action. * - * @return static */ - public function animated($animated) + public function animated(AnimatedEdit $animated): static { return $this->addAction(ClassUtils::verifyInstance($animated, AnimatedEdit::class)); } diff --git a/src/Transformation/Image/ImageTransformationInterface.php b/src/Transformation/Image/ImageTransformationInterface.php index dd3ce14..31c7afc 100644 --- a/src/Transformation/Image/ImageTransformationInterface.php +++ b/src/Transformation/Image/ImageTransformationInterface.php @@ -18,42 +18,49 @@ interface ImageTransformationInterface extends CommonTransformationInterface /** * Applies a filter or an effect on an image. * - * @param EffectQualifier|EffectAction $effect The effect to apply. + * @param EffectAction|EffectQualifier $effect The effect to apply. * - * @return static * - * @see \Cloudinary\Transformation\EffectAction - * @see \Cloudinary\Transformation\EffectQualifier + * @see EffectAction + * @see EffectQualifier */ - public function effect($effect); + public function effect(EffectQualifier|EffectAction $effect): static; /** * Adds an overlay over the base image. * - * @param string $layer The public ID of the image to overlay. - * @param Position|AbsolutePosition $position The position of the overlay with respect to the base image. - * @param string $blendMode The blend mode. Use the constants defined in the BlendMode class. + * @param string $layer The public ID of the image to overlay. + * @param AbsolutePosition|Position|null $position The position of the overlay with respect to the base image. + * @param string|null $blendMode The blend mode. Use the constants defined in the BlendMode + * class. * - * @return static * - * @see \Cloudinary\Transformation\ImageOverlay - * @see \Cloudinary\Transformation\BlendMode + * @see ImageOverlay + * @see BlendMode */ - public function overlay($layer, $position = null, $blendMode = null); + public function overlay( + string $layer, + Position|AbsolutePosition|null $position = null, + ?string $blendMode = null + ): static; /** * Adds an underlay under the base image. * - * @param string $layer The public ID of the image to underlay. - * @param Position|AbsolutePosition $position The position of the underlay with respect to the base image. - * @param string $blendMode The blend mode. Use the constants defined in the BlendMode class. + * @param string $layer The public ID of the image to underlay. + * @param AbsolutePosition|Position|null $position The position of the underlay with respect to the base image. + * @param string|null $blendMode The blend mode. Use the constants defined in the BlendMode + * class. * - * @return static * - * @see \Cloudinary\Transformation\OverlayOverlay - * @see \Cloudinary\Transformation\BlendMode + * @see OverlayOverlay + * @see BlendMode */ - public function underlay($layer, $position = null, $blendMode = null); + public function underlay( + string $layer, + Position|AbsolutePosition|null $position = null, + ?string $blendMode = null + ): static; /** * Adds a border around the image. @@ -61,9 +68,8 @@ public function underlay($layer, $position = null, $blendMode = null); * @param Border $border A Border object in which you set the width, style and color of the border. * See the Border class. * - * @return static * - * @see \Cloudinary\Transformation\Border + * @see Border */ - public function border(Border $border); + public function border(Border $border): static; } diff --git a/src/Transformation/Image/LayeredImageTransformationTrait.php b/src/Transformation/Image/LayeredImageTransformationTrait.php index 27050e9..37c1d23 100644 --- a/src/Transformation/Image/LayeredImageTransformationTrait.php +++ b/src/Transformation/Image/LayeredImageTransformationTrait.php @@ -24,11 +24,10 @@ trait LayeredImageTransformationTrait * * @param PageQualifier|string|int ...$pages * - * @return static * * @see https://cloudinary.com/documentation/paged_and_layered_media#deliver_a_pdf_or_selected_pages_of_a_pdf */ - public function extract(...$pages) + public function extract(...$pages): static { return $this->addAction(ClassUtils::verifyVarArgsInstance($pages, Page::class)); } @@ -38,11 +37,10 @@ public function extract(...$pages) * * @param PageQualifier|string|int ...$pages * - * @return static * * @see https://cloudinary.com/documentation/paged_and_layered_media#deliver_a_pdf_or_selected_pages_of_a_pdf */ - public function psdTools(...$pages) + public function psdTools(...$pages): static { return $this->addAction(ClassUtils::verifyVarArgsInstance($pages, BasePageAction::class)); } diff --git a/src/Transformation/Image/Qualifier/DefaultImage.php b/src/Transformation/Image/Qualifier/DefaultImage.php index e944b64..c381e86 100644 --- a/src/Transformation/Image/Qualifier/DefaultImage.php +++ b/src/Transformation/Image/Qualifier/DefaultImage.php @@ -20,5 +20,5 @@ class DefaultImage extends BaseQualifier /** * @var string $key Serialization key. */ - protected static $key = 'd'; + protected static string $key = 'd'; } diff --git a/src/Transformation/Image/Qualifier/Delay.php b/src/Transformation/Image/Qualifier/Delay.php index e178dad..217faf9 100644 --- a/src/Transformation/Image/Qualifier/Delay.php +++ b/src/Transformation/Image/Qualifier/Delay.php @@ -20,5 +20,5 @@ class Delay extends BaseQualifier /** * @var string $key Serialization key. */ - protected static $key = 'dl'; + protected static string $key = 'dl'; } diff --git a/src/Transformation/Image/Qualifier/Density.php b/src/Transformation/Image/Qualifier/Density.php index 0df896b..4d28cb6 100644 --- a/src/Transformation/Image/Qualifier/Density.php +++ b/src/Transformation/Image/Qualifier/Density.php @@ -33,10 +33,10 @@ class Density extends BaseQualifier /** * @var string INITIAL_DENSITY Pre-normalized initial density of the original image. */ - const INITIAL_DENSITY = 'idn'; + public const INITIAL_DENSITY = 'idn'; /** * @var string $key Serialization key. */ - protected static $key = 'dn'; + protected static string $key = 'dn'; } diff --git a/src/Transformation/Image/Qualifier/ImageQualifierTrait.php b/src/Transformation/Image/Qualifier/ImageQualifierTrait.php index 0885d96..1718a37 100644 --- a/src/Transformation/Image/Qualifier/ImageQualifierTrait.php +++ b/src/Transformation/Image/Qualifier/ImageQualifierTrait.php @@ -22,9 +22,8 @@ trait ImageQualifierTrait * * @param string $defaultImage Default image public ID * - * @return DefaultImage */ - public static function defaultImage($defaultImage) + public static function defaultImage(string $defaultImage): DefaultImage { return new DefaultImage($defaultImage); } @@ -34,9 +33,8 @@ public static function defaultImage($defaultImage) * * @param int $delay The delay in milliseconds * - * @return Delay */ - public static function delay($delay) + public static function delay(int $delay): Delay { return new Delay($delay); } @@ -45,11 +43,10 @@ public static function delay($delay) * Controls the density to use when delivering an image or when converting a vector file such as a PDF or EPS * document to a web image delivery format. * - * @param int|string $density The density in dpi. + * @param int|float|string $density The density in dpi. * - * @return Density */ - public static function density($density) + public static function density(int|float|string $density): Density { return new Density($density); } @@ -59,9 +56,8 @@ public static function density($density) * * @param string $prefix The style class name prefix. * - * @return Prefix */ - public static function prefix($prefix) + public static function prefix(string $prefix): Prefix { return new Prefix($prefix); } diff --git a/src/Transformation/Image/Qualifier/ImageQualifierTransformationTrait.php b/src/Transformation/Image/Qualifier/ImageQualifierTransformationTrait.php index a0969ba..409db37 100644 --- a/src/Transformation/Image/Qualifier/ImageQualifierTransformationTrait.php +++ b/src/Transformation/Image/Qualifier/ImageQualifierTransformationTrait.php @@ -22,11 +22,9 @@ trait ImageQualifierTransformationTrait /** * Sets the delay between frames of an animated image in milliseconds. * - * @param Delay|int $delay * - * @return static */ - public function delay($delay) + public function delay(Delay|int $delay): static { return $this->addAction(ClassUtils::verifyInstance($delay, Delay::class)); } @@ -36,9 +34,8 @@ public function delay($delay) * * @param string $defaultImage Default image public ID * - * @return static */ - public function defaultImage($defaultImage) + public function defaultImage(string $defaultImage): static { return $this->addAction(ClassUtils::verifyInstance($defaultImage, DefaultImage::class)); } @@ -49,9 +46,8 @@ public function defaultImage($defaultImage) * * @param int|string $density The density in dpi. * - * @return static */ - public function density($density) + public function density(int|string $density): static { return $this->addAction(ClassUtils::verifyInstance($density, Density::class)); } @@ -61,9 +57,8 @@ public function density($density) * * @param string $prefix The style class name prefix. * - * @return static */ - public function prefix($prefix) + public function prefix(string $prefix): static { return $this->addAction(ClassUtils::verifyInstance($prefix, Prefix::class)); } diff --git a/src/Transformation/Layer/AssetBasedSource.php b/src/Transformation/Layer/AssetBasedSource.php index 8b45677..d69896d 100644 --- a/src/Transformation/Layer/AssetBasedSource.php +++ b/src/Transformation/Layer/AssetBasedSource.php @@ -18,7 +18,6 @@ abstract class AssetBasedSource extends BaseSource /** * AssetBasedLayer constructor. * - * @param $asset */ public function __construct($asset = null) { @@ -34,7 +33,7 @@ public function __construct($asset = null) * * @return $this */ - public function setSource($source) + public function setSource(BaseSourceQualifier|string $source): static { if ($source instanceof BaseSourceQualifier) { $this->getSourceQualifier()->setQualifierValue($source->getValue()); diff --git a/src/Transformation/Layer/AudioOverlay.php b/src/Transformation/Layer/AudioOverlay.php index 6098a9e..4640dba 100644 --- a/src/Transformation/Layer/AudioOverlay.php +++ b/src/Transformation/Layer/AudioOverlay.php @@ -25,20 +25,16 @@ class AudioOverlay extends BaseSourceContainer { /** - * @var Timeline $timeline The timeline position of the overlay. + * @var ?Timeline $timeline The timeline position of the overlay. */ - protected $timeline; + protected ?Timeline $timeline; /** * BaseLayerContainer constructor. * * @param BaseSource|string $source - * @param Timeline|null $timeline */ - public function __construct( - $source = null, - $timeline = null - ) { + public function __construct($source = null, ?Timeline $timeline = null) { parent::__construct($source); $this->timeline($timeline); @@ -49,9 +45,8 @@ public function __construct( * * @param Timeline|null $timeline The timeline position of the overlay. * - * @return AudioOverlay */ - public function timeline(?Timeline $timeline = null) + public function timeline(?Timeline $timeline = null): static { $this->timeline = $timeline; @@ -63,7 +58,7 @@ public function timeline(?Timeline $timeline = null) * * @return $this */ - protected function concatenate() + protected function concatenate(): static { $this->source->setFlag(LayerFlag::splice()); @@ -73,21 +68,17 @@ protected function concatenate() /** * Sets the source. * - * @param BaseSource $source The source. + * @param BaseSource|string|null $source The source. * - * @return static */ - public function source($source) + public function source(BaseSource|string|null $source): static { $this->source = ClassUtils::verifyInstance($source, BaseSource::class, AudioSource::class); return $this; } - /** - * @return array - */ - protected function getSubActionQualifiers() + protected function getSubActionQualifiers(): array { $subActionQualifiers = parent::getSubActionQualifiers(); diff --git a/src/Transformation/Layer/AudioSource.php b/src/Transformation/Layer/AudioSource.php index 1f49283..71d7fe9 100644 --- a/src/Transformation/Layer/AudioSource.php +++ b/src/Transformation/Layer/AudioSource.php @@ -29,7 +29,6 @@ class AudioSource extends AssetBasedSource /** * AudioSource constructor. * - * @param $source */ public function __construct($source) { @@ -41,11 +40,10 @@ public function __construct($source) * * Creates a new VideoTransformation if not initialized. * - * @return VideoTransformation * * @internal */ - public function getTransformation() + public function getTransformation(): VideoTransformation { if (! isset($this->transformation)) { $this->transformation = new VideoTransformation(); @@ -57,11 +55,10 @@ public function getTransformation() /** * Getter for the layer qualifier. * - * @return AudioSourceQualifier * * @internal */ - protected function getSourceQualifier() + protected function getSourceQualifier(): AudioSourceQualifier { if (! isset($this->qualifiers['source'])) { $this->qualifiers['source'] = new AudioSourceQualifier(null); @@ -74,11 +71,10 @@ protected function getSourceQualifier() /** * Named constructor. * - * @param BaseSource|string $source The layer source. + * @param string|BaseSource $source The layer source. * - * @return static */ - protected static function createWithSource($source) + protected static function createWithSource(BaseSource|string $source): BaseSource|string|static { return $source; } diff --git a/src/Transformation/Layer/AudioSourceQualifier.php b/src/Transformation/Layer/AudioSourceQualifier.php index c708dcc..d3cbf07 100644 --- a/src/Transformation/Layer/AudioSourceQualifier.php +++ b/src/Transformation/Layer/AudioSourceQualifier.php @@ -20,12 +20,11 @@ class AudioSourceQualifier extends BaseSourceQualifier /** * @var string $sourceType The type of the layer. */ - protected $sourceType = 'audio'; + protected string $sourceType = 'audio'; /** * AudioSourceQualifier constructor. * - * @param $source */ public function __construct($source) { @@ -37,11 +36,11 @@ public function __construct($source) /** * Sets the audio source. * - * @param SourceValue|string $source The audio source. + * @param string|SourceValue|null $source The audio source. * * @return $this */ - public function audio($source) + public function audio(SourceValue|string|null $source): static { $this->value->setValue(ClassUtils::verifyInstance($source, SourceValue::class)); diff --git a/src/Transformation/Layer/AudioSourceTrait.php b/src/Transformation/Layer/AudioSourceTrait.php index f974266..316bce2 100644 --- a/src/Transformation/Layer/AudioSourceTrait.php +++ b/src/Transformation/Layer/AudioSourceTrait.php @@ -22,11 +22,10 @@ trait AudioSourceTrait /** * Adds another audio layer. * - * @param string $audioId The public ID of the new audio layer. + * @param string|null $audioId The public ID of the new audio layer. * - * @return static|AudioSource */ - public static function audio($audioId = null) + public static function audio(?string $audioId = null): AudioSource|static { return static::createWithSource(ClassUtils::verifyInstance($audioId, AudioSource::class)); } diff --git a/src/Transformation/Layer/BasePositionalSourceContainer.php b/src/Transformation/Layer/BasePositionalSourceContainer.php index 43dc967..b46f9ac 100644 --- a/src/Transformation/Layer/BasePositionalSourceContainer.php +++ b/src/Transformation/Layer/BasePositionalSourceContainer.php @@ -23,17 +23,17 @@ abstract class BasePositionalSourceContainer extends BaseSourceContainer { /** - * @var Position $position Layer position. + * @var ?BasePosition $position Layer position. */ - protected $position; + protected ?BasePosition $position; /** * BaseLayerContainer constructor. * - * @param BaseSource|string $source The source. - * @param Position $position Layer position. + * @param BaseSource|string|null $source The source. + * @param BasePosition|null $position Layer position. */ - public function __construct($source = null, $position = null) + public function __construct(BaseSource|string|null $source = null, ?BasePosition $position = null) { parent::__construct(); @@ -44,11 +44,10 @@ public function __construct($source = null, $position = null) /** * Sets the source position. * - * @param Position $position The Position of the layer. + * @param Position|null $position The Position of the layer. * - * @return static */ - abstract public function position($position = null); + abstract public function position(?BasePosition $position = null): static; /** * Collects source based action grouped by sub-actions. @@ -69,7 +68,7 @@ abstract public function position($position = null); * * @internal */ - protected function getSubActionQualifiers() + protected function getSubActionQualifiers(): array { $subActionQualifiers = parent::getSubActionQualifiers(); @@ -84,9 +83,8 @@ protected function getSubActionQualifiers() /** * Serializes to json. * - * @return array */ - public function jsonSerialize() + public function jsonSerialize(): array { $result = parent::jsonSerialize(); diff --git a/src/Transformation/Layer/BaseSource.php b/src/Transformation/Layer/BaseSource.php index 2657ac0..c186e4f 100644 --- a/src/Transformation/Layer/BaseSource.php +++ b/src/Transformation/Layer/BaseSource.php @@ -21,16 +21,15 @@ abstract class BaseSource extends BaseAction /** * @var CommonTransformation $transformation Transformation of the source. */ - protected $transformation; + protected CommonTransformation $transformation; /** * Sets layer transformation. * * @param CommonTransformation $t The transformation to set. * - * @return static */ - public function transformation(CommonTransformation $t) + public function transformation(CommonTransformation $t): static { $this->transformation = clone $t; @@ -44,7 +43,7 @@ public function transformation(CommonTransformation $t) * * @return $this */ - public function setStackPosition($position) + public function setStackPosition(string $position): static { $this->qualifiers['source']->setStackPosition($position); @@ -57,9 +56,8 @@ public function setStackPosition($position) * @param BaseAction|BaseQualifier|mixed $action The transformation action to add. * If BaseQualifier is provided, it is wrapped with action. * - * @return static */ - public function addAction($action) + public function addAction(mixed $action): static { $this->getTransformation()->addAction($action); @@ -69,11 +67,10 @@ public function addAction($action) /** * Adds a flag as a separate action. * - * @param FlagQualifier|string $flag The flag to add. + * @param string|FlagQualifier $flag The flag to add. * - * @return static */ - public function addFlag($flag) + public function addFlag(FlagQualifier|string $flag): static { $this->getTransformation()->addFlag($flag); @@ -86,11 +83,10 @@ public function addFlag($flag) * * Appended transformation is nested. * - * @param CommonTransformation $transformation The transformation to add. + * @param CommonTransformation|BaseAction $transformation The transformation to add. * - * @return static */ - public function addTransformation($transformation) + public function addTransformation(CommonTransformation|BaseAction $transformation): static { $this->getTransformation()->addTransformation($transformation); @@ -111,10 +107,8 @@ public function __toString() /** * Serializes to json. - * - * @return mixed */ - public function jsonSerialize() + public function jsonSerialize(): array { return [ 'source' => $this::getName(), @@ -125,18 +119,17 @@ public function jsonSerialize() /** * Gets the transformation. * - * @return Transformation * * @internal */ - abstract public function getTransformation(); + abstract public function getTransformation(): CommonTransformation; /** * Gets the layer qualifier. * - * @return BaseSourceQualifier * * @internal */ - abstract protected function getSourceQualifier(); + abstract protected function getSourceQualifier( + ): BaseSourceQualifier|ImageSourceQualifier|VideoSourceQualifier|FetchSourceQualifier; } diff --git a/src/Transformation/Layer/BaseSourceContainer.php b/src/Transformation/Layer/BaseSourceContainer.php index 4be57ee..10786dd 100644 --- a/src/Transformation/Layer/BaseSourceContainer.php +++ b/src/Transformation/Layer/BaseSourceContainer.php @@ -22,16 +22,16 @@ abstract class BaseSourceContainer extends BaseAction { /** - * @var BaseSource $source The source of the layer. + * @var ?BaseSource $source The source of the layer. */ - protected $source; + protected ?BaseSource $source; /** * BaseSourceContainer constructor. * - * @param BaseSource|string $source The source. + * @param BaseSource|string|null $source The source. */ - public function __construct($source = null) + public function __construct(BaseSource|string|null $source = null) { parent::__construct(); @@ -41,11 +41,10 @@ public function __construct($source = null) /** * Sets the source. * - * @param BaseSource $source The source. + * @param BaseSource|string|null $source The source. * - * @return static */ - abstract public function source($source); + abstract public function source(BaseSource|string|null $source): static; /** * Sets stack position of the source. @@ -54,7 +53,7 @@ abstract public function source($source); * * @return $this */ - public function setStackPosition($stackPosition) + public function setStackPosition(string $stackPosition): static { $this->source->setStackPosition($stackPosition); @@ -80,7 +79,7 @@ public function setStackPosition($stackPosition) * * @internal */ - protected function getSubActionQualifiers() + protected function getSubActionQualifiers(): array { $sourceQualifiers = $this->source ? $this->source->getStringQualifiers() : []; $sourceTransformation = $this->source ? $this->source->getTransformation() : null; @@ -114,9 +113,8 @@ public function __toString() /** * Serializes to json. * - * @return array */ - public function jsonSerialize() + public function jsonSerialize(): array { return [ 'source' => $this->source, diff --git a/src/Transformation/Layer/BaseSourceQualifier.php b/src/Transformation/Layer/BaseSourceQualifier.php index 491aa3b..fca0c19 100644 --- a/src/Transformation/Layer/BaseSourceQualifier.php +++ b/src/Transformation/Layer/BaseSourceQualifier.php @@ -21,33 +21,32 @@ class BaseSourceQualifier extends BaseQualifier /** * @var string $name The name of the source qualifier. */ - protected static $name = 'source'; + protected static string $name = 'source'; /** * @var string $sourceType The type of the source. */ - protected $sourceType; + protected string $sourceType; /** - * @var string $assetType The type of the asset. + * @var ?string $assetType The type of the asset. */ - protected $assetType; + protected ?string $assetType; /** * @var string The stack position of the layer. */ - protected $stackPosition = LayerStackPosition::OVERLAY; + protected string $stackPosition = LayerStackPosition::OVERLAY; /** * Gets the source key. * * Key depends on the stack position. * - * @return string * * @internal */ - public function getSourceKey() + public function getSourceKey(): string { if ($this->stackPosition === LayerStackPosition::UNDERLAY) { return 'u'; @@ -61,7 +60,7 @@ public function getSourceKey() * * @return string Component name. */ - public function getFullName() + public function getFullName(): string { return ArrayUtils::implodeFiltered('_', [parent::getFullName(), $this->stackPosition]); } @@ -73,7 +72,7 @@ public function getFullName() * * @return $this */ - public function setStackPosition($stackPosition) + public function setStackPosition(string $stackPosition): static { $this->stackPosition = $stackPosition; @@ -83,11 +82,11 @@ public function setStackPosition($stackPosition) /** * Sets the asset type. * - * @param string $assetType The type of the asset. + * @param ?string $assetType The type of the asset. * * @return $this */ - public function assetType($assetType) + public function assetType(?string $assetType): static { $this->assetType = $assetType; @@ -101,8 +100,8 @@ public function assetType($assetType) */ public function __toString() { - $sourceTypeStr = $this->sourceType ? "$this->sourceType:" : ''; - $assetTypeStr = $this->assetType && $this->assetType != "image" ? "$this->assetType:" : ''; + $sourceTypeStr = isset($this->sourceType) && $this->sourceType ? "$this->sourceType:" : ''; + $assetTypeStr = isset($this->assetType) && $this->assetType && $this->assetType != "image" ? "$this->assetType:" : ''; return empty((string)$this->value) ? '' : "{$this->getSourceKey()}_$assetTypeStr$sourceTypeStr$this->value"; } diff --git a/src/Transformation/Layer/BlendMode.php b/src/Transformation/Layer/BlendMode.php index 441a651..03bb600 100644 --- a/src/Transformation/Layer/BlendMode.php +++ b/src/Transformation/Layer/BlendMode.php @@ -24,42 +24,41 @@ class BlendMode extends EffectQualifier /** * @var string $name Serialization name. */ - protected static $name = 'blend_mode'; + protected static string $name = 'blend_mode'; /** * Each pixel of the image is made darker according to the pixel value of the overlaid image. */ - const MULTIPLY = 'multiply'; + public const MULTIPLY = 'multiply'; /** * Each pixel of the image is made brighter according to the pixel value of the overlaid image. */ - const SCREEN = 'screen'; + public const SCREEN = 'screen'; /** * Each pixel of the image is made darker or brighter according to the pixel value of the overlaid image. */ - const OVERLAY = 'overlay'; + public const OVERLAY = 'overlay'; /** * Each pixel of the image is 'cut-out' according to the non-transparent pixels of the overlaid * image. */ - const MASK = 'mask'; + public const MASK = 'mask'; /** * The overlay is slightly distorted to prevent easy removal. */ - const ANTI_REMOVAL = 'anti_removal'; + public const ANTI_REMOVAL = 'anti_removal'; /** * Add an overlay image blended using the 'multiply' blend mode. * * In this mode, each pixel of the image is made darker according to the pixel value of the overlaid image. * - * @return BlendMode */ - public static function multiply() + public static function multiply(): BlendMode { return new self(self::MULTIPLY); } @@ -69,9 +68,8 @@ public static function multiply() * * In this mode, each pixel of the image is made brighter according to the pixel value of the overlaid image. * - * @return BlendMode */ - public static function screen() + public static function screen(): BlendMode { return new self(self::SCREEN); } @@ -82,9 +80,8 @@ public static function screen() * In this mode, each pixel of the image is made darker or brighter according to the pixel value of the overlaid * image. * - * @return BlendMode */ - public static function overlay() + public static function overlay(): BlendMode { return new self(self::OVERLAY); } @@ -95,9 +92,8 @@ public static function overlay() * In this mode, each pixel of the image is 'cut-out' according to the non-transparent pixels of the overlaid * image. * - * @return BlendMode */ - public static function mask() + public static function mask(): BlendMode { return new self(self::MASK); } @@ -107,11 +103,10 @@ public static function mask() * * In this mode, the overlay is slightly distorted to prevent easy removal. * - * @param int $level The level of distortion. (Range: 1 to 100, Server default: 50) + * @param int|null $level The level of distortion. (Range: 1 to 100, Server default: 50) * - * @return BlendMode */ - public static function antiRemoval($level = null) + public static function antiRemoval(?int $level = null): BlendMode { return new self(self::ANTI_REMOVAL, $level); } diff --git a/src/Transformation/Layer/FetchImageSource.php b/src/Transformation/Layer/FetchImageSource.php index e3aa7c1..8d04b40 100644 --- a/src/Transformation/Layer/FetchImageSource.php +++ b/src/Transformation/Layer/FetchImageSource.php @@ -28,7 +28,7 @@ class FetchImageSource extends ImageSource * * @return $this */ - public function setSource($source) + public function setSource(BaseSourceQualifier|string $source): static { if ($source instanceof BaseSourceQualifier) { @@ -46,11 +46,9 @@ public function setSource($source) /** * Gets the layer qualifier. * - * @return ImageSourceQualifier - * * @internal */ - protected function getSourceQualifier() + protected function getSourceQualifier(): FetchSourceQualifier|ImageSourceQualifier { if (! isset($this->qualifiers['source'])) { $this->qualifiers['source'] = new FetchSourceQualifier(null); diff --git a/src/Transformation/Layer/FetchSourceQualifier.php b/src/Transformation/Layer/FetchSourceQualifier.php index c7e037b..bbcf8ca 100644 --- a/src/Transformation/Layer/FetchSourceQualifier.php +++ b/src/Transformation/Layer/FetchSourceQualifier.php @@ -18,12 +18,12 @@ class FetchSourceQualifier extends BaseSourceQualifier { - const VALUE_CLASS = RemoteSourceValue::class; + protected const VALUE_CLASS = RemoteSourceValue::class; /** - * @var string|RemoteSourceValue $sourceType The type of the layer. + * @var string $sourceType The type of the layer. */ - protected $sourceType = 'fetch'; + protected string $sourceType = 'fetch'; /** * FetchLayerQualifier constructor. @@ -40,14 +40,14 @@ public function __construct($fetchUrl) /** * Sets the URL of the remote asset. * - * @param string|RemoteSourceValue $fetchUrl The URL of the asset. + * @param string|RemoteSourceValue|null $fetchUrl The URL of the asset. * * @return $this */ - public function fetchUrl($fetchUrl) + public function fetchUrl(RemoteSourceValue|string|null $fetchUrl): static { if (StringUtils::contains($fetchUrl, ':fetch:')) { - list($this->assetType, $this->sourceType, $fetchUrl) = explode(':', $fetchUrl, 3); + [$this->assetType, $this->sourceType, $fetchUrl] = explode(':', $fetchUrl, 3); } $this->setQualifierValue(StringUtils::truncatePrefix($fetchUrl, 'fetch:')); diff --git a/src/Transformation/Layer/FetchVideoSource.php b/src/Transformation/Layer/FetchVideoSource.php index 3a1e975..fa1789f 100644 --- a/src/Transformation/Layer/FetchVideoSource.php +++ b/src/Transformation/Layer/FetchVideoSource.php @@ -10,8 +10,6 @@ namespace Cloudinary\Transformation; -use Cloudinary\ClassUtils; - /** * Defines how to manipulate a fetched video layer. * @@ -26,7 +24,6 @@ class FetchVideoSource extends VideoSource /** * VideoLayer constructor. * - * @param $source */ public function __construct($source) { @@ -37,11 +34,11 @@ public function __construct($source) /** * Sets the source of the layer. * - * @param string|FetchSourceQualifier $source The source. + * @param string|BaseSourceQualifier $source The source. * * @return $this */ - public function setSource($source) + public function setSource(BaseSourceQualifier|string $source): static { if ($source instanceof FetchSourceQualifier) { @@ -59,11 +56,10 @@ public function setSource($source) /** * Gets the layer qualifier. * - * @return FetchSourceQualifier * * @internal */ - protected function getSourceQualifier() + protected function getSourceQualifier(): FetchSourceQualifier { if (! isset($this->qualifiers['source'])) { $this->qualifiers['source'] = (new FetchSourceQualifier(null))->assetType("video"); diff --git a/src/Transformation/Layer/ImageOverlay.php b/src/Transformation/Layer/ImageOverlay.php index 6c2c793..325df06 100644 --- a/src/Transformation/Layer/ImageOverlay.php +++ b/src/Transformation/Layer/ImageOverlay.php @@ -21,18 +21,18 @@ class ImageOverlay extends BasePositionalSourceContainer use ImageSourceTrait; /** - * @var BlendMode $blendMode Layer blend mode. + * @var ?BlendMode $blendMode Layer blend mode. */ - protected $blendMode; + protected ?BlendMode $blendMode; /** - * BaseLayerContainer constructor. + * ImageOverlay constructor. * - * @param BaseSource|string $source The source. - * @param Position $position Layer position. - * @param string|BlendMode $blendMode Layer blend mode. + * @param BaseSource|string $source The source. + * @param ?BasePosition $position Layer position. + * @param BlendMode|string|null $blendMode Layer blend mode. */ - public function __construct($source = null, $position = null, $blendMode = null) + public function __construct($source = null, ?BasePosition $position = null, BlendMode|string|null $blendMode = null) { parent::__construct($source, $position); $this->blendMode($blendMode); @@ -41,11 +41,10 @@ public function __construct($source = null, $position = null, $blendMode = null) /** * Sets layer blend mode. * - * @param BlendMode $blendMode The blend mode. + * @param BlendMode|string|null $blendMode The blend mode. * - * @return static */ - public function blendMode($blendMode = null) + public function blendMode(BlendMode|string|null $blendMode = null): static { $this->blendMode = ClassUtils::verifyInstance($blendMode, EffectQualifier::class, BlendMode::class); @@ -55,11 +54,10 @@ public function blendMode($blendMode = null) /** * Sets the source. * - * @param BaseSource|string $source The source. + * @param BaseSource|string|null $source The source. * - * @return static */ - public function source($source) + public function source(BaseSource|string|null $source): static { $this->source = ClassUtils::verifyInstance($source, BaseSource::class, ImageSource::class); @@ -69,27 +67,23 @@ public function source($source) /** * Sets the position of the layer. * - * @param BasePosition $position The position. + * @param BasePosition|null $position The position. * - * @return static */ - public function position($position = null) + public function position(?BasePosition $position = null): static { $this->position = ClassUtils::verifyInstance($position, BasePosition::class, AbsolutePosition::class); return $this; } - /** - * @return array - */ - protected function getSubActionQualifiers() + protected function getSubActionQualifiers(): array { $subActionQualifiers = parent::getSubActionQualifiers(); $subActionQualifiers['additional'] = ArrayUtils::mergeNonEmpty( $subActionQualifiers['additional'], - $this->blendMode? $this->blendMode->getStringQualifiers(): [] + $this->blendMode ? $this->blendMode->getStringQualifiers() : [] ); return $subActionQualifiers; diff --git a/src/Transformation/Layer/ImageSource.php b/src/Transformation/Layer/ImageSource.php index 61d00be..344d2e5 100644 --- a/src/Transformation/Layer/ImageSource.php +++ b/src/Transformation/Layer/ImageSource.php @@ -27,7 +27,6 @@ class ImageSource extends AssetBasedSource implements ImageTransformationInterfa /** * ImageLayer constructor. * - * @param $source */ public function __construct($source) { @@ -37,11 +36,9 @@ public function __construct($source) /** * Gets the transformation. * - * @return ImageTransformation - * * @internal */ - public function getTransformation() + public function getTransformation(): CommonTransformation|ImageTransformation { if (! isset($this->transformation)) { $this->transformation = new ImageTransformation(); @@ -53,11 +50,10 @@ public function getTransformation() /** * Gets the layer qualifier. * - * @return ImageSourceQualifier * * @internal */ - protected function getSourceQualifier() + protected function getSourceQualifier(): ImageSourceQualifier|BaseSourceQualifier { if (! isset($this->qualifiers['source'])) { $this->qualifiers['source'] = new ImageSourceQualifier(null); diff --git a/src/Transformation/Layer/ImageSourceQualifier.php b/src/Transformation/Layer/ImageSourceQualifier.php index 289b46b..9cacc84 100644 --- a/src/Transformation/Layer/ImageSourceQualifier.php +++ b/src/Transformation/Layer/ImageSourceQualifier.php @@ -11,6 +11,7 @@ namespace Cloudinary\Transformation; use Cloudinary\ClassUtils; +use Cloudinary\Transformation\Qualifier\BaseQualifier; /** * Class ImageSourceQualifier @@ -22,7 +23,7 @@ class ImageSourceQualifier extends BaseSourceQualifier /** * @var string $sourceType The type of the layer. */ - protected $sourceType; + protected string $sourceType; /** * ImageSourceQualifier constructor. @@ -33,4 +34,24 @@ public function __construct($source) { parent::__construct(ClassUtils::verifyInstance($source, SourceValue::class)); } + + /** + * Sets the source of the layer. + * + * @param string|BaseSourceQualifier|QualifierMultiValue $source The source. + * + * + * @internal + * + */ + public function setSource(BaseSourceQualifier|QualifierMultiValue|string $source): static + { + if ($source instanceof BaseQualifier) { + $source = $source->getValue(); + } + + $this->getValue()->setSimpleValue('source', $source); + + return $this; + } } diff --git a/src/Transformation/Layer/ImageSourceTrait.php b/src/Transformation/Layer/ImageSourceTrait.php index f88b8c4..c2b8ec2 100644 --- a/src/Transformation/Layer/ImageSourceTrait.php +++ b/src/Transformation/Layer/ImageSourceTrait.php @@ -24,9 +24,8 @@ trait ImageSourceTrait * * @param string $publicId The public ID of the new image layer. * - * @return static|ImageSource */ - public static function image($publicId) + public static function image(string $publicId): ImageSource|static { return static::createWithSource(ClassUtils::verifyInstance($publicId, ImageSource::class)); } @@ -36,9 +35,8 @@ public static function image($publicId) * * @param string|null $fetchUrl The URL of the asset to fetch. * - * @return static|FetchImageSource */ - public static function fetch($fetchUrl) + public static function fetch(?string $fetchUrl): FetchImageSource|static { return static::createWithSource(ClassUtils::verifyInstance($fetchUrl, FetchImageSource::class)); } @@ -48,9 +46,8 @@ public static function fetch($fetchUrl) * * @param string $lutId The public ID of the LUT file. * - * @return static|LutLayer */ - public static function lut($lutId) + public static function lut(string $lutId): LutLayer|static { return static::createWithSource(ClassUtils::verifyInstance($lutId, LutLayer::class)); } @@ -58,15 +55,14 @@ public static function lut($lutId) /** * Adds a text layer. * - * @param string $text The text to display. - * @param string $style The text style. - * @param string $color The text color. + * @param string|null $text The text to display. + * @param string|null $style The text style. + * @param string|null $color The text color. * - * @return static|TextSource * - * @see \Cloudinary\Transformation\TextSource + * @see TextSource */ - public static function text($text = null, $style = null, $color = null) + public static function text(?string $text = null, ?string $style = null, ?string $color = null): TextSource|static { return static::createWithSource(new TextSource($text, $style, $color)); } @@ -74,11 +70,10 @@ public static function text($text = null, $style = null, $color = null) /** * Named constructor. * - * @param BaseSource|string $source The layer source. + * @param string|BaseSource $source The layer source. * - * @return static */ - protected static function createWithSource($source) + protected static function createWithSource(BaseSource|string $source): BaseSource|string|static { return $source; } diff --git a/src/Transformation/Layer/LayerQualifierFactory.php b/src/Transformation/Layer/LayerQualifierFactory.php index 642234f..d500010 100644 --- a/src/Transformation/Layer/LayerQualifierFactory.php +++ b/src/Transformation/Layer/LayerQualifierFactory.php @@ -24,15 +24,13 @@ class LayerQualifierFactory * * Overlay properties can come as array or as string. * - * @param string|array $layerQualifiers * @param string $layerStackPosition Supported values: LayerStackPosition::OVERLAY, * LayerStackPosition::UNDERLAY * - * @return BaseSourceQualifier * * @see LayerStackPosition::OVERLAY */ - public static function fromParams($layerQualifiers, $layerStackPosition = LayerStackPosition::OVERLAY) + public static function fromParams(array|string $layerQualifiers, string $layerStackPosition = LayerStackPosition::OVERLAY): BaseSourceQualifier { return self::handleQualifierValue($layerQualifiers)->setStackPosition($layerStackPosition); } @@ -40,11 +38,10 @@ public static function fromParams($layerQualifiers, $layerStackPosition = LayerS /** * Handles layer qualifier value. * - * @param string|array $layerQualifiers The layer qualifiers. + * @param array|string $layerQualifiers The layer qualifiers. * - * @return BaseSourceQualifier */ - protected static function handleQualifierValue($layerQualifiers) + protected static function handleQualifierValue(array|string $layerQualifiers): FetchSourceQualifier|ImageSourceQualifier|BaseSourceQualifier|LutSourceQualifier|VideoSourceQualifier|SubtitlesSourceQualifier { // Handle layer params if (is_array($layerQualifiers)) { diff --git a/src/Transformation/Layer/LayerQualifierTrait.php b/src/Transformation/Layer/LayerQualifierTrait.php index 68e40ab..2a856dc 100644 --- a/src/Transformation/Layer/LayerQualifierTrait.php +++ b/src/Transformation/Layer/LayerQualifierTrait.php @@ -24,9 +24,8 @@ trait LayerQualifierTrait * * @param string|mixed $source The source of the layer. * - * @return ImageSource */ - public static function overlay($source) + public static function overlay(mixed $source): ImageSource { return ClassUtils::verifyInstance($source, BaseSource::class, ImageSource::class); } @@ -36,9 +35,8 @@ public static function overlay($source) * * @param string|mixed $source The source of the layer. * - * @return ImageSource */ - public static function underlay($source) + public static function underlay(mixed $source): ImageSource { $layer = ClassUtils::verifyInstance($source, BaseSource::class, ImageSource::class); diff --git a/src/Transformation/Layer/LayerSourceTrait.php b/src/Transformation/Layer/LayerSourceTrait.php index 3ef4bd1..7386aca 100644 --- a/src/Transformation/Layer/LayerSourceTrait.php +++ b/src/Transformation/Layer/LayerSourceTrait.php @@ -20,11 +20,10 @@ trait LayerSourceTrait /** * Sets the source of the layer. * - * @param string|SourceValue|BaseSourceQualifier $source The source. + * @param string|BaseSourceQualifier|SourceValue $source The source. * - * @return static */ - public function source($source) + public function source(SourceValue|BaseSourceQualifier|string $source): static { return $this->setSource($source); } @@ -32,14 +31,13 @@ public function source($source) /** * Sets the source of the layer. * - * @param string|QualifierMultiValue|BaseSourceQualifier $source The source. + * @param string|BaseSourceQualifier|QualifierMultiValue $source The source. * - * @return static * * @internal * */ - public function setSource($source) + public function setSource(BaseSourceQualifier|QualifierMultiValue|string $source): static { if ($source instanceof BaseQualifier) { $source = $source->getValue(); diff --git a/src/Transformation/Layer/LayerStackPosition.php b/src/Transformation/Layer/LayerStackPosition.php index 9feac00..e2d4717 100644 --- a/src/Transformation/Layer/LayerStackPosition.php +++ b/src/Transformation/Layer/LayerStackPosition.php @@ -23,6 +23,6 @@ */ class LayerStackPosition { - const OVERLAY = 'overlay'; - const UNDERLAY = 'underlay'; + public const OVERLAY = 'overlay'; + public const UNDERLAY = 'underlay'; } diff --git a/src/Transformation/Layer/LutLayer.php b/src/Transformation/Layer/LutLayer.php index 644f929..b0d3a6b 100644 --- a/src/Transformation/Layer/LutLayer.php +++ b/src/Transformation/Layer/LutLayer.php @@ -28,7 +28,6 @@ class LutLayer extends AssetBasedSource implements AdjustmentInterface /** * LutLayer constructor. * - * @param $lut */ public function __construct($lut) { @@ -38,9 +37,8 @@ public function __construct($lut) /** * Gets the transformation. * - * @return Transformation */ - public function getTransformation() + public function getTransformation(): Transformation { if (! isset($this->transformation)) { $this->transformation = new Transformation(); @@ -52,11 +50,10 @@ public function getTransformation() /** * Gets the layer qualifier. * - * @return LutSourceQualifier * * @internal */ - protected function getSourceQualifier() + protected function getSourceQualifier(): LutSourceQualifier { if (! isset($this->qualifiers['source'])) { $this->qualifiers['source'] = new LutSourceQualifier(null); diff --git a/src/Transformation/Layer/LutSourceQualifier.php b/src/Transformation/Layer/LutSourceQualifier.php index 1d4beff..3cfd0f0 100644 --- a/src/Transformation/Layer/LutSourceQualifier.php +++ b/src/Transformation/Layer/LutSourceQualifier.php @@ -20,12 +20,11 @@ class LutSourceQualifier extends BaseSourceQualifier /** * @var string $sourceType The type of the layer. */ - protected $sourceType = 'lut'; + protected string $sourceType = 'lut'; /** * LutLayerQualifier constructor. * - * @param $lutId */ public function __construct($lutId) { @@ -37,11 +36,11 @@ public function __construct($lutId) /** * Sets the lut source. * - * @param string|SourceValue $lutId The public ID of the LUT asset. + * @param string|SourceValue|null $lutId The public ID of the LUT asset. * * @return $this */ - public function lut($lutId) + public function lut(SourceValue|string|null $lutId): static { $this->value->setValue(ClassUtils::verifyInstance($lutId, SourceValue::class)); diff --git a/src/Transformation/Layer/MediaOverlay.php b/src/Transformation/Layer/MediaOverlay.php index f824d87..3b1639d 100644 --- a/src/Transformation/Layer/MediaOverlay.php +++ b/src/Transformation/Layer/MediaOverlay.php @@ -22,32 +22,28 @@ class MediaOverlay extends ImageOverlay /** * @var Timeline $timeline The timeline position of the overlay. */ - protected $timeline; + protected Timeline $timeline; /** * Sets the timeline position of the overlay. * * @param Timeline|null $timeline The timeline position of the overlay. * - * @return MediaOverlay */ - public function timeline(?Timeline $timeline = null) + public function timeline(?Timeline $timeline = null): static { $this->timeline = $timeline; return $this; } - /** - * @return array - */ - protected function getSubActionQualifiers() + protected function getSubActionQualifiers(): array { $subActionQualifiers = parent::getSubActionQualifiers(); $subActionQualifiers['additional'] = ArrayUtils::mergeNonEmpty( $subActionQualifiers['additional'], - $this->timeline? $this->timeline->getStringQualifiers(): [] + !empty($this->timeline) ? $this->timeline->getStringQualifiers(): [] ); return $subActionQualifiers; diff --git a/src/Transformation/Layer/Overlay.php b/src/Transformation/Layer/Overlay.php index 6b05330..6a99dee 100644 --- a/src/Transformation/Layer/Overlay.php +++ b/src/Transformation/Layer/Overlay.php @@ -20,42 +20,22 @@ */ abstract class Overlay { - /** - * @param $source - * - * @return MediaOverlay - */ - public static function source($source) + public static function source($source): MediaOverlay { return ClassUtils::verifyInstance($source, BaseSourceContainer::class, MediaOverlay::class); } - /** - * @param $source - * - * @return ImageOverlay - */ - public static function imageSource($source) + public static function imageSource($source): ImageOverlay { return ClassUtils::verifyInstance($source, BasePositionalSourceContainer::class, ImageOverlay::class); } - /** - * @param $source - * - * @return VideoOverlay - */ - public static function videoSource($source) + public static function videoSource($source): VideoOverlay { return ClassUtils::verifyInstance($source, BasePositionalSourceContainer::class, VideoOverlay::class); } - /** - * @param $source - * - * @return AudioOverlay - */ - public static function audioSource($source) + public static function audioSource($source): AudioOverlay { return ClassUtils::verifyInstance($source, BaseSourceContainer::class, AudioOverlay::class); } diff --git a/src/Transformation/Layer/SourceValue.php b/src/Transformation/Layer/SourceValue.php index 80a4a4a..7bf2452 100644 --- a/src/Transformation/Layer/SourceValue.php +++ b/src/Transformation/Layer/SourceValue.php @@ -15,8 +15,8 @@ */ class SourceValue extends QualifierMultiValue { - const UNSAFE_DELIMITER = '/'; - const SAFE_DELIMITER = ':'; + protected const UNSAFE_DELIMITER = '/'; + protected const SAFE_DELIMITER = ':'; use LayerSourceTrait; diff --git a/src/Transformation/Layer/SubtitlesSource.php b/src/Transformation/Layer/SubtitlesSource.php index a3161a0..581618b 100644 --- a/src/Transformation/Layer/SubtitlesSource.php +++ b/src/Transformation/Layer/SubtitlesSource.php @@ -31,7 +31,6 @@ class SubtitlesSource extends AssetBasedSource /** * SubtitlesLayer constructor. * - * @param $subtitlesId */ public function __construct($subtitlesId) { @@ -41,9 +40,8 @@ public function __construct($subtitlesId) /** * Gets the transformation. * - * @return VideoTransformation */ - public function getTransformation() + public function getTransformation(): VideoTransformation { if (! isset($this->transformation)) { $this->transformation = new VideoTransformation(); @@ -59,7 +57,7 @@ public function getTransformation() * * @return $this */ - public function textStyle($style) + public function textStyle(array|TextStyle $style): static { $this->getSourceQualifier()->textStyle($style); @@ -73,13 +71,15 @@ public function textStyle($style) * @param string $value The style. * @param bool $named Indicates whether the property is a named property. * - * @return static - * * @internal */ - protected function setStyleProperty($styleName, $value, $named = false) - { - $this->getSourceQualifier()->setStyleProperty($styleName, $value, $named); + protected function setStyleProperty( + string $styleName, + string $value, + bool $named = false, + ?string $defaultValue = null + ): static { + $this->getSourceQualifier()->setStyleProperty($styleName, $value, $named, $defaultValue); return $this; } @@ -87,11 +87,10 @@ protected function setStyleProperty($styleName, $value, $named = false) /** * Gets the layer qualifier. * - * @return SubtitlesSourceQualifier * * @internal */ - protected function getSourceQualifier() + protected function getSourceQualifier(): SubtitlesSourceQualifier { if (! isset($this->qualifiers['source'])) { $this->qualifiers['source'] = new SubtitlesSourceQualifier(null); diff --git a/src/Transformation/Layer/SubtitlesSourceQualifier.php b/src/Transformation/Layer/SubtitlesSourceQualifier.php index 1cedb38..d3f0341 100644 --- a/src/Transformation/Layer/SubtitlesSourceQualifier.php +++ b/src/Transformation/Layer/SubtitlesSourceQualifier.php @@ -21,12 +21,12 @@ class SubtitlesSourceQualifier extends BaseSourceQualifier /** * @var string $sourceType The type of the layer. */ - protected $sourceType = 'subtitles'; + protected string $sourceType = 'subtitles'; /** * @var array $valueOrder The order of the values. */ - protected $valueOrder = ['text_style', 'subtitles_id']; + protected array $valueOrder = ['text_style', 'subtitles_id']; use TextStyleTrait; @@ -34,9 +34,9 @@ class SubtitlesSourceQualifier extends BaseSourceQualifier * SubtitlesLayerQualifier constructor. * * @param string|SourceValue|mixed $subtitlesId The public ID of the subtitles asset. - * @param TextStyle $style The text style of subtitles. + * @param array|TextStyle|null $style The text style of subtitles. */ - public function __construct($subtitlesId, $style = null) + public function __construct($subtitlesId, array|TextStyle|null $style = null) { parent::__construct(); @@ -50,7 +50,7 @@ public function __construct($subtitlesId, $style = null) * * @return $this */ - public function subtitlesId($subtitlesId) + public function subtitlesId(mixed $subtitlesId): static { $this->value->setSimpleValue('subtitles_id', ClassUtils::verifyInstance($subtitlesId, SourceValue::class)); @@ -60,11 +60,11 @@ public function subtitlesId($subtitlesId) /** * Sets the text style of the subtitles. * - * @param array|TextStyle $style The style. + * @param array|TextStyle|null $style The style. * * @return $this */ - public function textStyle($style) + public function textStyle(array|TextStyle|null $style): static { if (is_array($style)) { $style = TextStyle::fromParams($style); @@ -78,11 +78,10 @@ public function textStyle($style) /** * Gets the text style. * - * @return TextStyle */ - protected function getStyle() + protected function getStyle(): TextStyle { - if (!$this->value->getSimpleValue('text_style')) { + if (! $this->value->getSimpleValue('text_style')) { $this->value->setValue(new TextStyle()); } @@ -95,14 +94,17 @@ protected function getStyle() * @param string $styleName The style name. * @param string $value The style. * @param bool $named Indicates whether the property is a named property. - * @param null|string $defaultValue The default value of the property. Used for omitting values that are default. + * @param string|null $defaultValue The default value of the property. Used for omitting values that are default. * - * @return static * * @internal */ - public function setStyleProperty($styleName, $value, $named = false, $defaultValue = null) - { + public function setStyleProperty( + string $styleName, + string $value, + bool $named = false, + ?string $defaultValue = null + ): static { $this->getStyle()->setStyleProperty($styleName, $value, $named, $defaultValue); return $this; diff --git a/src/Transformation/Layer/TextSource.php b/src/Transformation/Layer/TextSource.php index ef88d0c..6cab177 100644 --- a/src/Transformation/Layer/TextSource.php +++ b/src/Transformation/Layer/TextSource.php @@ -13,8 +13,6 @@ use Cloudinary\Transformation\Argument\ColorValue; use Cloudinary\Transformation\Argument\Text\Stroke; use Cloudinary\Transformation\Argument\Text\TextStyleTrait; -use Cloudinary\Transformation\Background; -use Cloudinary\Transformation\TextStyle; /** * Defines how to manipulate a text layer. @@ -39,13 +37,17 @@ class TextSource extends BaseSource implements ImageTransformationInterface /** * TextLayer constructor. * - * @param string $text - * @param string|TextStyle $style - * @param string $color - * @param string|Background|ColorValue $backgroundColor + * @param string|null $text The text. + * @param string|TextStyle|null $style The text style. + * @param string|null $color The text color. + * @param string|Background|ColorValue|null $backgroundColor Text Background color. */ - public function __construct($text = null, $style = null, $color = null, $backgroundColor = null) - { + public function __construct( + ?string $text = null, + string|TextStyle|null $style = null, + ?string $color = null, + string|Background|ColorValue|null $backgroundColor = null + ) { parent::__construct(); $this->text($text); @@ -57,11 +59,9 @@ public function __construct($text = null, $style = null, $color = null, $backgro /** * Gets the transformation. * - * @return ImageTransformation - * * @internal */ - public function getTransformation() + public function getTransformation(): ImageTransformation|CommonTransformation { if (! isset($this->transformation)) { $this->transformation = new ImageTransformation(); @@ -73,11 +73,10 @@ public function getTransformation() /** * Gets the layer qualifier. * - * @return TextSourceQualifier * * @internal */ - protected function getSourceQualifier() + protected function getSourceQualifier(): TextSourceQualifier { if (! isset($this->qualifiers['source'])) { $this->qualifiers['source'] = new TextSourceQualifier(); @@ -89,11 +88,11 @@ protected function getSourceQualifier() /** * Sets the text. * - * @param string $text The text. + * @param ?string $text The text. * * @return $this */ - public function text($text) + public function text(?string $text): static { $this->getSourceQualifier()->text($text); @@ -103,11 +102,11 @@ public function text($text) /** * Sets the text style. * - * @param string|array|TextStyle $style The text style. + * @param array|string|TextStyle|null $style The text style. * * @return $this */ - public function textStyle($style) + public function textStyle(array|string|TextStyle|null $style): static { $this->getSourceQualifier()->textStyle($style); @@ -121,7 +120,7 @@ public function textStyle($style) * * @see Flag::textNoTrim */ - public function noTrim() + public function noTrim(): static { return $this->addFlag(Flag::textNoTrim()); } @@ -133,7 +132,7 @@ public function noTrim() * * @see Flag::textDisallowOverflow */ - public function disallowOverflow() + public function disallowOverflow(): static { return $this->addFlag(Flag::textDisallowOverflow()); } @@ -145,13 +144,16 @@ public function disallowOverflow() * @param string $value The style. * @param bool $named Indicates whether the property is a named property. * - * @return static * * @internal */ - protected function setStyleProperty($styleName, $value, $named = false) - { - $this->getSourceQualifier()->setStyleProperty($styleName, $value, $named); + protected function setStyleProperty( + string $styleName, + string $value, + bool $named = false, + ?string $defaultValue = null + ): static { + $this->getSourceQualifier()->setStyleProperty($styleName, $value, $named, $defaultValue); return $this; } @@ -159,13 +161,12 @@ protected function setStyleProperty($styleName, $value, $named = false) /** * Sets whether to include an outline stroke. * - * @param string|BorderQualifier $stroke The text outline stroke. + * @param BorderQualifier|string|null $stroke The text outline stroke. * - * @return static * - * @see \Cloudinary\Transformation\Argument\Text\Stroke + * @see Stroke */ - public function stroke($stroke = Stroke::STROKE) + public function stroke(BorderQualifier|string|null $stroke = Stroke::STROKE): static { if ($stroke instanceof BorderQualifier) { $this->addQualifier($stroke); diff --git a/src/Transformation/Layer/TextSourceQualifier.php b/src/Transformation/Layer/TextSourceQualifier.php index 64053d9..014e576 100644 --- a/src/Transformation/Layer/TextSourceQualifier.php +++ b/src/Transformation/Layer/TextSourceQualifier.php @@ -24,20 +24,20 @@ class TextSourceQualifier extends BaseSourceQualifier /** * @var string $sourceType The type of the layer. */ - protected $sourceType = 'text'; + protected string $sourceType = 'text'; /** * @var array $valueOrder The order of the values. */ - protected $valueOrder = ['text_style', 'source_value', 'text']; + protected array $valueOrder = ['text_style', 'source_value', 'text']; /** * TextSourceQualifier constructor. * - * @param string|Text $text The text. - * @param array|TextStyle $style The text style. + * @param string|Text|null $text The text. + * @param array|string|TextStyle|null $style The text style. */ - public function __construct($text = null, $style = null) + public function __construct(string|Text|null $text = null, array|string|TextStyle|null $style = null) { parent::__construct(); @@ -47,11 +47,11 @@ public function __construct($text = null, $style = null) /** * Sets the text. * - * @param string|Text $text The text. + * @param string|Text|null $text The text. * * @return $this */ - public function text($text) + public function text(string|Text|null $text): static { $this->value->setValue(ClassUtils::verifyInstance($text, Text::class)); @@ -61,11 +61,11 @@ public function text($text) /** * Sets the text style. * - * @param array|TextStyle|string $style The text style. + * @param array|string|TextStyle|null $style The text style. * * @return $this */ - public function textStyle($style) + public function textStyle(array|string|TextStyle|null $style): static { if (is_array($style)) { $style = TextStyle::fromParams($style); @@ -79,11 +79,11 @@ public function textStyle($style) /** * Text style can be set to a public ID of the text asset that contains style. * - * @param string|SourceValue $publicId The public ID of the text asset. + * @param SourceValue|string|null $publicId The public ID of the text asset. * * @return $this */ - public function styleFromPublicId($publicId) + public function styleFromPublicId(SourceValue|string|null $publicId): static { $this->value->setValue(ClassUtils::verifyInstance($publicId, SourceValue::class)); @@ -93,11 +93,10 @@ public function styleFromPublicId($publicId) /** * Gets the text style. * - * @return TextStyle */ - protected function getStyle() + protected function getStyle(): TextStyle { - if (!$this->value->getSimpleValue('text_style')) { + if (! $this->value->getSimpleValue('text_style')) { $this->value->setValue(new TextStyle()); } @@ -107,16 +106,20 @@ protected function getStyle() /** * Internal setter for text style property. * - * @param string $styleName The style name. - * @param string $value The style. - * @param bool $named Indicates whether the property is a named property. - * - * @return static - * + * @param string $styleName The style name. + * @param ?string $value The style. + * @param bool $named Indicates whether the property is a named property. + * @param string|null $defaultValue The default value of the property. Used for omitting values that are default. * @internal */ - public function setStyleProperty($styleName, $value, $named = false) - { - return $this->getStyle()->setStyleProperty($styleName, $value, $named); + public function setStyleProperty( + string $styleName, + ?string $value, + bool $named = false, + ?string $defaultValue = null + ): static { + $this->getStyle()->setStyleProperty($styleName, $value, $named, $defaultValue); + + return $this; } } diff --git a/src/Transformation/Layer/Transition.php b/src/Transformation/Layer/Transition.php index 74cd1cf..77ccfe8 100644 --- a/src/Transformation/Layer/Transition.php +++ b/src/Transformation/Layer/Transition.php @@ -26,7 +26,6 @@ class Transition extends VideoSource /** * VideoTransitionSource constructor. * - * @param $source */ public function __construct($source) { @@ -38,11 +37,9 @@ public function __construct($source) /** * Named constructor. * - * @param $source * - * @return Transition */ - public static function videoSource($source) + public static function videoSource($source): Transition { return new self($source); } diff --git a/src/Transformation/Layer/Underlay.php b/src/Transformation/Layer/Underlay.php index 5892c28..8ac4650 100644 --- a/src/Transformation/Layer/Underlay.php +++ b/src/Transformation/Layer/Underlay.php @@ -19,12 +19,7 @@ */ abstract class Underlay { - /** - * @param $source - * - * @return ImageOverlay - */ - public static function source($source) + public static function source($source): ImageOverlay { return ClassUtils::forceInstance($source, ImageOverlay::class)->setStackPosition(LayerStackPosition::UNDERLAY); } diff --git a/src/Transformation/Layer/VideoOverlay.php b/src/Transformation/Layer/VideoOverlay.php index e494e49..a418843 100644 --- a/src/Transformation/Layer/VideoOverlay.php +++ b/src/Transformation/Layer/VideoOverlay.php @@ -25,21 +25,21 @@ class VideoOverlay extends BasePositionalSourceContainer { /** - * @var Timeline $timeline The timeline position of the overlay. + * @var ?Timeline $timeline The timeline position of the overlay. */ - protected $timeline; + protected ?Timeline $timeline; /** * BaseLayerContainer constructor. * - * @param BaseSource|string $source - * @param BasePosition|null $position - * @param Timeline|null $timeline + * @param BaseSource|string|null $source Overlay source. + * @param BasePosition|null $position Overlay position. + * @param Timeline|null $timeline Overlay timeline position. */ public function __construct( - $source = null, - $position = null, - $timeline = null + BaseSource|string|null $source = null, + BasePosition|null $position = null, + Timeline|null $timeline = null ) { parent::__construct($source, $position); @@ -51,9 +51,8 @@ public function __construct( * * @param Timeline|null $timeline The timeline position of the overlay. * - * @return BasePositionalSourceContainer */ - public function timeline(?Timeline $timeline = null) + public function timeline(?Timeline $timeline = null): BasePositionalSourceContainer { $this->timeline = $timeline; @@ -65,7 +64,7 @@ public function timeline(?Timeline $timeline = null) * * @return $this */ - protected function concatenate() + protected function concatenate(): static { $this->source->setFlag(LayerFlag::splice()); @@ -77,7 +76,7 @@ protected function concatenate() * * @return $this */ - public function cutter() + public function cutter(): static { $this->source->setFlag(LayerFlag::cutter()); @@ -87,11 +86,10 @@ public function cutter() /** * Sets the source. * - * @param BaseSource $source The source. + * @param BaseSource|string|null $source The source. * - * @return static */ - public function source($source) + public function source(BaseSource|string|null $source): static { $this->source = ClassUtils::verifyInstance($source, BaseSource::class, VideoSource::class); @@ -101,21 +99,17 @@ public function source($source) /** * Sets the layer position. * - * @param Position $position The Position of the layer. + * @param Position|BasePosition|null $position The Position of the layer. * - * @return static */ - public function position($position = null) + public function position(Position|BasePosition|null $position = null): static { $this->position = ClassUtils::verifyInstance($position, BasePosition::class, AbsolutePosition::class); return $this; } - /** - * @return array - */ - protected function getSubActionQualifiers() + protected function getSubActionQualifiers(): array { $subActionQualifiers = parent::getSubActionQualifiers(); diff --git a/src/Transformation/Layer/VideoSource.php b/src/Transformation/Layer/VideoSource.php index 000ee44..1e1014c 100644 --- a/src/Transformation/Layer/VideoSource.php +++ b/src/Transformation/Layer/VideoSource.php @@ -31,7 +31,6 @@ class VideoSource extends AssetBasedSource /** * VideoLayer constructor. * - * @param $source */ public function __construct($source) { @@ -43,11 +42,10 @@ public function __construct($source) * * Creates a new VideoTransformation if not initialized. * - * @return VideoTransformation * * @internal */ - public function getTransformation() + public function getTransformation(): VideoTransformation { if (! isset($this->transformation)) { $this->transformation = new VideoTransformation(); @@ -59,11 +57,10 @@ public function getTransformation() /** * Getter for the layer qualifier. * - * @return VideoSourceQualifier * * @internal */ - protected function getSourceQualifier() + protected function getSourceQualifier(): VideoSourceQualifier|BaseSourceQualifier { if (! isset($this->qualifiers['source'])) { $this->qualifiers['source'] = new VideoSourceQualifier(null); diff --git a/src/Transformation/Layer/VideoSourceQualifier.php b/src/Transformation/Layer/VideoSourceQualifier.php index d08676d..ddf5047 100644 --- a/src/Transformation/Layer/VideoSourceQualifier.php +++ b/src/Transformation/Layer/VideoSourceQualifier.php @@ -18,14 +18,13 @@ class VideoSourceQualifier extends BaseSourceQualifier { /** - * @var string $assetType The asset type of the layer. + * @var ?string $assetType The asset type of the layer. */ - protected $assetType = 'video'; + protected ?string $assetType = 'video'; /** * VideoSourceQualifier constructor. * - * @param $source */ public function __construct($source) { @@ -37,11 +36,11 @@ public function __construct($source) /** * Sets the video source. * - * @param SourceValue|string $source The video source. + * @param string|SourceValue|null $source The video source. * * @return $this */ - public function video($source) + public function video(SourceValue|string|null $source): static { $this->value->setValue(ClassUtils::verifyInstance($source, SourceValue::class)); diff --git a/src/Transformation/Layer/VideoSourceTrait.php b/src/Transformation/Layer/VideoSourceTrait.php index 9f3d8f0..be122f1 100644 --- a/src/Transformation/Layer/VideoSourceTrait.php +++ b/src/Transformation/Layer/VideoSourceTrait.php @@ -22,11 +22,10 @@ trait VideoSourceTrait /** * Adds another video layer. * - * @param string $videoId The public ID of the new video layer. + * @param string|null $videoId The public ID of the new video layer. * - * @return static|VideoSource */ - public static function video($videoId = null) + public static function video(?string $videoId = null): VideoSource|static { return static::createWithSource(ClassUtils::verifyInstance($videoId, VideoSource::class)); } @@ -36,9 +35,8 @@ public static function video($videoId = null) * * @param string|null $fetchUrl The URL of the asset to fetch. * - * @return static|FetchVideoSource */ - public static function fetchVideo($fetchUrl) + public static function fetchVideo(?string $fetchUrl): FetchVideoSource|static { return static::createWithSource(ClassUtils::verifyInstance($fetchUrl, FetchVideoSource::class)); } @@ -46,11 +44,10 @@ public static function fetchVideo($fetchUrl) /** * Adds subtitles to a video. * - * @param string $subtitlesId The public ID of the subtitles file. + * @param string|null $subtitlesId The public ID of the subtitles file. * - * @return static|SubtitlesSource */ - public static function subtitles($subtitlesId = null) + public static function subtitles(?string $subtitlesId = null): SubtitlesSource|static { return static::createWithSource(ClassUtils::verifyInstance($subtitlesId, SubtitlesSource::class)); } diff --git a/src/Transformation/Named/NamedTransformation.php b/src/Transformation/Named/NamedTransformation.php index 06c2cc1..1b919ee 100644 --- a/src/Transformation/Named/NamedTransformation.php +++ b/src/Transformation/Named/NamedTransformation.php @@ -20,15 +20,10 @@ class NamedTransformation extends BaseQualifier /** * @var string $key Serialization key. */ - protected static $key = 't'; + protected static string $key = 't'; - /** - * @param $transformationName - * - * @return static - */ - public static function name($transformationName) + public static function name($transformationName): static { return new static($transformationName); } diff --git a/src/Transformation/Named/NamedTransformationQualifierTrait.php b/src/Transformation/Named/NamedTransformationQualifierTrait.php index 3fd34f9..8773756 100644 --- a/src/Transformation/Named/NamedTransformationQualifierTrait.php +++ b/src/Transformation/Named/NamedTransformationQualifierTrait.php @@ -22,11 +22,10 @@ trait NamedTransformationQualifierTrait * * @param string $transformationName The name of the transformation. * - * @return NamedTransformation * - * @see \Cloudinary\Transformation\NamedTransformation + * @see NamedTransformation */ - public static function namedTransformation($transformationName) + public static function namedTransformation(string $transformationName): NamedTransformation { return new NamedTransformation($transformationName); } diff --git a/src/Transformation/Page/BasePageAction.php b/src/Transformation/Page/BasePageAction.php index c269ec5..88f95ff 100644 --- a/src/Transformation/Page/BasePageAction.php +++ b/src/Transformation/Page/BasePageAction.php @@ -15,7 +15,7 @@ */ class BasePageAction extends BaseAction { - const MAIN_QUALIFIER = PageQualifier::class; + protected const MAIN_QUALIFIER = PageQualifier::class; /** * Adds values to the main qualifier value. @@ -26,7 +26,7 @@ class BasePageAction extends BaseAction * * @internal */ - public function add(...$values) + public function add(...$values): static { $this->getMainQualifier()->add(...$values); diff --git a/src/Transformation/Page/ClippingPath.php b/src/Transformation/Page/ClippingPath.php index f2b174a..a9332da 100644 --- a/src/Transformation/Page/ClippingPath.php +++ b/src/Transformation/Page/ClippingPath.php @@ -25,8 +25,8 @@ class ClippingPath extends BasePageAction /** * ClippingPath constructor. * - * @param string $clippingPath The clipping path name. - * @param FlagQualifier $method The clipping method. Can be Flag::clip() or Flag::clipEvenOdd(). + * @param string $clippingPath The clipping path name. + * @param FlagQualifier|null $method The clipping method. Can be Flag::clip() or Flag::clipEvenOdd(). * * @see Flag::clip * @see Flag::clipEvenOdd @@ -44,9 +44,8 @@ public function __construct($clippingPath, ?FlagQualifier $method = null) /** * Trims pixels according to a clipping path included in the original image using an evenodd clipping rule. * - * @return static */ - public function evenOdd() + public function evenOdd(): static { return $this->unsetFlag(Flag::clip())->setFlag(Flag::clipEvenOdd()); } diff --git a/src/Transformation/Page/Extract.php b/src/Transformation/Page/Extract.php index 95330cf..97207af 100644 --- a/src/Transformation/Page/Extract.php +++ b/src/Transformation/Page/Extract.php @@ -28,11 +28,10 @@ abstract class Extract * * @param Page|PageQualifier|int ...$pages * - * @return Page * * @internal */ - public static function getPage(...$pages) + public static function getPage(...$pages): Page { return ClassUtils::forceVarArgsInstance($pages, Page::class); } @@ -42,10 +41,9 @@ public static function getPage(...$pages) * * @param Frame|PageQualifier|int ...$frames * - * @return Page */ - public static function getFrame(...$frames) + public static function getFrame(...$frames): Page { - return static::getPage($frames); + return static::getPage(...$frames); } } diff --git a/src/Transformation/Page/Frame.php b/src/Transformation/Page/Frame.php index 6986ece..80b1d60 100644 --- a/src/Transformation/Page/Frame.php +++ b/src/Transformation/Page/Frame.php @@ -19,20 +19,16 @@ * * @api */ -abstract class Frame +abstract class Frame extends BasePageAction { use PageNumberTrait; /** * Internal named constructor. * - * @param $value - * - * @return PageQualifier - * * @internal */ - public static function createWithPageQualifier(...$value) + public static function createWithPageQualifier(...$value): PageQualifier { return new PageQualifier(...$value); } diff --git a/src/Transformation/Page/LayerName.php b/src/Transformation/Page/LayerName.php index c24cb88..0c85a79 100644 --- a/src/Transformation/Page/LayerName.php +++ b/src/Transformation/Page/LayerName.php @@ -17,11 +17,11 @@ */ class LayerName extends BaseNamedArgument { - const ARG_NAME_VALUE_DELIMITER = ':'; - const ARG_INNER_VALUE_DELIMITER = ';'; + public const ARG_NAME_VALUE_DELIMITER = ':'; + public const ARG_INNER_VALUE_DELIMITER = ';'; /** * @var string The name of the argument. */ - protected static $name = 'name'; + protected static string $name = 'name'; } diff --git a/src/Transformation/Page/Page.php b/src/Transformation/Page/Page.php index ba591f3..6e55234 100644 --- a/src/Transformation/Page/Page.php +++ b/src/Transformation/Page/Page.php @@ -18,7 +18,7 @@ class Page extends BasePageAction /** * @var string MAIN_PARAMETER Represents the main qualifier of the action. (some actions do not have main qualifier) */ - const MAIN_QUALIFIER = PageQualifier::class; + protected const MAIN_QUALIFIER = PageQualifier::class; use PageNumberTrait; use PageRangeTrait; diff --git a/src/Transformation/Page/PageAllTrait.php b/src/Transformation/Page/PageAllTrait.php index e08aa4c..72cbe21 100644 --- a/src/Transformation/Page/PageAllTrait.php +++ b/src/Transformation/Page/PageAllTrait.php @@ -20,9 +20,8 @@ trait PageAllTrait /** * Gets all pages. * - * @return mixed */ - public function all() + public function all(): Page { return $this->add('all'); } diff --git a/src/Transformation/Page/PageIndexTrait.php b/src/Transformation/Page/PageIndexTrait.php index fd5162b..1cdf646 100644 --- a/src/Transformation/Page/PageIndexTrait.php +++ b/src/Transformation/Page/PageIndexTrait.php @@ -22,9 +22,8 @@ trait PageIndexTrait * * @param int $index The index. * - * @return static */ - public function byIndex($index) + public function byIndex(int $index): static { $this->add($index); diff --git a/src/Transformation/Page/PageLayerNameTrait.php b/src/Transformation/Page/PageLayerNameTrait.php index ac89860..1965910 100644 --- a/src/Transformation/Page/PageLayerNameTrait.php +++ b/src/Transformation/Page/PageLayerNameTrait.php @@ -22,12 +22,11 @@ trait PageLayerNameTrait /** * Creates an instance using the name. * - * @param string $name The name - * @param int $index The optional index. + * @param string $name The name + * @param int|null $index The optional index. * - * @return static */ - public function byLayerName($name, $index = null) + public function byLayerName(string $name, ?int $index = null): static { $this->add(new LayerName(new IndexedArgument($name, $index))); diff --git a/src/Transformation/Page/PageLayerNamesTrait.php b/src/Transformation/Page/PageLayerNamesTrait.php index 77ccdb0..3691495 100644 --- a/src/Transformation/Page/PageLayerNamesTrait.php +++ b/src/Transformation/Page/PageLayerNamesTrait.php @@ -22,9 +22,8 @@ trait PageLayerNamesTrait * * @param string ...$names The names. * - * @return static */ - public function byLayerNames(...$names) + public function byLayerNames(...$names): static { $this->add(new LayerName(...$names)); diff --git a/src/Transformation/Page/PageNameTrait.php b/src/Transformation/Page/PageNameTrait.php index 949249f..8f9b6f1 100644 --- a/src/Transformation/Page/PageNameTrait.php +++ b/src/Transformation/Page/PageNameTrait.php @@ -22,12 +22,11 @@ trait PageNameTrait /** * Creates an instance using the name. * - * @param string $name The name - * @param int $index The optional index. + * @param string $name The name + * @param int|null $index The optional index. * - * @return static */ - public function byName($name, $index = null) + public function byName(string $name, ?int $index = null): static { $this->add(new LayerName(new IndexedArgument($name, $index))); diff --git a/src/Transformation/Page/PageNamesTrait.php b/src/Transformation/Page/PageNamesTrait.php index f935ee5..7ea0980 100644 --- a/src/Transformation/Page/PageNamesTrait.php +++ b/src/Transformation/Page/PageNamesTrait.php @@ -22,9 +22,8 @@ trait PageNamesTrait * * @param string ...$names The names. * - * @return static */ - public function byNames(...$names) + public function byNames(...$names): static { $this->add(new LayerName(...$names)); diff --git a/src/Transformation/Page/PageNumberTrait.php b/src/Transformation/Page/PageNumberTrait.php index 2b32c0a..bec74be 100644 --- a/src/Transformation/Page/PageNumberTrait.php +++ b/src/Transformation/Page/PageNumberTrait.php @@ -20,11 +20,10 @@ trait PageNumberTrait /** * Gets the page using the specified number. * - * @param int $number The number. + * @param int|string|null $number The number. * - * @return static */ - public function byNumber($number) + public function byNumber(int|string|null $number): static { $this->add($number); diff --git a/src/Transformation/Page/PageQualifier.php b/src/Transformation/Page/PageQualifier.php index ac3ec7d..711885f 100644 --- a/src/Transformation/Page/PageQualifier.php +++ b/src/Transformation/Page/PageQualifier.php @@ -17,10 +17,10 @@ */ class PageQualifier extends BaseQualifier { - const VALUE_CLASS = PageValue::class; + protected const VALUE_CLASS = PageValue::class; /** * @var string $key Serialization key. */ - protected static $key = 'pg'; + protected static string $key = 'pg'; } diff --git a/src/Transformation/Page/PageQualifierTrait.php b/src/Transformation/Page/PageQualifierTrait.php index f9d432a..4918740 100644 --- a/src/Transformation/Page/PageQualifierTrait.php +++ b/src/Transformation/Page/PageQualifierTrait.php @@ -22,9 +22,8 @@ trait PageQualifierTrait * * @param int|string|array|mixed $page The page(s) to extract. * - * @return PageQualifier */ - public static function page($page) + public static function page(mixed $page): PageQualifier { return new PageQualifier($page); } diff --git a/src/Transformation/Page/PageRangeTrait.php b/src/Transformation/Page/PageRangeTrait.php index e59cef0..ba19b8a 100644 --- a/src/Transformation/Page/PageRangeTrait.php +++ b/src/Transformation/Page/PageRangeTrait.php @@ -22,12 +22,11 @@ trait PageRangeTrait /** * Gets pages using the specified range. * - * @param int|string $start The start of the range. - * @param int|string $end The end of the range. + * @param int|string $start The start of the range. + * @param int|string|null $end The end of the range. * - * @return static */ - public function byRange($start, $end = null) + public function byRange(int|string $start, int|string|null $end = null): static { $this->add(new RangeArgument($start, $end)); diff --git a/src/Transformation/Page/PageValue.php b/src/Transformation/Page/PageValue.php index 0294b33..be1b49d 100644 --- a/src/Transformation/Page/PageValue.php +++ b/src/Transformation/Page/PageValue.php @@ -15,18 +15,17 @@ */ class PageValue extends QualifierMultiValue { - const VALUE_DELIMITER = ';'; + protected const VALUE_DELIMITER = ';'; /** * Adds values. * * @param mixed $values The values to add. * - * @return static * * @internal */ - public function addValues(...$values) + public function addValues(...$values): static { foreach ($values as $value) { $found = false; diff --git a/src/Transformation/Page/PsdTools.php b/src/Transformation/Page/PsdTools.php index 0635cf2..0cde26d 100644 --- a/src/Transformation/Page/PsdTools.php +++ b/src/Transformation/Page/PsdTools.php @@ -26,11 +26,10 @@ abstract class PsdTools * * @param PsdLayer|int ...$layers * - * @return PsdLayer * * @see https://cloudinary.com/documentation/paged_and_layered_media#deliver_selected_layers_of_a_psd_image */ - public static function getLayer(...$layers) + public static function getLayer(...$layers): PsdLayer { return ClassUtils::forceVarArgsInstance($layers, PsdLayer::class); } @@ -40,9 +39,8 @@ public static function getLayer(...$layers) * * @param SmartObject|int ...$smartObjects * - * @return SmartObject */ - public static function smartObject(...$smartObjects) + public static function smartObject(...$smartObjects): SmartObject { return ClassUtils::forceVarArgsInstance($smartObjects, SmartObject::class); } @@ -50,11 +48,10 @@ public static function smartObject(...$smartObjects) /** * Trims the pixels of a PSD image according to a Photoshop clipping path that is stored in the image's metadata. * - * @param int|string $clippingPath Number or the name of the clipping path. + * @param int|string|null $clippingPath Number or the name of the clipping path. * - * @return ClippingPath */ - public static function clip($clippingPath = null) + public static function clip(int|string|null $clippingPath = null): ClippingPath { return ClassUtils::forceInstance($clippingPath, ClippingPath::class) ; } diff --git a/src/Transformation/Page/SmartObject.php b/src/Transformation/Page/SmartObject.php index 81eedb6..e839f90 100644 --- a/src/Transformation/Page/SmartObject.php +++ b/src/Transformation/Page/SmartObject.php @@ -22,7 +22,7 @@ */ class SmartObject extends BasePageAction { - const MAIN_QUALIFIER = SmartObjectQualifier::class; + protected const MAIN_QUALIFIER = SmartObjectQualifier::class; use PageLayerNameTrait; use PageLayerNamesTrait; diff --git a/src/Transformation/Page/SmartObjectName.php b/src/Transformation/Page/SmartObjectName.php index 3a7b393..e8ba330 100644 --- a/src/Transformation/Page/SmartObjectName.php +++ b/src/Transformation/Page/SmartObjectName.php @@ -17,11 +17,11 @@ */ class SmartObjectName extends BaseNamedArgument { - const ARG_NAME_VALUE_DELIMITER = ':'; - const ARG_INNER_VALUE_DELIMITER = ';'; + public const ARG_NAME_VALUE_DELIMITER = ':'; + public const ARG_INNER_VALUE_DELIMITER = ';'; /** * @var string $name The name. */ - protected static $name = 'embedded'; + protected static string $name = 'embedded'; } diff --git a/src/Transformation/Page/SmartObjectQualifier.php b/src/Transformation/Page/SmartObjectQualifier.php index c1e5bbd..23dceac 100644 --- a/src/Transformation/Page/SmartObjectQualifier.php +++ b/src/Transformation/Page/SmartObjectQualifier.php @@ -15,5 +15,5 @@ */ class SmartObjectQualifier extends PageQualifier { - const VALUE_CLASS = SmartObjectName::class; + protected const VALUE_CLASS = SmartObjectName::class; } diff --git a/src/Transformation/Positioning/AbsolutePosition.php b/src/Transformation/Positioning/AbsolutePosition.php index 1c06365..c13d333 100644 --- a/src/Transformation/Positioning/AbsolutePosition.php +++ b/src/Transformation/Positioning/AbsolutePosition.php @@ -20,10 +20,10 @@ class AbsolutePosition extends BasePosition /** * AbsolutePosition constructor. * - * @param mixed $x - * @param mixed $y + * @param mixed $x + * @param mixed|null $y */ - public function __construct($x = null, $y = null) + public function __construct($x = null, mixed $y = null) { parent::__construct(); @@ -33,13 +33,11 @@ public function __construct($x = null, $y = null) /** * Internal setter for the point value. * - * @param mixed $value * - * @return static * * @internal */ - public function setPointValue($value) + public function setPointValue(mixed $value): static { if (! isset($this->qualifiers[Point::getName()])) { $this->addQualifier(new Point()); diff --git a/src/Transformation/Positioning/AbsolutePositionTrait.php b/src/Transformation/Positioning/AbsolutePositionTrait.php index 93a4990..41a7bf8 100644 --- a/src/Transformation/Positioning/AbsolutePositionTrait.php +++ b/src/Transformation/Positioning/AbsolutePositionTrait.php @@ -22,12 +22,12 @@ trait AbsolutePositionTrait /** * Sets the absolute position. * - * @param int|float|string $x The x dimension. - * @param int|float|string $y The y dimension. + * @param float|int|string|null $x The x dimension. + * @param float|int|string|null $y The y dimension. * * @return $this */ - public function position($x = null, $y = null) + public function position(float|int|string|null $x = null, float|int|string|null $y = null): static { return $this->point($x, $y); } diff --git a/src/Transformation/Positioning/CompassGravityTrait.php b/src/Transformation/Positioning/CompassGravityTrait.php index 19e7ff0..147618f 100644 --- a/src/Transformation/Positioning/CompassGravityTrait.php +++ b/src/Transformation/Positioning/CompassGravityTrait.php @@ -24,14 +24,10 @@ trait CompassGravityTrait * * The compass direction represents a location in the image, for example, Gravity::northEast() represents the * top right corner. - * - * @param string $compassGravity - * - * @return static - * + * @see Gravity::northEast */ - public function gravity($compassGravity) + public function gravity(string|GravityQualifier|null $compassGravity): static { if (! $compassGravity instanceof GravityQualifier) { $compassGravity = new CompassGravity($compassGravity); diff --git a/src/Transformation/Positioning/CompassPosition.php b/src/Transformation/Positioning/CompassPosition.php index 08fd2a9..6be86f4 100644 --- a/src/Transformation/Positioning/CompassPosition.php +++ b/src/Transformation/Positioning/CompassPosition.php @@ -20,12 +20,15 @@ class CompassPosition extends BasePosition /** * CompassPosition constructor. * - * @param string $gravity - * @param float|int|string $x Offset x - * @param float|int|string $y Offset y + * @param mixed $gravity The gravity. + * @param float|int|string|null $x Offset x. + * @param float|int|string|null $y Offset y. */ - public function __construct($gravity = null, $x = null, $y = null) - { + public function __construct( + mixed $gravity = null, + float|int|string|null $x = null, + float|int|string|null $y = null + ) { parent::__construct(); $this->gravity($gravity); @@ -35,11 +38,9 @@ public function __construct($gravity = null, $x = null, $y = null) /** * @internal * - * @param $value * - * @return static */ - public function setOffsetValue($value) + public function setOffsetValue($value): static { if (! isset($this->qualifiers[Offset::getName()])) { $this->addQualifier(new Offset()); diff --git a/src/Transformation/Positioning/FocalGravityTrait.php b/src/Transformation/Positioning/FocalGravityTrait.php index afa6971..d2557a8 100644 --- a/src/Transformation/Positioning/FocalGravityTrait.php +++ b/src/Transformation/Positioning/FocalGravityTrait.php @@ -20,11 +20,10 @@ trait FocalGravityTrait /** * Sets the focal gravity for resizing. * - * @param mixed $focalGravity * * @return $this */ - public function gravity($focalGravity) + public function gravity(mixed $focalGravity): static { return $this->addQualifier( ClassUtils::verifyInstance($focalGravity, GravityQualifier::class, FocalGravity::class) diff --git a/src/Transformation/Positioning/Gravity/AutoGravity.php b/src/Transformation/Positioning/Gravity/AutoGravity.php index 270599c..38961e7 100644 --- a/src/Transformation/Positioning/Gravity/AutoGravity.php +++ b/src/Transformation/Positioning/Gravity/AutoGravity.php @@ -23,22 +23,16 @@ */ class AutoGravity extends GravityQualifier { - const AUTO = 'auto'; - const CLASSIC = 'classic'; - const SUBJECT = 'subject'; + public const AUTO = 'auto'; + public const CLASSIC = 'classic'; + public const SUBJECT = 'subject'; - /** - * @return string - */ - public static function classic() + public static function classic(): string { return self::CLASSIC; } - /** - * @return string - */ - public static function subject() + public static function subject(): string { return self::SUBJECT; } @@ -46,9 +40,8 @@ public static function subject() /** * @param mixed $gravity The gravity to use. * - * @return AutoGravityObject */ - public static function object($gravity) + public static function object(mixed $gravity): AutoGravityObject { return new AutoGravityObject($gravity); } @@ -58,9 +51,8 @@ public static function object($gravity) * * @param array|AutoGravity|ObjectGravity|string|mixed $fallbackGravities The fallback gravities. * - * @return AutoGravity */ - public function autoFocus(...$fallbackGravities) + public function autoFocus(...$fallbackGravities): AutoGravity { return $this->add(...$fallbackGravities); } diff --git a/src/Transformation/Positioning/Gravity/AutoGravityBuilderTrait.php b/src/Transformation/Positioning/Gravity/AutoGravityBuilderTrait.php index db4d0de..3798db8 100644 --- a/src/Transformation/Positioning/Gravity/AutoGravityBuilderTrait.php +++ b/src/Transformation/Positioning/Gravity/AutoGravityBuilderTrait.php @@ -24,9 +24,8 @@ trait AutoGravityBuilderTrait * * @param mixed ...$fallback Fallback gravities. * - * @return AutoGravity */ - public static function auto(...$fallback) + public static function auto(...$fallback): AutoGravity { return self::createWithAutoGravity(AutoGravity::AUTO, ...$fallback); } @@ -34,13 +33,11 @@ public static function auto(...$fallback) /** * Alias for Gravity::auto() * - * @param mixed ...$fallback * - * @return AutoGravity * * @see AutoGravity::auto */ - public static function autoGravity(...$fallback) + public static function autoGravity(...$fallback): AutoGravity { return self::auto(...$fallback); } @@ -51,9 +48,8 @@ public static function autoGravity(...$fallback) * @param string $gravity The main gravity. * @param array $fallback Fallback gravities. * - * @return AutoGravity */ - protected static function createWithAutoGravity($gravity, ...$fallback) + protected static function createWithAutoGravity(string $gravity, ...$fallback): AutoGravity { return new AutoGravity($gravity, ...$fallback); } diff --git a/src/Transformation/Positioning/Gravity/AutoGravityObject.php b/src/Transformation/Positioning/Gravity/AutoGravityObject.php index f324403..306b345 100644 --- a/src/Transformation/Positioning/Gravity/AutoGravityObject.php +++ b/src/Transformation/Positioning/Gravity/AutoGravityObject.php @@ -19,12 +19,12 @@ */ class AutoGravityObject extends QualifierMultiValue { - const VALUE_DELIMITER = '_'; + protected const VALUE_DELIMITER = '_'; /** * @var array $argumentOrder The order of the arguments. */ - protected $argumentOrder = ['gravity', 'avoid', 'weight']; + protected array $argumentOrder = ['gravity', 'avoid', 'weight']; /** * AutoGravityObject constructor. @@ -41,11 +41,10 @@ public function __construct($gravity) /** * Sets the object gravity. * - * @param $gravity * * @return $this */ - public function gravity($gravity) + public function gravity($gravity): static { if ($gravity instanceof BaseQualifier) { $gravity = $gravity->getValue(); @@ -59,7 +58,7 @@ public function gravity($gravity) * * @return $this */ - public function avoid() + public function avoid(): static { return $this->setSimpleValue('avoid', 'avoid'); } @@ -71,7 +70,7 @@ public function avoid() * * @return $this */ - public function weight($weight) + public function weight(int $weight): static { return $this->setSimpleValue('weight', $weight); } diff --git a/src/Transformation/Positioning/Gravity/Compass.php b/src/Transformation/Positioning/Gravity/Compass.php index 6b1ac8f..140c374 100644 --- a/src/Transformation/Positioning/Gravity/Compass.php +++ b/src/Transformation/Positioning/Gravity/Compass.php @@ -25,16 +25,16 @@ class Compass extends QualifierMultiValue { use CompassGravityBuilderTrait; - const NORTH_WEST = 'north_west'; - const NORTH = 'north'; - const NORTH_EAST = 'north_east'; - const WEST = 'west'; - const CENTER = 'center'; - const EAST = 'east'; - const SOUTH_WEST = 'south_west'; - const SOUTH = 'south'; - const SOUTH_EAST = 'south_east'; - const XY_CENTER = 'xy_center'; + public const NORTH_WEST = 'north_west'; + public const NORTH = 'north'; + public const NORTH_EAST = 'north_east'; + public const WEST = 'west'; + public const CENTER = 'center'; + public const EAST = 'east'; + public const SOUTH_WEST = 'south_west'; + public const SOUTH = 'south'; + public const SOUTH_EAST = 'south_east'; + public const XY_CENTER = 'xy_center'; /** * Compass constructor. @@ -51,11 +51,10 @@ public function __construct($direction = null) /** * Sets the compass gravity direction. * - * @param string $direction The gravity direction. Use the constants defined in this class. + * @param ?string $direction The gravity direction. Use the constants defined in this class. * - * @return Compass */ - protected function direction($direction) + protected function direction(?string $direction): static { $this->setSimpleValue('direction', $direction); diff --git a/src/Transformation/Positioning/Gravity/CompassGravity.php b/src/Transformation/Positioning/Gravity/CompassGravity.php index 8c2aaed..c0299b7 100644 --- a/src/Transformation/Positioning/Gravity/CompassGravity.php +++ b/src/Transformation/Positioning/Gravity/CompassGravity.php @@ -23,16 +23,16 @@ */ class CompassGravity extends GravityQualifier { - const VALUE_CLASS = Compass::class; + protected const VALUE_CLASS = Compass::class; use CompassGravityBuilderTrait; /** * CompassGravity constructor. * - * @param string $direction + * @param ?string $direction Compass direction. */ - public function __construct($direction = null) + public function __construct(?string $direction = null) { parent::__construct(); @@ -42,11 +42,10 @@ public function __construct($direction = null) /** * Sets the compass gravity direction. * - * @param string $direction The gravity direction. Use the constants defined in this class. + * @param ?string $direction The gravity direction. Use the constants defined in this class. * - * @return CompassGravity */ - protected function direction($direction) + protected function direction(?string $direction): static { $this->setQualifierValue($direction); diff --git a/src/Transformation/Positioning/Gravity/CompassGravityBuilderTrait.php b/src/Transformation/Positioning/Gravity/CompassGravityBuilderTrait.php index c4cffb9..1984d21 100644 --- a/src/Transformation/Positioning/Gravity/CompassGravityBuilderTrait.php +++ b/src/Transformation/Positioning/Gravity/CompassGravityBuilderTrait.php @@ -10,6 +10,8 @@ namespace Cloudinary\Transformation; +use Cloudinary\ClassUtils; + /** * Trait CompassGravityTrait * @@ -18,13 +20,12 @@ trait CompassGravityBuilderTrait { /** - * North west corner (top left). + * North-west corner (top left). * * @param array $args Additional arguments. * - * @return CompassGravity|CompassPosition */ - public static function northWest(...$args) + public static function northWest(...$args): CompassGravity|CompassPosition { return static::createWithCompassGravity(Compass::NORTH_WEST, ...$args); } @@ -34,21 +35,19 @@ public static function northWest(...$args) * * @param array $args Additional arguments. * - * @return CompassGravity|CompassPosition */ - public static function north(...$args) + public static function north(...$args): CompassGravity|CompassPosition { return static::createWithCompassGravity(Compass::NORTH, ...$args); } /** - * North east corner (top right). + * North-east corner (top right). * * @param array $args Additional arguments. * - * @return CompassGravity|CompassPosition */ - public static function northEast(...$args) + public static function northEast(...$args): CompassGravity|CompassPosition { return static::createWithCompassGravity(Compass::NORTH_EAST, ...$args); } @@ -58,9 +57,8 @@ public static function northEast(...$args) * * @param array $args Additional arguments. * - * @return CompassGravity|CompassPosition */ - public static function west(...$args) + public static function west(...$args): CompassGravity|CompassPosition { return static::createWithCompassGravity(Compass::WEST, ...$args); } @@ -70,9 +68,8 @@ public static function west(...$args) * * @param array $args Additional arguments. * - * @return CompassGravity|CompassPosition */ - public static function center(...$args) + public static function center(...$args): CompassGravity|CompassPosition { return static::createWithCompassGravity(Compass::CENTER, ...$args); } @@ -82,9 +79,8 @@ public static function center(...$args) * * @param array $args Additional arguments. * - * @return CompassGravity|CompassPosition */ - public static function east(...$args) + public static function east(...$args): CompassGravity|CompassPosition { return static::createWithCompassGravity(Compass::EAST, ...$args); } @@ -94,9 +90,8 @@ public static function east(...$args) * * @param array $args Additional arguments. * - * @return CompassGravity|CompassPosition */ - public static function southWest(...$args) + public static function southWest(...$args): CompassGravity|CompassPosition { return static::createWithCompassGravity(Compass::SOUTH_WEST, ...$args); } @@ -106,9 +101,8 @@ public static function southWest(...$args) * * @param array $args Additional arguments. * - * @return CompassGravity|CompassPosition */ - public static function south(...$args) + public static function south(...$args): CompassGravity|CompassPosition { return static::createWithCompassGravity(Compass::SOUTH, ...$args); } @@ -118,9 +112,8 @@ public static function south(...$args) * * @param array $args Additional arguments. * - * @return CompassGravity|CompassPosition */ - public static function southEast(...$args) + public static function southEast(...$args): CompassGravity|CompassPosition { return static::createWithCompassGravity(Compass::SOUTH_EAST, ...$args); } @@ -130,9 +123,8 @@ public static function southEast(...$args) * * @param array $args Additional arguments. * - * @return CompassGravity|CompassPosition */ - public static function xyCenter(...$args) + public static function xyCenter(...$args): CompassGravity|CompassPosition { return static::createWithCompassGravity(Compass::XY_CENTER, ...$args); } @@ -140,12 +132,11 @@ public static function xyCenter(...$args) /** * Creates a new instance of the CompassGravity class. * - * @param string $direction The gravity direction. - * @param array $args Additional arguments. + * @param string|CompassGravity $direction The gravity direction. + * @param array $args Additional arguments. * - * @return CompassGravity */ - public static function compass($direction, ...$args) + public static function compass(string|CompassGravity $direction, ...$args): CompassGravity { return static::createWithCompassGravity($direction, ...$args); } @@ -153,13 +144,12 @@ public static function compass($direction, ...$args) /** * Creates a new instance of the CompassGravity class. * - * @param string $direction The gravity direction. - * @param array $args Additional arguments. + * @param string|CompassGravity $direction The gravity direction. + * @param array $args Additional arguments. * - * @return CompassGravity */ - protected static function createWithCompassGravity($direction, ...$args) + protected static function createWithCompassGravity(string|CompassGravity $direction, ...$args): CompassGravity { - return new CompassGravity($direction); + return ClassUtils::forceInstance($direction, CompassGravity::class, null, $args); } } diff --git a/src/Transformation/Positioning/Gravity/FocalGravity.php b/src/Transformation/Positioning/Gravity/FocalGravity.php index 9c267b5..6bf1eb1 100644 --- a/src/Transformation/Positioning/Gravity/FocalGravity.php +++ b/src/Transformation/Positioning/Gravity/FocalGravity.php @@ -28,7 +28,6 @@ class FocalGravity extends GravityQualifier implements FocalGravityInterface /** * FocalGravity constructor. * - * @param $focalGravity * @param array $fallBacks */ public function __construct($focalGravity, ...$fallBacks) @@ -41,14 +40,13 @@ public function __construct($focalGravity, ...$fallBacks) /** * Sets the gravity. * - * @param FocalGravity|string $focalGravity The gravity. + * @param string|FocalGravity $focalGravity The gravity. * @param array $fallBacks Fallback gravities. * - * @return FocalGravity * * @internal */ - protected function setGravity($focalGravity, ...$fallBacks) + protected function setGravity(string|FocalGravity $focalGravity, ...$fallBacks): static { $this->setQualifierValue($focalGravity, ...$fallBacks); @@ -60,11 +58,10 @@ protected function setGravity($focalGravity, ...$fallBacks) * * @param array $fallBacks The fallback gravities. * - * @return FocalGravity * * @internal */ - protected function addFallBacks(...$fallBacks) + protected function addFallBacks(...$fallBacks): static { $this->value->addValues(...$fallBacks); diff --git a/src/Transformation/Positioning/Gravity/FocalGravityBuilderTrait.php b/src/Transformation/Positioning/Gravity/FocalGravityBuilderTrait.php index 7dd3535..722f828 100644 --- a/src/Transformation/Positioning/Gravity/FocalGravityBuilderTrait.php +++ b/src/Transformation/Positioning/Gravity/FocalGravityBuilderTrait.php @@ -25,11 +25,10 @@ trait FocalGravityBuilderTrait * * @param mixed ...$fallback Fallback gravities. * - * @return FocalGravity * * @see https://cloudinary.com/documentation/advanced_facial_attributes_detection_addon#face_detection_based_cropping */ - public static function advancedFace(...$fallback) + public static function advancedFace(...$fallback): FocalGravity { return self::createWithFocalGravity(FocalGravity::ADVANCED_FACE, ...$fallback); } @@ -42,11 +41,10 @@ public static function advancedFace(...$fallback) * * @param mixed ...$fallback Fallback gravities. * - * @return FocalGravity * * @see https://cloudinary.com/documentation/advanced_facial_attributes_detection_addon#face_detection_based_cropping */ - public static function advancedFaces(...$fallback) + public static function advancedFaces(...$fallback): FocalGravity { return self::createWithFocalGravity(FocalGravity::ADVANCED_FACES, ...$fallback); } @@ -59,11 +57,10 @@ public static function advancedFaces(...$fallback) * * @param mixed ...$fallback Fallback gravities. * - * @return FocalGravity * * @see https://cloudinary.com/documentation/advanced_facial_attributes_detection_addon#eyes_detection_based_cropping */ - public static function advancedEyes(...$fallback) + public static function advancedEyes(...$fallback): FocalGravity { return self::createWithFocalGravity(FocalGravity::ADVANCED_EYES, ...$fallback); } @@ -73,9 +70,8 @@ public static function advancedEyes(...$fallback) * * @param mixed ...$fallback Fallback gravities. * - * @return FocalGravity */ - public static function body(...$fallback) + public static function body(...$fallback): FocalGravity { return self::createWithFocalGravity(FocalGravity::BODY, ...$fallback); } @@ -85,9 +81,8 @@ public static function body(...$fallback) * * @param mixed ...$fallback Fallback gravities. * - * @return FocalGravity */ - public static function face(...$fallback) + public static function face(...$fallback): FocalGravity { return self::createWithFocalGravity(FocalGravity::FACE, ...$fallback); } @@ -97,9 +92,8 @@ public static function face(...$fallback) * * @param mixed ...$fallback Fallback gravities. * - * @return FocalGravity */ - public static function faces(...$fallback) + public static function faces(...$fallback): FocalGravity { return self::createWithFocalGravity(FocalGravity::FACES, ...$fallback); } @@ -109,9 +103,8 @@ public static function faces(...$fallback) * * @param mixed ...$fallback Fallback gravities. * - * @return FocalGravity */ - public static function noFaces(...$fallback) + public static function noFaces(...$fallback): FocalGravity { return self::createWithFocalGravity(FocalGravity::NO_FACES, ...$fallback); } @@ -124,9 +117,8 @@ public static function noFaces(...$fallback) * * @param mixed ...$fallback Fallback gravities. * - * @return FocalGravity */ - public static function custom(...$fallback) + public static function custom(...$fallback): FocalGravity { return self::createWithFocalGravity(FocalGravity::CUSTOM, ...$fallback); } @@ -137,9 +129,8 @@ public static function custom(...$fallback) * * @param mixed ...$fallback Fallback gravities. * - * @return FocalGravity */ - public static function customNoOverride(...$fallback) + public static function customNoOverride(...$fallback): FocalGravity { return self::createWithFocalGravity(FocalGravity::CUSTOM_NO_OVERRIDE, ...$fallback); } @@ -152,11 +143,10 @@ public static function customNoOverride(...$fallback) * * @param mixed ...$fallback Fallback gravities. * - * @return FocalGravity * * @see https://cloudinary.com/documentation/ocr_text_detection_and_extraction_addon */ - public static function ocrText(...$fallback) + public static function ocrText(...$fallback): FocalGravity { return self::createWithFocalGravity(FocalGravity::OCR_TEXT, ...$fallback); } @@ -164,13 +154,11 @@ public static function ocrText(...$fallback) /** * Alias for Gravity::ocrText() * - * @param mixed ...$fallback * - * @return FocalGravity * * @see FocalGravity::ocrText */ - public static function ocr(...$fallback) + public static function ocr(...$fallback): FocalGravity { return self::ocrText(...$fallback); } @@ -181,9 +169,8 @@ public static function ocr(...$fallback) * @param string $gravity The main gravity. * @param array $fallback Fallback gravities. * - * @return FocalGravity */ - protected static function createWithFocalGravity($gravity, ...$fallback) + protected static function createWithFocalGravity(string $gravity, ...$fallback): FocalGravity { return new FocalGravity($gravity, ...$fallback); } diff --git a/src/Transformation/Positioning/Gravity/FocalGravityInterface.php b/src/Transformation/Positioning/Gravity/FocalGravityInterface.php index e3e020d..9903b8d 100644 --- a/src/Transformation/Positioning/Gravity/FocalGravityInterface.php +++ b/src/Transformation/Positioning/Gravity/FocalGravityInterface.php @@ -17,18 +17,18 @@ */ interface FocalGravityInterface { - const ADVANCED_FACE = 'adv_face'; - const ADV_FACE = 'adv_face'; - const ADVANCED_FACES = 'adv_faces'; - const ADV_FACES = 'adv_faces'; - const ADVANCED_EYES = 'adv_eyes'; - const ADV_EYES = 'adv_eyes'; - const BODY = 'body'; - const FACE = 'face'; - const FACES = 'faces'; - const NO_FACES = 'no_faces'; - const CUSTOM = 'custom'; - const CUSTOM_NO_OVERRIDE = 'custom_no_override'; - const OCR_TEXT = 'ocr_text'; - const NONE = 'none'; + public const ADVANCED_FACE = 'adv_face'; + public const ADV_FACE = 'adv_face'; + public const ADVANCED_FACES = 'adv_faces'; + public const ADV_FACES = 'adv_faces'; + public const ADVANCED_EYES = 'adv_eyes'; + public const ADV_EYES = 'adv_eyes'; + public const BODY = 'body'; + public const FACE = 'face'; + public const FACES = 'faces'; + public const NO_FACES = 'no_faces'; + public const CUSTOM = 'custom'; + public const CUSTOM_NO_OVERRIDE = 'custom_no_override'; + public const OCR_TEXT = 'ocr_text'; + public const NONE = 'none'; } diff --git a/src/Transformation/Positioning/Gravity/Gravity.php b/src/Transformation/Positioning/Gravity/Gravity.php index 86bd81f..19faa5b 100644 --- a/src/Transformation/Positioning/Gravity/Gravity.php +++ b/src/Transformation/Positioning/Gravity/Gravity.php @@ -33,9 +33,8 @@ abstract class Gravity * * @param mixed ...$objects The names of the objects. * - * @return ObjectGravity */ - public static function focusOn(...$objects) + public static function focusOn(...$objects): ObjectGravity { return new ObjectGravity(...$objects); } diff --git a/src/Transformation/Positioning/Gravity/GravityQualifier.php b/src/Transformation/Positioning/Gravity/GravityQualifier.php index 0c976ec..784a54a 100644 --- a/src/Transformation/Positioning/Gravity/GravityQualifier.php +++ b/src/Transformation/Positioning/Gravity/GravityQualifier.php @@ -20,5 +20,5 @@ class GravityQualifier extends BaseQualifier /** * @var string $name The name. */ - protected static $name = 'gravity'; + protected static string $name = 'gravity'; } diff --git a/src/Transformation/Positioning/Gravity/GravityQualifierTrait.php b/src/Transformation/Positioning/Gravity/GravityQualifierTrait.php index e03fe6d..b75c33d 100644 --- a/src/Transformation/Positioning/Gravity/GravityQualifierTrait.php +++ b/src/Transformation/Positioning/Gravity/GravityQualifierTrait.php @@ -26,9 +26,8 @@ trait GravityQualifierTrait * @param mixed $gravity The area of the image. Use the constants defined in any of the classes that extend * GravityQualifier, such as CompassGravity or ObjectGravity. * - * @return GravityQualifier */ - public static function gravity($gravity) + public static function gravity(mixed $gravity): GravityQualifier { return ClassUtils::verifyInstance($gravity, GravityQualifier::class); } diff --git a/src/Transformation/Positioning/Gravity/LiquidRescaling.php b/src/Transformation/Positioning/Gravity/LiquidRescaling.php index c2f1a0a..74fe801 100644 --- a/src/Transformation/Positioning/Gravity/LiquidRescaling.php +++ b/src/Transformation/Positioning/Gravity/LiquidRescaling.php @@ -33,7 +33,7 @@ */ class LiquidRescaling extends GravityQualifier { - const LIQUID = 'liquid'; + protected const LIQUID = 'liquid'; /** * LiquidRescaling constructor. diff --git a/src/Transformation/Positioning/Gravity/ObjectGravity/AccessoryObjectGravityBuilderTrait.php b/src/Transformation/Positioning/Gravity/ObjectGravity/AccessoryObjectGravityBuilderTrait.php index 4a48ff4..62dd946 100644 --- a/src/Transformation/Positioning/Gravity/ObjectGravity/AccessoryObjectGravityBuilderTrait.php +++ b/src/Transformation/Positioning/Gravity/ObjectGravity/AccessoryObjectGravityBuilderTrait.php @@ -1,4 +1,5 @@ -getValue(); @@ -54,4 +53,12 @@ public function fallbackGravity($fallbackGravity) return $this->add($fallbackGravity); } + + + public function priority(?string $priorityName = null, ?int $weight = null): static + { + $this->value->setSimpleNamedValue($priorityName, $weight); + + return $this; + } } diff --git a/src/Transformation/Positioning/Gravity/ObjectGravity/ObjectGravityBuilderTrait.php b/src/Transformation/Positioning/Gravity/ObjectGravity/ObjectGravityBuilderTrait.php index fea98ac..5cc8b40 100644 --- a/src/Transformation/Positioning/Gravity/ObjectGravity/ObjectGravityBuilderTrait.php +++ b/src/Transformation/Positioning/Gravity/ObjectGravity/ObjectGravityBuilderTrait.php @@ -22,9 +22,8 @@ trait ObjectGravityBuilderTrait * * @param mixed ...$objects The names of the objects. * - * @return string */ - public static function object(...$objects) + public static function object(...$objects): ObjectGravity { return new ObjectGravity(...$objects); } diff --git a/src/Transformation/Positioning/Gravity/ObjectGravity/ObjectGravityPriorityBuilderTrait.php b/src/Transformation/Positioning/Gravity/ObjectGravity/ObjectGravityPriorityBuilderTrait.php index 2d10331..de38726 100644 --- a/src/Transformation/Positioning/Gravity/ObjectGravity/ObjectGravityPriorityBuilderTrait.php +++ b/src/Transformation/Positioning/Gravity/ObjectGravity/ObjectGravityPriorityBuilderTrait.php @@ -26,7 +26,7 @@ trait ObjectGravityPriorityBuilderTrait * * @return $this */ - public function focus($weight = null) + public function focus(?int $weight = null): static { return $this->priority(ObjectGravity::FOCUS, $weight); } @@ -38,7 +38,7 @@ public function focus($weight = null) * * @return $this */ - public function center($weight = null) + public function center(?int $weight = null): static { return $this->priority(ObjectGravity::CENTER, $weight); } @@ -50,7 +50,7 @@ public function center($weight = null) * * @return $this */ - public function large($weight = null) + public function large(?int $weight = null): static { return $this->priority(ObjectGravity::LARGE, $weight); } @@ -58,15 +58,10 @@ public function large($weight = null) /** * Sets any priority to the specified weighting. * - * @param string $priorityName The name of the priority. - * @param int $weight The priority weighting. + * @param string|null $priorityName The name of the priority. + * @param int|null $weight The priority weighting. * * @return $this */ - public function priority($priorityName = null, $weight = null) - { - $this->value->setSimpleNamedValue($priorityName, $weight); - - return $this; - } + abstract public function priority(?string $priorityName = null, ?int $weight = null): static; } diff --git a/src/Transformation/Positioning/Gravity/ObjectGravity/ObjectGravityPriorityInterface.php b/src/Transformation/Positioning/Gravity/ObjectGravity/ObjectGravityPriorityInterface.php index 6008b71..4a57fa3 100644 --- a/src/Transformation/Positioning/Gravity/ObjectGravity/ObjectGravityPriorityInterface.php +++ b/src/Transformation/Positioning/Gravity/ObjectGravity/ObjectGravityPriorityInterface.php @@ -18,7 +18,7 @@ interface ObjectGravityPriorityInterface { //Priority types - const FOCUS = 'focus'; - const CENTER = 'center'; - const LARGE = 'large'; + public const FOCUS = 'focus'; + public const CENTER = 'center'; + public const LARGE = 'large'; } diff --git a/src/Transformation/Positioning/Gravity/ObjectGravity/OutdoorObjectGravityBuilderTrait.php b/src/Transformation/Positioning/Gravity/ObjectGravity/OutdoorObjectGravityBuilderTrait.php index fb9ffae..7c4160c 100644 --- a/src/Transformation/Positioning/Gravity/ObjectGravity/OutdoorObjectGravityBuilderTrait.php +++ b/src/Transformation/Positioning/Gravity/ObjectGravity/OutdoorObjectGravityBuilderTrait.php @@ -20,9 +20,8 @@ trait OutdoorObjectGravityBuilderTrait /** * Gravity outdoor. * - * @return string */ - public static function outdoor() + public static function outdoor(): string { return ObjectGravity::OUTDOOR; } @@ -30,9 +29,8 @@ public static function outdoor() /** * Gravity trafficLight. * - * @return string */ - public static function trafficLight() + public static function trafficLight(): string { return ObjectGravity::TRAFFIC_LIGHT; } @@ -40,9 +38,8 @@ public static function trafficLight() /** * Gravity stopSign. * - * @return string */ - public static function stopSign() + public static function stopSign(): string { return ObjectGravity::STOP_SIGN; } @@ -50,9 +47,8 @@ public static function stopSign() /** * Gravity parkingMeter. * - * @return string */ - public static function parkingMeter() + public static function parkingMeter(): string { return ObjectGravity::PARKING_METER; } @@ -60,9 +56,8 @@ public static function parkingMeter() /** * Gravity fireHydrant. * - * @return string */ - public static function fireHydrant() + public static function fireHydrant(): string { return ObjectGravity::FIRE_HYDRANT; } @@ -70,9 +65,8 @@ public static function fireHydrant() /** * Gravity bench. * - * @return string */ - public static function bench() + public static function bench(): string { return ObjectGravity::BENCH; } diff --git a/src/Transformation/Positioning/Gravity/ObjectGravity/OutdoorObjectGravityInterface.php b/src/Transformation/Positioning/Gravity/ObjectGravity/OutdoorObjectGravityInterface.php index 8d78e9f..a1a52ba 100644 --- a/src/Transformation/Positioning/Gravity/ObjectGravity/OutdoorObjectGravityInterface.php +++ b/src/Transformation/Positioning/Gravity/ObjectGravity/OutdoorObjectGravityInterface.php @@ -18,10 +18,10 @@ interface OutdoorObjectGravityInterface { //Outdoor Category - const OUTDOOR = 'outdoor'; - const TRAFFIC_LIGHT = 'traffic_light'; - const STOP_SIGN = 'stopsign'; - const PARKING_METER = 'parkingmeter'; - const FIRE_HYDRANT = 'firehydrant'; - const BENCH = 'bench'; + public const OUTDOOR = 'outdoor'; + public const TRAFFIC_LIGHT = 'traffic_light'; + public const STOP_SIGN = 'stopsign'; + public const PARKING_METER = 'parkingmeter'; + public const FIRE_HYDRANT = 'firehydrant'; + public const BENCH = 'bench'; } diff --git a/src/Transformation/Positioning/Gravity/ObjectGravity/PersonObjectGravityBuilderTrait.php b/src/Transformation/Positioning/Gravity/ObjectGravity/PersonObjectGravityBuilderTrait.php index 6d12313..0c50736 100644 --- a/src/Transformation/Positioning/Gravity/ObjectGravity/PersonObjectGravityBuilderTrait.php +++ b/src/Transformation/Positioning/Gravity/ObjectGravity/PersonObjectGravityBuilderTrait.php @@ -20,9 +20,8 @@ trait PersonObjectGravityBuilderTrait /** * Gravity person. * - * @return string */ - public static function person() + public static function person(): string { return ObjectGravity::PERSON; } diff --git a/src/Transformation/Positioning/Gravity/ObjectGravity/PersonObjectGravityInterface.php b/src/Transformation/Positioning/Gravity/ObjectGravity/PersonObjectGravityInterface.php index 3771af4..243d6dd 100644 --- a/src/Transformation/Positioning/Gravity/ObjectGravity/PersonObjectGravityInterface.php +++ b/src/Transformation/Positioning/Gravity/ObjectGravity/PersonObjectGravityInterface.php @@ -18,5 +18,5 @@ interface PersonObjectGravityInterface { //Person Category - const PERSON = 'person'; + public const PERSON = 'person'; } diff --git a/src/Transformation/Positioning/Gravity/ObjectGravity/VehicleObjectGravityBuilderTrait.php b/src/Transformation/Positioning/Gravity/ObjectGravity/VehicleObjectGravityBuilderTrait.php index 378d71b..7e4b1a2 100644 --- a/src/Transformation/Positioning/Gravity/ObjectGravity/VehicleObjectGravityBuilderTrait.php +++ b/src/Transformation/Positioning/Gravity/ObjectGravity/VehicleObjectGravityBuilderTrait.php @@ -20,9 +20,8 @@ trait VehicleObjectGravityBuilderTrait /** * Gravity vehicle. * - * @return string */ - public static function vehicle() + public static function vehicle(): string { return ObjectGravity::VEHICLE; } @@ -30,9 +29,8 @@ public static function vehicle() /** * Gravity bicycle. * - * @return string */ - public static function bicycle() + public static function bicycle(): string { return ObjectGravity::BICYCLE; } @@ -40,9 +38,8 @@ public static function bicycle() /** * Gravity car. * - * @return string */ - public static function car() + public static function car(): string { return ObjectGravity::CAR; } @@ -50,9 +47,8 @@ public static function car() /** * Gravity motorbike. * - * @return string */ - public static function motorbike() + public static function motorbike(): string { return ObjectGravity::MOTORBIKE; } @@ -60,9 +56,8 @@ public static function motorbike() /** * Gravity aeroplane. * - * @return string */ - public static function aeroplane() + public static function aeroplane(): string { return ObjectGravity::AEROPLANE; } @@ -70,9 +65,8 @@ public static function aeroplane() /** * Gravity bus. * - * @return string */ - public static function bus() + public static function bus(): string { return ObjectGravity::BUS; } @@ -80,9 +74,8 @@ public static function bus() /** * Gravity train. * - * @return string */ - public static function train() + public static function train(): string { return ObjectGravity::TRAIN; } @@ -90,9 +83,8 @@ public static function train() /** * Gravity truck. * - * @return string */ - public static function truck() + public static function truck(): string { return ObjectGravity::TRUCK; } @@ -100,9 +92,8 @@ public static function truck() /** * Gravity boat. * - * @return string */ - public static function boat() + public static function boat(): string { return ObjectGravity::BOAT; } diff --git a/src/Transformation/Positioning/Gravity/ObjectGravity/VehicleObjectGravityInterface.php b/src/Transformation/Positioning/Gravity/ObjectGravity/VehicleObjectGravityInterface.php index 81eb39e..502b1bf 100644 --- a/src/Transformation/Positioning/Gravity/ObjectGravity/VehicleObjectGravityInterface.php +++ b/src/Transformation/Positioning/Gravity/ObjectGravity/VehicleObjectGravityInterface.php @@ -18,13 +18,13 @@ interface VehicleObjectGravityInterface { //Vehicle Category - const VEHICLE = 'vehicle'; - const BICYCLE = 'bicycle'; - const CAR = 'car'; - const MOTORBIKE = 'motorbike'; - const AEROPLANE = 'aeroplane'; - const BUS = 'bus'; - const TRAIN = 'train'; - const TRUCK = 'truck'; - const BOAT = 'boat'; + public const VEHICLE = 'vehicle'; + public const BICYCLE = 'bicycle'; + public const CAR = 'car'; + public const MOTORBIKE = 'motorbike'; + public const AEROPLANE = 'aeroplane'; + public const BUS = 'bus'; + public const TRAIN = 'train'; + public const TRUCK = 'truck'; + public const BOAT = 'boat'; } diff --git a/src/Transformation/Positioning/GravityTrait.php b/src/Transformation/Positioning/GravityTrait.php index 4d67497..e7387bc 100644 --- a/src/Transformation/Positioning/GravityTrait.php +++ b/src/Transformation/Positioning/GravityTrait.php @@ -24,7 +24,7 @@ trait GravityTrait * * @return $this */ - public function gravity($gravity) + public function gravity(mixed $gravity): static { return $this->addQualifier(ClassUtils::verifyInstance($gravity, GravityQualifier::class)); } diff --git a/src/Transformation/Positioning/Offset.php b/src/Transformation/Positioning/Offset.php index 287c88c..27a8c37 100644 --- a/src/Transformation/Positioning/Offset.php +++ b/src/Transformation/Positioning/Offset.php @@ -20,10 +20,10 @@ class Offset extends BaseAction /** * Offset constructor. * - * @param float|int|string $x - * @param float|int|string $y + * @param float|int|string|null $x + * @param float|int|string|null $y */ - public function __construct($x = null, $y = null) + public function __construct(float|int|string|null $x = null, float|int|string|null $y = null) { parent::__construct(); @@ -33,11 +33,9 @@ public function __construct($x = null, $y = null) /** * @internal * - * @param $value * - * @return static */ - public function setOffsetValue($value) + public function setOffsetValue($value): static { return $this->addQualifier($value); } diff --git a/src/Transformation/Positioning/OffsetTrait.php b/src/Transformation/Positioning/OffsetTrait.php index bd27786..0831f28 100644 --- a/src/Transformation/Positioning/OffsetTrait.php +++ b/src/Transformation/Positioning/OffsetTrait.php @@ -22,11 +22,11 @@ trait OffsetTrait /** * Sets the x offset. * - * @param int|float|string $x The x offset. + * @param float|int|string|null $x The x offset. * * @return $this */ - public function offsetX($x) + public function offsetX(float|int|string|null $x): static { return $this->setOffsetValue(ClassUtils::verifyInstance($x, X::class)); } @@ -34,11 +34,11 @@ public function offsetX($x) /** * Sets the y offset. * - * @param int|float|string $y The y offset. + * @param float|int|string|null $y The y offset. * * @return $this */ - public function offsetY($y) + public function offsetY(float|int|string|null $y): static { return $this->setOffsetValue(ClassUtils::verifyInstance($y, Y::class)); } @@ -46,12 +46,11 @@ public function offsetY($y) /** * Sets the x and y offset. * - * @param int|float|string $x The x offset. - * @param int|float|string $y The y offset. + * @param float|int|string|null $x The x offset. + * @param float|int|string|null $y The y offset. * - * @return static */ - public function offset($x = null, $y = null) + public function offset(float|int|string|null $x = null, float|int|string|null $y = null): static { return $this->offsetX($x)->offsetY($y); } @@ -59,9 +58,7 @@ public function offset($x = null, $y = null) /** * @internal * - * @param $value * - * @return static */ - abstract public function setOffsetValue($value); + abstract public function setOffsetValue($value): static; } diff --git a/src/Transformation/Positioning/PixelEffectRegionTrait.php b/src/Transformation/Positioning/PixelEffectRegionTrait.php index fff040a..d274c9c 100644 --- a/src/Transformation/Positioning/PixelEffectRegionTrait.php +++ b/src/Transformation/Positioning/PixelEffectRegionTrait.php @@ -18,9 +18,8 @@ trait PixelEffectRegionTrait /** * Sets the faces region. * - * @return Region */ - public static function faces() + public static function faces(): Region { return (new Region())->gravity(Gravity::faces()); } @@ -28,9 +27,8 @@ public static function faces() /** * Sets the OCR region. * - * @return Region */ - public static function ocr() + public static function ocr(): Region { return (new Region())->gravity(Gravity::ocr()); } @@ -38,30 +36,37 @@ public static function ocr() /** * Sets the custom region. * - * @param int|string $x - * @param int|string $y - * @param int|string $width - * @param int|string $height + * @param int|string|null $x + * @param int|string|null $y + * @param int|string|null $width + * @param int|string|null $height * * @return Region */ - public static function custom($x = null, $y = null, $width = null, $height = null) - { + public static function custom( + int|string|null $x = null, + int|string|null $y = null, + int|string|null $width = null, + int|string|null $height = null + ): Region { return new Region($x, $y, $width, $height); } /** * Returns the rectangle region. * - * @param int $x X. - * @param int $y Y. - * @param int $width Width. - * @param int $height Height. + * @param int|null $x X. + * @param int|null $y Y. + * @param int|null $width Width. + * @param int|null $height Height. * - * @return RectangleRegion */ - public static function rectangle($x = null, $y = null, $width = null, $height = null) - { + public static function rectangle( + ?int $x = null, + ?int $y = null, + ?int $width = null, + ?int $height = null + ): RectangleRegion { return new RectangleRegion($x, $y, $width, $height); } } diff --git a/src/Transformation/Positioning/Point.php b/src/Transformation/Positioning/Point.php index 378c710..855d916 100644 --- a/src/Transformation/Positioning/Point.php +++ b/src/Transformation/Positioning/Point.php @@ -20,10 +20,10 @@ class Point extends BaseAction /** * Point constructor. * - * @param float|int|string $x - * @param float|int|string $y + * @param float|int|string $x + * @param float|int|string|null $y */ - public function __construct($x = null, $y = null) + public function __construct(float|int|string|null $x = null, float|int|string|null $y = null) { parent::__construct(); @@ -33,13 +33,11 @@ public function __construct($x = null, $y = null) /** * Internal setter for the point value. * - * @param mixed $value * - * @return static * * @internal */ - public function setPointValue($value) + public function setPointValue(mixed $value): static { return $this->addQualifier($value); } diff --git a/src/Transformation/Positioning/PointTrait.php b/src/Transformation/Positioning/PointTrait.php index 45ae606..f401c5d 100644 --- a/src/Transformation/Positioning/PointTrait.php +++ b/src/Transformation/Positioning/PointTrait.php @@ -22,11 +22,11 @@ trait PointTrait /** * Sets the x dimension of the point. * - * @param int|float|string $x The value of the x dimension. + * @param float|int|string|null $x The value of the x dimension. * * @return $this */ - public function x($x) + public function x(float|int|string|null $x): static { return $this->setPointValue(ClassUtils::verifyInstance($x, X::class)); } @@ -34,11 +34,11 @@ public function x($x) /** * Sets the y dimension of the point. * - * @param int|float|string $y The value of the y dimension. + * @param float|int|string|null $y The value of the y dimension. * * @return $this */ - public function y($y) + public function y(float|int|string|null $y): static { return $this->setPointValue(ClassUtils::verifyInstance($y, Y::class)); } @@ -46,12 +46,11 @@ public function y($y) /** * Sets the x and y dimensions of the point. * - * @param int|float|string $x The value of the x dimension. - * @param int|float|string $y The value of the y dimension. + * @param float|int|string|null $x The value of the x dimension. + * @param float|int|string|null $y The value of the y dimension. * - * @return static */ - public function point($x = null, $y = null) + public function point(float|int|string|null $x = null, float|int|string|null $y = null): static { return $this->x($x)->y($y); } @@ -59,11 +58,9 @@ public function point($x = null, $y = null) /** * Internal setter for the point value. * - * @param mixed $value * - * @return static * * @internal */ - abstract public function setPointValue($value); + abstract public function setPointValue(mixed $value): static; } diff --git a/src/Transformation/Positioning/Position.php b/src/Transformation/Positioning/Position.php index 0edaf1e..7812cba 100644 --- a/src/Transformation/Positioning/Position.php +++ b/src/Transformation/Positioning/Position.php @@ -26,12 +26,11 @@ class Position extends BasePosition /** * Absolute position on the canvas. * - * @param int|float|string $x The x coordinate. - * @param int|float|string $y The y coordinate. + * @param float|int|string|null $x The x coordinate. + * @param float|int|string|null $y The y coordinate. * - * @return AbsolutePosition */ - public static function absolute($x = null, $y = null) + public static function absolute(float|int|string|null $x = null, float|int|string|null $y = null): AbsolutePosition { return new AbsolutePosition($x, $y); } @@ -39,15 +38,14 @@ public static function absolute($x = null, $y = null) /** * Named constructor. * - * @param string|CompassGravity $direction The compass gravity.. + * @param string $direction The compass gravity.. * - * @param array $args Additional arguments. + * @param array $args Additional arguments. * - * @return CompassPosition * * @internal */ - protected static function createWithCompassGravity($direction, ...$args) + protected static function createWithCompassGravity(string $direction, ...$args): CompassPosition { return new CompassPosition($direction, ...$args); } @@ -55,26 +53,23 @@ protected static function createWithCompassGravity($direction, ...$args) /** * Named constructor. * - * @param string|FocalGravity $gravity The focal gravity. - * @param array $fallback Fallback gravities. + * @param string $gravity The focal gravity. + * @param array $fallback Fallback gravities. * - * @return FocalPosition * * @internal */ - protected static function createWithFocalGravity($gravity, ...$fallback) + protected static function createWithFocalGravity(string $gravity, ...$fallback): FocalPosition { return new FocalPosition($gravity); } /** - * @param $value * - * @return static * @internal * */ - public function setOffsetValue($value) + public function setOffsetValue($value): static { if (! isset($this->qualifiers[Offset::getName()])) { $this->addQualifier(new Offset()); @@ -88,13 +83,11 @@ public function setOffsetValue($value) /** * Internal setter for the point value. * - * @param mixed $value * - * @return static * * @internal */ - public function setPointValue($value) + public function setPointValue(mixed $value): static { if (! isset($this->qualifiers[AbsolutePosition::getName()])) { $this->addQualifier(self::absolute()); diff --git a/src/Transformation/Positioning/PositionFlagTrait.php b/src/Transformation/Positioning/PositionFlagTrait.php index 8a67624..fb58f57 100644 --- a/src/Transformation/Positioning/PositionFlagTrait.php +++ b/src/Transformation/Positioning/PositionFlagTrait.php @@ -20,9 +20,8 @@ trait PositionFlagTrait /** * Tiles the added overlay over the entire image. * - * @return static */ - public function tiled() + public function tiled(): static { return $this->setFlag(Flag::tiled()); } @@ -33,11 +32,10 @@ public function tiled() * * @param bool $allowOverflow Indicates whether to allow overflow. * - * @return static * * @see Flag::noOverflow */ - public function allowOverflow($allowOverflow = false) + public function allowOverflow(bool $allowOverflow = false): static { $this->setFlag(Flag::noOverflow(), !$allowOverflow); diff --git a/src/Transformation/Positioning/PositioningQualifierTrait.php b/src/Transformation/Positioning/PositioningQualifierTrait.php index ac60966..b21e341 100644 --- a/src/Transformation/Positioning/PositioningQualifierTrait.php +++ b/src/Transformation/Positioning/PositioningQualifierTrait.php @@ -22,9 +22,8 @@ trait PositioningQualifierTrait * * @param int $x The x position. * - * @return X */ - public static function x($x) + public static function x(int $x): X { return new X($x); } @@ -34,9 +33,8 @@ public static function x($x) * * @param int $y The y position. * - * @return Y */ - public static function y($y) + public static function y(int $y): Y { return new Y($y); } diff --git a/src/Transformation/Positioning/Region.php b/src/Transformation/Positioning/Region.php index 1207c6f..75fef8f 100644 --- a/src/Transformation/Positioning/Region.php +++ b/src/Transformation/Positioning/Region.php @@ -17,23 +17,22 @@ */ class Region extends BaseAction { - const FACES = "faces"; - const GRAVITY = "gravity"; - const CUSTOM = "custom"; + public const FACES = "faces"; + public const GRAVITY = "gravity"; + public const CUSTOM = "custom"; use RegionTrait; use PixelEffectRegionTrait; /** * Region constructor. - * - * @param int|string $x - * @param int|string $y - * @param int|string $width - * @param int|string $height */ - public function __construct($x = null, $y = null, $width = null, $height = null) - { + public function __construct( + int|string|null $x = null, + int|string|null $y = null, + int|string|null $width = null, + int|string|null $height = null + ) { parent::__construct(); $this->x($x)->y($y)->width($width)->height($height); @@ -42,13 +41,11 @@ public function __construct($x = null, $y = null, $width = null, $height = null) /** * Internal setter for the point value. * - * @param $value * - * @return static * * @internal */ - public function setPointValue($value) + public function setPointValue($value): static { if (! isset($this->qualifiers[Point::getName()])) { $this->addQualifier(new Point()); @@ -62,13 +59,11 @@ public function setPointValue($value) /** * Internal setter for the dimensions. * - * @param $value * - * @return static * * @internal */ - public function setDimension($value) + public function setDimension($value): static { if (! isset($this->qualifiers[Dimensions::getName()])) { $this->addQualifier(new Dimensions()); @@ -79,10 +74,7 @@ public function setDimension($value) return $this; } - /** - * @return string - */ - public function getRegionType() + public function getRegionType(): string { if (isset($this->qualifiers[GravityQualifier::getName()])) { $gravityQualifier = $this->qualifiers[GravityQualifier::getName()]; diff --git a/src/Transformation/Positioning/RegionTrait.php b/src/Transformation/Positioning/RegionTrait.php index 21b9c76..543a331 100644 --- a/src/Transformation/Positioning/RegionTrait.php +++ b/src/Transformation/Positioning/RegionTrait.php @@ -28,7 +28,7 @@ trait RegionTrait * * @return $this */ - public function region($region) + public function region(Region $region): static { return $this->addQualifier($region); } diff --git a/src/Transformation/Qualifier/BaseExpressionQualifier.php b/src/Transformation/Qualifier/BaseExpressionQualifier.php index 3deed5e..58701cb 100644 --- a/src/Transformation/Qualifier/BaseExpressionQualifier.php +++ b/src/Transformation/Qualifier/BaseExpressionQualifier.php @@ -20,5 +20,5 @@ abstract class BaseExpressionQualifier extends BaseQualifier /** * @var string VALUE_CLASS The class of the qualifier value. Can be customized by derived classes. */ - const VALUE_CLASS = ExpressionQualifierMultiValue::class; + protected const VALUE_CLASS = ExpressionQualifierMultiValue::class; } diff --git a/src/Transformation/Qualifier/BaseQualifier.php b/src/Transformation/Qualifier/BaseQualifier.php index 13343fe..355cc67 100644 --- a/src/Transformation/Qualifier/BaseQualifier.php +++ b/src/Transformation/Qualifier/BaseQualifier.php @@ -13,7 +13,6 @@ use Cloudinary\ArrayUtils; use Cloudinary\StringUtils; use Cloudinary\Transformation\BaseComponent; -use Cloudinary\Transformation\Expression\ExpressionUtils; use Cloudinary\Transformation\QualifierMultiValue; /** @@ -24,32 +23,32 @@ abstract class BaseQualifier extends BaseComponent /** * @var string VALUE_CLASS The class of the qualifier value. Can be customized by derived classes. */ - const VALUE_CLASS = QualifierMultiValue::class; + protected const VALUE_CLASS = QualifierMultiValue::class; /** * @var string KEY_VALUE_DELIMITER The delimiter between the key and the value. */ - const KEY_VALUE_DELIMITER = '_'; + protected const KEY_VALUE_DELIMITER = '_'; /** - * @var string Omit class suffix, example: QualityQualifier -> quality_qualifier -> quality -> q + * @var string[] Omit class suffix, example: QualityQualifier -> quality_qualifier -> quality -> q */ - const CLASS_NAME_SUFFIX_EXCLUSIONS = ['qualifier']; + protected const CLASS_NAME_SUFFIX_EXCLUSIONS = ['qualifier']; /** * @var string $key Serialisation Key. */ - protected static $key; + protected static string $key = ""; /** - * @var QualifierMultiValue $value The value. + * @var mixed $value The value. */ - protected $value; + protected mixed $value; /** * @var array $valueOrder The order of the values. */ - protected $valueOrder = []; // FIXME: move to QualifierTraitMultiValue + protected array $valueOrder = []; // FIXME: move to QualifierTraitMultiValue /** * BaseQualifier constructor. @@ -73,9 +72,8 @@ public function __construct(...$value) * * @param mixed $value The value. * - * @return static */ - public static function fromValue($value) + public static function fromValue(mixed $value): static { return new static($value); } @@ -83,14 +81,12 @@ public static function fromValue($value) /** * Collects values from BaseQualifiers. * - * @param array $values * - * @return array */ - protected static function collectValues(array $values) + protected static function collectValues(array $values): array { foreach ($values as &$value) { - $value = ($value instanceof self) ? $value->getValue() : $value; + $value = $value instanceof self ? $value->getValue() : $value; } return $values; @@ -99,11 +95,10 @@ protected static function collectValues(array $values) /** * Sets ((re)initializes) the qualifier value. * - * @param $value + * @param mixed ...$value The qualifier value(s). * - * @return static */ - public function setQualifierValue(...$value) + public function setQualifierValue(...$value): static { $value = self::collectValues($value); @@ -127,7 +122,7 @@ public function setQualifierValue(...$value) * * @internal */ - public function add(...$value) + public function add(...$value): static { $this->value->addValues(...$value); @@ -137,11 +132,10 @@ public function add(...$value) /** * Internal getter of the value. * - * @return QualifierMultiValue * * @internal */ - public function getValue() + public function getValue(): QualifierMultiValue { return $this->value; } @@ -149,11 +143,10 @@ public function getValue() /** * Gets the qualifier key. * - * @return mixed * * @internal */ - public static function getKey() + public static function getKey(): string { $key = static::$key; @@ -167,9 +160,8 @@ public static function getKey() /** * Gets string representation of the qualifiers * - * @return array */ - public function getStringQualifiers() + public function getStringQualifiers(): array { return [(string)$this]; } @@ -189,10 +181,8 @@ public function __toString() /** * Serializes to json. - * - * @return mixed */ - public function jsonSerialize() + public function jsonSerialize(): array { $value = ArrayUtils::flatten($this->value); diff --git a/src/Transformation/Qualifier/Color/ColorQualifier.php b/src/Transformation/Qualifier/Color/ColorQualifier.php index f7bbfd8..7ddb47b 100644 --- a/src/Transformation/Qualifier/Color/ColorQualifier.php +++ b/src/Transformation/Qualifier/Color/ColorQualifier.php @@ -27,12 +27,11 @@ class ColorQualifier extends BaseQualifier /** * @var string $key Serialization key. */ - protected static $key = 'co'; + protected static string $key = 'co'; /** * Color constructor. * - * @param $color */ public function __construct($color) { diff --git a/src/Transformation/Qualifier/Color/ColorQualifierTrait.php b/src/Transformation/Qualifier/Color/ColorQualifierTrait.php index 25d31de..df399a8 100644 --- a/src/Transformation/Qualifier/Color/ColorQualifierTrait.php +++ b/src/Transformation/Qualifier/Color/ColorQualifierTrait.php @@ -22,9 +22,8 @@ trait ColorQualifierTrait * * @param string $color The color. * - * @return ColorQualifier */ - public static function color($color) + public static function color(string $color): ColorQualifier { return new ColorQualifier($color); } diff --git a/src/Transformation/Qualifier/Color/ColorToReplaceTrait.php b/src/Transformation/Qualifier/Color/ColorToReplaceTrait.php index 6adb180..c4bf020 100644 --- a/src/Transformation/Qualifier/Color/ColorToReplaceTrait.php +++ b/src/Transformation/Qualifier/Color/ColorToReplaceTrait.php @@ -24,7 +24,7 @@ trait ColorToReplaceTrait * * @return $this */ - public function colorToReplace($color) + public function colorToReplace(string $color): static { $this->addQualifier(ClassUtils::verifyInstance($color, ColorQualifier::class)); diff --git a/src/Transformation/Qualifier/Color/ColorTrait.php b/src/Transformation/Qualifier/Color/ColorTrait.php index 1fc9fee..2d48fb6 100644 --- a/src/Transformation/Qualifier/Color/ColorTrait.php +++ b/src/Transformation/Qualifier/Color/ColorTrait.php @@ -20,11 +20,11 @@ trait ColorTrait /** * Sets the color. * - * @param string $color The color. + * @param ?string $color The color. * * @return $this */ - public function color($color) + public function color(?string $color): static { $this->addQualifier(ClassUtils::verifyInstance($color, ColorQualifier::class)); diff --git a/src/Transformation/Qualifier/Color/TextColorTrait.php b/src/Transformation/Qualifier/Color/TextColorTrait.php index ac8d570..af1fce5 100644 --- a/src/Transformation/Qualifier/Color/TextColorTrait.php +++ b/src/Transformation/Qualifier/Color/TextColorTrait.php @@ -20,11 +20,11 @@ trait TextColorTrait /** * Sets the color of the text. * - * @param string $color The color. + * @param ?string $color The color. * * @return $this */ - public function textColor($color) + public function textColor(?string $color): static { $this->addQualifier(ClassUtils::verifyInstance($color, ColorQualifier::class)); diff --git a/src/Transformation/Qualifier/Dimensions/AspectRatio.php b/src/Transformation/Qualifier/Dimensions/AspectRatio.php index 114def6..1a75ea1 100644 --- a/src/Transformation/Qualifier/Dimensions/AspectRatio.php +++ b/src/Transformation/Qualifier/Dimensions/AspectRatio.php @@ -18,22 +18,21 @@ */ class AspectRatio extends BaseExpressionQualifier { - const MAX_VALUES = 2; + protected const MAX_VALUES = 2; - const AR_1X1 = '1:1'; - const AR_5X4 = '5:4'; - const AR_4X3 = '4:3'; - const AR_3X2 = '3:2'; - const AR_16X9 = '16:9'; - const AR_3X1 = '3:1'; - const IGNORE_INITIAL = "ignore_aspect_ratio"; + public const AR_1X1 = '1:1'; + public const AR_5X4 = '5:4'; + public const AR_4X3 = '4:3'; + public const AR_3X2 = '3:2'; + public const AR_16X9 = '16:9'; + public const AR_3X1 = '3:1'; + public const IGNORE_INITIAL = "ignore_aspect_ratio"; /** * Aspect ratio 1:1. * - * @return AspectRatio */ - public static function ar1x1() + public static function ar1x1(): AspectRatio { return new self(self::AR_1X1); } @@ -41,9 +40,8 @@ public static function ar1x1() /** * Aspect ratio 5:4. * - * @return AspectRatio */ - public static function ar5x4() + public static function ar5x4(): AspectRatio { return new self(self::AR_5X4); } @@ -51,9 +49,8 @@ public static function ar5x4() /** * Aspect ratio 4:3. * - * @return AspectRatio */ - public static function ar4x3() + public static function ar4x3(): AspectRatio { return new self(self::AR_4X3); } @@ -61,9 +58,8 @@ public static function ar4x3() /** * Aspect ratio 3:2. * - * @return AspectRatio */ - public static function ar3x2() + public static function ar3x2(): AspectRatio { return new self(self::AR_3X2); } @@ -71,9 +67,8 @@ public static function ar3x2() /** * Aspect ratio 16:9. * - * @return AspectRatio */ - public static function ar16x9() + public static function ar16x9(): AspectRatio { return new self(self::AR_16X9); } @@ -81,9 +76,8 @@ public static function ar16x9() /** * Aspect ratio 3:1. * - * @return AspectRatio */ - public static function ar3x1() + public static function ar3x1(): AspectRatio { return new self(self::AR_3X1); } @@ -91,9 +85,8 @@ public static function ar3x1() /** * Set to ignore initial aspect ratio. * - * @return AspectRatio */ - public static function ignoreInitialAspectRatio() + public static function ignoreInitialAspectRatio(): AspectRatio { return new self(self::IGNORE_INITIAL); } diff --git a/src/Transformation/Qualifier/Dimensions/Dimensions.php b/src/Transformation/Qualifier/Dimensions/Dimensions.php index 231bf58..b75d35b 100644 --- a/src/Transformation/Qualifier/Dimensions/Dimensions.php +++ b/src/Transformation/Qualifier/Dimensions/Dimensions.php @@ -24,11 +24,11 @@ class Dimensions extends BaseAction /** * Dimensions constructor. * - * @param int|string|Expression $width - * @param int|string|Expression $height - * @param mixed|AspectRatio ...$aspectRatio + * @param int|string|Expression|null $width + * @param int|string|Expression|null $height + * @param mixed|AspectRatio ...$aspectRatio */ - public function __construct($width = null, $height = null, ...$aspectRatio) + public function __construct($width = null, Expression|int|string|null $height = null, ...$aspectRatio) { parent::__construct(); @@ -40,13 +40,12 @@ public function __construct($width = null, $height = null, ...$aspectRatio) /** * Internal setter for the dimensions. * - * @param Dimensions|mixed $value The dimensions. + * @param mixed|null $value The dimensions. * - * @return static * * @internal */ - protected function setDimension($value = null) + protected function setDimension(mixed $value = null): static { $this->addQualifier($value); diff --git a/src/Transformation/Qualifier/Dimensions/DimensionsQualifierTrait.php b/src/Transformation/Qualifier/Dimensions/DimensionsQualifierTrait.php index bd548e3..5a7c1a7 100644 --- a/src/Transformation/Qualifier/Dimensions/DimensionsQualifierTrait.php +++ b/src/Transformation/Qualifier/Dimensions/DimensionsQualifierTrait.php @@ -24,14 +24,13 @@ trait DimensionsQualifierTrait /** * Sets the width of the asset. * - * @param int|float $width The width in pixels (if an integer is specified) or as a percentage (if a float is - * specified). + * @param float|int|string|null $width The width in pixels (if an integer is specified) or as a percentage + * (if a float is specified). * - * @return Width * - * @see \Cloudinary\Transformation\Qualifier\Dimensions\Width + * @see Width */ - public static function width($width) + public static function width(float|int|string|null $width): Width { return new Width($width); } @@ -39,14 +38,13 @@ public static function width($width) /** * Sets the height of the asset. * - * @param int|float $height The height in pixels (if an integer is specified) or as a percentage (if a float is - * specified). + * @param float|int|string|null $height The height in pixels (if an integer is specified) or as a percentage + * (if a float is specified). * - * @return Height * - * @see \Cloudinary\Transformation\Qualifier\Dimensions\Height + * @see Height */ - public static function height($height) + public static function height(float|int|string|null $height): Height { return new Height($height); } @@ -56,11 +54,10 @@ public static function height($height) * * @param float|array $aspectRatio The new aspect ratio, specified as a percentage or ratio. * - * @return AspectRatio * * @see \Cloudinary\Transformation\Qualifier\Dimensions\AspectRatio */ - public static function aspectRatio(...$aspectRatio) + public static function aspectRatio(...$aspectRatio): AspectRatio { return new AspectRatio(...$aspectRatio); } @@ -70,11 +67,10 @@ public static function aspectRatio(...$aspectRatio) * * @param float $dpr The device pixel ratio. * - * @return Dpr * - * @see \Cloudinary\Transformation\Qualifier\Dimensions\Dpr + * @see Dpr */ - public static function dpr($dpr) + public static function dpr(float $dpr): Dpr { return new Dpr($dpr); } diff --git a/src/Transformation/Qualifier/Dimensions/DimensionsTrait.php b/src/Transformation/Qualifier/Dimensions/DimensionsTrait.php index 5f7ce86..18770a7 100644 --- a/src/Transformation/Qualifier/Dimensions/DimensionsTrait.php +++ b/src/Transformation/Qualifier/Dimensions/DimensionsTrait.php @@ -24,11 +24,10 @@ trait DimensionsTrait /** * Sets the width of the asset. * - * @param int|string|Expression $width The width in pixels. + * @param mixed $width The width in pixels. * - * @return static */ - public function width($width) + public function width(mixed $width): static { $this->setDimension(ClassUtils::verifyInstance($width, Width::class)); @@ -40,9 +39,8 @@ public function width($width) * * @param int|string|Expression $height The height in pixels. * - * @return static */ - public function height($height) + public function height(mixed $height): static { $this->setDimension(ClassUtils::verifyInstance($height, Height::class)); @@ -56,9 +54,9 @@ public function height($height) * * @return $this */ - public function size($size) + public function size(string $size): static { - list($width, $height) = explode('x', $size); + [$width, $height] = explode('x', $size); $this->width($width)->height($height); @@ -70,9 +68,8 @@ public function size($size) * * @param float|array|AspectRatio $aspectRatio The new aspect ratio, specified as a percentage or ratio. * - * @return static */ - public function aspectRatio(...$aspectRatio) + public function aspectRatio(...$aspectRatio): static { $this->setDimension(ClassUtils::verifyVarArgsInstance($aspectRatio, AspectRatio::class)); @@ -82,9 +79,7 @@ public function aspectRatio(...$aspectRatio) /** * Internal setter for the dimensions. * - * @param mixed $value * - * @return static */ - abstract protected function setDimension($value); + abstract protected function setDimension(mixed $value): static; } diff --git a/src/Transformation/Qualifier/Dimensions/TextFit.php b/src/Transformation/Qualifier/Dimensions/TextFit.php index 9ba02a2..4afe974 100644 --- a/src/Transformation/Qualifier/Dimensions/TextFit.php +++ b/src/Transformation/Qualifier/Dimensions/TextFit.php @@ -23,10 +23,10 @@ class TextFit extends BaseAction /** * TextFit constructor. * - * @param int|string|Expression $width The width in pixels. - * @param int|string|Expression $height The height in pixels. + * @param int|string|Expression $width The width in pixels. + * @param int|string|Expression|null $height The height in pixels. */ - public function __construct($width, $height = null) + public function __construct($width, Expression|int|string|null $height = null) { parent::__construct(CropMode::fit()); @@ -37,12 +37,12 @@ public function __construct($width, $height = null) /** * TextFit named constructor. * - * @param int|string|Expression $width The width in pixels. - * @param int|string|Expression $height The height in pixels. + * @param int|string|Expression $width The width in pixels. + * @param int|string|Expression|null $height The height in pixels. * * @return $this */ - public static function size($width, $height = null) + public static function size(Expression|int|string $width, Expression|int|string|null $height = null): TextFit|static { return new TextFit($width, $height); } @@ -52,9 +52,8 @@ public static function size($width, $height = null) * * @param int|string|Expression $width The width in pixels. * - * @return static */ - public function width($width) + public function width(Expression|int|string $width): static { $this->setDimension(ClassUtils::verifyInstance($width, Width::class)); @@ -66,9 +65,8 @@ public function width($width) * * @param int|string|Expression $height The height in pixels. * - * @return static */ - public function height($height) + public function height(Expression|int|string $height): static { $this->setDimension(ClassUtils::verifyInstance($height, Height::class)); @@ -78,13 +76,12 @@ public function height($height) /** * Internal setter for the dimensions. * - * @param mixed $value The dimension. + * @param mixed|null $value The dimension. * - * @return static * * @internal */ - protected function setDimension($value = null) + protected function setDimension(mixed $value = null): static { $this->addQualifier($value); diff --git a/src/Transformation/Qualifier/Dimensions/TextFitTrait.php b/src/Transformation/Qualifier/Dimensions/TextFitTrait.php index 89f4bd2..f7cf4c5 100644 --- a/src/Transformation/Qualifier/Dimensions/TextFitTrait.php +++ b/src/Transformation/Qualifier/Dimensions/TextFitTrait.php @@ -22,12 +22,14 @@ trait TextFitTrait * Sets the text fit. * * @param int|string|Expression|TextFit $widthOrTextFit The width in pixels or the TextFit class. - * @param int|string|Expression $height The height in pixels. + * @param int|string|Expression|null $height The height in pixels. * * @return $this */ - public function textFit($widthOrTextFit, $height = null) - { + public function textFit( + Expression|int|string|TextFit $widthOrTextFit, + Expression|int|string|null $height = null + ): static { $this->addQualifier(ClassUtils::verifyInstance($widthOrTextFit, TextFit::class, null, $height)); return $this; diff --git a/src/Transformation/Qualifier/GenericQualifier.php b/src/Transformation/Qualifier/GenericQualifier.php index c147bdb..b48f4da 100644 --- a/src/Transformation/Qualifier/GenericQualifier.php +++ b/src/Transformation/Qualifier/GenericQualifier.php @@ -20,13 +20,11 @@ class GenericQualifier extends BaseQualifier /** * @var string $genericKey User provided generic key instead of static class key */ - protected $genericKey; + protected string $genericKey; /** * GenericQualifier constructor. * - * @param $genericKey - * @param mixed ...$value */ public function __construct($genericKey, ...$value) { @@ -42,7 +40,7 @@ public function __construct($genericKey, ...$value) * * @return $this */ - public function setKey($genericKey) + public function setKey(string $genericKey): static { $this->genericKey = $genericKey; @@ -52,9 +50,8 @@ public function setKey($genericKey) /** * Gets qualifier full name. * - * @return string */ - public function getFullName() + public function getFullName(): string { return ArrayUtils::implodeFiltered('_', [parent::getFullName(), $this->genericKey]); } diff --git a/src/Transformation/Qualifier/Misc/BreakpointsJson.php b/src/Transformation/Qualifier/Misc/BreakpointsJson.php index 6b4a180..4239028 100644 --- a/src/Transformation/Qualifier/Misc/BreakpointsJson.php +++ b/src/Transformation/Qualifier/Misc/BreakpointsJson.php @@ -22,56 +22,61 @@ */ class BreakpointsJson extends BaseQualifier { - const DEFAULT_BYTES_STEP = 20000; - const DEFAULT_MIN_WIDTH = 375; - const DEFAULT_MAX_WIDTH = 3840; - const DEFAULT_MAX_IMAGES = 5; + public const DEFAULT_BYTES_STEP = 20000; + public const DEFAULT_MIN_WIDTH = 375; + public const DEFAULT_MAX_WIDTH = 3840; + public const DEFAULT_MAX_IMAGES = 5; /** * @var string $name The name of the qualifier. Actually width qualifier is used for this purpose. */ - protected static $name = 'width'; + protected static string $name = 'width'; /** * @var string $name The key of the qualifier. */ - protected static $key = 'w'; + protected static string $key = 'w'; /** * @var int The minimum width needed for this image. Default: 50. */ - protected $minWidth; + protected int $minWidth; /** * @var int The maximum width needed for this image. If specifying a width bigger than the original image, * the width of the original image is used instead. Default: 1000. */ - protected $maxWidth; + protected int $maxWidth; /** * @var int The minimum number of bytes between two consecutive breakpoints (images). Default: 20000. */ - protected $bytesStep; + protected int $bytesStep; /** * @var int The maximum number of breakpoints to find, between 3 and 200. This means that there might be size * differences bigger than the given bytes_step value between consecutive images. Default: 20. */ - protected $maxImages; + protected int $maxImages; /** * BreakpointsJson qualifier constructor. * - * @param int $minWidth The minimum width needed for this image. Default: 50. - * @param int $maxWidth The maximum width needed for this image. If specifying a width bigger than the original - * image, the width of the original image is used instead. Default: 1000. - * @param int $bytesStep The minimum number of bytes between two consecutive breakpoints (images). Default: 20000. - * @param int $maxImages The maximum number of breakpoints to find, between 3 and 200. This means that there might - * be size differences bigger than the given bytes_step value between consecutive images. - * Default: 20. + * @param int|null $minWidth The minimum width needed for this image. Default: 50. + * @param int|null $maxWidth The maximum width needed for this image. If specifying a width bigger than the + * original image, the width of the original image is used instead. Default: 1000. + * @param int|null $bytesStep The minimum number of bytes between two consecutive breakpoints (images). Default: + * 20000. + * @param int|null $maxImages The maximum number of breakpoints to find, between 3 and 200. This means that there + * might be size differences bigger than the given bytes_step value between consecutive + * images. Default: 20. * */ - public function __construct($minWidth = null, $maxWidth = null, $bytesStep = null, $maxImages = null) - { + public function __construct( + ?int $minWidth = null, + ?int $maxWidth = null, + ?int $bytesStep = null, + ?int $maxImages = null + ) { parent::__construct(); $this->minWidth($minWidth); @@ -83,11 +88,10 @@ public function __construct($minWidth = null, $maxWidth = null, $bytesStep = nul /** * Sets the minimum width. * - * @param int $minWidth The minimum width needed for this image. Default: 50. + * @param ?int $minWidth The minimum width needed for this image. Default: 50. * - * @return BreakpointsJson */ - public function minWidth($minWidth) + public function minWidth(?int $minWidth): static { $this->minWidth = $minWidth ?: self::DEFAULT_MIN_WIDTH; @@ -97,12 +101,11 @@ public function minWidth($minWidth) /** * Sets the maximum width. * - * @param int $maxWidth The maximum width needed for this image. If specifying a width bigger than the original - * image, the width of the original image is used instead. Default: 1000. + * @param ?int $maxWidth The maximum width needed for this image. If specifying a width bigger than the original + * image, the width of the original image is used instead. Default: 1000. * - * @return BreakpointsJson */ - public function maxWidth($maxWidth) + public function maxWidth(?int $maxWidth): static { $this->maxWidth = $maxWidth ?: self::DEFAULT_MAX_WIDTH; @@ -112,11 +115,10 @@ public function maxWidth($maxWidth) /** * Sets the size step (in bytes). * - * @param int $bytesStep The minimum number of bytes between two consecutive breakpoints (images). Default: 20000. + * @param ?int $bytesStep The minimum number of bytes between two consecutive breakpoints (images). Default: 20000. * - * @return BreakpointsJson */ - public function bytesStep($bytesStep) + public function bytesStep(?int $bytesStep): static { $this->bytesStep = $bytesStep ?: self::DEFAULT_BYTES_STEP; @@ -126,13 +128,12 @@ public function bytesStep($bytesStep) /** * Sets the maximum amount of breakpoints. * - * @param int $maxImages The maximum number of breakpoints to find, between 3 and 200. This means that there might - * be size differences bigger than the given bytes_step value between consecutive images. - * Default: 20. + * @param ?int $maxImages The maximum number of breakpoints to find, between 3 and 200. This means that there might + * be size differences bigger than the given bytes_step value between consecutive images. + * Default: 20. * - * @return BreakpointsJson */ - public function maxImages($maxImages) + public function maxImages(?int $maxImages): static { $this->maxImages = $maxImages ?: self::DEFAULT_MAX_IMAGES; @@ -155,7 +156,7 @@ public function __toString() * * @return array[] */ - public function jsonSerialize() + public function jsonSerialize(): array { // TODO: finalize serialization return [ diff --git a/src/Transformation/Qualifier/Qualifier.php b/src/Transformation/Qualifier/Qualifier.php index efeab48..810d5f7 100644 --- a/src/Transformation/Qualifier/Qualifier.php +++ b/src/Transformation/Qualifier/Qualifier.php @@ -52,9 +52,8 @@ abstract class Qualifier * @param string $genericKey The name of any qualifier. * @param mixed ...$value The value of the qualifier. * - * @return GenericQualifier */ - public static function generic($genericKey, ...$value) + public static function generic(string $genericKey, ...$value): GenericQualifier { return new GenericQualifier($genericKey, ...$value); } diff --git a/src/Transformation/Qualifier/QualifierValue/BaseNamedArgument.php b/src/Transformation/Qualifier/QualifierValue/BaseNamedArgument.php index 6a6b91f..0b6dcfb 100644 --- a/src/Transformation/Qualifier/QualifierValue/BaseNamedArgument.php +++ b/src/Transformation/Qualifier/QualifierValue/BaseNamedArgument.php @@ -18,28 +18,28 @@ */ abstract class BaseNamedArgument extends BaseComponent { - const ARG_NAME_VALUE_DELIMITER = '_'; - const ARG_INNER_VALUE_DELIMITER = ':'; + public const ARG_NAME_VALUE_DELIMITER = '_'; + public const ARG_INNER_VALUE_DELIMITER = ':'; /** * @var string $argName The name of the argument. */ - protected $argName; + protected string $argName; /** - * @var array $argMultiValue The value of the argument. + * @var mixed $argMultiValue The value of the argument. */ - protected $argMultiValue = []; + protected mixed $argMultiValue = []; /** * @var string $nameValueDelimiter Run-time settable name-value delimiter. */ - protected $nameValueDelimiter; + protected string $nameValueDelimiter; /** * @var string $innerValueDelimiter Run-time settable inner value delimiter. */ - protected $innerValueDelimiter; + protected string $innerValueDelimiter; /** * BaseNamedArgument constructor. @@ -50,16 +50,18 @@ public function __construct(...$value) { parent::__construct(); + $this->nameValueDelimiter = static::ARG_NAME_VALUE_DELIMITER; + $this->innerValueDelimiter = static::ARG_INNER_VALUE_DELIMITER; + $this->addValues(...$value); } /** - * @param mixed ...$value * * @return $this */ - public function addValues(...$values) + public function addValues(...$values): static { $this->argMultiValue = array_merge($this->argMultiValue, $values); @@ -69,9 +71,8 @@ public function addValues(...$values) /** * Gets the multi value of the argument. * - * @return array */ - public function getMultiValue() + public function getMultiValue(): array { return $this->argMultiValue; } @@ -98,9 +99,8 @@ public function __toString() /** * Serializes to json. * - * @return mixed */ - public function jsonSerialize() + public function jsonSerialize(): array { return ['name' => $this->getArgName(), 'value' => ArrayUtils::flatten($this->argMultiValue)]; } @@ -108,13 +108,16 @@ public function jsonSerialize() /** * Gets the argument name. * - * @return string * * @internal */ - protected function getArgName() + protected function getArgName(): string { - return $this->argName ?: $this->getFullName(); + if (!isset($this->argName)){ + $this->argName = $this->getFullName(); + } + + return $this->argName; } } diff --git a/src/Transformation/Qualifier/QualifierValue/Canvas/PointValue.php b/src/Transformation/Qualifier/QualifierValue/Canvas/PointValue.php index ca3e1e2..d1bcf26 100644 --- a/src/Transformation/Qualifier/QualifierValue/Canvas/PointValue.php +++ b/src/Transformation/Qualifier/QualifierValue/Canvas/PointValue.php @@ -20,20 +20,20 @@ class PointValue extends BaseComponent /** * @var int|string $x The x dimension of the point. */ - protected $x; + protected string|int $x; /** * @var int|string $y The y dimension of the point. */ - protected $y; + protected string|int $y; /** * PointValue constructor. * - * @param int $x - * @param int $y + * @param int|null $x + * @param int|null $y */ - public function __construct($x = null, $y = null) + public function __construct(?int $x = null, ?int $y = null) { parent::__construct(); @@ -43,11 +43,10 @@ public function __construct($x = null, $y = null) /** * Sets the x dimension of the point. * - * @param int $x The value of the x dimension. + * @param ?int $x The value of the x dimension. * - * @return PointValue */ - public function x($x) + public function x(?int $x): static { $this->x = $x; @@ -57,11 +56,10 @@ public function x($x) /** * Sets the y dimension of the point. * - * @param int $y The value of the y dimension. + * @param ?int $y The value of the y dimension. * - * @return PointValue */ - public function y($y) + public function y(?int $y): static { $this->y = $y; @@ -81,13 +79,12 @@ public function __toString() /** * Serializes to json. * - * @return mixed */ - public function jsonSerialize() + public function jsonSerialize(): array { return [ 'x' => $this->x, - 'y' => $this->y + 'y' => $this->y, ]; } } diff --git a/src/Transformation/Qualifier/QualifierValue/Canvas/RectangleRegion.php b/src/Transformation/Qualifier/QualifierValue/Canvas/RectangleRegion.php index 969d570..abd2c0d 100644 --- a/src/Transformation/Qualifier/QualifierValue/Canvas/RectangleRegion.php +++ b/src/Transformation/Qualifier/QualifierValue/Canvas/RectangleRegion.php @@ -10,8 +10,6 @@ namespace Cloudinary\Transformation; -use Cloudinary\ArrayUtils; - /** * Class RectangleRegion */ @@ -25,7 +23,7 @@ class RectangleRegion extends FullListExpressionQualifierMultiValue * @param int $width Width. * @param int $height Height. */ - public function __construct($x, $y, $width, $height) + public function __construct($x, int $y, int $width, int $height) { parent::__construct(); diff --git a/src/Transformation/Qualifier/QualifierValue/Color/Color.php b/src/Transformation/Qualifier/QualifierValue/Color/Color.php index 4c60fc3..d17b864 100644 --- a/src/Transformation/Qualifier/QualifierValue/Color/Color.php +++ b/src/Transformation/Qualifier/QualifierValue/Color/Color.php @@ -19,677 +19,677 @@ */ class Color extends BaseArgument { - const SNOW = 'snow'; - const SNOW1 = 'snow1'; - const SNOW2 = 'snow2'; - const ROSYBROWN1 = 'rosybrown1'; - const ROSYBROWN2 = 'rosybrown2'; - const SNOW3 = 'snow3'; - const LIGHTCORAL = 'lightcoral'; - const INDIANRED1 = 'indianred1'; - const ROSYBROWN3 = 'rosybrown3'; - const INDIANRED2 = 'indianred2'; - const ROSYBROWN = 'rosybrown'; - const BROWN1 = 'brown1'; - const FIREBRICK1 = 'firebrick1'; - const BROWN2 = 'brown2'; - const INDIANRED = 'indianred'; - const INDIANRED3 = 'indianred3'; - const FIREBRICK2 = 'firebrick2'; - const SNOW4 = 'snow4'; - const BROWN3 = 'brown3'; - const RED = 'red'; - const RED1 = 'red1'; - const ROSYBROWN4 = 'rosybrown4'; - const FIREBRICK3 = 'firebrick3'; - const RED2 = 'red2'; - const FIREBRICK = 'firebrick'; - const BROWN = 'brown'; - const RED3 = 'red3'; - const INDIANRED4 = 'indianred4'; - const BROWN4 = 'brown4'; - const FIREBRICK4 = 'firebrick4'; - const DARKRED = 'darkred'; - const RED4 = 'red4'; - const LIGHTPINK1 = 'lightpink1'; - const LIGHTPINK3 = 'lightpink3'; - const LIGHTPINK4 = 'lightpink4'; - const LIGHTPINK2 = 'lightpink2'; - const LIGHTPINK = 'lightpink'; - const PINK = 'pink'; - const CRIMSON = 'crimson'; - const PINK1 = 'pink1'; - const PINK2 = 'pink2'; - const PINK3 = 'pink3'; - const PINK4 = 'pink4'; - const PALEVIOLETRED4 = 'palevioletred4'; - const PALEVIOLETRED = 'palevioletred'; - const PALEVIOLETRED2 = 'palevioletred2'; - const PALEVIOLETRED1 = 'palevioletred1'; - const PALEVIOLETRED3 = 'palevioletred3'; - const LAVENDERBLUSH = 'lavenderblush'; - const LAVENDERBLUSH1 = 'lavenderblush1'; - const LAVENDERBLUSH3 = 'lavenderblush3'; - const LAVENDERBLUSH2 = 'lavenderblush2'; - const LAVENDERBLUSH4 = 'lavenderblush4'; - const MAROON = 'maroon'; - const HOTPINK3 = 'hotpink3'; - const VIOLETRED3 = 'violetred3'; - const VIOLETRED1 = 'violetred1'; - const VIOLETRED2 = 'violetred2'; - const VIOLETRED4 = 'violetred4'; - const HOTPINK2 = 'hotpink2'; - const HOTPINK1 = 'hotpink1'; - const HOTPINK4 = 'hotpink4'; - const HOTPINK = 'hotpink'; - const DEEPPINK = 'deeppink'; - const DEEPPINK1 = 'deeppink1'; - const DEEPPINK2 = 'deeppink2'; - const DEEPPINK3 = 'deeppink3'; - const DEEPPINK4 = 'deeppink4'; - const MAROON1 = 'maroon1'; - const MAROON2 = 'maroon2'; - const MAROON3 = 'maroon3'; - const MAROON4 = 'maroon4'; - const MEDIUMVIOLETRED = 'mediumvioletred'; - const VIOLETRED = 'violetred'; - const ORCHID2 = 'orchid2'; - const ORCHID = 'orchid'; - const ORCHID1 = 'orchid1'; - const ORCHID3 = 'orchid3'; - const ORCHID4 = 'orchid4'; - const THISTLE1 = 'thistle1'; - const THISTLE2 = 'thistle2'; - const PLUM1 = 'plum1'; - const PLUM2 = 'plum2'; - const THISTLE = 'thistle'; - const THISTLE3 = 'thistle3'; - const PLUM = 'plum'; - const VIOLET = 'violet'; - const PLUM3 = 'plum3'; - const THISTLE4 = 'thistle4'; - const FUCHSIA = 'fuchsia'; - const MAGENTA = 'magenta'; - const MAGENTA1 = 'magenta1'; - const PLUM4 = 'plum4'; - const MAGENTA2 = 'magenta2'; - const MAGENTA3 = 'magenta3'; - const DARKMAGENTA = 'darkmagenta'; - const MAGENTA4 = 'magenta4'; - const PURPLE = 'purple'; - const MEDIUMORCHID = 'mediumorchid'; - const MEDIUMORCHID1 = 'mediumorchid1'; - const MEDIUMORCHID2 = 'mediumorchid2'; - const MEDIUMORCHID3 = 'mediumorchid3'; - const MEDIUMORCHID4 = 'mediumorchid4'; - const DARKVIOLET = 'darkviolet'; - const DARKORCHID = 'darkorchid'; - const DARKORCHID1 = 'darkorchid1'; - const DARKORCHID3 = 'darkorchid3'; - const DARKORCHID2 = 'darkorchid2'; - const DARKORCHID4 = 'darkorchid4'; - const INDIGO = 'indigo'; - const BLUEVIOLET = 'blueviolet'; - const PURPLE2 = 'purple2'; - const PURPLE3 = 'purple3'; - const PURPLE4 = 'purple4'; - const PURPLE1 = 'purple1'; - const MEDIUMPURPLE = 'mediumpurple'; - const MEDIUMPURPLE1 = 'mediumpurple1'; - const MEDIUMPURPLE2 = 'mediumpurple2'; - const MEDIUMPURPLE3 = 'mediumpurple3'; - const MEDIUMPURPLE4 = 'mediumpurple4'; - const DARKSLATEBLUE = 'darkslateblue'; - const LIGHTSLATEBLUE = 'lightslateblue'; - const MEDIUMSLATEBLUE = 'mediumslateblue'; - const SLATEBLUE = 'slateblue'; - const SLATEBLUE1 = 'slateblue1'; - const SLATEBLUE2 = 'slateblue2'; - const SLATEBLUE3 = 'slateblue3'; - const SLATEBLUE4 = 'slateblue4'; - const GHOSTWHITE = 'ghostwhite'; - const LAVENDER = 'lavender'; - const BLUE = 'blue'; - const BLUE1 = 'blue1'; - const BLUE2 = 'blue2'; - const BLUE3 = 'blue3'; - const MEDIUMBLUE = 'mediumblue'; - const BLUE4 = 'blue4'; - const DARKBLUE = 'darkblue'; - const MIDNIGHTBLUE = 'midnightblue'; - const NAVY = 'navy'; - const NAVYBLUE = 'navyblue'; - const ROYALBLUE = 'royalblue'; - const ROYALBLUE1 = 'royalblue1'; - const ROYALBLUE2 = 'royalblue2'; - const ROYALBLUE3 = 'royalblue3'; - const ROYALBLUE4 = 'royalblue4'; - const CORNFLOWERBLUE = 'cornflowerblue'; - const LIGHTSTEELBLUE = 'lightsteelblue'; - const LIGHTSTEELBLUE1 = 'lightsteelblue1'; - const LIGHTSTEELBLUE2 = 'lightsteelblue2'; - const LIGHTSTEELBLUE3 = 'lightsteelblue3'; - const LIGHTSTEELBLUE4 = 'lightsteelblue4'; - const SLATEGRAY4 = 'slategray4'; - const SLATEGRAY1 = 'slategray1'; - const SLATEGRAY2 = 'slategray2'; - const SLATEGRAY3 = 'slategray3'; - const LIGHTSLATEGRAY = 'lightslategray'; - const LIGHTSLATEGREY = 'lightslategrey'; - const SLATEGRAY = 'slategray'; - const SLATEGREY = 'slategrey'; - const DODGERBLUE = 'dodgerblue'; - const DODGERBLUE1 = 'dodgerblue1'; - const DODGERBLUE2 = 'dodgerblue2'; - const DODGERBLUE4 = 'dodgerblue4'; - const DODGERBLUE3 = 'dodgerblue3'; - const ALICEBLUE = 'aliceblue'; - const STEELBLUE4 = 'steelblue4'; - const STEELBLUE = 'steelblue'; - const STEELBLUE1 = 'steelblue1'; - const STEELBLUE2 = 'steelblue2'; - const STEELBLUE3 = 'steelblue3'; - const SKYBLUE4 = 'skyblue4'; - const SKYBLUE1 = 'skyblue1'; - const SKYBLUE2 = 'skyblue2'; - const SKYBLUE3 = 'skyblue3'; - const LIGHTSKYBLUE = 'lightskyblue'; - const LIGHTSKYBLUE4 = 'lightskyblue4'; - const LIGHTSKYBLUE1 = 'lightskyblue1'; - const LIGHTSKYBLUE2 = 'lightskyblue2'; - const LIGHTSKYBLUE3 = 'lightskyblue3'; - const SKYBLUE = 'skyblue'; - const LIGHTBLUE3 = 'lightblue3'; - const DEEPSKYBLUE = 'deepskyblue'; - const DEEPSKYBLUE1 = 'deepskyblue1'; - const DEEPSKYBLUE2 = 'deepskyblue2'; - const DEEPSKYBLUE4 = 'deepskyblue4'; - const DEEPSKYBLUE3 = 'deepskyblue3'; - const LIGHTBLUE1 = 'lightblue1'; - const LIGHTBLUE2 = 'lightblue2'; - const LIGHTBLUE = 'lightblue'; - const LIGHTBLUE4 = 'lightblue4'; - const POWDERBLUE = 'powderblue'; - const CADETBLUE1 = 'cadetblue1'; - const CADETBLUE2 = 'cadetblue2'; - const CADETBLUE3 = 'cadetblue3'; - const CADETBLUE4 = 'cadetblue4'; - const TURQUOISE1 = 'turquoise1'; - const TURQUOISE2 = 'turquoise2'; - const TURQUOISE3 = 'turquoise3'; - const TURQUOISE4 = 'turquoise4'; - const CADETBLUE = 'cadetblue'; - const DARKTURQUOISE = 'darkturquoise'; - const AZURE = 'azure'; - const AZURE1 = 'azure1'; - const LIGHTCYAN1 = 'lightcyan1'; - const LIGHTCYAN = 'lightcyan'; - const AZURE2 = 'azure2'; - const LIGHTCYAN2 = 'lightcyan2'; - const PALETURQUOISE1 = 'paleturquoise1'; - const PALETURQUOISE = 'paleturquoise'; - const PALETURQUOISE2 = 'paleturquoise2'; - const DARKSLATEGRAY1 = 'darkslategray1'; - const AZURE3 = 'azure3'; - const LIGHTCYAN3 = 'lightcyan3'; - const DARKSLATEGRAY2 = 'darkslategray2'; - const PALETURQUOISE3 = 'paleturquoise3'; - const DARKSLATEGRAY3 = 'darkslategray3'; - const AZURE4 = 'azure4'; - const LIGHTCYAN4 = 'lightcyan4'; - const AQUA = 'aqua'; - const CYAN = 'cyan'; - const CYAN1 = 'cyan1'; - const PALETURQUOISE4 = 'paleturquoise4'; - const CYAN2 = 'cyan2'; - const DARKSLATEGRAY4 = 'darkslategray4'; - const CYAN3 = 'cyan3'; - const CYAN4 = 'cyan4'; - const DARKCYAN = 'darkcyan'; - const TEAL = 'teal'; - const DARKSLATEGRAY = 'darkslategray'; - const DARKSLATEGREY = 'darkslategrey'; - const MEDIUMTURQUOISE = 'mediumturquoise'; - const LIGHTSEAGREEN = 'lightseagreen'; - const TURQUOISE = 'turquoise'; - const AQUAMARINE4 = 'aquamarine4'; - const AQUAMARINE = 'aquamarine'; - const AQUAMARINE1 = 'aquamarine1'; - const AQUAMARINE2 = 'aquamarine2'; - const AQUAMARINE3 = 'aquamarine3'; - const MEDIUMAQUAMARINE = 'mediumaquamarine'; - const MEDIUMSPRINGGREEN = 'mediumspringgreen'; - const MINTCREAM = 'mintcream'; - const SPRINGGREEN = 'springgreen'; - const SPRINGGREEN1 = 'springgreen1'; - const SPRINGGREEN2 = 'springgreen2'; - const SPRINGGREEN3 = 'springgreen3'; - const SPRINGGREEN4 = 'springgreen4'; - const MEDIUMSEAGREEN = 'mediumseagreen'; - const SEAGREEN = 'seagreen'; - const SEAGREEN3 = 'seagreen3'; - const SEAGREEN1 = 'seagreen1'; - const SEAGREEN4 = 'seagreen4'; - const SEAGREEN2 = 'seagreen2'; - const MEDIUMFORESTGREEN = 'mediumforestgreen'; - const HONEYDEW = 'honeydew'; - const HONEYDEW1 = 'honeydew1'; - const HONEYDEW2 = 'honeydew2'; - const DARKSEAGREEN1 = 'darkseagreen1'; - const DARKSEAGREEN2 = 'darkseagreen2'; - const PALEGREEN1 = 'palegreen1'; - const PALEGREEN = 'palegreen'; - const HONEYDEW3 = 'honeydew3'; - const LIGHTGREEN = 'lightgreen'; - const PALEGREEN2 = 'palegreen2'; - const DARKSEAGREEN3 = 'darkseagreen3'; - const DARKSEAGREEN = 'darkseagreen'; - const PALEGREEN3 = 'palegreen3'; - const HONEYDEW4 = 'honeydew4'; - const GREEN1 = 'green1'; - const LIME = 'lime'; - const LIMEGREEN = 'limegreen'; - const DARKSEAGREEN4 = 'darkseagreen4'; - const GREEN2 = 'green2'; - const PALEGREEN4 = 'palegreen4'; - const GREEN3 = 'green3'; - const FORESTGREEN = 'forestgreen'; - const GREEN4 = 'green4'; - const GREEN = 'green'; - const DARKGREEN = 'darkgreen'; - const LAWNGREEN = 'lawngreen'; - const CHARTREUSE = 'chartreuse'; - const CHARTREUSE1 = 'chartreuse1'; - const CHARTREUSE2 = 'chartreuse2'; - const CHARTREUSE3 = 'chartreuse3'; - const CHARTREUSE4 = 'chartreuse4'; - const GREENYELLOW = 'greenyellow'; - const DARKOLIVEGREEN3 = 'darkolivegreen3'; - const DARKOLIVEGREEN1 = 'darkolivegreen1'; - const DARKOLIVEGREEN2 = 'darkolivegreen2'; - const DARKOLIVEGREEN4 = 'darkolivegreen4'; - const DARKOLIVEGREEN = 'darkolivegreen'; - const OLIVEDRAB = 'olivedrab'; - const OLIVEDRAB1 = 'olivedrab1'; - const OLIVEDRAB2 = 'olivedrab2'; - const OLIVEDRAB3 = 'olivedrab3'; - const YELLOWGREEN = 'yellowgreen'; - const OLIVEDRAB4 = 'olivedrab4'; - const IVORY = 'ivory'; - const IVORY1 = 'ivory1'; - const LIGHTYELLOW = 'lightyellow'; - const LIGHTYELLOW1 = 'lightyellow1'; - const BEIGE = 'beige'; - const IVORY2 = 'ivory2'; - const LIGHTGOLDENRODYELLOW = 'lightgoldenrodyellow'; - const LIGHTYELLOW2 = 'lightyellow2'; - const IVORY3 = 'ivory3'; - const LIGHTYELLOW3 = 'lightyellow3'; - const IVORY4 = 'ivory4'; - const LIGHTYELLOW4 = 'lightyellow4'; - const YELLOW = 'yellow'; - const YELLOW1 = 'yellow1'; - const YELLOW2 = 'yellow2'; - const YELLOW3 = 'yellow3'; - const YELLOW4 = 'yellow4'; - const OLIVE = 'olive'; - const DARKKHAKI = 'darkkhaki'; - const KHAKI2 = 'khaki2'; - const LEMONCHIFFON4 = 'lemonchiffon4'; - const KHAKI1 = 'khaki1'; - const KHAKI3 = 'khaki3'; - const KHAKI4 = 'khaki4'; - const PALEGOLDENROD = 'palegoldenrod'; - const LEMONCHIFFON = 'lemonchiffon'; - const LEMONCHIFFON1 = 'lemonchiffon1'; - const KHAKI = 'khaki'; - const LEMONCHIFFON3 = 'lemonchiffon3'; - const LEMONCHIFFON2 = 'lemonchiffon2'; - const MEDIUMGOLDENROD = 'mediumgoldenrod'; - const CORNSILK4 = 'cornsilk4'; - const GOLD = 'gold'; - const GOLD1 = 'gold1'; - const GOLD2 = 'gold2'; - const GOLD3 = 'gold3'; - const GOLD4 = 'gold4'; - const LIGHTGOLDENROD = 'lightgoldenrod'; - const LIGHTGOLDENROD4 = 'lightgoldenrod4'; - const LIGHTGOLDENROD1 = 'lightgoldenrod1'; - const LIGHTGOLDENROD3 = 'lightgoldenrod3'; - const LIGHTGOLDENROD2 = 'lightgoldenrod2'; - const CORNSILK3 = 'cornsilk3'; - const CORNSILK2 = 'cornsilk2'; - const CORNSILK = 'cornsilk'; - const CORNSILK1 = 'cornsilk1'; - const GOLDENROD = 'goldenrod'; - const GOLDENROD1 = 'goldenrod1'; - const GOLDENROD2 = 'goldenrod2'; - const GOLDENROD3 = 'goldenrod3'; - const GOLDENROD4 = 'goldenrod4'; - const DARKGOLDENROD = 'darkgoldenrod'; - const DARKGOLDENROD1 = 'darkgoldenrod1'; - const DARKGOLDENROD2 = 'darkgoldenrod2'; - const DARKGOLDENROD3 = 'darkgoldenrod3'; - const DARKGOLDENROD4 = 'darkgoldenrod4'; - const FLORALWHITE = 'floralwhite'; - const WHEAT2 = 'wheat2'; - const OLDLACE = 'oldlace'; - const WHEAT = 'wheat'; - const WHEAT1 = 'wheat1'; - const WHEAT3 = 'wheat3'; - const ORANGE = 'orange'; - const ORANGE1 = 'orange1'; - const ORANGE2 = 'orange2'; - const ORANGE3 = 'orange3'; - const ORANGE4 = 'orange4'; - const WHEAT4 = 'wheat4'; - const MOCCASIN = 'moccasin'; - const PAPAYAWHIP = 'papayawhip'; - const NAVAJOWHITE3 = 'navajowhite3'; - const BLANCHEDALMOND = 'blanchedalmond'; - const NAVAJOWHITE = 'navajowhite'; - const NAVAJOWHITE1 = 'navajowhite1'; - const NAVAJOWHITE2 = 'navajowhite2'; - const NAVAJOWHITE4 = 'navajowhite4'; - const ANTIQUEWHITE4 = 'antiquewhite4'; - const ANTIQUEWHITE = 'antiquewhite'; - const TAN = 'tan'; - const BISQUE4 = 'bisque4'; - const BURLYWOOD = 'burlywood'; - const ANTIQUEWHITE2 = 'antiquewhite2'; - const BURLYWOOD1 = 'burlywood1'; - const BURLYWOOD3 = 'burlywood3'; - const BURLYWOOD2 = 'burlywood2'; - const ANTIQUEWHITE1 = 'antiquewhite1'; - const BURLYWOOD4 = 'burlywood4'; - const ANTIQUEWHITE3 = 'antiquewhite3'; - const DARKORANGE = 'darkorange'; - const BISQUE2 = 'bisque2'; - const BISQUE = 'bisque'; - const BISQUE1 = 'bisque1'; - const BISQUE3 = 'bisque3'; - const DARKORANGE1 = 'darkorange1'; - const LINEN = 'linen'; - const DARKORANGE2 = 'darkorange2'; - const DARKORANGE3 = 'darkorange3'; - const DARKORANGE4 = 'darkorange4'; - const PERU = 'peru'; - const TAN1 = 'tan1'; - const TAN2 = 'tan2'; - const TAN3 = 'tan3'; - const TAN4 = 'tan4'; - const PEACHPUFF = 'peachpuff'; - const PEACHPUFF1 = 'peachpuff1'; - const PEACHPUFF4 = 'peachpuff4'; - const PEACHPUFF2 = 'peachpuff2'; - const PEACHPUFF3 = 'peachpuff3'; - const SANDYBROWN = 'sandybrown'; - const SEASHELL4 = 'seashell4'; - const SEASHELL2 = 'seashell2'; - const SEASHELL3 = 'seashell3'; - const CHOCOLATE = 'chocolate'; - const CHOCOLATE1 = 'chocolate1'; - const CHOCOLATE2 = 'chocolate2'; - const CHOCOLATE3 = 'chocolate3'; - const CHOCOLATE4 = 'chocolate4'; - const SADDLEBROWN = 'saddlebrown'; - const SEASHELL = 'seashell'; - const SEASHELL1 = 'seashell1'; - const SIENNA4 = 'sienna4'; - const SIENNA = 'sienna'; - const SIENNA1 = 'sienna1'; - const SIENNA2 = 'sienna2'; - const SIENNA3 = 'sienna3'; - const LIGHTSALMON3 = 'lightsalmon3'; - const LIGHTSALMON = 'lightsalmon'; - const LIGHTSALMON1 = 'lightsalmon1'; - const LIGHTSALMON4 = 'lightsalmon4'; - const LIGHTSALMON2 = 'lightsalmon2'; - const CORAL = 'coral'; - const ORANGERED = 'orangered'; - const ORANGERED1 = 'orangered1'; - const ORANGERED2 = 'orangered2'; - const ORANGERED3 = 'orangered3'; - const ORANGERED4 = 'orangered4'; - const DARKSALMON = 'darksalmon'; - const SALMON1 = 'salmon1'; - const SALMON2 = 'salmon2'; - const SALMON3 = 'salmon3'; - const SALMON4 = 'salmon4'; - const CORAL1 = 'coral1'; - const CORAL2 = 'coral2'; - const CORAL3 = 'coral3'; - const CORAL4 = 'coral4'; - const TOMATO4 = 'tomato4'; - const TOMATO = 'tomato'; - const TOMATO1 = 'tomato1'; - const TOMATO2 = 'tomato2'; - const TOMATO3 = 'tomato3'; - const MISTYROSE4 = 'mistyrose4'; - const MISTYROSE2 = 'mistyrose2'; - const MISTYROSE = 'mistyrose'; - const MISTYROSE1 = 'mistyrose1'; - const SALMON = 'salmon'; - const MISTYROSE3 = 'mistyrose3'; - const WHITE = 'white'; - const GRAY100 = 'gray100'; - const GREY100 = 'grey100'; - const GRAY99 = 'gray99'; - const GREY99 = 'grey99'; - const GRAY98 = 'gray98'; - const GREY98 = 'grey98'; - const GRAY97 = 'gray97'; - const GREY97 = 'grey97'; - const GRAY96 = 'gray96'; - const GREY96 = 'grey96'; - const WHITESMOKE = 'whitesmoke'; - const GRAY95 = 'gray95'; - const GREY95 = 'grey95'; - const GRAY94 = 'gray94'; - const GREY94 = 'grey94'; - const GRAY93 = 'gray93'; - const GREY93 = 'grey93'; - const GRAY92 = 'gray92'; - const GREY92 = 'grey92'; - const GRAY91 = 'gray91'; - const GREY91 = 'grey91'; - const GRAY90 = 'gray90'; - const GREY90 = 'grey90'; - const GRAY89 = 'gray89'; - const GREY89 = 'grey89'; - const GRAY88 = 'gray88'; - const GREY88 = 'grey88'; - const GRAY87 = 'gray87'; - const GREY87 = 'grey87'; - const GAINSBORO = 'gainsboro'; - const GRAY86 = 'gray86'; - const GREY86 = 'grey86'; - const GRAY85 = 'gray85'; - const GREY85 = 'grey85'; - const GRAY84 = 'gray84'; - const GREY84 = 'grey84'; - const GRAY83 = 'gray83'; - const GREY83 = 'grey83'; - const LIGHTGRAY = 'lightgray'; - const LIGHTGREY = 'lightgrey'; - const GRAY82 = 'gray82'; - const GREY82 = 'grey82'; - const GRAY81 = 'gray81'; - const GREY81 = 'grey81'; - const GRAY80 = 'gray80'; - const GREY80 = 'grey80'; - const GRAY79 = 'gray79'; - const GREY79 = 'grey79'; - const GRAY78 = 'gray78'; - const GREY78 = 'grey78'; - const GRAY77 = 'gray77'; - const GREY77 = 'grey77'; - const GRAY76 = 'gray76'; - const GREY76 = 'grey76'; - const SILVER = 'silver'; - const GRAY75 = 'gray75'; - const GREY75 = 'grey75'; - const GRAY74 = 'gray74'; - const GREY74 = 'grey74'; - const GRAY73 = 'gray73'; - const GREY73 = 'grey73'; - const GRAY72 = 'gray72'; - const GREY72 = 'grey72'; - const GRAY71 = 'gray71'; - const GREY71 = 'grey71'; - const GRAY70 = 'gray70'; - const GREY70 = 'grey70'; - const GRAY69 = 'gray69'; - const GREY69 = 'grey69'; - const GRAY68 = 'gray68'; - const GREY68 = 'grey68'; - const GRAY67 = 'gray67'; - const GREY67 = 'grey67'; - const DARKGRAY = 'darkgray'; - const DARKGREY = 'darkgrey'; - const GRAY66 = 'gray66'; - const GREY66 = 'grey66'; - const GRAY65 = 'gray65'; - const GREY65 = 'grey65'; - const GRAY64 = 'gray64'; - const GREY64 = 'grey64'; - const GRAY63 = 'gray63'; - const GREY63 = 'grey63'; - const GRAY62 = 'gray62'; - const GREY62 = 'grey62'; - const GRAY61 = 'gray61'; - const GREY61 = 'grey61'; - const GRAY60 = 'gray60'; - const GREY60 = 'grey60'; - const GRAY59 = 'gray59'; - const GREY59 = 'grey59'; - const GRAY58 = 'gray58'; - const GREY58 = 'grey58'; - const GRAY57 = 'gray57'; - const GREY57 = 'grey57'; - const GRAY56 = 'gray56'; - const GREY56 = 'grey56'; - const GRAY55 = 'gray55'; - const GREY55 = 'grey55'; - const GRAY54 = 'gray54'; - const GREY54 = 'grey54'; - const GRAY53 = 'gray53'; - const GREY53 = 'grey53'; - const GRAY52 = 'gray52'; - const GREY52 = 'grey52'; - const GRAY51 = 'gray51'; - const GREY51 = 'grey51'; - const FRACTAL = 'fractal'; - const GRAY50 = 'gray50'; - const GREY50 = 'grey50'; - const GRAY = 'gray'; - const GREY = 'grey'; - const GRAY49 = 'gray49'; - const GREY49 = 'grey49'; - const GRAY48 = 'gray48'; - const GREY48 = 'grey48'; - const GRAY47 = 'gray47'; - const GREY47 = 'grey47'; - const GRAY46 = 'gray46'; - const GREY46 = 'grey46'; - const GRAY45 = 'gray45'; - const GREY45 = 'grey45'; - const GRAY44 = 'gray44'; - const GREY44 = 'grey44'; - const GRAY43 = 'gray43'; - const GREY43 = 'grey43'; - const GRAY42 = 'gray42'; - const GREY42 = 'grey42'; - const DIMGRAY = 'dimgray'; - const DIMGREY = 'dimgrey'; - const GRAY41 = 'gray41'; - const GREY41 = 'grey41'; - const GRAY40 = 'gray40'; - const GREY40 = 'grey40'; - const GRAY39 = 'gray39'; - const GREY39 = 'grey39'; - const GRAY38 = 'gray38'; - const GREY38 = 'grey38'; - const GRAY37 = 'gray37'; - const GREY37 = 'grey37'; - const GRAY36 = 'gray36'; - const GREY36 = 'grey36'; - const GRAY35 = 'gray35'; - const GREY35 = 'grey35'; - const GRAY34 = 'gray34'; - const GREY34 = 'grey34'; - const GRAY33 = 'gray33'; - const GREY33 = 'grey33'; - const GRAY32 = 'gray32'; - const GREY32 = 'grey32'; - const GRAY31 = 'gray31'; - const GREY31 = 'grey31'; - const GRAY30 = 'gray30'; - const GREY30 = 'grey30'; - const GRAY29 = 'gray29'; - const GREY29 = 'grey29'; - const GRAY28 = 'gray28'; - const GREY28 = 'grey28'; - const GRAY27 = 'gray27'; - const GREY27 = 'grey27'; - const GRAY26 = 'gray26'; - const GREY26 = 'grey26'; - const GRAY25 = 'gray25'; - const GREY25 = 'grey25'; - const GRAY24 = 'gray24'; - const GREY24 = 'grey24'; - const GRAY23 = 'gray23'; - const GREY23 = 'grey23'; - const GRAY22 = 'gray22'; - const GREY22 = 'grey22'; - const GRAY21 = 'gray21'; - const GREY21 = 'grey21'; - const GRAY20 = 'gray20'; - const GREY20 = 'grey20'; - const GRAY19 = 'gray19'; - const GREY19 = 'grey19'; - const GRAY18 = 'gray18'; - const GREY18 = 'grey18'; - const GRAY17 = 'gray17'; - const GREY17 = 'grey17'; - const GRAY16 = 'gray16'; - const GREY16 = 'grey16'; - const GRAY15 = 'gray15'; - const GREY15 = 'grey15'; - const GRAY14 = 'gray14'; - const GREY14 = 'grey14'; - const GRAY13 = 'gray13'; - const GREY13 = 'grey13'; - const GRAY12 = 'gray12'; - const GREY12 = 'grey12'; - const GRAY11 = 'gray11'; - const GREY11 = 'grey11'; - const GRAY10 = 'gray10'; - const GREY10 = 'grey10'; - const GRAY9 = 'gray9'; - const GREY9 = 'grey9'; - const GRAY8 = 'gray8'; - const GREY8 = 'grey8'; - const GRAY7 = 'gray7'; - const GREY7 = 'grey7'; - const GRAY6 = 'gray6'; - const GREY6 = 'grey6'; - const GRAY5 = 'gray5'; - const GREY5 = 'grey5'; - const GRAY4 = 'gray4'; - const GREY4 = 'grey4'; - const GRAY3 = 'gray3'; - const GREY3 = 'grey3'; - const GRAY2 = 'gray2'; - const GREY2 = 'grey2'; - const GRAY1 = 'gray1'; - const GREY1 = 'grey1'; - const BLACK = 'black'; - const GRAY0 = 'gray0'; - const GREY0 = 'grey0'; - const OPAQUE = 'opaque'; - const NONE = 'none'; - const TRANSPARENT = 'transparent'; + public const SNOW = 'snow'; + public const SNOW1 = 'snow1'; + public const SNOW2 = 'snow2'; + public const ROSYBROWN1 = 'rosybrown1'; + public const ROSYBROWN2 = 'rosybrown2'; + public const SNOW3 = 'snow3'; + public const LIGHTCORAL = 'lightcoral'; + public const INDIANRED1 = 'indianred1'; + public const ROSYBROWN3 = 'rosybrown3'; + public const INDIANRED2 = 'indianred2'; + public const ROSYBROWN = 'rosybrown'; + public const BROWN1 = 'brown1'; + public const FIREBRICK1 = 'firebrick1'; + public const BROWN2 = 'brown2'; + public const INDIANRED = 'indianred'; + public const INDIANRED3 = 'indianred3'; + public const FIREBRICK2 = 'firebrick2'; + public const SNOW4 = 'snow4'; + public const BROWN3 = 'brown3'; + public const RED = 'red'; + public const RED1 = 'red1'; + public const ROSYBROWN4 = 'rosybrown4'; + public const FIREBRICK3 = 'firebrick3'; + public const RED2 = 'red2'; + public const FIREBRICK = 'firebrick'; + public const BROWN = 'brown'; + public const RED3 = 'red3'; + public const INDIANRED4 = 'indianred4'; + public const BROWN4 = 'brown4'; + public const FIREBRICK4 = 'firebrick4'; + public const DARKRED = 'darkred'; + public const RED4 = 'red4'; + public const LIGHTPINK1 = 'lightpink1'; + public const LIGHTPINK3 = 'lightpink3'; + public const LIGHTPINK4 = 'lightpink4'; + public const LIGHTPINK2 = 'lightpink2'; + public const LIGHTPINK = 'lightpink'; + public const PINK = 'pink'; + public const CRIMSON = 'crimson'; + public const PINK1 = 'pink1'; + public const PINK2 = 'pink2'; + public const PINK3 = 'pink3'; + public const PINK4 = 'pink4'; + public const PALEVIOLETRED4 = 'palevioletred4'; + public const PALEVIOLETRED = 'palevioletred'; + public const PALEVIOLETRED2 = 'palevioletred2'; + public const PALEVIOLETRED1 = 'palevioletred1'; + public const PALEVIOLETRED3 = 'palevioletred3'; + public const LAVENDERBLUSH = 'lavenderblush'; + public const LAVENDERBLUSH1 = 'lavenderblush1'; + public const LAVENDERBLUSH3 = 'lavenderblush3'; + public const LAVENDERBLUSH2 = 'lavenderblush2'; + public const LAVENDERBLUSH4 = 'lavenderblush4'; + public const MAROON = 'maroon'; + public const HOTPINK3 = 'hotpink3'; + public const VIOLETRED3 = 'violetred3'; + public const VIOLETRED1 = 'violetred1'; + public const VIOLETRED2 = 'violetred2'; + public const VIOLETRED4 = 'violetred4'; + public const HOTPINK2 = 'hotpink2'; + public const HOTPINK1 = 'hotpink1'; + public const HOTPINK4 = 'hotpink4'; + public const HOTPINK = 'hotpink'; + public const DEEPPINK = 'deeppink'; + public const DEEPPINK1 = 'deeppink1'; + public const DEEPPINK2 = 'deeppink2'; + public const DEEPPINK3 = 'deeppink3'; + public const DEEPPINK4 = 'deeppink4'; + public const MAROON1 = 'maroon1'; + public const MAROON2 = 'maroon2'; + public const MAROON3 = 'maroon3'; + public const MAROON4 = 'maroon4'; + public const MEDIUMVIOLETRED = 'mediumvioletred'; + public const VIOLETRED = 'violetred'; + public const ORCHID2 = 'orchid2'; + public const ORCHID = 'orchid'; + public const ORCHID1 = 'orchid1'; + public const ORCHID3 = 'orchid3'; + public const ORCHID4 = 'orchid4'; + public const THISTLE1 = 'thistle1'; + public const THISTLE2 = 'thistle2'; + public const PLUM1 = 'plum1'; + public const PLUM2 = 'plum2'; + public const THISTLE = 'thistle'; + public const THISTLE3 = 'thistle3'; + public const PLUM = 'plum'; + public const VIOLET = 'violet'; + public const PLUM3 = 'plum3'; + public const THISTLE4 = 'thistle4'; + public const FUCHSIA = 'fuchsia'; + public const MAGENTA = 'magenta'; + public const MAGENTA1 = 'magenta1'; + public const PLUM4 = 'plum4'; + public const MAGENTA2 = 'magenta2'; + public const MAGENTA3 = 'magenta3'; + public const DARKMAGENTA = 'darkmagenta'; + public const MAGENTA4 = 'magenta4'; + public const PURPLE = 'purple'; + public const MEDIUMORCHID = 'mediumorchid'; + public const MEDIUMORCHID1 = 'mediumorchid1'; + public const MEDIUMORCHID2 = 'mediumorchid2'; + public const MEDIUMORCHID3 = 'mediumorchid3'; + public const MEDIUMORCHID4 = 'mediumorchid4'; + public const DARKVIOLET = 'darkviolet'; + public const DARKORCHID = 'darkorchid'; + public const DARKORCHID1 = 'darkorchid1'; + public const DARKORCHID3 = 'darkorchid3'; + public const DARKORCHID2 = 'darkorchid2'; + public const DARKORCHID4 = 'darkorchid4'; + public const INDIGO = 'indigo'; + public const BLUEVIOLET = 'blueviolet'; + public const PURPLE2 = 'purple2'; + public const PURPLE3 = 'purple3'; + public const PURPLE4 = 'purple4'; + public const PURPLE1 = 'purple1'; + public const MEDIUMPURPLE = 'mediumpurple'; + public const MEDIUMPURPLE1 = 'mediumpurple1'; + public const MEDIUMPURPLE2 = 'mediumpurple2'; + public const MEDIUMPURPLE3 = 'mediumpurple3'; + public const MEDIUMPURPLE4 = 'mediumpurple4'; + public const DARKSLATEBLUE = 'darkslateblue'; + public const LIGHTSLATEBLUE = 'lightslateblue'; + public const MEDIUMSLATEBLUE = 'mediumslateblue'; + public const SLATEBLUE = 'slateblue'; + public const SLATEBLUE1 = 'slateblue1'; + public const SLATEBLUE2 = 'slateblue2'; + public const SLATEBLUE3 = 'slateblue3'; + public const SLATEBLUE4 = 'slateblue4'; + public const GHOSTWHITE = 'ghostwhite'; + public const LAVENDER = 'lavender'; + public const BLUE = 'blue'; + public const BLUE1 = 'blue1'; + public const BLUE2 = 'blue2'; + public const BLUE3 = 'blue3'; + public const MEDIUMBLUE = 'mediumblue'; + public const BLUE4 = 'blue4'; + public const DARKBLUE = 'darkblue'; + public const MIDNIGHTBLUE = 'midnightblue'; + public const NAVY = 'navy'; + public const NAVYBLUE = 'navyblue'; + public const ROYALBLUE = 'royalblue'; + public const ROYALBLUE1 = 'royalblue1'; + public const ROYALBLUE2 = 'royalblue2'; + public const ROYALBLUE3 = 'royalblue3'; + public const ROYALBLUE4 = 'royalblue4'; + public const CORNFLOWERBLUE = 'cornflowerblue'; + public const LIGHTSTEELBLUE = 'lightsteelblue'; + public const LIGHTSTEELBLUE1 = 'lightsteelblue1'; + public const LIGHTSTEELBLUE2 = 'lightsteelblue2'; + public const LIGHTSTEELBLUE3 = 'lightsteelblue3'; + public const LIGHTSTEELBLUE4 = 'lightsteelblue4'; + public const SLATEGRAY4 = 'slategray4'; + public const SLATEGRAY1 = 'slategray1'; + public const SLATEGRAY2 = 'slategray2'; + public const SLATEGRAY3 = 'slategray3'; + public const LIGHTSLATEGRAY = 'lightslategray'; + public const LIGHTSLATEGREY = 'lightslategrey'; + public const SLATEGRAY = 'slategray'; + public const SLATEGREY = 'slategrey'; + public const DODGERBLUE = 'dodgerblue'; + public const DODGERBLUE1 = 'dodgerblue1'; + public const DODGERBLUE2 = 'dodgerblue2'; + public const DODGERBLUE4 = 'dodgerblue4'; + public const DODGERBLUE3 = 'dodgerblue3'; + public const ALICEBLUE = 'aliceblue'; + public const STEELBLUE4 = 'steelblue4'; + public const STEELBLUE = 'steelblue'; + public const STEELBLUE1 = 'steelblue1'; + public const STEELBLUE2 = 'steelblue2'; + public const STEELBLUE3 = 'steelblue3'; + public const SKYBLUE4 = 'skyblue4'; + public const SKYBLUE1 = 'skyblue1'; + public const SKYBLUE2 = 'skyblue2'; + public const SKYBLUE3 = 'skyblue3'; + public const LIGHTSKYBLUE = 'lightskyblue'; + public const LIGHTSKYBLUE4 = 'lightskyblue4'; + public const LIGHTSKYBLUE1 = 'lightskyblue1'; + public const LIGHTSKYBLUE2 = 'lightskyblue2'; + public const LIGHTSKYBLUE3 = 'lightskyblue3'; + public const SKYBLUE = 'skyblue'; + public const LIGHTBLUE3 = 'lightblue3'; + public const DEEPSKYBLUE = 'deepskyblue'; + public const DEEPSKYBLUE1 = 'deepskyblue1'; + public const DEEPSKYBLUE2 = 'deepskyblue2'; + public const DEEPSKYBLUE4 = 'deepskyblue4'; + public const DEEPSKYBLUE3 = 'deepskyblue3'; + public const LIGHTBLUE1 = 'lightblue1'; + public const LIGHTBLUE2 = 'lightblue2'; + public const LIGHTBLUE = 'lightblue'; + public const LIGHTBLUE4 = 'lightblue4'; + public const POWDERBLUE = 'powderblue'; + public const CADETBLUE1 = 'cadetblue1'; + public const CADETBLUE2 = 'cadetblue2'; + public const CADETBLUE3 = 'cadetblue3'; + public const CADETBLUE4 = 'cadetblue4'; + public const TURQUOISE1 = 'turquoise1'; + public const TURQUOISE2 = 'turquoise2'; + public const TURQUOISE3 = 'turquoise3'; + public const TURQUOISE4 = 'turquoise4'; + public const CADETBLUE = 'cadetblue'; + public const DARKTURQUOISE = 'darkturquoise'; + public const AZURE = 'azure'; + public const AZURE1 = 'azure1'; + public const LIGHTCYAN1 = 'lightcyan1'; + public const LIGHTCYAN = 'lightcyan'; + public const AZURE2 = 'azure2'; + public const LIGHTCYAN2 = 'lightcyan2'; + public const PALETURQUOISE1 = 'paleturquoise1'; + public const PALETURQUOISE = 'paleturquoise'; + public const PALETURQUOISE2 = 'paleturquoise2'; + public const DARKSLATEGRAY1 = 'darkslategray1'; + public const AZURE3 = 'azure3'; + public const LIGHTCYAN3 = 'lightcyan3'; + public const DARKSLATEGRAY2 = 'darkslategray2'; + public const PALETURQUOISE3 = 'paleturquoise3'; + public const DARKSLATEGRAY3 = 'darkslategray3'; + public const AZURE4 = 'azure4'; + public const LIGHTCYAN4 = 'lightcyan4'; + public const AQUA = 'aqua'; + public const CYAN = 'cyan'; + public const CYAN1 = 'cyan1'; + public const PALETURQUOISE4 = 'paleturquoise4'; + public const CYAN2 = 'cyan2'; + public const DARKSLATEGRAY4 = 'darkslategray4'; + public const CYAN3 = 'cyan3'; + public const CYAN4 = 'cyan4'; + public const DARKCYAN = 'darkcyan'; + public const TEAL = 'teal'; + public const DARKSLATEGRAY = 'darkslategray'; + public const DARKSLATEGREY = 'darkslategrey'; + public const MEDIUMTURQUOISE = 'mediumturquoise'; + public const LIGHTSEAGREEN = 'lightseagreen'; + public const TURQUOISE = 'turquoise'; + public const AQUAMARINE4 = 'aquamarine4'; + public const AQUAMARINE = 'aquamarine'; + public const AQUAMARINE1 = 'aquamarine1'; + public const AQUAMARINE2 = 'aquamarine2'; + public const AQUAMARINE3 = 'aquamarine3'; + public const MEDIUMAQUAMARINE = 'mediumaquamarine'; + public const MEDIUMSPRINGGREEN = 'mediumspringgreen'; + public const MINTCREAM = 'mintcream'; + public const SPRINGGREEN = 'springgreen'; + public const SPRINGGREEN1 = 'springgreen1'; + public const SPRINGGREEN2 = 'springgreen2'; + public const SPRINGGREEN3 = 'springgreen3'; + public const SPRINGGREEN4 = 'springgreen4'; + public const MEDIUMSEAGREEN = 'mediumseagreen'; + public const SEAGREEN = 'seagreen'; + public const SEAGREEN3 = 'seagreen3'; + public const SEAGREEN1 = 'seagreen1'; + public const SEAGREEN4 = 'seagreen4'; + public const SEAGREEN2 = 'seagreen2'; + public const MEDIUMFORESTGREEN = 'mediumforestgreen'; + public const HONEYDEW = 'honeydew'; + public const HONEYDEW1 = 'honeydew1'; + public const HONEYDEW2 = 'honeydew2'; + public const DARKSEAGREEN1 = 'darkseagreen1'; + public const DARKSEAGREEN2 = 'darkseagreen2'; + public const PALEGREEN1 = 'palegreen1'; + public const PALEGREEN = 'palegreen'; + public const HONEYDEW3 = 'honeydew3'; + public const LIGHTGREEN = 'lightgreen'; + public const PALEGREEN2 = 'palegreen2'; + public const DARKSEAGREEN3 = 'darkseagreen3'; + public const DARKSEAGREEN = 'darkseagreen'; + public const PALEGREEN3 = 'palegreen3'; + public const HONEYDEW4 = 'honeydew4'; + public const GREEN1 = 'green1'; + public const LIME = 'lime'; + public const LIMEGREEN = 'limegreen'; + public const DARKSEAGREEN4 = 'darkseagreen4'; + public const GREEN2 = 'green2'; + public const PALEGREEN4 = 'palegreen4'; + public const GREEN3 = 'green3'; + public const FORESTGREEN = 'forestgreen'; + public const GREEN4 = 'green4'; + public const GREEN = 'green'; + public const DARKGREEN = 'darkgreen'; + public const LAWNGREEN = 'lawngreen'; + public const CHARTREUSE = 'chartreuse'; + public const CHARTREUSE1 = 'chartreuse1'; + public const CHARTREUSE2 = 'chartreuse2'; + public const CHARTREUSE3 = 'chartreuse3'; + public const CHARTREUSE4 = 'chartreuse4'; + public const GREENYELLOW = 'greenyellow'; + public const DARKOLIVEGREEN3 = 'darkolivegreen3'; + public const DARKOLIVEGREEN1 = 'darkolivegreen1'; + public const DARKOLIVEGREEN2 = 'darkolivegreen2'; + public const DARKOLIVEGREEN4 = 'darkolivegreen4'; + public const DARKOLIVEGREEN = 'darkolivegreen'; + public const OLIVEDRAB = 'olivedrab'; + public const OLIVEDRAB1 = 'olivedrab1'; + public const OLIVEDRAB2 = 'olivedrab2'; + public const OLIVEDRAB3 = 'olivedrab3'; + public const YELLOWGREEN = 'yellowgreen'; + public const OLIVEDRAB4 = 'olivedrab4'; + public const IVORY = 'ivory'; + public const IVORY1 = 'ivory1'; + public const LIGHTYELLOW = 'lightyellow'; + public const LIGHTYELLOW1 = 'lightyellow1'; + public const BEIGE = 'beige'; + public const IVORY2 = 'ivory2'; + public const LIGHTGOLDENRODYELLOW = 'lightgoldenrodyellow'; + public const LIGHTYELLOW2 = 'lightyellow2'; + public const IVORY3 = 'ivory3'; + public const LIGHTYELLOW3 = 'lightyellow3'; + public const IVORY4 = 'ivory4'; + public const LIGHTYELLOW4 = 'lightyellow4'; + public const YELLOW = 'yellow'; + public const YELLOW1 = 'yellow1'; + public const YELLOW2 = 'yellow2'; + public const YELLOW3 = 'yellow3'; + public const YELLOW4 = 'yellow4'; + public const OLIVE = 'olive'; + public const DARKKHAKI = 'darkkhaki'; + public const KHAKI2 = 'khaki2'; + public const LEMONCHIFFON4 = 'lemonchiffon4'; + public const KHAKI1 = 'khaki1'; + public const KHAKI3 = 'khaki3'; + public const KHAKI4 = 'khaki4'; + public const PALEGOLDENROD = 'palegoldenrod'; + public const LEMONCHIFFON = 'lemonchiffon'; + public const LEMONCHIFFON1 = 'lemonchiffon1'; + public const KHAKI = 'khaki'; + public const LEMONCHIFFON3 = 'lemonchiffon3'; + public const LEMONCHIFFON2 = 'lemonchiffon2'; + public const MEDIUMGOLDENROD = 'mediumgoldenrod'; + public const CORNSILK4 = 'cornsilk4'; + public const GOLD = 'gold'; + public const GOLD1 = 'gold1'; + public const GOLD2 = 'gold2'; + public const GOLD3 = 'gold3'; + public const GOLD4 = 'gold4'; + public const LIGHTGOLDENROD = 'lightgoldenrod'; + public const LIGHTGOLDENROD4 = 'lightgoldenrod4'; + public const LIGHTGOLDENROD1 = 'lightgoldenrod1'; + public const LIGHTGOLDENROD3 = 'lightgoldenrod3'; + public const LIGHTGOLDENROD2 = 'lightgoldenrod2'; + public const CORNSILK3 = 'cornsilk3'; + public const CORNSILK2 = 'cornsilk2'; + public const CORNSILK = 'cornsilk'; + public const CORNSILK1 = 'cornsilk1'; + public const GOLDENROD = 'goldenrod'; + public const GOLDENROD1 = 'goldenrod1'; + public const GOLDENROD2 = 'goldenrod2'; + public const GOLDENROD3 = 'goldenrod3'; + public const GOLDENROD4 = 'goldenrod4'; + public const DARKGOLDENROD = 'darkgoldenrod'; + public const DARKGOLDENROD1 = 'darkgoldenrod1'; + public const DARKGOLDENROD2 = 'darkgoldenrod2'; + public const DARKGOLDENROD3 = 'darkgoldenrod3'; + public const DARKGOLDENROD4 = 'darkgoldenrod4'; + public const FLORALWHITE = 'floralwhite'; + public const WHEAT2 = 'wheat2'; + public const OLDLACE = 'oldlace'; + public const WHEAT = 'wheat'; + public const WHEAT1 = 'wheat1'; + public const WHEAT3 = 'wheat3'; + public const ORANGE = 'orange'; + public const ORANGE1 = 'orange1'; + public const ORANGE2 = 'orange2'; + public const ORANGE3 = 'orange3'; + public const ORANGE4 = 'orange4'; + public const WHEAT4 = 'wheat4'; + public const MOCCASIN = 'moccasin'; + public const PAPAYAWHIP = 'papayawhip'; + public const NAVAJOWHITE3 = 'navajowhite3'; + public const BLANCHEDALMOND = 'blanchedalmond'; + public const NAVAJOWHITE = 'navajowhite'; + public const NAVAJOWHITE1 = 'navajowhite1'; + public const NAVAJOWHITE2 = 'navajowhite2'; + public const NAVAJOWHITE4 = 'navajowhite4'; + public const ANTIQUEWHITE4 = 'antiquewhite4'; + public const ANTIQUEWHITE = 'antiquewhite'; + public const TAN = 'tan'; + public const BISQUE4 = 'bisque4'; + public const BURLYWOOD = 'burlywood'; + public const ANTIQUEWHITE2 = 'antiquewhite2'; + public const BURLYWOOD1 = 'burlywood1'; + public const BURLYWOOD3 = 'burlywood3'; + public const BURLYWOOD2 = 'burlywood2'; + public const ANTIQUEWHITE1 = 'antiquewhite1'; + public const BURLYWOOD4 = 'burlywood4'; + public const ANTIQUEWHITE3 = 'antiquewhite3'; + public const DARKORANGE = 'darkorange'; + public const BISQUE2 = 'bisque2'; + public const BISQUE = 'bisque'; + public const BISQUE1 = 'bisque1'; + public const BISQUE3 = 'bisque3'; + public const DARKORANGE1 = 'darkorange1'; + public const LINEN = 'linen'; + public const DARKORANGE2 = 'darkorange2'; + public const DARKORANGE3 = 'darkorange3'; + public const DARKORANGE4 = 'darkorange4'; + public const PERU = 'peru'; + public const TAN1 = 'tan1'; + public const TAN2 = 'tan2'; + public const TAN3 = 'tan3'; + public const TAN4 = 'tan4'; + public const PEACHPUFF = 'peachpuff'; + public const PEACHPUFF1 = 'peachpuff1'; + public const PEACHPUFF4 = 'peachpuff4'; + public const PEACHPUFF2 = 'peachpuff2'; + public const PEACHPUFF3 = 'peachpuff3'; + public const SANDYBROWN = 'sandybrown'; + public const SEASHELL4 = 'seashell4'; + public const SEASHELL2 = 'seashell2'; + public const SEASHELL3 = 'seashell3'; + public const CHOCOLATE = 'chocolate'; + public const CHOCOLATE1 = 'chocolate1'; + public const CHOCOLATE2 = 'chocolate2'; + public const CHOCOLATE3 = 'chocolate3'; + public const CHOCOLATE4 = 'chocolate4'; + public const SADDLEBROWN = 'saddlebrown'; + public const SEASHELL = 'seashell'; + public const SEASHELL1 = 'seashell1'; + public const SIENNA4 = 'sienna4'; + public const SIENNA = 'sienna'; + public const SIENNA1 = 'sienna1'; + public const SIENNA2 = 'sienna2'; + public const SIENNA3 = 'sienna3'; + public const LIGHTSALMON3 = 'lightsalmon3'; + public const LIGHTSALMON = 'lightsalmon'; + public const LIGHTSALMON1 = 'lightsalmon1'; + public const LIGHTSALMON4 = 'lightsalmon4'; + public const LIGHTSALMON2 = 'lightsalmon2'; + public const CORAL = 'coral'; + public const ORANGERED = 'orangered'; + public const ORANGERED1 = 'orangered1'; + public const ORANGERED2 = 'orangered2'; + public const ORANGERED3 = 'orangered3'; + public const ORANGERED4 = 'orangered4'; + public const DARKSALMON = 'darksalmon'; + public const SALMON1 = 'salmon1'; + public const SALMON2 = 'salmon2'; + public const SALMON3 = 'salmon3'; + public const SALMON4 = 'salmon4'; + public const CORAL1 = 'coral1'; + public const CORAL2 = 'coral2'; + public const CORAL3 = 'coral3'; + public const CORAL4 = 'coral4'; + public const TOMATO4 = 'tomato4'; + public const TOMATO = 'tomato'; + public const TOMATO1 = 'tomato1'; + public const TOMATO2 = 'tomato2'; + public const TOMATO3 = 'tomato3'; + public const MISTYROSE4 = 'mistyrose4'; + public const MISTYROSE2 = 'mistyrose2'; + public const MISTYROSE = 'mistyrose'; + public const MISTYROSE1 = 'mistyrose1'; + public const SALMON = 'salmon'; + public const MISTYROSE3 = 'mistyrose3'; + public const WHITE = 'white'; + public const GRAY100 = 'gray100'; + public const GREY100 = 'grey100'; + public const GRAY99 = 'gray99'; + public const GREY99 = 'grey99'; + public const GRAY98 = 'gray98'; + public const GREY98 = 'grey98'; + public const GRAY97 = 'gray97'; + public const GREY97 = 'grey97'; + public const GRAY96 = 'gray96'; + public const GREY96 = 'grey96'; + public const WHITESMOKE = 'whitesmoke'; + public const GRAY95 = 'gray95'; + public const GREY95 = 'grey95'; + public const GRAY94 = 'gray94'; + public const GREY94 = 'grey94'; + public const GRAY93 = 'gray93'; + public const GREY93 = 'grey93'; + public const GRAY92 = 'gray92'; + public const GREY92 = 'grey92'; + public const GRAY91 = 'gray91'; + public const GREY91 = 'grey91'; + public const GRAY90 = 'gray90'; + public const GREY90 = 'grey90'; + public const GRAY89 = 'gray89'; + public const GREY89 = 'grey89'; + public const GRAY88 = 'gray88'; + public const GREY88 = 'grey88'; + public const GRAY87 = 'gray87'; + public const GREY87 = 'grey87'; + public const GAINSBORO = 'gainsboro'; + public const GRAY86 = 'gray86'; + public const GREY86 = 'grey86'; + public const GRAY85 = 'gray85'; + public const GREY85 = 'grey85'; + public const GRAY84 = 'gray84'; + public const GREY84 = 'grey84'; + public const GRAY83 = 'gray83'; + public const GREY83 = 'grey83'; + public const LIGHTGRAY = 'lightgray'; + public const LIGHTGREY = 'lightgrey'; + public const GRAY82 = 'gray82'; + public const GREY82 = 'grey82'; + public const GRAY81 = 'gray81'; + public const GREY81 = 'grey81'; + public const GRAY80 = 'gray80'; + public const GREY80 = 'grey80'; + public const GRAY79 = 'gray79'; + public const GREY79 = 'grey79'; + public const GRAY78 = 'gray78'; + public const GREY78 = 'grey78'; + public const GRAY77 = 'gray77'; + public const GREY77 = 'grey77'; + public const GRAY76 = 'gray76'; + public const GREY76 = 'grey76'; + public const SILVER = 'silver'; + public const GRAY75 = 'gray75'; + public const GREY75 = 'grey75'; + public const GRAY74 = 'gray74'; + public const GREY74 = 'grey74'; + public const GRAY73 = 'gray73'; + public const GREY73 = 'grey73'; + public const GRAY72 = 'gray72'; + public const GREY72 = 'grey72'; + public const GRAY71 = 'gray71'; + public const GREY71 = 'grey71'; + public const GRAY70 = 'gray70'; + public const GREY70 = 'grey70'; + public const GRAY69 = 'gray69'; + public const GREY69 = 'grey69'; + public const GRAY68 = 'gray68'; + public const GREY68 = 'grey68'; + public const GRAY67 = 'gray67'; + public const GREY67 = 'grey67'; + public const DARKGRAY = 'darkgray'; + public const DARKGREY = 'darkgrey'; + public const GRAY66 = 'gray66'; + public const GREY66 = 'grey66'; + public const GRAY65 = 'gray65'; + public const GREY65 = 'grey65'; + public const GRAY64 = 'gray64'; + public const GREY64 = 'grey64'; + public const GRAY63 = 'gray63'; + public const GREY63 = 'grey63'; + public const GRAY62 = 'gray62'; + public const GREY62 = 'grey62'; + public const GRAY61 = 'gray61'; + public const GREY61 = 'grey61'; + public const GRAY60 = 'gray60'; + public const GREY60 = 'grey60'; + public const GRAY59 = 'gray59'; + public const GREY59 = 'grey59'; + public const GRAY58 = 'gray58'; + public const GREY58 = 'grey58'; + public const GRAY57 = 'gray57'; + public const GREY57 = 'grey57'; + public const GRAY56 = 'gray56'; + public const GREY56 = 'grey56'; + public const GRAY55 = 'gray55'; + public const GREY55 = 'grey55'; + public const GRAY54 = 'gray54'; + public const GREY54 = 'grey54'; + public const GRAY53 = 'gray53'; + public const GREY53 = 'grey53'; + public const GRAY52 = 'gray52'; + public const GREY52 = 'grey52'; + public const GRAY51 = 'gray51'; + public const GREY51 = 'grey51'; + public const FRACTAL = 'fractal'; + public const GRAY50 = 'gray50'; + public const GREY50 = 'grey50'; + public const GRAY = 'gray'; + public const GREY = 'grey'; + public const GRAY49 = 'gray49'; + public const GREY49 = 'grey49'; + public const GRAY48 = 'gray48'; + public const GREY48 = 'grey48'; + public const GRAY47 = 'gray47'; + public const GREY47 = 'grey47'; + public const GRAY46 = 'gray46'; + public const GREY46 = 'grey46'; + public const GRAY45 = 'gray45'; + public const GREY45 = 'grey45'; + public const GRAY44 = 'gray44'; + public const GREY44 = 'grey44'; + public const GRAY43 = 'gray43'; + public const GREY43 = 'grey43'; + public const GRAY42 = 'gray42'; + public const GREY42 = 'grey42'; + public const DIMGRAY = 'dimgray'; + public const DIMGREY = 'dimgrey'; + public const GRAY41 = 'gray41'; + public const GREY41 = 'grey41'; + public const GRAY40 = 'gray40'; + public const GREY40 = 'grey40'; + public const GRAY39 = 'gray39'; + public const GREY39 = 'grey39'; + public const GRAY38 = 'gray38'; + public const GREY38 = 'grey38'; + public const GRAY37 = 'gray37'; + public const GREY37 = 'grey37'; + public const GRAY36 = 'gray36'; + public const GREY36 = 'grey36'; + public const GRAY35 = 'gray35'; + public const GREY35 = 'grey35'; + public const GRAY34 = 'gray34'; + public const GREY34 = 'grey34'; + public const GRAY33 = 'gray33'; + public const GREY33 = 'grey33'; + public const GRAY32 = 'gray32'; + public const GREY32 = 'grey32'; + public const GRAY31 = 'gray31'; + public const GREY31 = 'grey31'; + public const GRAY30 = 'gray30'; + public const GREY30 = 'grey30'; + public const GRAY29 = 'gray29'; + public const GREY29 = 'grey29'; + public const GRAY28 = 'gray28'; + public const GREY28 = 'grey28'; + public const GRAY27 = 'gray27'; + public const GREY27 = 'grey27'; + public const GRAY26 = 'gray26'; + public const GREY26 = 'grey26'; + public const GRAY25 = 'gray25'; + public const GREY25 = 'grey25'; + public const GRAY24 = 'gray24'; + public const GREY24 = 'grey24'; + public const GRAY23 = 'gray23'; + public const GREY23 = 'grey23'; + public const GRAY22 = 'gray22'; + public const GREY22 = 'grey22'; + public const GRAY21 = 'gray21'; + public const GREY21 = 'grey21'; + public const GRAY20 = 'gray20'; + public const GREY20 = 'grey20'; + public const GRAY19 = 'gray19'; + public const GREY19 = 'grey19'; + public const GRAY18 = 'gray18'; + public const GREY18 = 'grey18'; + public const GRAY17 = 'gray17'; + public const GREY17 = 'grey17'; + public const GRAY16 = 'gray16'; + public const GREY16 = 'grey16'; + public const GRAY15 = 'gray15'; + public const GREY15 = 'grey15'; + public const GRAY14 = 'gray14'; + public const GREY14 = 'grey14'; + public const GRAY13 = 'gray13'; + public const GREY13 = 'grey13'; + public const GRAY12 = 'gray12'; + public const GREY12 = 'grey12'; + public const GRAY11 = 'gray11'; + public const GREY11 = 'grey11'; + public const GRAY10 = 'gray10'; + public const GREY10 = 'grey10'; + public const GRAY9 = 'gray9'; + public const GREY9 = 'grey9'; + public const GRAY8 = 'gray8'; + public const GREY8 = 'grey8'; + public const GRAY7 = 'gray7'; + public const GREY7 = 'grey7'; + public const GRAY6 = 'gray6'; + public const GREY6 = 'grey6'; + public const GRAY5 = 'gray5'; + public const GREY5 = 'grey5'; + public const GRAY4 = 'gray4'; + public const GREY4 = 'grey4'; + public const GRAY3 = 'gray3'; + public const GREY3 = 'grey3'; + public const GRAY2 = 'gray2'; + public const GREY2 = 'grey2'; + public const GRAY1 = 'gray1'; + public const GREY1 = 'grey1'; + public const BLACK = 'black'; + public const GRAY0 = 'gray0'; + public const GREY0 = 'grey0'; + public const OPAQUE = 'opaque'; + public const NONE = 'none'; + public const TRANSPARENT = 'transparent'; use ColorTrait; } diff --git a/src/Transformation/Qualifier/QualifierValue/Color/ColorTrait.php b/src/Transformation/Qualifier/QualifierValue/Color/ColorTrait.php index 9ca5534..521fea7 100644 --- a/src/Transformation/Qualifier/QualifierValue/Color/ColorTrait.php +++ b/src/Transformation/Qualifier/QualifierValue/Color/ColorTrait.php @@ -22,9 +22,8 @@ trait ColorTrait /** * Color snow. * - * @return static */ - public static function snow() + public static function snow(): static { return new static(Color::SNOW); } @@ -32,9 +31,8 @@ public static function snow() /** * Color snow1. * - * @return static */ - public static function snow1() + public static function snow1(): static { return new static(Color::SNOW1); } @@ -42,9 +40,8 @@ public static function snow1() /** * Color snow2. * - * @return static */ - public static function snow2() + public static function snow2(): static { return new static(Color::SNOW2); } @@ -52,9 +49,8 @@ public static function snow2() /** * Color rosybrown1. * - * @return static */ - public static function rosybrown1() + public static function rosybrown1(): static { return new static(Color::ROSYBROWN1); } @@ -62,9 +58,8 @@ public static function rosybrown1() /** * Color rosybrown2. * - * @return static */ - public static function rosybrown2() + public static function rosybrown2(): static { return new static(Color::ROSYBROWN2); } @@ -72,9 +67,8 @@ public static function rosybrown2() /** * Color snow3. * - * @return static */ - public static function snow3() + public static function snow3(): static { return new static(Color::SNOW3); } @@ -82,9 +76,8 @@ public static function snow3() /** * Color lightcoral. * - * @return static */ - public static function lightcoral() + public static function lightcoral(): static { return new static(Color::LIGHTCORAL); } @@ -92,9 +85,8 @@ public static function lightcoral() /** * Color indianred1. * - * @return static */ - public static function indianred1() + public static function indianred1(): static { return new static(Color::INDIANRED1); } @@ -102,9 +94,8 @@ public static function indianred1() /** * Color rosybrown3. * - * @return static */ - public static function rosybrown3() + public static function rosybrown3(): static { return new static(Color::ROSYBROWN3); } @@ -112,9 +103,8 @@ public static function rosybrown3() /** * Color indianred2. * - * @return static */ - public static function indianred2() + public static function indianred2(): static { return new static(Color::INDIANRED2); } @@ -122,9 +112,8 @@ public static function indianred2() /** * Color rosybrown. * - * @return static */ - public static function rosybrown() + public static function rosybrown(): static { return new static(Color::ROSYBROWN); } @@ -132,9 +121,8 @@ public static function rosybrown() /** * Color brown1. * - * @return static */ - public static function brown1() + public static function brown1(): static { return new static(Color::BROWN1); } @@ -142,9 +130,8 @@ public static function brown1() /** * Color firebrick1. * - * @return static */ - public static function firebrick1() + public static function firebrick1(): static { return new static(Color::FIREBRICK1); } @@ -152,9 +139,8 @@ public static function firebrick1() /** * Color brown2. * - * @return static */ - public static function brown2() + public static function brown2(): static { return new static(Color::BROWN2); } @@ -162,9 +148,8 @@ public static function brown2() /** * Color indianred. * - * @return static */ - public static function indianred() + public static function indianred(): static { return new static(Color::INDIANRED); } @@ -172,9 +157,8 @@ public static function indianred() /** * Color indianred3. * - * @return static */ - public static function indianred3() + public static function indianred3(): static { return new static(Color::INDIANRED3); } @@ -182,9 +166,8 @@ public static function indianred3() /** * Color firebrick2. * - * @return static */ - public static function firebrick2() + public static function firebrick2(): static { return new static(Color::FIREBRICK2); } @@ -192,9 +175,8 @@ public static function firebrick2() /** * Color snow4. * - * @return static */ - public static function snow4() + public static function snow4(): static { return new static(Color::SNOW4); } @@ -202,9 +184,8 @@ public static function snow4() /** * Color brown3. * - * @return static */ - public static function brown3() + public static function brown3(): static { return new static(Color::BROWN3); } @@ -212,9 +193,8 @@ public static function brown3() /** * Color red. * - * @return static */ - public static function red() + public static function red(): static { return new static(Color::RED); } @@ -222,9 +202,8 @@ public static function red() /** * Color red1. * - * @return static */ - public static function red1() + public static function red1(): static { return new static(Color::RED1); } @@ -232,9 +211,8 @@ public static function red1() /** * Color rosybrown4. * - * @return static */ - public static function rosybrown4() + public static function rosybrown4(): static { return new static(Color::ROSYBROWN4); } @@ -242,9 +220,8 @@ public static function rosybrown4() /** * Color firebrick3. * - * @return static */ - public static function firebrick3() + public static function firebrick3(): static { return new static(Color::FIREBRICK3); } @@ -252,9 +229,8 @@ public static function firebrick3() /** * Color red2. * - * @return static */ - public static function red2() + public static function red2(): static { return new static(Color::RED2); } @@ -262,9 +238,8 @@ public static function red2() /** * Color firebrick. * - * @return static */ - public static function firebrick() + public static function firebrick(): static { return new static(Color::FIREBRICK); } @@ -272,9 +247,8 @@ public static function firebrick() /** * Color brown. * - * @return static */ - public static function brown() + public static function brown(): static { return new static(Color::BROWN); } @@ -282,9 +256,8 @@ public static function brown() /** * Color red3. * - * @return static */ - public static function red3() + public static function red3(): static { return new static(Color::RED3); } @@ -292,9 +265,8 @@ public static function red3() /** * Color indianred4. * - * @return static */ - public static function indianred4() + public static function indianred4(): static { return new static(Color::INDIANRED4); } @@ -302,9 +274,8 @@ public static function indianred4() /** * Color brown4. * - * @return static */ - public static function brown4() + public static function brown4(): static { return new static(Color::BROWN4); } @@ -312,9 +283,8 @@ public static function brown4() /** * Color firebrick4. * - * @return static */ - public static function firebrick4() + public static function firebrick4(): static { return new static(Color::FIREBRICK4); } @@ -322,9 +292,8 @@ public static function firebrick4() /** * Color darkred. * - * @return static */ - public static function darkred() + public static function darkred(): static { return new static(Color::DARKRED); } @@ -332,9 +301,8 @@ public static function darkred() /** * Color red4. * - * @return static */ - public static function red4() + public static function red4(): static { return new static(Color::RED4); } @@ -342,9 +310,8 @@ public static function red4() /** * Color lightpink1. * - * @return static */ - public static function lightpink1() + public static function lightpink1(): static { return new static(Color::LIGHTPINK1); } @@ -352,9 +319,8 @@ public static function lightpink1() /** * Color lightpink3. * - * @return static */ - public static function lightpink3() + public static function lightpink3(): static { return new static(Color::LIGHTPINK3); } @@ -362,9 +328,8 @@ public static function lightpink3() /** * Color lightpink4. * - * @return static */ - public static function lightpink4() + public static function lightpink4(): static { return new static(Color::LIGHTPINK4); } @@ -372,9 +337,8 @@ public static function lightpink4() /** * Color lightpink2. * - * @return static */ - public static function lightpink2() + public static function lightpink2(): static { return new static(Color::LIGHTPINK2); } @@ -382,9 +346,8 @@ public static function lightpink2() /** * Color lightpink. * - * @return static */ - public static function lightpink() + public static function lightpink(): static { return new static(Color::LIGHTPINK); } @@ -392,9 +355,8 @@ public static function lightpink() /** * Color pink. * - * @return static */ - public static function pink() + public static function pink(): static { return new static(Color::PINK); } @@ -402,9 +364,8 @@ public static function pink() /** * Color crimson. * - * @return static */ - public static function crimson() + public static function crimson(): static { return new static(Color::CRIMSON); } @@ -412,9 +373,8 @@ public static function crimson() /** * Color pink1. * - * @return static */ - public static function pink1() + public static function pink1(): static { return new static(Color::PINK1); } @@ -422,9 +382,8 @@ public static function pink1() /** * Color pink2. * - * @return static */ - public static function pink2() + public static function pink2(): static { return new static(Color::PINK2); } @@ -432,9 +391,8 @@ public static function pink2() /** * Color pink3. * - * @return static */ - public static function pink3() + public static function pink3(): static { return new static(Color::PINK3); } @@ -442,9 +400,8 @@ public static function pink3() /** * Color pink4. * - * @return static */ - public static function pink4() + public static function pink4(): static { return new static(Color::PINK4); } @@ -452,9 +409,8 @@ public static function pink4() /** * Color palevioletred4. * - * @return static */ - public static function palevioletred4() + public static function palevioletred4(): static { return new static(Color::PALEVIOLETRED4); } @@ -462,9 +418,8 @@ public static function palevioletred4() /** * Color palevioletred. * - * @return static */ - public static function palevioletred() + public static function palevioletred(): static { return new static(Color::PALEVIOLETRED); } @@ -472,9 +427,8 @@ public static function palevioletred() /** * Color palevioletred2. * - * @return static */ - public static function palevioletred2() + public static function palevioletred2(): static { return new static(Color::PALEVIOLETRED2); } @@ -482,9 +436,8 @@ public static function palevioletred2() /** * Color palevioletred1. * - * @return static */ - public static function palevioletred1() + public static function palevioletred1(): static { return new static(Color::PALEVIOLETRED1); } @@ -492,9 +445,8 @@ public static function palevioletred1() /** * Color palevioletred3. * - * @return static */ - public static function palevioletred3() + public static function palevioletred3(): static { return new static(Color::PALEVIOLETRED3); } @@ -502,9 +454,8 @@ public static function palevioletred3() /** * Color lavenderblush. * - * @return static */ - public static function lavenderblush() + public static function lavenderblush(): static { return new static(Color::LAVENDERBLUSH); } @@ -512,9 +463,8 @@ public static function lavenderblush() /** * Color lavenderblush1. * - * @return static */ - public static function lavenderblush1() + public static function lavenderblush1(): static { return new static(Color::LAVENDERBLUSH1); } @@ -522,9 +472,8 @@ public static function lavenderblush1() /** * Color lavenderblush3. * - * @return static */ - public static function lavenderblush3() + public static function lavenderblush3(): static { return new static(Color::LAVENDERBLUSH3); } @@ -532,9 +481,8 @@ public static function lavenderblush3() /** * Color lavenderblush2. * - * @return static */ - public static function lavenderblush2() + public static function lavenderblush2(): static { return new static(Color::LAVENDERBLUSH2); } @@ -542,9 +490,8 @@ public static function lavenderblush2() /** * Color lavenderblush4. * - * @return static */ - public static function lavenderblush4() + public static function lavenderblush4(): static { return new static(Color::LAVENDERBLUSH4); } @@ -552,9 +499,8 @@ public static function lavenderblush4() /** * Color maroon. * - * @return static */ - public static function maroon() + public static function maroon(): static { return new static(Color::MAROON); } @@ -562,9 +508,8 @@ public static function maroon() /** * Color hotpink3. * - * @return static */ - public static function hotpink3() + public static function hotpink3(): static { return new static(Color::HOTPINK3); } @@ -572,9 +517,8 @@ public static function hotpink3() /** * Color violetred3. * - * @return static */ - public static function violetred3() + public static function violetred3(): static { return new static(Color::VIOLETRED3); } @@ -582,9 +526,8 @@ public static function violetred3() /** * Color violetred1. * - * @return static */ - public static function violetred1() + public static function violetred1(): static { return new static(Color::VIOLETRED1); } @@ -592,9 +535,8 @@ public static function violetred1() /** * Color violetred2. * - * @return static */ - public static function violetred2() + public static function violetred2(): static { return new static(Color::VIOLETRED2); } @@ -602,9 +544,8 @@ public static function violetred2() /** * Color violetred4. * - * @return static */ - public static function violetred4() + public static function violetred4(): static { return new static(Color::VIOLETRED4); } @@ -612,9 +553,8 @@ public static function violetred4() /** * Color hotpink2. * - * @return static */ - public static function hotpink2() + public static function hotpink2(): static { return new static(Color::HOTPINK2); } @@ -622,9 +562,8 @@ public static function hotpink2() /** * Color hotpink1. * - * @return static */ - public static function hotpink1() + public static function hotpink1(): static { return new static(Color::HOTPINK1); } @@ -632,9 +571,8 @@ public static function hotpink1() /** * Color hotpink4. * - * @return static */ - public static function hotpink4() + public static function hotpink4(): static { return new static(Color::HOTPINK4); } @@ -642,9 +580,8 @@ public static function hotpink4() /** * Color hotpink. * - * @return static */ - public static function hotpink() + public static function hotpink(): static { return new static(Color::HOTPINK); } @@ -652,9 +589,8 @@ public static function hotpink() /** * Color deeppink. * - * @return static */ - public static function deeppink() + public static function deeppink(): static { return new static(Color::DEEPPINK); } @@ -662,9 +598,8 @@ public static function deeppink() /** * Color deeppink1. * - * @return static */ - public static function deeppink1() + public static function deeppink1(): static { return new static(Color::DEEPPINK1); } @@ -672,9 +607,8 @@ public static function deeppink1() /** * Color deeppink2. * - * @return static */ - public static function deeppink2() + public static function deeppink2(): static { return new static(Color::DEEPPINK2); } @@ -682,9 +616,8 @@ public static function deeppink2() /** * Color deeppink3. * - * @return static */ - public static function deeppink3() + public static function deeppink3(): static { return new static(Color::DEEPPINK3); } @@ -692,9 +625,8 @@ public static function deeppink3() /** * Color deeppink4. * - * @return static */ - public static function deeppink4() + public static function deeppink4(): static { return new static(Color::DEEPPINK4); } @@ -702,9 +634,8 @@ public static function deeppink4() /** * Color maroon1. * - * @return static */ - public static function maroon1() + public static function maroon1(): static { return new static(Color::MAROON1); } @@ -712,9 +643,8 @@ public static function maroon1() /** * Color maroon2. * - * @return static */ - public static function maroon2() + public static function maroon2(): static { return new static(Color::MAROON2); } @@ -722,9 +652,8 @@ public static function maroon2() /** * Color maroon3. * - * @return static */ - public static function maroon3() + public static function maroon3(): static { return new static(Color::MAROON3); } @@ -732,9 +661,8 @@ public static function maroon3() /** * Color maroon4. * - * @return static */ - public static function maroon4() + public static function maroon4(): static { return new static(Color::MAROON4); } @@ -742,9 +670,8 @@ public static function maroon4() /** * Color mediumvioletred. * - * @return static */ - public static function mediumvioletred() + public static function mediumvioletred(): static { return new static(Color::MEDIUMVIOLETRED); } @@ -752,9 +679,8 @@ public static function mediumvioletred() /** * Color violetred. * - * @return static */ - public static function violetred() + public static function violetred(): static { return new static(Color::VIOLETRED); } @@ -762,9 +688,8 @@ public static function violetred() /** * Color orchid2. * - * @return static */ - public static function orchid2() + public static function orchid2(): static { return new static(Color::ORCHID2); } @@ -772,9 +697,8 @@ public static function orchid2() /** * Color orchid. * - * @return static */ - public static function orchid() + public static function orchid(): static { return new static(Color::ORCHID); } @@ -782,9 +706,8 @@ public static function orchid() /** * Color orchid1. * - * @return static */ - public static function orchid1() + public static function orchid1(): static { return new static(Color::ORCHID1); } @@ -792,9 +715,8 @@ public static function orchid1() /** * Color orchid3. * - * @return static */ - public static function orchid3() + public static function orchid3(): static { return new static(Color::ORCHID3); } @@ -802,9 +724,8 @@ public static function orchid3() /** * Color orchid4. * - * @return static */ - public static function orchid4() + public static function orchid4(): static { return new static(Color::ORCHID4); } @@ -812,9 +733,8 @@ public static function orchid4() /** * Color thistle1. * - * @return static */ - public static function thistle1() + public static function thistle1(): static { return new static(Color::THISTLE1); } @@ -822,9 +742,8 @@ public static function thistle1() /** * Color thistle2. * - * @return static */ - public static function thistle2() + public static function thistle2(): static { return new static(Color::THISTLE2); } @@ -832,9 +751,8 @@ public static function thistle2() /** * Color plum1. * - * @return static */ - public static function plum1() + public static function plum1(): static { return new static(Color::PLUM1); } @@ -842,9 +760,8 @@ public static function plum1() /** * Color plum2. * - * @return static */ - public static function plum2() + public static function plum2(): static { return new static(Color::PLUM2); } @@ -852,9 +769,8 @@ public static function plum2() /** * Color thistle. * - * @return static */ - public static function thistle() + public static function thistle(): static { return new static(Color::THISTLE); } @@ -862,9 +778,8 @@ public static function thistle() /** * Color thistle3. * - * @return static */ - public static function thistle3() + public static function thistle3(): static { return new static(Color::THISTLE3); } @@ -872,9 +787,8 @@ public static function thistle3() /** * Color plum. * - * @return static */ - public static function plum() + public static function plum(): static { return new static(Color::PLUM); } @@ -882,9 +796,8 @@ public static function plum() /** * Color violet. * - * @return static */ - public static function violet() + public static function violet(): static { return new static(Color::VIOLET); } @@ -892,9 +805,8 @@ public static function violet() /** * Color plum3. * - * @return static */ - public static function plum3() + public static function plum3(): static { return new static(Color::PLUM3); } @@ -902,9 +814,8 @@ public static function plum3() /** * Color thistle4. * - * @return static */ - public static function thistle4() + public static function thistle4(): static { return new static(Color::THISTLE4); } @@ -912,9 +823,8 @@ public static function thistle4() /** * Color fuchsia. * - * @return static */ - public static function fuchsia() + public static function fuchsia(): static { return new static(Color::FUCHSIA); } @@ -922,9 +832,8 @@ public static function fuchsia() /** * Color magenta. * - * @return static */ - public static function magenta() + public static function magenta(): static { return new static(Color::MAGENTA); } @@ -932,9 +841,8 @@ public static function magenta() /** * Color magenta1. * - * @return static */ - public static function magenta1() + public static function magenta1(): static { return new static(Color::MAGENTA1); } @@ -942,9 +850,8 @@ public static function magenta1() /** * Color plum4. * - * @return static */ - public static function plum4() + public static function plum4(): static { return new static(Color::PLUM4); } @@ -952,9 +859,8 @@ public static function plum4() /** * Color magenta2. * - * @return static */ - public static function magenta2() + public static function magenta2(): static { return new static(Color::MAGENTA2); } @@ -962,9 +868,8 @@ public static function magenta2() /** * Color magenta3. * - * @return static */ - public static function magenta3() + public static function magenta3(): static { return new static(Color::MAGENTA3); } @@ -972,9 +877,8 @@ public static function magenta3() /** * Color darkmagenta. * - * @return static */ - public static function darkmagenta() + public static function darkmagenta(): static { return new static(Color::DARKMAGENTA); } @@ -982,9 +886,8 @@ public static function darkmagenta() /** * Color magenta4. * - * @return static */ - public static function magenta4() + public static function magenta4(): static { return new static(Color::MAGENTA4); } @@ -992,9 +895,8 @@ public static function magenta4() /** * Color purple. * - * @return static */ - public static function purple() + public static function purple(): static { return new static(Color::PURPLE); } @@ -1002,9 +904,8 @@ public static function purple() /** * Color mediumorchid. * - * @return static */ - public static function mediumorchid() + public static function mediumorchid(): static { return new static(Color::MEDIUMORCHID); } @@ -1012,9 +913,8 @@ public static function mediumorchid() /** * Color mediumorchid1. * - * @return static */ - public static function mediumorchid1() + public static function mediumorchid1(): static { return new static(Color::MEDIUMORCHID1); } @@ -1022,9 +922,8 @@ public static function mediumorchid1() /** * Color mediumorchid2. * - * @return static */ - public static function mediumorchid2() + public static function mediumorchid2(): static { return new static(Color::MEDIUMORCHID2); } @@ -1032,9 +931,8 @@ public static function mediumorchid2() /** * Color mediumorchid3. * - * @return static */ - public static function mediumorchid3() + public static function mediumorchid3(): static { return new static(Color::MEDIUMORCHID3); } @@ -1042,9 +940,8 @@ public static function mediumorchid3() /** * Color mediumorchid4. * - * @return static */ - public static function mediumorchid4() + public static function mediumorchid4(): static { return new static(Color::MEDIUMORCHID4); } @@ -1052,9 +949,8 @@ public static function mediumorchid4() /** * Color darkviolet. * - * @return static */ - public static function darkviolet() + public static function darkviolet(): static { return new static(Color::DARKVIOLET); } @@ -1062,9 +958,8 @@ public static function darkviolet() /** * Color darkorchid. * - * @return static */ - public static function darkorchid() + public static function darkorchid(): static { return new static(Color::DARKORCHID); } @@ -1072,9 +967,8 @@ public static function darkorchid() /** * Color darkorchid1. * - * @return static */ - public static function darkorchid1() + public static function darkorchid1(): static { return new static(Color::DARKORCHID1); } @@ -1082,9 +976,8 @@ public static function darkorchid1() /** * Color darkorchid3. * - * @return static */ - public static function darkorchid3() + public static function darkorchid3(): static { return new static(Color::DARKORCHID3); } @@ -1092,9 +985,8 @@ public static function darkorchid3() /** * Color darkorchid2. * - * @return static */ - public static function darkorchid2() + public static function darkorchid2(): static { return new static(Color::DARKORCHID2); } @@ -1102,9 +994,8 @@ public static function darkorchid2() /** * Color darkorchid4. * - * @return static */ - public static function darkorchid4() + public static function darkorchid4(): static { return new static(Color::DARKORCHID4); } @@ -1112,9 +1003,8 @@ public static function darkorchid4() /** * Color indigo. * - * @return static */ - public static function indigo() + public static function indigo(): static { return new static(Color::INDIGO); } @@ -1122,9 +1012,8 @@ public static function indigo() /** * Color blueviolet. * - * @return static */ - public static function blueviolet() + public static function blueviolet(): static { return new static(Color::BLUEVIOLET); } @@ -1132,9 +1021,8 @@ public static function blueviolet() /** * Color purple2. * - * @return static */ - public static function purple2() + public static function purple2(): static { return new static(Color::PURPLE2); } @@ -1142,9 +1030,8 @@ public static function purple2() /** * Color purple3. * - * @return static */ - public static function purple3() + public static function purple3(): static { return new static(Color::PURPLE3); } @@ -1152,9 +1039,8 @@ public static function purple3() /** * Color purple4. * - * @return static */ - public static function purple4() + public static function purple4(): static { return new static(Color::PURPLE4); } @@ -1162,9 +1048,8 @@ public static function purple4() /** * Color purple1. * - * @return static */ - public static function purple1() + public static function purple1(): static { return new static(Color::PURPLE1); } @@ -1172,9 +1057,8 @@ public static function purple1() /** * Color mediumpurple. * - * @return static */ - public static function mediumpurple() + public static function mediumpurple(): static { return new static(Color::MEDIUMPURPLE); } @@ -1182,9 +1066,8 @@ public static function mediumpurple() /** * Color mediumpurple1. * - * @return static */ - public static function mediumpurple1() + public static function mediumpurple1(): static { return new static(Color::MEDIUMPURPLE1); } @@ -1192,9 +1075,8 @@ public static function mediumpurple1() /** * Color mediumpurple2. * - * @return static */ - public static function mediumpurple2() + public static function mediumpurple2(): static { return new static(Color::MEDIUMPURPLE2); } @@ -1202,9 +1084,8 @@ public static function mediumpurple2() /** * Color mediumpurple3. * - * @return static */ - public static function mediumpurple3() + public static function mediumpurple3(): static { return new static(Color::MEDIUMPURPLE3); } @@ -1212,9 +1093,8 @@ public static function mediumpurple3() /** * Color mediumpurple4. * - * @return static */ - public static function mediumpurple4() + public static function mediumpurple4(): static { return new static(Color::MEDIUMPURPLE4); } @@ -1222,9 +1102,8 @@ public static function mediumpurple4() /** * Color darkslateblue. * - * @return static */ - public static function darkslateblue() + public static function darkslateblue(): static { return new static(Color::DARKSLATEBLUE); } @@ -1232,9 +1111,8 @@ public static function darkslateblue() /** * Color lightslateblue. * - * @return static */ - public static function lightslateblue() + public static function lightslateblue(): static { return new static(Color::LIGHTSLATEBLUE); } @@ -1242,9 +1120,8 @@ public static function lightslateblue() /** * Color mediumslateblue. * - * @return static */ - public static function mediumslateblue() + public static function mediumslateblue(): static { return new static(Color::MEDIUMSLATEBLUE); } @@ -1252,9 +1129,8 @@ public static function mediumslateblue() /** * Color slateblue. * - * @return static */ - public static function slateblue() + public static function slateblue(): static { return new static(Color::SLATEBLUE); } @@ -1262,9 +1138,8 @@ public static function slateblue() /** * Color slateblue1. * - * @return static */ - public static function slateblue1() + public static function slateblue1(): static { return new static(Color::SLATEBLUE1); } @@ -1272,9 +1147,8 @@ public static function slateblue1() /** * Color slateblue2. * - * @return static */ - public static function slateblue2() + public static function slateblue2(): static { return new static(Color::SLATEBLUE2); } @@ -1282,9 +1156,8 @@ public static function slateblue2() /** * Color slateblue3. * - * @return static */ - public static function slateblue3() + public static function slateblue3(): static { return new static(Color::SLATEBLUE3); } @@ -1292,9 +1165,8 @@ public static function slateblue3() /** * Color slateblue4. * - * @return static */ - public static function slateblue4() + public static function slateblue4(): static { return new static(Color::SLATEBLUE4); } @@ -1302,9 +1174,8 @@ public static function slateblue4() /** * Color ghostwhite. * - * @return static */ - public static function ghostwhite() + public static function ghostwhite(): static { return new static(Color::GHOSTWHITE); } @@ -1312,9 +1183,8 @@ public static function ghostwhite() /** * Color lavender. * - * @return static */ - public static function lavender() + public static function lavender(): static { return new static(Color::LAVENDER); } @@ -1322,9 +1192,8 @@ public static function lavender() /** * Color blue. * - * @return static */ - public static function blue() + public static function blue(): static { return new static(Color::BLUE); } @@ -1332,9 +1201,8 @@ public static function blue() /** * Color blue1. * - * @return static */ - public static function blue1() + public static function blue1(): static { return new static(Color::BLUE1); } @@ -1342,9 +1210,8 @@ public static function blue1() /** * Color blue2. * - * @return static */ - public static function blue2() + public static function blue2(): static { return new static(Color::BLUE2); } @@ -1352,9 +1219,8 @@ public static function blue2() /** * Color blue3. * - * @return static */ - public static function blue3() + public static function blue3(): static { return new static(Color::BLUE3); } @@ -1362,9 +1228,8 @@ public static function blue3() /** * Color mediumblue. * - * @return static */ - public static function mediumblue() + public static function mediumblue(): static { return new static(Color::MEDIUMBLUE); } @@ -1372,9 +1237,8 @@ public static function mediumblue() /** * Color blue4. * - * @return static */ - public static function blue4() + public static function blue4(): static { return new static(Color::BLUE4); } @@ -1382,9 +1246,8 @@ public static function blue4() /** * Color darkblue. * - * @return static */ - public static function darkblue() + public static function darkblue(): static { return new static(Color::DARKBLUE); } @@ -1392,9 +1255,8 @@ public static function darkblue() /** * Color midnightblue. * - * @return static */ - public static function midnightblue() + public static function midnightblue(): static { return new static(Color::MIDNIGHTBLUE); } @@ -1402,9 +1264,8 @@ public static function midnightblue() /** * Color navy. * - * @return static */ - public static function navy() + public static function navy(): static { return new static(Color::NAVY); } @@ -1412,9 +1273,8 @@ public static function navy() /** * Color navyblue. * - * @return static */ - public static function navyblue() + public static function navyblue(): static { return new static(Color::NAVYBLUE); } @@ -1422,9 +1282,8 @@ public static function navyblue() /** * Color royalblue. * - * @return static */ - public static function royalblue() + public static function royalblue(): static { return new static(Color::ROYALBLUE); } @@ -1432,9 +1291,8 @@ public static function royalblue() /** * Color royalblue1. * - * @return static */ - public static function royalblue1() + public static function royalblue1(): static { return new static(Color::ROYALBLUE1); } @@ -1442,9 +1300,8 @@ public static function royalblue1() /** * Color royalblue2. * - * @return static */ - public static function royalblue2() + public static function royalblue2(): static { return new static(Color::ROYALBLUE2); } @@ -1452,9 +1309,8 @@ public static function royalblue2() /** * Color royalblue3. * - * @return static */ - public static function royalblue3() + public static function royalblue3(): static { return new static(Color::ROYALBLUE3); } @@ -1462,9 +1318,8 @@ public static function royalblue3() /** * Color royalblue4. * - * @return static */ - public static function royalblue4() + public static function royalblue4(): static { return new static(Color::ROYALBLUE4); } @@ -1472,9 +1327,8 @@ public static function royalblue4() /** * Color cornflowerblue. * - * @return static */ - public static function cornflowerblue() + public static function cornflowerblue(): static { return new static(Color::CORNFLOWERBLUE); } @@ -1482,9 +1336,8 @@ public static function cornflowerblue() /** * Color lightsteelblue. * - * @return static */ - public static function lightsteelblue() + public static function lightsteelblue(): static { return new static(Color::LIGHTSTEELBLUE); } @@ -1492,9 +1345,8 @@ public static function lightsteelblue() /** * Color lightsteelblue1. * - * @return static */ - public static function lightsteelblue1() + public static function lightsteelblue1(): static { return new static(Color::LIGHTSTEELBLUE1); } @@ -1502,9 +1354,8 @@ public static function lightsteelblue1() /** * Color lightsteelblue2. * - * @return static */ - public static function lightsteelblue2() + public static function lightsteelblue2(): static { return new static(Color::LIGHTSTEELBLUE2); } @@ -1512,9 +1363,8 @@ public static function lightsteelblue2() /** * Color lightsteelblue3. * - * @return static */ - public static function lightsteelblue3() + public static function lightsteelblue3(): static { return new static(Color::LIGHTSTEELBLUE3); } @@ -1522,9 +1372,8 @@ public static function lightsteelblue3() /** * Color lightsteelblue4. * - * @return static */ - public static function lightsteelblue4() + public static function lightsteelblue4(): static { return new static(Color::LIGHTSTEELBLUE4); } @@ -1532,9 +1381,8 @@ public static function lightsteelblue4() /** * Color slategray4. * - * @return static */ - public static function slategray4() + public static function slategray4(): static { return new static(Color::SLATEGRAY4); } @@ -1542,9 +1390,8 @@ public static function slategray4() /** * Color slategray1. * - * @return static */ - public static function slategray1() + public static function slategray1(): static { return new static(Color::SLATEGRAY1); } @@ -1552,9 +1399,8 @@ public static function slategray1() /** * Color slategray2. * - * @return static */ - public static function slategray2() + public static function slategray2(): static { return new static(Color::SLATEGRAY2); } @@ -1562,9 +1408,8 @@ public static function slategray2() /** * Color slategray3. * - * @return static */ - public static function slategray3() + public static function slategray3(): static { return new static(Color::SLATEGRAY3); } @@ -1572,9 +1417,8 @@ public static function slategray3() /** * Color lightslategray. * - * @return static */ - public static function lightslategray() + public static function lightslategray(): static { return new static(Color::LIGHTSLATEGRAY); } @@ -1582,9 +1426,8 @@ public static function lightslategray() /** * Color lightslategrey. * - * @return static */ - public static function lightslategrey() + public static function lightslategrey(): static { return new static(Color::LIGHTSLATEGREY); } @@ -1592,9 +1435,8 @@ public static function lightslategrey() /** * Color slategray. * - * @return static */ - public static function slategray() + public static function slategray(): static { return new static(Color::SLATEGRAY); } @@ -1602,9 +1444,8 @@ public static function slategray() /** * Color slategrey. * - * @return static */ - public static function slategrey() + public static function slategrey(): static { return new static(Color::SLATEGREY); } @@ -1612,9 +1453,8 @@ public static function slategrey() /** * Color dodgerblue. * - * @return static */ - public static function dodgerblue() + public static function dodgerblue(): static { return new static(Color::DODGERBLUE); } @@ -1622,9 +1462,8 @@ public static function dodgerblue() /** * Color dodgerblue1. * - * @return static */ - public static function dodgerblue1() + public static function dodgerblue1(): static { return new static(Color::DODGERBLUE1); } @@ -1632,9 +1471,8 @@ public static function dodgerblue1() /** * Color dodgerblue2. * - * @return static */ - public static function dodgerblue2() + public static function dodgerblue2(): static { return new static(Color::DODGERBLUE2); } @@ -1642,9 +1480,8 @@ public static function dodgerblue2() /** * Color dodgerblue4. * - * @return static */ - public static function dodgerblue4() + public static function dodgerblue4(): static { return new static(Color::DODGERBLUE4); } @@ -1652,9 +1489,8 @@ public static function dodgerblue4() /** * Color dodgerblue3. * - * @return static */ - public static function dodgerblue3() + public static function dodgerblue3(): static { return new static(Color::DODGERBLUE3); } @@ -1662,9 +1498,8 @@ public static function dodgerblue3() /** * Color aliceblue. * - * @return static */ - public static function aliceblue() + public static function aliceblue(): static { return new static(Color::ALICEBLUE); } @@ -1672,9 +1507,8 @@ public static function aliceblue() /** * Color steelblue4. * - * @return static */ - public static function steelblue4() + public static function steelblue4(): static { return new static(Color::STEELBLUE4); } @@ -1682,9 +1516,8 @@ public static function steelblue4() /** * Color steelblue. * - * @return static */ - public static function steelblue() + public static function steelblue(): static { return new static(Color::STEELBLUE); } @@ -1692,9 +1525,8 @@ public static function steelblue() /** * Color steelblue1. * - * @return static */ - public static function steelblue1() + public static function steelblue1(): static { return new static(Color::STEELBLUE1); } @@ -1702,9 +1534,8 @@ public static function steelblue1() /** * Color steelblue2. * - * @return static */ - public static function steelblue2() + public static function steelblue2(): static { return new static(Color::STEELBLUE2); } @@ -1712,9 +1543,8 @@ public static function steelblue2() /** * Color steelblue3. * - * @return static */ - public static function steelblue3() + public static function steelblue3(): static { return new static(Color::STEELBLUE3); } @@ -1722,9 +1552,8 @@ public static function steelblue3() /** * Color skyblue4. * - * @return static */ - public static function skyblue4() + public static function skyblue4(): static { return new static(Color::SKYBLUE4); } @@ -1732,9 +1561,8 @@ public static function skyblue4() /** * Color skyblue1. * - * @return static */ - public static function skyblue1() + public static function skyblue1(): static { return new static(Color::SKYBLUE1); } @@ -1742,9 +1570,8 @@ public static function skyblue1() /** * Color skyblue2. * - * @return static */ - public static function skyblue2() + public static function skyblue2(): static { return new static(Color::SKYBLUE2); } @@ -1752,9 +1579,8 @@ public static function skyblue2() /** * Color skyblue3. * - * @return static */ - public static function skyblue3() + public static function skyblue3(): static { return new static(Color::SKYBLUE3); } @@ -1762,9 +1588,8 @@ public static function skyblue3() /** * Color lightskyblue. * - * @return static */ - public static function lightskyblue() + public static function lightskyblue(): static { return new static(Color::LIGHTSKYBLUE); } @@ -1772,9 +1597,8 @@ public static function lightskyblue() /** * Color lightskyblue4. * - * @return static */ - public static function lightskyblue4() + public static function lightskyblue4(): static { return new static(Color::LIGHTSKYBLUE4); } @@ -1782,9 +1606,8 @@ public static function lightskyblue4() /** * Color lightskyblue1. * - * @return static */ - public static function lightskyblue1() + public static function lightskyblue1(): static { return new static(Color::LIGHTSKYBLUE1); } @@ -1792,9 +1615,8 @@ public static function lightskyblue1() /** * Color lightskyblue2. * - * @return static */ - public static function lightskyblue2() + public static function lightskyblue2(): static { return new static(Color::LIGHTSKYBLUE2); } @@ -1802,9 +1624,8 @@ public static function lightskyblue2() /** * Color lightskyblue3. * - * @return static */ - public static function lightskyblue3() + public static function lightskyblue3(): static { return new static(Color::LIGHTSKYBLUE3); } @@ -1812,9 +1633,8 @@ public static function lightskyblue3() /** * Color skyblue. * - * @return static */ - public static function skyblue() + public static function skyblue(): static { return new static(Color::SKYBLUE); } @@ -1822,9 +1642,8 @@ public static function skyblue() /** * Color lightblue3. * - * @return static */ - public static function lightblue3() + public static function lightblue3(): static { return new static(Color::LIGHTBLUE3); } @@ -1832,9 +1651,8 @@ public static function lightblue3() /** * Color deepskyblue. * - * @return static */ - public static function deepskyblue() + public static function deepskyblue(): static { return new static(Color::DEEPSKYBLUE); } @@ -1842,9 +1660,8 @@ public static function deepskyblue() /** * Color deepskyblue1. * - * @return static */ - public static function deepskyblue1() + public static function deepskyblue1(): static { return new static(Color::DEEPSKYBLUE1); } @@ -1852,9 +1669,8 @@ public static function deepskyblue1() /** * Color deepskyblue2. * - * @return static */ - public static function deepskyblue2() + public static function deepskyblue2(): static { return new static(Color::DEEPSKYBLUE2); } @@ -1862,9 +1678,8 @@ public static function deepskyblue2() /** * Color deepskyblue4. * - * @return static */ - public static function deepskyblue4() + public static function deepskyblue4(): static { return new static(Color::DEEPSKYBLUE4); } @@ -1872,9 +1687,8 @@ public static function deepskyblue4() /** * Color deepskyblue3. * - * @return static */ - public static function deepskyblue3() + public static function deepskyblue3(): static { return new static(Color::DEEPSKYBLUE3); } @@ -1882,9 +1696,8 @@ public static function deepskyblue3() /** * Color lightblue1. * - * @return static */ - public static function lightblue1() + public static function lightblue1(): static { return new static(Color::LIGHTBLUE1); } @@ -1892,9 +1705,8 @@ public static function lightblue1() /** * Color lightblue2. * - * @return static */ - public static function lightblue2() + public static function lightblue2(): static { return new static(Color::LIGHTBLUE2); } @@ -1902,9 +1714,8 @@ public static function lightblue2() /** * Color lightblue. * - * @return static */ - public static function lightblue() + public static function lightblue(): static { return new static(Color::LIGHTBLUE); } @@ -1912,9 +1723,8 @@ public static function lightblue() /** * Color lightblue4. * - * @return static */ - public static function lightblue4() + public static function lightblue4(): static { return new static(Color::LIGHTBLUE4); } @@ -1922,9 +1732,8 @@ public static function lightblue4() /** * Color powderblue. * - * @return static */ - public static function powderblue() + public static function powderblue(): static { return new static(Color::POWDERBLUE); } @@ -1932,9 +1741,8 @@ public static function powderblue() /** * Color cadetblue1. * - * @return static */ - public static function cadetblue1() + public static function cadetblue1(): static { return new static(Color::CADETBLUE1); } @@ -1942,9 +1750,8 @@ public static function cadetblue1() /** * Color cadetblue2. * - * @return static */ - public static function cadetblue2() + public static function cadetblue2(): static { return new static(Color::CADETBLUE2); } @@ -1952,9 +1759,8 @@ public static function cadetblue2() /** * Color cadetblue3. * - * @return static */ - public static function cadetblue3() + public static function cadetblue3(): static { return new static(Color::CADETBLUE3); } @@ -1962,9 +1768,8 @@ public static function cadetblue3() /** * Color cadetblue4. * - * @return static */ - public static function cadetblue4() + public static function cadetblue4(): static { return new static(Color::CADETBLUE4); } @@ -1972,9 +1777,8 @@ public static function cadetblue4() /** * Color turquoise1. * - * @return static */ - public static function turquoise1() + public static function turquoise1(): static { return new static(Color::TURQUOISE1); } @@ -1982,9 +1786,8 @@ public static function turquoise1() /** * Color turquoise2. * - * @return static */ - public static function turquoise2() + public static function turquoise2(): static { return new static(Color::TURQUOISE2); } @@ -1992,9 +1795,8 @@ public static function turquoise2() /** * Color turquoise3. * - * @return static */ - public static function turquoise3() + public static function turquoise3(): static { return new static(Color::TURQUOISE3); } @@ -2002,9 +1804,8 @@ public static function turquoise3() /** * Color turquoise4. * - * @return static */ - public static function turquoise4() + public static function turquoise4(): static { return new static(Color::TURQUOISE4); } @@ -2012,9 +1813,8 @@ public static function turquoise4() /** * Color cadetblue. * - * @return static */ - public static function cadetblue() + public static function cadetblue(): static { return new static(Color::CADETBLUE); } @@ -2022,9 +1822,8 @@ public static function cadetblue() /** * Color darkturquoise. * - * @return static */ - public static function darkturquoise() + public static function darkturquoise(): static { return new static(Color::DARKTURQUOISE); } @@ -2032,9 +1831,8 @@ public static function darkturquoise() /** * Color azure. * - * @return static */ - public static function azure() + public static function azure(): static { return new static(Color::AZURE); } @@ -2042,9 +1840,8 @@ public static function azure() /** * Color azure1. * - * @return static */ - public static function azure1() + public static function azure1(): static { return new static(Color::AZURE1); } @@ -2052,9 +1849,8 @@ public static function azure1() /** * Color lightcyan1. * - * @return static */ - public static function lightcyan1() + public static function lightcyan1(): static { return new static(Color::LIGHTCYAN1); } @@ -2062,9 +1858,8 @@ public static function lightcyan1() /** * Color lightcyan. * - * @return static */ - public static function lightcyan() + public static function lightcyan(): static { return new static(Color::LIGHTCYAN); } @@ -2072,9 +1867,8 @@ public static function lightcyan() /** * Color azure2. * - * @return static */ - public static function azure2() + public static function azure2(): static { return new static(Color::AZURE2); } @@ -2082,9 +1876,8 @@ public static function azure2() /** * Color lightcyan2. * - * @return static */ - public static function lightcyan2() + public static function lightcyan2(): static { return new static(Color::LIGHTCYAN2); } @@ -2092,9 +1885,8 @@ public static function lightcyan2() /** * Color paleturquoise1. * - * @return static */ - public static function paleturquoise1() + public static function paleturquoise1(): static { return new static(Color::PALETURQUOISE1); } @@ -2102,9 +1894,8 @@ public static function paleturquoise1() /** * Color paleturquoise. * - * @return static */ - public static function paleturquoise() + public static function paleturquoise(): static { return new static(Color::PALETURQUOISE); } @@ -2112,9 +1903,8 @@ public static function paleturquoise() /** * Color paleturquoise2. * - * @return static */ - public static function paleturquoise2() + public static function paleturquoise2(): static { return new static(Color::PALETURQUOISE2); } @@ -2122,9 +1912,8 @@ public static function paleturquoise2() /** * Color darkslategray1. * - * @return static */ - public static function darkslategray1() + public static function darkslategray1(): static { return new static(Color::DARKSLATEGRAY1); } @@ -2132,9 +1921,8 @@ public static function darkslategray1() /** * Color azure3. * - * @return static */ - public static function azure3() + public static function azure3(): static { return new static(Color::AZURE3); } @@ -2142,9 +1930,8 @@ public static function azure3() /** * Color lightcyan3. * - * @return static */ - public static function lightcyan3() + public static function lightcyan3(): static { return new static(Color::LIGHTCYAN3); } @@ -2152,9 +1939,8 @@ public static function lightcyan3() /** * Color darkslategray2. * - * @return static */ - public static function darkslategray2() + public static function darkslategray2(): static { return new static(Color::DARKSLATEGRAY2); } @@ -2162,9 +1948,8 @@ public static function darkslategray2() /** * Color paleturquoise3. * - * @return static */ - public static function paleturquoise3() + public static function paleturquoise3(): static { return new static(Color::PALETURQUOISE3); } @@ -2172,9 +1957,8 @@ public static function paleturquoise3() /** * Color darkslategray3. * - * @return static */ - public static function darkslategray3() + public static function darkslategray3(): static { return new static(Color::DARKSLATEGRAY3); } @@ -2182,9 +1966,8 @@ public static function darkslategray3() /** * Color azure4. * - * @return static */ - public static function azure4() + public static function azure4(): static { return new static(Color::AZURE4); } @@ -2192,9 +1975,8 @@ public static function azure4() /** * Color lightcyan4. * - * @return static */ - public static function lightcyan4() + public static function lightcyan4(): static { return new static(Color::LIGHTCYAN4); } @@ -2202,9 +1984,8 @@ public static function lightcyan4() /** * Color aqua. * - * @return static */ - public static function aqua() + public static function aqua(): static { return new static(Color::AQUA); } @@ -2212,9 +1993,8 @@ public static function aqua() /** * Color cyan. * - * @return static */ - public static function cyan() + public static function cyan(): static { return new static(Color::CYAN); } @@ -2222,9 +2002,8 @@ public static function cyan() /** * Color cyan1. * - * @return static */ - public static function cyan1() + public static function cyan1(): static { return new static(Color::CYAN1); } @@ -2232,9 +2011,8 @@ public static function cyan1() /** * Color paleturquoise4. * - * @return static */ - public static function paleturquoise4() + public static function paleturquoise4(): static { return new static(Color::PALETURQUOISE4); } @@ -2242,9 +2020,8 @@ public static function paleturquoise4() /** * Color cyan2. * - * @return static */ - public static function cyan2() + public static function cyan2(): static { return new static(Color::CYAN2); } @@ -2252,9 +2029,8 @@ public static function cyan2() /** * Color darkslategray4. * - * @return static */ - public static function darkslategray4() + public static function darkslategray4(): static { return new static(Color::DARKSLATEGRAY4); } @@ -2262,9 +2038,8 @@ public static function darkslategray4() /** * Color cyan3. * - * @return static */ - public static function cyan3() + public static function cyan3(): static { return new static(Color::CYAN3); } @@ -2272,9 +2047,8 @@ public static function cyan3() /** * Color cyan4. * - * @return static */ - public static function cyan4() + public static function cyan4(): static { return new static(Color::CYAN4); } @@ -2282,9 +2056,8 @@ public static function cyan4() /** * Color darkcyan. * - * @return static */ - public static function darkcyan() + public static function darkcyan(): static { return new static(Color::DARKCYAN); } @@ -2292,9 +2065,8 @@ public static function darkcyan() /** * Color teal. * - * @return static */ - public static function teal() + public static function teal(): static { return new static(Color::TEAL); } @@ -2302,9 +2074,8 @@ public static function teal() /** * Color darkslategray. * - * @return static */ - public static function darkslategray() + public static function darkslategray(): static { return new static(Color::DARKSLATEGRAY); } @@ -2312,9 +2083,8 @@ public static function darkslategray() /** * Color darkslategrey. * - * @return static */ - public static function darkslategrey() + public static function darkslategrey(): static { return new static(Color::DARKSLATEGREY); } @@ -2322,9 +2092,8 @@ public static function darkslategrey() /** * Color mediumturquoise. * - * @return static */ - public static function mediumturquoise() + public static function mediumturquoise(): static { return new static(Color::MEDIUMTURQUOISE); } @@ -2332,9 +2101,8 @@ public static function mediumturquoise() /** * Color lightseagreen. * - * @return static */ - public static function lightseagreen() + public static function lightseagreen(): static { return new static(Color::LIGHTSEAGREEN); } @@ -2342,9 +2110,8 @@ public static function lightseagreen() /** * Color turquoise. * - * @return static */ - public static function turquoise() + public static function turquoise(): static { return new static(Color::TURQUOISE); } @@ -2352,9 +2119,8 @@ public static function turquoise() /** * Color aquamarine4. * - * @return static */ - public static function aquamarine4() + public static function aquamarine4(): static { return new static(Color::AQUAMARINE4); } @@ -2362,9 +2128,8 @@ public static function aquamarine4() /** * Color aquamarine. * - * @return static */ - public static function aquamarine() + public static function aquamarine(): static { return new static(Color::AQUAMARINE); } @@ -2372,9 +2137,8 @@ public static function aquamarine() /** * Color aquamarine1. * - * @return static */ - public static function aquamarine1() + public static function aquamarine1(): static { return new static(Color::AQUAMARINE1); } @@ -2382,9 +2146,8 @@ public static function aquamarine1() /** * Color aquamarine2. * - * @return static */ - public static function aquamarine2() + public static function aquamarine2(): static { return new static(Color::AQUAMARINE2); } @@ -2392,9 +2155,8 @@ public static function aquamarine2() /** * Color aquamarine3. * - * @return static */ - public static function aquamarine3() + public static function aquamarine3(): static { return new static(Color::AQUAMARINE3); } @@ -2402,9 +2164,8 @@ public static function aquamarine3() /** * Color mediumaquamarine. * - * @return static */ - public static function mediumaquamarine() + public static function mediumaquamarine(): static { return new static(Color::MEDIUMAQUAMARINE); } @@ -2412,9 +2173,8 @@ public static function mediumaquamarine() /** * Color mediumspringgreen. * - * @return static */ - public static function mediumspringgreen() + public static function mediumspringgreen(): static { return new static(Color::MEDIUMSPRINGGREEN); } @@ -2422,9 +2182,8 @@ public static function mediumspringgreen() /** * Color mintcream. * - * @return static */ - public static function mintcream() + public static function mintcream(): static { return new static(Color::MINTCREAM); } @@ -2432,9 +2191,8 @@ public static function mintcream() /** * Color springgreen. * - * @return static */ - public static function springgreen() + public static function springgreen(): static { return new static(Color::SPRINGGREEN); } @@ -2442,9 +2200,8 @@ public static function springgreen() /** * Color springgreen1. * - * @return static */ - public static function springgreen1() + public static function springgreen1(): static { return new static(Color::SPRINGGREEN1); } @@ -2452,9 +2209,8 @@ public static function springgreen1() /** * Color springgreen2. * - * @return static */ - public static function springgreen2() + public static function springgreen2(): static { return new static(Color::SPRINGGREEN2); } @@ -2462,9 +2218,8 @@ public static function springgreen2() /** * Color springgreen3. * - * @return static */ - public static function springgreen3() + public static function springgreen3(): static { return new static(Color::SPRINGGREEN3); } @@ -2472,9 +2227,8 @@ public static function springgreen3() /** * Color springgreen4. * - * @return static */ - public static function springgreen4() + public static function springgreen4(): static { return new static(Color::SPRINGGREEN4); } @@ -2482,9 +2236,8 @@ public static function springgreen4() /** * Color mediumseagreen. * - * @return static */ - public static function mediumseagreen() + public static function mediumseagreen(): static { return new static(Color::MEDIUMSEAGREEN); } @@ -2492,9 +2245,8 @@ public static function mediumseagreen() /** * Color seagreen. * - * @return static */ - public static function seagreen() + public static function seagreen(): static { return new static(Color::SEAGREEN); } @@ -2502,9 +2254,8 @@ public static function seagreen() /** * Color seagreen3. * - * @return static */ - public static function seagreen3() + public static function seagreen3(): static { return new static(Color::SEAGREEN3); } @@ -2512,9 +2263,8 @@ public static function seagreen3() /** * Color seagreen1. * - * @return static */ - public static function seagreen1() + public static function seagreen1(): static { return new static(Color::SEAGREEN1); } @@ -2522,9 +2272,8 @@ public static function seagreen1() /** * Color seagreen4. * - * @return static */ - public static function seagreen4() + public static function seagreen4(): static { return new static(Color::SEAGREEN4); } @@ -2532,9 +2281,8 @@ public static function seagreen4() /** * Color seagreen2. * - * @return static */ - public static function seagreen2() + public static function seagreen2(): static { return new static(Color::SEAGREEN2); } @@ -2542,9 +2290,8 @@ public static function seagreen2() /** * Color mediumforestgreen. * - * @return static */ - public static function mediumforestgreen() + public static function mediumforestgreen(): static { return new static(Color::MEDIUMFORESTGREEN); } @@ -2552,9 +2299,8 @@ public static function mediumforestgreen() /** * Color honeydew. * - * @return static */ - public static function honeydew() + public static function honeydew(): static { return new static(Color::HONEYDEW); } @@ -2562,9 +2308,8 @@ public static function honeydew() /** * Color honeydew1. * - * @return static */ - public static function honeydew1() + public static function honeydew1(): static { return new static(Color::HONEYDEW1); } @@ -2572,9 +2317,8 @@ public static function honeydew1() /** * Color honeydew2. * - * @return static */ - public static function honeydew2() + public static function honeydew2(): static { return new static(Color::HONEYDEW2); } @@ -2582,9 +2326,8 @@ public static function honeydew2() /** * Color darkseagreen1. * - * @return static */ - public static function darkseagreen1() + public static function darkseagreen1(): static { return new static(Color::DARKSEAGREEN1); } @@ -2592,9 +2335,8 @@ public static function darkseagreen1() /** * Color darkseagreen2. * - * @return static */ - public static function darkseagreen2() + public static function darkseagreen2(): static { return new static(Color::DARKSEAGREEN2); } @@ -2602,9 +2344,8 @@ public static function darkseagreen2() /** * Color palegreen1. * - * @return static */ - public static function palegreen1() + public static function palegreen1(): static { return new static(Color::PALEGREEN1); } @@ -2612,9 +2353,8 @@ public static function palegreen1() /** * Color palegreen. * - * @return static */ - public static function palegreen() + public static function palegreen(): static { return new static(Color::PALEGREEN); } @@ -2622,9 +2362,8 @@ public static function palegreen() /** * Color honeydew3. * - * @return static */ - public static function honeydew3() + public static function honeydew3(): static { return new static(Color::HONEYDEW3); } @@ -2632,9 +2371,8 @@ public static function honeydew3() /** * Color lightgreen. * - * @return static */ - public static function lightgreen() + public static function lightgreen(): static { return new static(Color::LIGHTGREEN); } @@ -2642,9 +2380,8 @@ public static function lightgreen() /** * Color palegreen2. * - * @return static */ - public static function palegreen2() + public static function palegreen2(): static { return new static(Color::PALEGREEN2); } @@ -2652,9 +2389,8 @@ public static function palegreen2() /** * Color darkseagreen3. * - * @return static */ - public static function darkseagreen3() + public static function darkseagreen3(): static { return new static(Color::DARKSEAGREEN3); } @@ -2662,9 +2398,8 @@ public static function darkseagreen3() /** * Color darkseagreen. * - * @return static */ - public static function darkseagreen() + public static function darkseagreen(): static { return new static(Color::DARKSEAGREEN); } @@ -2672,9 +2407,8 @@ public static function darkseagreen() /** * Color palegreen3. * - * @return static */ - public static function palegreen3() + public static function palegreen3(): static { return new static(Color::PALEGREEN3); } @@ -2682,9 +2416,8 @@ public static function palegreen3() /** * Color honeydew4. * - * @return static */ - public static function honeydew4() + public static function honeydew4(): static { return new static(Color::HONEYDEW4); } @@ -2692,9 +2425,8 @@ public static function honeydew4() /** * Color green1. * - * @return static */ - public static function green1() + public static function green1(): static { return new static(Color::GREEN1); } @@ -2702,9 +2434,8 @@ public static function green1() /** * Color lime. * - * @return static */ - public static function lime() + public static function lime(): static { return new static(Color::LIME); } @@ -2712,9 +2443,8 @@ public static function lime() /** * Color limegreen. * - * @return static */ - public static function limegreen() + public static function limegreen(): static { return new static(Color::LIMEGREEN); } @@ -2722,9 +2452,8 @@ public static function limegreen() /** * Color darkseagreen4. * - * @return static */ - public static function darkseagreen4() + public static function darkseagreen4(): static { return new static(Color::DARKSEAGREEN4); } @@ -2732,9 +2461,8 @@ public static function darkseagreen4() /** * Color green2. * - * @return static */ - public static function green2() + public static function green2(): static { return new static(Color::GREEN2); } @@ -2742,9 +2470,8 @@ public static function green2() /** * Color palegreen4. * - * @return static */ - public static function palegreen4() + public static function palegreen4(): static { return new static(Color::PALEGREEN4); } @@ -2752,9 +2479,8 @@ public static function palegreen4() /** * Color green3. * - * @return static */ - public static function green3() + public static function green3(): static { return new static(Color::GREEN3); } @@ -2762,9 +2488,8 @@ public static function green3() /** * Color forestgreen. * - * @return static */ - public static function forestgreen() + public static function forestgreen(): static { return new static(Color::FORESTGREEN); } @@ -2772,9 +2497,8 @@ public static function forestgreen() /** * Color green4. * - * @return static */ - public static function green4() + public static function green4(): static { return new static(Color::GREEN4); } @@ -2782,9 +2506,8 @@ public static function green4() /** * Color green. * - * @return static */ - public static function green() + public static function green(): static { return new static(Color::GREEN); } @@ -2792,9 +2515,8 @@ public static function green() /** * Color darkgreen. * - * @return static */ - public static function darkgreen() + public static function darkgreen(): static { return new static(Color::DARKGREEN); } @@ -2802,9 +2524,8 @@ public static function darkgreen() /** * Color lawngreen. * - * @return static */ - public static function lawngreen() + public static function lawngreen(): static { return new static(Color::LAWNGREEN); } @@ -2812,9 +2533,8 @@ public static function lawngreen() /** * Color chartreuse. * - * @return static */ - public static function chartreuse() + public static function chartreuse(): static { return new static(Color::CHARTREUSE); } @@ -2822,9 +2542,8 @@ public static function chartreuse() /** * Color chartreuse1. * - * @return static */ - public static function chartreuse1() + public static function chartreuse1(): static { return new static(Color::CHARTREUSE1); } @@ -2832,9 +2551,8 @@ public static function chartreuse1() /** * Color chartreuse2. * - * @return static */ - public static function chartreuse2() + public static function chartreuse2(): static { return new static(Color::CHARTREUSE2); } @@ -2842,9 +2560,8 @@ public static function chartreuse2() /** * Color chartreuse3. * - * @return static */ - public static function chartreuse3() + public static function chartreuse3(): static { return new static(Color::CHARTREUSE3); } @@ -2852,9 +2569,8 @@ public static function chartreuse3() /** * Color chartreuse4. * - * @return static */ - public static function chartreuse4() + public static function chartreuse4(): static { return new static(Color::CHARTREUSE4); } @@ -2862,9 +2578,8 @@ public static function chartreuse4() /** * Color greenyellow. * - * @return static */ - public static function greenyellow() + public static function greenyellow(): static { return new static(Color::GREENYELLOW); } @@ -2872,9 +2587,8 @@ public static function greenyellow() /** * Color darkolivegreen3. * - * @return static */ - public static function darkolivegreen3() + public static function darkolivegreen3(): static { return new static(Color::DARKOLIVEGREEN3); } @@ -2882,9 +2596,8 @@ public static function darkolivegreen3() /** * Color darkolivegreen1. * - * @return static */ - public static function darkolivegreen1() + public static function darkolivegreen1(): static { return new static(Color::DARKOLIVEGREEN1); } @@ -2892,9 +2605,8 @@ public static function darkolivegreen1() /** * Color darkolivegreen2. * - * @return static */ - public static function darkolivegreen2() + public static function darkolivegreen2(): static { return new static(Color::DARKOLIVEGREEN2); } @@ -2902,9 +2614,8 @@ public static function darkolivegreen2() /** * Color darkolivegreen4. * - * @return static */ - public static function darkolivegreen4() + public static function darkolivegreen4(): static { return new static(Color::DARKOLIVEGREEN4); } @@ -2912,9 +2623,8 @@ public static function darkolivegreen4() /** * Color darkolivegreen. * - * @return static */ - public static function darkolivegreen() + public static function darkolivegreen(): static { return new static(Color::DARKOLIVEGREEN); } @@ -2922,9 +2632,8 @@ public static function darkolivegreen() /** * Color olivedrab. * - * @return static */ - public static function olivedrab() + public static function olivedrab(): static { return new static(Color::OLIVEDRAB); } @@ -2932,9 +2641,8 @@ public static function olivedrab() /** * Color olivedrab1. * - * @return static */ - public static function olivedrab1() + public static function olivedrab1(): static { return new static(Color::OLIVEDRAB1); } @@ -2942,9 +2650,8 @@ public static function olivedrab1() /** * Color olivedrab2. * - * @return static */ - public static function olivedrab2() + public static function olivedrab2(): static { return new static(Color::OLIVEDRAB2); } @@ -2952,9 +2659,8 @@ public static function olivedrab2() /** * Color olivedrab3. * - * @return static */ - public static function olivedrab3() + public static function olivedrab3(): static { return new static(Color::OLIVEDRAB3); } @@ -2962,9 +2668,8 @@ public static function olivedrab3() /** * Color yellowgreen. * - * @return static */ - public static function yellowgreen() + public static function yellowgreen(): static { return new static(Color::YELLOWGREEN); } @@ -2972,9 +2677,8 @@ public static function yellowgreen() /** * Color olivedrab4. * - * @return static */ - public static function olivedrab4() + public static function olivedrab4(): static { return new static(Color::OLIVEDRAB4); } @@ -2982,9 +2686,8 @@ public static function olivedrab4() /** * Color ivory. * - * @return static */ - public static function ivory() + public static function ivory(): static { return new static(Color::IVORY); } @@ -2992,9 +2695,8 @@ public static function ivory() /** * Color ivory1. * - * @return static */ - public static function ivory1() + public static function ivory1(): static { return new static(Color::IVORY1); } @@ -3002,9 +2704,8 @@ public static function ivory1() /** * Color lightyellow. * - * @return static */ - public static function lightyellow() + public static function lightyellow(): static { return new static(Color::LIGHTYELLOW); } @@ -3012,9 +2713,8 @@ public static function lightyellow() /** * Color lightyellow1. * - * @return static */ - public static function lightyellow1() + public static function lightyellow1(): static { return new static(Color::LIGHTYELLOW1); } @@ -3022,9 +2722,8 @@ public static function lightyellow1() /** * Color beige. * - * @return static */ - public static function beige() + public static function beige(): static { return new static(Color::BEIGE); } @@ -3032,9 +2731,8 @@ public static function beige() /** * Color ivory2. * - * @return static */ - public static function ivory2() + public static function ivory2(): static { return new static(Color::IVORY2); } @@ -3042,9 +2740,8 @@ public static function ivory2() /** * Color lightgoldenrodyellow. * - * @return static */ - public static function lightgoldenrodyellow() + public static function lightgoldenrodyellow(): static { return new static(Color::LIGHTGOLDENRODYELLOW); } @@ -3052,9 +2749,8 @@ public static function lightgoldenrodyellow() /** * Color lightyellow2. * - * @return static */ - public static function lightyellow2() + public static function lightyellow2(): static { return new static(Color::LIGHTYELLOW2); } @@ -3062,9 +2758,8 @@ public static function lightyellow2() /** * Color ivory3. * - * @return static */ - public static function ivory3() + public static function ivory3(): static { return new static(Color::IVORY3); } @@ -3072,9 +2767,8 @@ public static function ivory3() /** * Color lightyellow3. * - * @return static */ - public static function lightyellow3() + public static function lightyellow3(): static { return new static(Color::LIGHTYELLOW3); } @@ -3082,9 +2776,8 @@ public static function lightyellow3() /** * Color ivory4. * - * @return static */ - public static function ivory4() + public static function ivory4(): static { return new static(Color::IVORY4); } @@ -3092,9 +2785,8 @@ public static function ivory4() /** * Color lightyellow4. * - * @return static */ - public static function lightyellow4() + public static function lightyellow4(): static { return new static(Color::LIGHTYELLOW4); } @@ -3102,9 +2794,8 @@ public static function lightyellow4() /** * Color yellow. * - * @return static */ - public static function yellow() + public static function yellow(): static { return new static(Color::YELLOW); } @@ -3112,9 +2803,8 @@ public static function yellow() /** * Color yellow1. * - * @return static */ - public static function yellow1() + public static function yellow1(): static { return new static(Color::YELLOW1); } @@ -3122,9 +2812,8 @@ public static function yellow1() /** * Color yellow2. * - * @return static */ - public static function yellow2() + public static function yellow2(): static { return new static(Color::YELLOW2); } @@ -3132,9 +2821,8 @@ public static function yellow2() /** * Color yellow3. * - * @return static */ - public static function yellow3() + public static function yellow3(): static { return new static(Color::YELLOW3); } @@ -3142,9 +2830,8 @@ public static function yellow3() /** * Color yellow4. * - * @return static */ - public static function yellow4() + public static function yellow4(): static { return new static(Color::YELLOW4); } @@ -3152,9 +2839,8 @@ public static function yellow4() /** * Color olive. * - * @return static */ - public static function olive() + public static function olive(): static { return new static(Color::OLIVE); } @@ -3162,9 +2848,8 @@ public static function olive() /** * Color darkkhaki. * - * @return static */ - public static function darkkhaki() + public static function darkkhaki(): static { return new static(Color::DARKKHAKI); } @@ -3172,9 +2857,8 @@ public static function darkkhaki() /** * Color khaki2. * - * @return static */ - public static function khaki2() + public static function khaki2(): static { return new static(Color::KHAKI2); } @@ -3182,9 +2866,8 @@ public static function khaki2() /** * Color lemonchiffon4. * - * @return static */ - public static function lemonchiffon4() + public static function lemonchiffon4(): static { return new static(Color::LEMONCHIFFON4); } @@ -3192,9 +2875,8 @@ public static function lemonchiffon4() /** * Color khaki1. * - * @return static */ - public static function khaki1() + public static function khaki1(): static { return new static(Color::KHAKI1); } @@ -3202,9 +2884,8 @@ public static function khaki1() /** * Color khaki3. * - * @return static */ - public static function khaki3() + public static function khaki3(): static { return new static(Color::KHAKI3); } @@ -3212,9 +2893,8 @@ public static function khaki3() /** * Color khaki4. * - * @return static */ - public static function khaki4() + public static function khaki4(): static { return new static(Color::KHAKI4); } @@ -3222,9 +2902,8 @@ public static function khaki4() /** * Color palegoldenrod. * - * @return static */ - public static function palegoldenrod() + public static function palegoldenrod(): static { return new static(Color::PALEGOLDENROD); } @@ -3232,9 +2911,8 @@ public static function palegoldenrod() /** * Color lemonchiffon. * - * @return static */ - public static function lemonchiffon() + public static function lemonchiffon(): static { return new static(Color::LEMONCHIFFON); } @@ -3242,9 +2920,8 @@ public static function lemonchiffon() /** * Color lemonchiffon1. * - * @return static */ - public static function lemonchiffon1() + public static function lemonchiffon1(): static { return new static(Color::LEMONCHIFFON1); } @@ -3252,9 +2929,8 @@ public static function lemonchiffon1() /** * Color khaki. * - * @return static */ - public static function khaki() + public static function khaki(): static { return new static(Color::KHAKI); } @@ -3262,9 +2938,8 @@ public static function khaki() /** * Color lemonchiffon3. * - * @return static */ - public static function lemonchiffon3() + public static function lemonchiffon3(): static { return new static(Color::LEMONCHIFFON3); } @@ -3272,9 +2947,8 @@ public static function lemonchiffon3() /** * Color lemonchiffon2. * - * @return static */ - public static function lemonchiffon2() + public static function lemonchiffon2(): static { return new static(Color::LEMONCHIFFON2); } @@ -3282,9 +2956,8 @@ public static function lemonchiffon2() /** * Color mediumgoldenrod. * - * @return static */ - public static function mediumgoldenrod() + public static function mediumgoldenrod(): static { return new static(Color::MEDIUMGOLDENROD); } @@ -3292,9 +2965,8 @@ public static function mediumgoldenrod() /** * Color cornsilk4. * - * @return static */ - public static function cornsilk4() + public static function cornsilk4(): static { return new static(Color::CORNSILK4); } @@ -3302,9 +2974,8 @@ public static function cornsilk4() /** * Color gold. * - * @return static */ - public static function gold() + public static function gold(): static { return new static(Color::GOLD); } @@ -3312,9 +2983,8 @@ public static function gold() /** * Color gold1. * - * @return static */ - public static function gold1() + public static function gold1(): static { return new static(Color::GOLD1); } @@ -3322,9 +2992,8 @@ public static function gold1() /** * Color gold2. * - * @return static */ - public static function gold2() + public static function gold2(): static { return new static(Color::GOLD2); } @@ -3332,9 +3001,8 @@ public static function gold2() /** * Color gold3. * - * @return static */ - public static function gold3() + public static function gold3(): static { return new static(Color::GOLD3); } @@ -3342,9 +3010,8 @@ public static function gold3() /** * Color gold4. * - * @return static */ - public static function gold4() + public static function gold4(): static { return new static(Color::GOLD4); } @@ -3352,9 +3019,8 @@ public static function gold4() /** * Color lightgoldenrod. * - * @return static */ - public static function lightgoldenrod() + public static function lightgoldenrod(): static { return new static(Color::LIGHTGOLDENROD); } @@ -3362,9 +3028,8 @@ public static function lightgoldenrod() /** * Color lightgoldenrod4. * - * @return static */ - public static function lightgoldenrod4() + public static function lightgoldenrod4(): static { return new static(Color::LIGHTGOLDENROD4); } @@ -3372,9 +3037,8 @@ public static function lightgoldenrod4() /** * Color lightgoldenrod1. * - * @return static */ - public static function lightgoldenrod1() + public static function lightgoldenrod1(): static { return new static(Color::LIGHTGOLDENROD1); } @@ -3382,9 +3046,8 @@ public static function lightgoldenrod1() /** * Color lightgoldenrod3. * - * @return static */ - public static function lightgoldenrod3() + public static function lightgoldenrod3(): static { return new static(Color::LIGHTGOLDENROD3); } @@ -3392,9 +3055,8 @@ public static function lightgoldenrod3() /** * Color lightgoldenrod2. * - * @return static */ - public static function lightgoldenrod2() + public static function lightgoldenrod2(): static { return new static(Color::LIGHTGOLDENROD2); } @@ -3402,9 +3064,8 @@ public static function lightgoldenrod2() /** * Color cornsilk3. * - * @return static */ - public static function cornsilk3() + public static function cornsilk3(): static { return new static(Color::CORNSILK3); } @@ -3412,9 +3073,8 @@ public static function cornsilk3() /** * Color cornsilk2. * - * @return static */ - public static function cornsilk2() + public static function cornsilk2(): static { return new static(Color::CORNSILK2); } @@ -3422,9 +3082,8 @@ public static function cornsilk2() /** * Color cornsilk. * - * @return static */ - public static function cornsilk() + public static function cornsilk(): static { return new static(Color::CORNSILK); } @@ -3432,9 +3091,8 @@ public static function cornsilk() /** * Color cornsilk1. * - * @return static */ - public static function cornsilk1() + public static function cornsilk1(): static { return new static(Color::CORNSILK1); } @@ -3442,9 +3100,8 @@ public static function cornsilk1() /** * Color goldenrod. * - * @return static */ - public static function goldenrod() + public static function goldenrod(): static { return new static(Color::GOLDENROD); } @@ -3452,9 +3109,8 @@ public static function goldenrod() /** * Color goldenrod1. * - * @return static */ - public static function goldenrod1() + public static function goldenrod1(): static { return new static(Color::GOLDENROD1); } @@ -3462,9 +3118,8 @@ public static function goldenrod1() /** * Color goldenrod2. * - * @return static */ - public static function goldenrod2() + public static function goldenrod2(): static { return new static(Color::GOLDENROD2); } @@ -3472,9 +3127,8 @@ public static function goldenrod2() /** * Color goldenrod3. * - * @return static */ - public static function goldenrod3() + public static function goldenrod3(): static { return new static(Color::GOLDENROD3); } @@ -3482,9 +3136,8 @@ public static function goldenrod3() /** * Color goldenrod4. * - * @return static */ - public static function goldenrod4() + public static function goldenrod4(): static { return new static(Color::GOLDENROD4); } @@ -3492,9 +3145,8 @@ public static function goldenrod4() /** * Color darkgoldenrod. * - * @return static */ - public static function darkgoldenrod() + public static function darkgoldenrod(): static { return new static(Color::DARKGOLDENROD); } @@ -3502,9 +3154,8 @@ public static function darkgoldenrod() /** * Color darkgoldenrod1. * - * @return static */ - public static function darkgoldenrod1() + public static function darkgoldenrod1(): static { return new static(Color::DARKGOLDENROD1); } @@ -3512,9 +3163,8 @@ public static function darkgoldenrod1() /** * Color darkgoldenrod2. * - * @return static */ - public static function darkgoldenrod2() + public static function darkgoldenrod2(): static { return new static(Color::DARKGOLDENROD2); } @@ -3522,9 +3172,8 @@ public static function darkgoldenrod2() /** * Color darkgoldenrod3. * - * @return static */ - public static function darkgoldenrod3() + public static function darkgoldenrod3(): static { return new static(Color::DARKGOLDENROD3); } @@ -3532,9 +3181,8 @@ public static function darkgoldenrod3() /** * Color darkgoldenrod4. * - * @return static */ - public static function darkgoldenrod4() + public static function darkgoldenrod4(): static { return new static(Color::DARKGOLDENROD4); } @@ -3542,9 +3190,8 @@ public static function darkgoldenrod4() /** * Color floralwhite. * - * @return static */ - public static function floralwhite() + public static function floralwhite(): static { return new static(Color::FLORALWHITE); } @@ -3552,9 +3199,8 @@ public static function floralwhite() /** * Color wheat2. * - * @return static */ - public static function wheat2() + public static function wheat2(): static { return new static(Color::WHEAT2); } @@ -3562,9 +3208,8 @@ public static function wheat2() /** * Color oldlace. * - * @return static */ - public static function oldlace() + public static function oldlace(): static { return new static(Color::OLDLACE); } @@ -3572,9 +3217,8 @@ public static function oldlace() /** * Color wheat. * - * @return static */ - public static function wheat() + public static function wheat(): static { return new static(Color::WHEAT); } @@ -3582,9 +3226,8 @@ public static function wheat() /** * Color wheat1. * - * @return static */ - public static function wheat1() + public static function wheat1(): static { return new static(Color::WHEAT1); } @@ -3592,9 +3235,8 @@ public static function wheat1() /** * Color wheat3. * - * @return static */ - public static function wheat3() + public static function wheat3(): static { return new static(Color::WHEAT3); } @@ -3602,9 +3244,8 @@ public static function wheat3() /** * Color orange. * - * @return static */ - public static function orange() + public static function orange(): static { return new static(Color::ORANGE); } @@ -3612,9 +3253,8 @@ public static function orange() /** * Color orange1. * - * @return static */ - public static function orange1() + public static function orange1(): static { return new static(Color::ORANGE1); } @@ -3622,9 +3262,8 @@ public static function orange1() /** * Color orange2. * - * @return static */ - public static function orange2() + public static function orange2(): static { return new static(Color::ORANGE2); } @@ -3632,9 +3271,8 @@ public static function orange2() /** * Color orange3. * - * @return static */ - public static function orange3() + public static function orange3(): static { return new static(Color::ORANGE3); } @@ -3642,9 +3280,8 @@ public static function orange3() /** * Color orange4. * - * @return static */ - public static function orange4() + public static function orange4(): static { return new static(Color::ORANGE4); } @@ -3652,9 +3289,8 @@ public static function orange4() /** * Color wheat4. * - * @return static */ - public static function wheat4() + public static function wheat4(): static { return new static(Color::WHEAT4); } @@ -3662,9 +3298,8 @@ public static function wheat4() /** * Color moccasin. * - * @return static */ - public static function moccasin() + public static function moccasin(): static { return new static(Color::MOCCASIN); } @@ -3672,9 +3307,8 @@ public static function moccasin() /** * Color papayawhip. * - * @return static */ - public static function papayawhip() + public static function papayawhip(): static { return new static(Color::PAPAYAWHIP); } @@ -3682,9 +3316,8 @@ public static function papayawhip() /** * Color navajowhite3. * - * @return static */ - public static function navajowhite3() + public static function navajowhite3(): static { return new static(Color::NAVAJOWHITE3); } @@ -3692,9 +3325,8 @@ public static function navajowhite3() /** * Color blanchedalmond. * - * @return static */ - public static function blanchedalmond() + public static function blanchedalmond(): static { return new static(Color::BLANCHEDALMOND); } @@ -3702,9 +3334,8 @@ public static function blanchedalmond() /** * Color navajowhite. * - * @return static */ - public static function navajowhite() + public static function navajowhite(): static { return new static(Color::NAVAJOWHITE); } @@ -3712,9 +3343,8 @@ public static function navajowhite() /** * Color navajowhite1. * - * @return static */ - public static function navajowhite1() + public static function navajowhite1(): static { return new static(Color::NAVAJOWHITE1); } @@ -3722,9 +3352,8 @@ public static function navajowhite1() /** * Color navajowhite2. * - * @return static */ - public static function navajowhite2() + public static function navajowhite2(): static { return new static(Color::NAVAJOWHITE2); } @@ -3732,9 +3361,8 @@ public static function navajowhite2() /** * Color navajowhite4. * - * @return static */ - public static function navajowhite4() + public static function navajowhite4(): static { return new static(Color::NAVAJOWHITE4); } @@ -3742,9 +3370,8 @@ public static function navajowhite4() /** * Color antiquewhite4. * - * @return static */ - public static function antiquewhite4() + public static function antiquewhite4(): static { return new static(Color::ANTIQUEWHITE4); } @@ -3752,9 +3379,8 @@ public static function antiquewhite4() /** * Color antiquewhite. * - * @return static */ - public static function antiquewhite() + public static function antiquewhite(): static { return new static(Color::ANTIQUEWHITE); } @@ -3762,9 +3388,8 @@ public static function antiquewhite() /** * Color tan. * - * @return static */ - public static function tan() + public static function tan(): static { return new static(Color::TAN); } @@ -3772,9 +3397,8 @@ public static function tan() /** * Color bisque4. * - * @return static */ - public static function bisque4() + public static function bisque4(): static { return new static(Color::BISQUE4); } @@ -3782,9 +3406,8 @@ public static function bisque4() /** * Color burlywood. * - * @return static */ - public static function burlywood() + public static function burlywood(): static { return new static(Color::BURLYWOOD); } @@ -3792,9 +3415,8 @@ public static function burlywood() /** * Color antiquewhite2. * - * @return static */ - public static function antiquewhite2() + public static function antiquewhite2(): static { return new static(Color::ANTIQUEWHITE2); } @@ -3802,9 +3424,8 @@ public static function antiquewhite2() /** * Color burlywood1. * - * @return static */ - public static function burlywood1() + public static function burlywood1(): static { return new static(Color::BURLYWOOD1); } @@ -3812,9 +3433,8 @@ public static function burlywood1() /** * Color burlywood3. * - * @return static */ - public static function burlywood3() + public static function burlywood3(): static { return new static(Color::BURLYWOOD3); } @@ -3822,9 +3442,8 @@ public static function burlywood3() /** * Color burlywood2. * - * @return static */ - public static function burlywood2() + public static function burlywood2(): static { return new static(Color::BURLYWOOD2); } @@ -3832,9 +3451,8 @@ public static function burlywood2() /** * Color antiquewhite1. * - * @return static */ - public static function antiquewhite1() + public static function antiquewhite1(): static { return new static(Color::ANTIQUEWHITE1); } @@ -3842,9 +3460,8 @@ public static function antiquewhite1() /** * Color burlywood4. * - * @return static */ - public static function burlywood4() + public static function burlywood4(): static { return new static(Color::BURLYWOOD4); } @@ -3852,9 +3469,8 @@ public static function burlywood4() /** * Color antiquewhite3. * - * @return static */ - public static function antiquewhite3() + public static function antiquewhite3(): static { return new static(Color::ANTIQUEWHITE3); } @@ -3862,9 +3478,8 @@ public static function antiquewhite3() /** * Color darkorange. * - * @return static */ - public static function darkorange() + public static function darkorange(): static { return new static(Color::DARKORANGE); } @@ -3872,9 +3487,8 @@ public static function darkorange() /** * Color bisque2. * - * @return static */ - public static function bisque2() + public static function bisque2(): static { return new static(Color::BISQUE2); } @@ -3882,9 +3496,8 @@ public static function bisque2() /** * Color bisque. * - * @return static */ - public static function bisque() + public static function bisque(): static { return new static(Color::BISQUE); } @@ -3892,9 +3505,8 @@ public static function bisque() /** * Color bisque1. * - * @return static */ - public static function bisque1() + public static function bisque1(): static { return new static(Color::BISQUE1); } @@ -3902,9 +3514,8 @@ public static function bisque1() /** * Color bisque3. * - * @return static */ - public static function bisque3() + public static function bisque3(): static { return new static(Color::BISQUE3); } @@ -3912,9 +3523,8 @@ public static function bisque3() /** * Color darkorange1. * - * @return static */ - public static function darkorange1() + public static function darkorange1(): static { return new static(Color::DARKORANGE1); } @@ -3922,9 +3532,8 @@ public static function darkorange1() /** * Color linen. * - * @return static */ - public static function linen() + public static function linen(): static { return new static(Color::LINEN); } @@ -3932,9 +3541,8 @@ public static function linen() /** * Color darkorange2. * - * @return static */ - public static function darkorange2() + public static function darkorange2(): static { return new static(Color::DARKORANGE2); } @@ -3942,9 +3550,8 @@ public static function darkorange2() /** * Color darkorange3. * - * @return static */ - public static function darkorange3() + public static function darkorange3(): static { return new static(Color::DARKORANGE3); } @@ -3952,9 +3559,8 @@ public static function darkorange3() /** * Color darkorange4. * - * @return static */ - public static function darkorange4() + public static function darkorange4(): static { return new static(Color::DARKORANGE4); } @@ -3962,9 +3568,8 @@ public static function darkorange4() /** * Color peru. * - * @return static */ - public static function peru() + public static function peru(): static { return new static(Color::PERU); } @@ -3972,9 +3577,8 @@ public static function peru() /** * Color tan1. * - * @return static */ - public static function tan1() + public static function tan1(): static { return new static(Color::TAN1); } @@ -3982,9 +3586,8 @@ public static function tan1() /** * Color tan2. * - * @return static */ - public static function tan2() + public static function tan2(): static { return new static(Color::TAN2); } @@ -3992,9 +3595,8 @@ public static function tan2() /** * Color tan3. * - * @return static */ - public static function tan3() + public static function tan3(): static { return new static(Color::TAN3); } @@ -4002,9 +3604,8 @@ public static function tan3() /** * Color tan4. * - * @return static */ - public static function tan4() + public static function tan4(): static { return new static(Color::TAN4); } @@ -4012,9 +3613,8 @@ public static function tan4() /** * Color peachpuff. * - * @return static */ - public static function peachpuff() + public static function peachpuff(): static { return new static(Color::PEACHPUFF); } @@ -4022,9 +3622,8 @@ public static function peachpuff() /** * Color peachpuff1. * - * @return static */ - public static function peachpuff1() + public static function peachpuff1(): static { return new static(Color::PEACHPUFF1); } @@ -4032,9 +3631,8 @@ public static function peachpuff1() /** * Color peachpuff4. * - * @return static */ - public static function peachpuff4() + public static function peachpuff4(): static { return new static(Color::PEACHPUFF4); } @@ -4042,9 +3640,8 @@ public static function peachpuff4() /** * Color peachpuff2. * - * @return static */ - public static function peachpuff2() + public static function peachpuff2(): static { return new static(Color::PEACHPUFF2); } @@ -4052,9 +3649,8 @@ public static function peachpuff2() /** * Color peachpuff3. * - * @return static */ - public static function peachpuff3() + public static function peachpuff3(): static { return new static(Color::PEACHPUFF3); } @@ -4062,9 +3658,8 @@ public static function peachpuff3() /** * Color sandybrown. * - * @return static */ - public static function sandybrown() + public static function sandybrown(): static { return new static(Color::SANDYBROWN); } @@ -4072,9 +3667,8 @@ public static function sandybrown() /** * Color seashell4. * - * @return static */ - public static function seashell4() + public static function seashell4(): static { return new static(Color::SEASHELL4); } @@ -4082,9 +3676,8 @@ public static function seashell4() /** * Color seashell2. * - * @return static */ - public static function seashell2() + public static function seashell2(): static { return new static(Color::SEASHELL2); } @@ -4092,9 +3685,8 @@ public static function seashell2() /** * Color seashell3. * - * @return static */ - public static function seashell3() + public static function seashell3(): static { return new static(Color::SEASHELL3); } @@ -4102,9 +3694,8 @@ public static function seashell3() /** * Color chocolate. * - * @return static */ - public static function chocolate() + public static function chocolate(): static { return new static(Color::CHOCOLATE); } @@ -4112,9 +3703,8 @@ public static function chocolate() /** * Color chocolate1. * - * @return static */ - public static function chocolate1() + public static function chocolate1(): static { return new static(Color::CHOCOLATE1); } @@ -4122,9 +3712,8 @@ public static function chocolate1() /** * Color chocolate2. * - * @return static */ - public static function chocolate2() + public static function chocolate2(): static { return new static(Color::CHOCOLATE2); } @@ -4132,9 +3721,8 @@ public static function chocolate2() /** * Color chocolate3. * - * @return static */ - public static function chocolate3() + public static function chocolate3(): static { return new static(Color::CHOCOLATE3); } @@ -4142,9 +3730,8 @@ public static function chocolate3() /** * Color chocolate4. * - * @return static */ - public static function chocolate4() + public static function chocolate4(): static { return new static(Color::CHOCOLATE4); } @@ -4152,9 +3739,8 @@ public static function chocolate4() /** * Color saddlebrown. * - * @return static */ - public static function saddlebrown() + public static function saddlebrown(): static { return new static(Color::SADDLEBROWN); } @@ -4162,9 +3748,8 @@ public static function saddlebrown() /** * Color seashell. * - * @return static */ - public static function seashell() + public static function seashell(): static { return new static(Color::SEASHELL); } @@ -4172,9 +3757,8 @@ public static function seashell() /** * Color seashell1. * - * @return static */ - public static function seashell1() + public static function seashell1(): static { return new static(Color::SEASHELL1); } @@ -4182,9 +3766,8 @@ public static function seashell1() /** * Color sienna4. * - * @return static */ - public static function sienna4() + public static function sienna4(): static { return new static(Color::SIENNA4); } @@ -4192,9 +3775,8 @@ public static function sienna4() /** * Color sienna. * - * @return static */ - public static function sienna() + public static function sienna(): static { return new static(Color::SIENNA); } @@ -4202,9 +3784,8 @@ public static function sienna() /** * Color sienna1. * - * @return static */ - public static function sienna1() + public static function sienna1(): static { return new static(Color::SIENNA1); } @@ -4212,9 +3793,8 @@ public static function sienna1() /** * Color sienna2. * - * @return static */ - public static function sienna2() + public static function sienna2(): static { return new static(Color::SIENNA2); } @@ -4222,9 +3802,8 @@ public static function sienna2() /** * Color sienna3. * - * @return static */ - public static function sienna3() + public static function sienna3(): static { return new static(Color::SIENNA3); } @@ -4232,9 +3811,8 @@ public static function sienna3() /** * Color lightsalmon3. * - * @return static */ - public static function lightsalmon3() + public static function lightsalmon3(): static { return new static(Color::LIGHTSALMON3); } @@ -4242,9 +3820,8 @@ public static function lightsalmon3() /** * Color lightsalmon. * - * @return static */ - public static function lightsalmon() + public static function lightsalmon(): static { return new static(Color::LIGHTSALMON); } @@ -4252,9 +3829,8 @@ public static function lightsalmon() /** * Color lightsalmon1. * - * @return static */ - public static function lightsalmon1() + public static function lightsalmon1(): static { return new static(Color::LIGHTSALMON1); } @@ -4262,9 +3838,8 @@ public static function lightsalmon1() /** * Color lightsalmon4. * - * @return static */ - public static function lightsalmon4() + public static function lightsalmon4(): static { return new static(Color::LIGHTSALMON4); } @@ -4272,9 +3847,8 @@ public static function lightsalmon4() /** * Color lightsalmon2. * - * @return static */ - public static function lightsalmon2() + public static function lightsalmon2(): static { return new static(Color::LIGHTSALMON2); } @@ -4282,9 +3856,8 @@ public static function lightsalmon2() /** * Color coral. * - * @return static */ - public static function coral() + public static function coral(): static { return new static(Color::CORAL); } @@ -4292,9 +3865,8 @@ public static function coral() /** * Color orangered. * - * @return static */ - public static function orangered() + public static function orangered(): static { return new static(Color::ORANGERED); } @@ -4302,9 +3874,8 @@ public static function orangered() /** * Color orangered1. * - * @return static */ - public static function orangered1() + public static function orangered1(): static { return new static(Color::ORANGERED1); } @@ -4312,9 +3883,8 @@ public static function orangered1() /** * Color orangered2. * - * @return static */ - public static function orangered2() + public static function orangered2(): static { return new static(Color::ORANGERED2); } @@ -4322,9 +3892,8 @@ public static function orangered2() /** * Color orangered3. * - * @return static */ - public static function orangered3() + public static function orangered3(): static { return new static(Color::ORANGERED3); } @@ -4332,9 +3901,8 @@ public static function orangered3() /** * Color orangered4. * - * @return static */ - public static function orangered4() + public static function orangered4(): static { return new static(Color::ORANGERED4); } @@ -4342,9 +3910,8 @@ public static function orangered4() /** * Color darksalmon. * - * @return static */ - public static function darksalmon() + public static function darksalmon(): static { return new static(Color::DARKSALMON); } @@ -4352,9 +3919,8 @@ public static function darksalmon() /** * Color salmon1. * - * @return static */ - public static function salmon1() + public static function salmon1(): static { return new static(Color::SALMON1); } @@ -4362,9 +3928,8 @@ public static function salmon1() /** * Color salmon2. * - * @return static */ - public static function salmon2() + public static function salmon2(): static { return new static(Color::SALMON2); } @@ -4372,9 +3937,8 @@ public static function salmon2() /** * Color salmon3. * - * @return static */ - public static function salmon3() + public static function salmon3(): static { return new static(Color::SALMON3); } @@ -4382,9 +3946,8 @@ public static function salmon3() /** * Color salmon4. * - * @return static */ - public static function salmon4() + public static function salmon4(): static { return new static(Color::SALMON4); } @@ -4392,9 +3955,8 @@ public static function salmon4() /** * Color coral1. * - * @return static */ - public static function coral1() + public static function coral1(): static { return new static(Color::CORAL1); } @@ -4402,9 +3964,8 @@ public static function coral1() /** * Color coral2. * - * @return static */ - public static function coral2() + public static function coral2(): static { return new static(Color::CORAL2); } @@ -4412,9 +3973,8 @@ public static function coral2() /** * Color coral3. * - * @return static */ - public static function coral3() + public static function coral3(): static { return new static(Color::CORAL3); } @@ -4422,9 +3982,8 @@ public static function coral3() /** * Color coral4. * - * @return static */ - public static function coral4() + public static function coral4(): static { return new static(Color::CORAL4); } @@ -4432,9 +3991,8 @@ public static function coral4() /** * Color tomato4. * - * @return static */ - public static function tomato4() + public static function tomato4(): static { return new static(Color::TOMATO4); } @@ -4442,9 +4000,8 @@ public static function tomato4() /** * Color tomato. * - * @return static */ - public static function tomato() + public static function tomato(): static { return new static(Color::TOMATO); } @@ -4452,9 +4009,8 @@ public static function tomato() /** * Color tomato1. * - * @return static */ - public static function tomato1() + public static function tomato1(): static { return new static(Color::TOMATO1); } @@ -4462,9 +4018,8 @@ public static function tomato1() /** * Color tomato2. * - * @return static */ - public static function tomato2() + public static function tomato2(): static { return new static(Color::TOMATO2); } @@ -4472,9 +4027,8 @@ public static function tomato2() /** * Color tomato3. * - * @return static */ - public static function tomato3() + public static function tomato3(): static { return new static(Color::TOMATO3); } @@ -4482,9 +4036,8 @@ public static function tomato3() /** * Color mistyrose4. * - * @return static */ - public static function mistyrose4() + public static function mistyrose4(): static { return new static(Color::MISTYROSE4); } @@ -4492,9 +4045,8 @@ public static function mistyrose4() /** * Color mistyrose2. * - * @return static */ - public static function mistyrose2() + public static function mistyrose2(): static { return new static(Color::MISTYROSE2); } @@ -4502,9 +4054,8 @@ public static function mistyrose2() /** * Color mistyrose. * - * @return static */ - public static function mistyrose() + public static function mistyrose(): static { return new static(Color::MISTYROSE); } @@ -4512,9 +4063,8 @@ public static function mistyrose() /** * Color mistyrose1. * - * @return static */ - public static function mistyrose1() + public static function mistyrose1(): static { return new static(Color::MISTYROSE1); } @@ -4522,9 +4072,8 @@ public static function mistyrose1() /** * Color salmon. * - * @return static */ - public static function salmon() + public static function salmon(): static { return new static(Color::SALMON); } @@ -4532,9 +4081,8 @@ public static function salmon() /** * Color mistyrose3. * - * @return static */ - public static function mistyrose3() + public static function mistyrose3(): static { return new static(Color::MISTYROSE3); } @@ -4542,9 +4090,8 @@ public static function mistyrose3() /** * Color white. * - * @return static */ - public static function white() + public static function white(): static { return new static(Color::WHITE); } @@ -4552,9 +4099,8 @@ public static function white() /** * Color gray100. * - * @return static */ - public static function gray100() + public static function gray100(): static { return new static(Color::GRAY100); } @@ -4562,9 +4108,8 @@ public static function gray100() /** * Color grey100. * - * @return static */ - public static function grey100() + public static function grey100(): static { return new static(Color::GREY100); } @@ -4572,9 +4117,8 @@ public static function grey100() /** * Color gray99. * - * @return static */ - public static function gray99() + public static function gray99(): static { return new static(Color::GRAY99); } @@ -4582,9 +4126,8 @@ public static function gray99() /** * Color grey99. * - * @return static */ - public static function grey99() + public static function grey99(): static { return new static(Color::GREY99); } @@ -4592,9 +4135,8 @@ public static function grey99() /** * Color gray98. * - * @return static */ - public static function gray98() + public static function gray98(): static { return new static(Color::GRAY98); } @@ -4602,9 +4144,8 @@ public static function gray98() /** * Color grey98. * - * @return static */ - public static function grey98() + public static function grey98(): static { return new static(Color::GREY98); } @@ -4612,9 +4153,8 @@ public static function grey98() /** * Color gray97. * - * @return static */ - public static function gray97() + public static function gray97(): static { return new static(Color::GRAY97); } @@ -4622,9 +4162,8 @@ public static function gray97() /** * Color grey97. * - * @return static */ - public static function grey97() + public static function grey97(): static { return new static(Color::GREY97); } @@ -4632,9 +4171,8 @@ public static function grey97() /** * Color gray96. * - * @return static */ - public static function gray96() + public static function gray96(): static { return new static(Color::GRAY96); } @@ -4642,9 +4180,8 @@ public static function gray96() /** * Color grey96. * - * @return static */ - public static function grey96() + public static function grey96(): static { return new static(Color::GREY96); } @@ -4652,9 +4189,8 @@ public static function grey96() /** * Color whitesmoke. * - * @return static */ - public static function whitesmoke() + public static function whitesmoke(): static { return new static(Color::WHITESMOKE); } @@ -4662,9 +4198,8 @@ public static function whitesmoke() /** * Color gray95. * - * @return static */ - public static function gray95() + public static function gray95(): static { return new static(Color::GRAY95); } @@ -4672,9 +4207,8 @@ public static function gray95() /** * Color grey95. * - * @return static */ - public static function grey95() + public static function grey95(): static { return new static(Color::GREY95); } @@ -4682,9 +4216,8 @@ public static function grey95() /** * Color gray94. * - * @return static */ - public static function gray94() + public static function gray94(): static { return new static(Color::GRAY94); } @@ -4692,9 +4225,8 @@ public static function gray94() /** * Color grey94. * - * @return static */ - public static function grey94() + public static function grey94(): static { return new static(Color::GREY94); } @@ -4702,9 +4234,8 @@ public static function grey94() /** * Color gray93. * - * @return static */ - public static function gray93() + public static function gray93(): static { return new static(Color::GRAY93); } @@ -4712,9 +4243,8 @@ public static function gray93() /** * Color grey93. * - * @return static */ - public static function grey93() + public static function grey93(): static { return new static(Color::GREY93); } @@ -4722,9 +4252,8 @@ public static function grey93() /** * Color gray92. * - * @return static */ - public static function gray92() + public static function gray92(): static { return new static(Color::GRAY92); } @@ -4732,9 +4261,8 @@ public static function gray92() /** * Color grey92. * - * @return static */ - public static function grey92() + public static function grey92(): static { return new static(Color::GREY92); } @@ -4742,9 +4270,8 @@ public static function grey92() /** * Color gray91. * - * @return static */ - public static function gray91() + public static function gray91(): static { return new static(Color::GRAY91); } @@ -4752,9 +4279,8 @@ public static function gray91() /** * Color grey91. * - * @return static */ - public static function grey91() + public static function grey91(): static { return new static(Color::GREY91); } @@ -4762,9 +4288,8 @@ public static function grey91() /** * Color gray90. * - * @return static */ - public static function gray90() + public static function gray90(): static { return new static(Color::GRAY90); } @@ -4772,9 +4297,8 @@ public static function gray90() /** * Color grey90. * - * @return static */ - public static function grey90() + public static function grey90(): static { return new static(Color::GREY90); } @@ -4782,9 +4306,8 @@ public static function grey90() /** * Color gray89. * - * @return static */ - public static function gray89() + public static function gray89(): static { return new static(Color::GRAY89); } @@ -4792,9 +4315,8 @@ public static function gray89() /** * Color grey89. * - * @return static */ - public static function grey89() + public static function grey89(): static { return new static(Color::GREY89); } @@ -4802,9 +4324,8 @@ public static function grey89() /** * Color gray88. * - * @return static */ - public static function gray88() + public static function gray88(): static { return new static(Color::GRAY88); } @@ -4812,9 +4333,8 @@ public static function gray88() /** * Color grey88. * - * @return static */ - public static function grey88() + public static function grey88(): static { return new static(Color::GREY88); } @@ -4822,9 +4342,8 @@ public static function grey88() /** * Color gray87. * - * @return static */ - public static function gray87() + public static function gray87(): static { return new static(Color::GRAY87); } @@ -4832,9 +4351,8 @@ public static function gray87() /** * Color grey87. * - * @return static */ - public static function grey87() + public static function grey87(): static { return new static(Color::GREY87); } @@ -4842,9 +4360,8 @@ public static function grey87() /** * Color gainsboro. * - * @return static */ - public static function gainsboro() + public static function gainsboro(): static { return new static(Color::GAINSBORO); } @@ -4852,9 +4369,8 @@ public static function gainsboro() /** * Color gray86. * - * @return static */ - public static function gray86() + public static function gray86(): static { return new static(Color::GRAY86); } @@ -4862,9 +4378,8 @@ public static function gray86() /** * Color grey86. * - * @return static */ - public static function grey86() + public static function grey86(): static { return new static(Color::GREY86); } @@ -4872,9 +4387,8 @@ public static function grey86() /** * Color gray85. * - * @return static */ - public static function gray85() + public static function gray85(): static { return new static(Color::GRAY85); } @@ -4882,9 +4396,8 @@ public static function gray85() /** * Color grey85. * - * @return static */ - public static function grey85() + public static function grey85(): static { return new static(Color::GREY85); } @@ -4892,9 +4405,8 @@ public static function grey85() /** * Color gray84. * - * @return static */ - public static function gray84() + public static function gray84(): static { return new static(Color::GRAY84); } @@ -4902,9 +4414,8 @@ public static function gray84() /** * Color grey84. * - * @return static */ - public static function grey84() + public static function grey84(): static { return new static(Color::GREY84); } @@ -4912,9 +4423,8 @@ public static function grey84() /** * Color gray83. * - * @return static */ - public static function gray83() + public static function gray83(): static { return new static(Color::GRAY83); } @@ -4922,9 +4432,8 @@ public static function gray83() /** * Color grey83. * - * @return static */ - public static function grey83() + public static function grey83(): static { return new static(Color::GREY83); } @@ -4932,9 +4441,8 @@ public static function grey83() /** * Color lightgray. * - * @return static */ - public static function lightgray() + public static function lightgray(): static { return new static(Color::LIGHTGRAY); } @@ -4942,9 +4450,8 @@ public static function lightgray() /** * Color lightgrey. * - * @return static */ - public static function lightgrey() + public static function lightgrey(): static { return new static(Color::LIGHTGREY); } @@ -4952,9 +4459,8 @@ public static function lightgrey() /** * Color gray82. * - * @return static */ - public static function gray82() + public static function gray82(): static { return new static(Color::GRAY82); } @@ -4962,9 +4468,8 @@ public static function gray82() /** * Color grey82. * - * @return static */ - public static function grey82() + public static function grey82(): static { return new static(Color::GREY82); } @@ -4972,9 +4477,8 @@ public static function grey82() /** * Color gray81. * - * @return static */ - public static function gray81() + public static function gray81(): static { return new static(Color::GRAY81); } @@ -4982,9 +4486,8 @@ public static function gray81() /** * Color grey81. * - * @return static */ - public static function grey81() + public static function grey81(): static { return new static(Color::GREY81); } @@ -4992,9 +4495,8 @@ public static function grey81() /** * Color gray80. * - * @return static */ - public static function gray80() + public static function gray80(): static { return new static(Color::GRAY80); } @@ -5002,9 +4504,8 @@ public static function gray80() /** * Color grey80. * - * @return static */ - public static function grey80() + public static function grey80(): static { return new static(Color::GREY80); } @@ -5012,9 +4513,8 @@ public static function grey80() /** * Color gray79. * - * @return static */ - public static function gray79() + public static function gray79(): static { return new static(Color::GRAY79); } @@ -5022,9 +4522,8 @@ public static function gray79() /** * Color grey79. * - * @return static */ - public static function grey79() + public static function grey79(): static { return new static(Color::GREY79); } @@ -5032,9 +4531,8 @@ public static function grey79() /** * Color gray78. * - * @return static */ - public static function gray78() + public static function gray78(): static { return new static(Color::GRAY78); } @@ -5042,9 +4540,8 @@ public static function gray78() /** * Color grey78. * - * @return static */ - public static function grey78() + public static function grey78(): static { return new static(Color::GREY78); } @@ -5052,9 +4549,8 @@ public static function grey78() /** * Color gray77. * - * @return static */ - public static function gray77() + public static function gray77(): static { return new static(Color::GRAY77); } @@ -5062,9 +4558,8 @@ public static function gray77() /** * Color grey77. * - * @return static */ - public static function grey77() + public static function grey77(): static { return new static(Color::GREY77); } @@ -5072,9 +4567,8 @@ public static function grey77() /** * Color gray76. * - * @return static */ - public static function gray76() + public static function gray76(): static { return new static(Color::GRAY76); } @@ -5082,9 +4576,8 @@ public static function gray76() /** * Color grey76. * - * @return static */ - public static function grey76() + public static function grey76(): static { return new static(Color::GREY76); } @@ -5092,9 +4585,8 @@ public static function grey76() /** * Color silver. * - * @return static */ - public static function silver() + public static function silver(): static { return new static(Color::SILVER); } @@ -5102,9 +4594,8 @@ public static function silver() /** * Color gray75. * - * @return static */ - public static function gray75() + public static function gray75(): static { return new static(Color::GRAY75); } @@ -5112,9 +4603,8 @@ public static function gray75() /** * Color grey75. * - * @return static */ - public static function grey75() + public static function grey75(): static { return new static(Color::GREY75); } @@ -5122,9 +4612,8 @@ public static function grey75() /** * Color gray74. * - * @return static */ - public static function gray74() + public static function gray74(): static { return new static(Color::GRAY74); } @@ -5132,9 +4621,8 @@ public static function gray74() /** * Color grey74. * - * @return static */ - public static function grey74() + public static function grey74(): static { return new static(Color::GREY74); } @@ -5142,9 +4630,8 @@ public static function grey74() /** * Color gray73. * - * @return static */ - public static function gray73() + public static function gray73(): static { return new static(Color::GRAY73); } @@ -5152,9 +4639,8 @@ public static function gray73() /** * Color grey73. * - * @return static */ - public static function grey73() + public static function grey73(): static { return new static(Color::GREY73); } @@ -5162,9 +4648,8 @@ public static function grey73() /** * Color gray72. * - * @return static */ - public static function gray72() + public static function gray72(): static { return new static(Color::GRAY72); } @@ -5172,9 +4657,8 @@ public static function gray72() /** * Color grey72. * - * @return static */ - public static function grey72() + public static function grey72(): static { return new static(Color::GREY72); } @@ -5182,9 +4666,8 @@ public static function grey72() /** * Color gray71. * - * @return static */ - public static function gray71() + public static function gray71(): static { return new static(Color::GRAY71); } @@ -5192,9 +4675,8 @@ public static function gray71() /** * Color grey71. * - * @return static */ - public static function grey71() + public static function grey71(): static { return new static(Color::GREY71); } @@ -5202,9 +4684,8 @@ public static function grey71() /** * Color gray70. * - * @return static */ - public static function gray70() + public static function gray70(): static { return new static(Color::GRAY70); } @@ -5212,9 +4693,8 @@ public static function gray70() /** * Color grey70. * - * @return static */ - public static function grey70() + public static function grey70(): static { return new static(Color::GREY70); } @@ -5222,9 +4702,8 @@ public static function grey70() /** * Color gray69. * - * @return static */ - public static function gray69() + public static function gray69(): static { return new static(Color::GRAY69); } @@ -5232,9 +4711,8 @@ public static function gray69() /** * Color grey69. * - * @return static */ - public static function grey69() + public static function grey69(): static { return new static(Color::GREY69); } @@ -5242,9 +4720,8 @@ public static function grey69() /** * Color gray68. * - * @return static */ - public static function gray68() + public static function gray68(): static { return new static(Color::GRAY68); } @@ -5252,9 +4729,8 @@ public static function gray68() /** * Color grey68. * - * @return static */ - public static function grey68() + public static function grey68(): static { return new static(Color::GREY68); } @@ -5262,9 +4738,8 @@ public static function grey68() /** * Color gray67. * - * @return static */ - public static function gray67() + public static function gray67(): static { return new static(Color::GRAY67); } @@ -5272,9 +4747,8 @@ public static function gray67() /** * Color grey67. * - * @return static */ - public static function grey67() + public static function grey67(): static { return new static(Color::GREY67); } @@ -5282,9 +4756,8 @@ public static function grey67() /** * Color darkgray. * - * @return static */ - public static function darkgray() + public static function darkgray(): static { return new static(Color::DARKGRAY); } @@ -5292,9 +4765,8 @@ public static function darkgray() /** * Color darkgrey. * - * @return static */ - public static function darkgrey() + public static function darkgrey(): static { return new static(Color::DARKGREY); } @@ -5302,9 +4774,8 @@ public static function darkgrey() /** * Color gray66. * - * @return static */ - public static function gray66() + public static function gray66(): static { return new static(Color::GRAY66); } @@ -5312,9 +4783,8 @@ public static function gray66() /** * Color grey66. * - * @return static */ - public static function grey66() + public static function grey66(): static { return new static(Color::GREY66); } @@ -5322,9 +4792,8 @@ public static function grey66() /** * Color gray65. * - * @return static */ - public static function gray65() + public static function gray65(): static { return new static(Color::GRAY65); } @@ -5332,9 +4801,8 @@ public static function gray65() /** * Color grey65. * - * @return static */ - public static function grey65() + public static function grey65(): static { return new static(Color::GREY65); } @@ -5342,9 +4810,8 @@ public static function grey65() /** * Color gray64. * - * @return static */ - public static function gray64() + public static function gray64(): static { return new static(Color::GRAY64); } @@ -5352,9 +4819,8 @@ public static function gray64() /** * Color grey64. * - * @return static */ - public static function grey64() + public static function grey64(): static { return new static(Color::GREY64); } @@ -5362,9 +4828,8 @@ public static function grey64() /** * Color gray63. * - * @return static */ - public static function gray63() + public static function gray63(): static { return new static(Color::GRAY63); } @@ -5372,9 +4837,8 @@ public static function gray63() /** * Color grey63. * - * @return static */ - public static function grey63() + public static function grey63(): static { return new static(Color::GREY63); } @@ -5382,9 +4846,8 @@ public static function grey63() /** * Color gray62. * - * @return static */ - public static function gray62() + public static function gray62(): static { return new static(Color::GRAY62); } @@ -5392,9 +4855,8 @@ public static function gray62() /** * Color grey62. * - * @return static */ - public static function grey62() + public static function grey62(): static { return new static(Color::GREY62); } @@ -5402,9 +4864,8 @@ public static function grey62() /** * Color gray61. * - * @return static */ - public static function gray61() + public static function gray61(): static { return new static(Color::GRAY61); } @@ -5412,9 +4873,8 @@ public static function gray61() /** * Color grey61. * - * @return static */ - public static function grey61() + public static function grey61(): static { return new static(Color::GREY61); } @@ -5422,9 +4882,8 @@ public static function grey61() /** * Color gray60. * - * @return static */ - public static function gray60() + public static function gray60(): static { return new static(Color::GRAY60); } @@ -5432,9 +4891,8 @@ public static function gray60() /** * Color grey60. * - * @return static */ - public static function grey60() + public static function grey60(): static { return new static(Color::GREY60); } @@ -5442,9 +4900,8 @@ public static function grey60() /** * Color gray59. * - * @return static */ - public static function gray59() + public static function gray59(): static { return new static(Color::GRAY59); } @@ -5452,9 +4909,8 @@ public static function gray59() /** * Color grey59. * - * @return static */ - public static function grey59() + public static function grey59(): static { return new static(Color::GREY59); } @@ -5462,9 +4918,8 @@ public static function grey59() /** * Color gray58. * - * @return static */ - public static function gray58() + public static function gray58(): static { return new static(Color::GRAY58); } @@ -5472,9 +4927,8 @@ public static function gray58() /** * Color grey58. * - * @return static */ - public static function grey58() + public static function grey58(): static { return new static(Color::GREY58); } @@ -5482,9 +4936,8 @@ public static function grey58() /** * Color gray57. * - * @return static */ - public static function gray57() + public static function gray57(): static { return new static(Color::GRAY57); } @@ -5492,9 +4945,8 @@ public static function gray57() /** * Color grey57. * - * @return static */ - public static function grey57() + public static function grey57(): static { return new static(Color::GREY57); } @@ -5502,9 +4954,8 @@ public static function grey57() /** * Color gray56. * - * @return static */ - public static function gray56() + public static function gray56(): static { return new static(Color::GRAY56); } @@ -5512,9 +4963,8 @@ public static function gray56() /** * Color grey56. * - * @return static */ - public static function grey56() + public static function grey56(): static { return new static(Color::GREY56); } @@ -5522,9 +4972,8 @@ public static function grey56() /** * Color gray55. * - * @return static */ - public static function gray55() + public static function gray55(): static { return new static(Color::GRAY55); } @@ -5532,9 +4981,8 @@ public static function gray55() /** * Color grey55. * - * @return static */ - public static function grey55() + public static function grey55(): static { return new static(Color::GREY55); } @@ -5542,9 +4990,8 @@ public static function grey55() /** * Color gray54. * - * @return static */ - public static function gray54() + public static function gray54(): static { return new static(Color::GRAY54); } @@ -5552,9 +4999,8 @@ public static function gray54() /** * Color grey54. * - * @return static */ - public static function grey54() + public static function grey54(): static { return new static(Color::GREY54); } @@ -5562,9 +5008,8 @@ public static function grey54() /** * Color gray53. * - * @return static */ - public static function gray53() + public static function gray53(): static { return new static(Color::GRAY53); } @@ -5572,9 +5017,8 @@ public static function gray53() /** * Color grey53. * - * @return static */ - public static function grey53() + public static function grey53(): static { return new static(Color::GREY53); } @@ -5582,9 +5026,8 @@ public static function grey53() /** * Color gray52. * - * @return static */ - public static function gray52() + public static function gray52(): static { return new static(Color::GRAY52); } @@ -5592,9 +5035,8 @@ public static function gray52() /** * Color grey52. * - * @return static */ - public static function grey52() + public static function grey52(): static { return new static(Color::GREY52); } @@ -5602,9 +5044,8 @@ public static function grey52() /** * Color gray51. * - * @return static */ - public static function gray51() + public static function gray51(): static { return new static(Color::GRAY51); } @@ -5612,9 +5053,8 @@ public static function gray51() /** * Color grey51. * - * @return static */ - public static function grey51() + public static function grey51(): static { return new static(Color::GREY51); } @@ -5622,9 +5062,8 @@ public static function grey51() /** * Color fractal. * - * @return static */ - public static function fractal() + public static function fractal(): static { return new static(Color::FRACTAL); } @@ -5632,9 +5071,8 @@ public static function fractal() /** * Color gray50. * - * @return static */ - public static function gray50() + public static function gray50(): static { return new static(Color::GRAY50); } @@ -5642,9 +5080,8 @@ public static function gray50() /** * Color grey50. * - * @return static */ - public static function grey50() + public static function grey50(): static { return new static(Color::GREY50); } @@ -5652,9 +5089,8 @@ public static function grey50() /** * Color gray. * - * @return static */ - public static function gray() + public static function gray(): static { return new static(Color::GRAY); } @@ -5662,9 +5098,8 @@ public static function gray() /** * Color grey. * - * @return static */ - public static function grey() + public static function grey(): static { return new static(Color::GREY); } @@ -5672,9 +5107,8 @@ public static function grey() /** * Color gray49. * - * @return static */ - public static function gray49() + public static function gray49(): static { return new static(Color::GRAY49); } @@ -5682,9 +5116,8 @@ public static function gray49() /** * Color grey49. * - * @return static */ - public static function grey49() + public static function grey49(): static { return new static(Color::GREY49); } @@ -5692,9 +5125,8 @@ public static function grey49() /** * Color gray48. * - * @return static */ - public static function gray48() + public static function gray48(): static { return new static(Color::GRAY48); } @@ -5702,9 +5134,8 @@ public static function gray48() /** * Color grey48. * - * @return static */ - public static function grey48() + public static function grey48(): static { return new static(Color::GREY48); } @@ -5712,9 +5143,8 @@ public static function grey48() /** * Color gray47. * - * @return static */ - public static function gray47() + public static function gray47(): static { return new static(Color::GRAY47); } @@ -5722,9 +5152,8 @@ public static function gray47() /** * Color grey47. * - * @return static */ - public static function grey47() + public static function grey47(): static { return new static(Color::GREY47); } @@ -5732,9 +5161,8 @@ public static function grey47() /** * Color gray46. * - * @return static */ - public static function gray46() + public static function gray46(): static { return new static(Color::GRAY46); } @@ -5742,9 +5170,8 @@ public static function gray46() /** * Color grey46. * - * @return static */ - public static function grey46() + public static function grey46(): static { return new static(Color::GREY46); } @@ -5752,9 +5179,8 @@ public static function grey46() /** * Color gray45. * - * @return static */ - public static function gray45() + public static function gray45(): static { return new static(Color::GRAY45); } @@ -5762,9 +5188,8 @@ public static function gray45() /** * Color grey45. * - * @return static */ - public static function grey45() + public static function grey45(): static { return new static(Color::GREY45); } @@ -5772,9 +5197,8 @@ public static function grey45() /** * Color gray44. * - * @return static */ - public static function gray44() + public static function gray44(): static { return new static(Color::GRAY44); } @@ -5782,9 +5206,8 @@ public static function gray44() /** * Color grey44. * - * @return static */ - public static function grey44() + public static function grey44(): static { return new static(Color::GREY44); } @@ -5792,9 +5215,8 @@ public static function grey44() /** * Color gray43. * - * @return static */ - public static function gray43() + public static function gray43(): static { return new static(Color::GRAY43); } @@ -5802,9 +5224,8 @@ public static function gray43() /** * Color grey43. * - * @return static */ - public static function grey43() + public static function grey43(): static { return new static(Color::GREY43); } @@ -5812,9 +5233,8 @@ public static function grey43() /** * Color gray42. * - * @return static */ - public static function gray42() + public static function gray42(): static { return new static(Color::GRAY42); } @@ -5822,9 +5242,8 @@ public static function gray42() /** * Color grey42. * - * @return static */ - public static function grey42() + public static function grey42(): static { return new static(Color::GREY42); } @@ -5832,9 +5251,8 @@ public static function grey42() /** * Color dimgray. * - * @return static */ - public static function dimgray() + public static function dimgray(): static { return new static(Color::DIMGRAY); } @@ -5842,9 +5260,8 @@ public static function dimgray() /** * Color dimgrey. * - * @return static */ - public static function dimgrey() + public static function dimgrey(): static { return new static(Color::DIMGREY); } @@ -5852,9 +5269,8 @@ public static function dimgrey() /** * Color gray41. * - * @return static */ - public static function gray41() + public static function gray41(): static { return new static(Color::GRAY41); } @@ -5862,9 +5278,8 @@ public static function gray41() /** * Color grey41. * - * @return static */ - public static function grey41() + public static function grey41(): static { return new static(Color::GREY41); } @@ -5872,9 +5287,8 @@ public static function grey41() /** * Color gray40. * - * @return static */ - public static function gray40() + public static function gray40(): static { return new static(Color::GRAY40); } @@ -5882,9 +5296,8 @@ public static function gray40() /** * Color grey40. * - * @return static */ - public static function grey40() + public static function grey40(): static { return new static(Color::GREY40); } @@ -5892,9 +5305,8 @@ public static function grey40() /** * Color gray39. * - * @return static */ - public static function gray39() + public static function gray39(): static { return new static(Color::GRAY39); } @@ -5902,9 +5314,8 @@ public static function gray39() /** * Color grey39. * - * @return static */ - public static function grey39() + public static function grey39(): static { return new static(Color::GREY39); } @@ -5912,9 +5323,8 @@ public static function grey39() /** * Color gray38. * - * @return static */ - public static function gray38() + public static function gray38(): static { return new static(Color::GRAY38); } @@ -5922,9 +5332,8 @@ public static function gray38() /** * Color grey38. * - * @return static */ - public static function grey38() + public static function grey38(): static { return new static(Color::GREY38); } @@ -5932,9 +5341,8 @@ public static function grey38() /** * Color gray37. * - * @return static */ - public static function gray37() + public static function gray37(): static { return new static(Color::GRAY37); } @@ -5942,9 +5350,8 @@ public static function gray37() /** * Color grey37. * - * @return static */ - public static function grey37() + public static function grey37(): static { return new static(Color::GREY37); } @@ -5952,9 +5359,8 @@ public static function grey37() /** * Color gray36. * - * @return static */ - public static function gray36() + public static function gray36(): static { return new static(Color::GRAY36); } @@ -5962,9 +5368,8 @@ public static function gray36() /** * Color grey36. * - * @return static */ - public static function grey36() + public static function grey36(): static { return new static(Color::GREY36); } @@ -5972,9 +5377,8 @@ public static function grey36() /** * Color gray35. * - * @return static */ - public static function gray35() + public static function gray35(): static { return new static(Color::GRAY35); } @@ -5982,9 +5386,8 @@ public static function gray35() /** * Color grey35. * - * @return static */ - public static function grey35() + public static function grey35(): static { return new static(Color::GREY35); } @@ -5992,9 +5395,8 @@ public static function grey35() /** * Color gray34. * - * @return static */ - public static function gray34() + public static function gray34(): static { return new static(Color::GRAY34); } @@ -6002,9 +5404,8 @@ public static function gray34() /** * Color grey34. * - * @return static */ - public static function grey34() + public static function grey34(): static { return new static(Color::GREY34); } @@ -6012,9 +5413,8 @@ public static function grey34() /** * Color gray33. * - * @return static */ - public static function gray33() + public static function gray33(): static { return new static(Color::GRAY33); } @@ -6022,9 +5422,8 @@ public static function gray33() /** * Color grey33. * - * @return static */ - public static function grey33() + public static function grey33(): static { return new static(Color::GREY33); } @@ -6032,9 +5431,8 @@ public static function grey33() /** * Color gray32. * - * @return static */ - public static function gray32() + public static function gray32(): static { return new static(Color::GRAY32); } @@ -6042,9 +5440,8 @@ public static function gray32() /** * Color grey32. * - * @return static */ - public static function grey32() + public static function grey32(): static { return new static(Color::GREY32); } @@ -6052,9 +5449,8 @@ public static function grey32() /** * Color gray31. * - * @return static */ - public static function gray31() + public static function gray31(): static { return new static(Color::GRAY31); } @@ -6062,9 +5458,8 @@ public static function gray31() /** * Color grey31. * - * @return static */ - public static function grey31() + public static function grey31(): static { return new static(Color::GREY31); } @@ -6072,9 +5467,8 @@ public static function grey31() /** * Color gray30. * - * @return static */ - public static function gray30() + public static function gray30(): static { return new static(Color::GRAY30); } @@ -6082,9 +5476,8 @@ public static function gray30() /** * Color grey30. * - * @return static */ - public static function grey30() + public static function grey30(): static { return new static(Color::GREY30); } @@ -6092,9 +5485,8 @@ public static function grey30() /** * Color gray29. * - * @return static */ - public static function gray29() + public static function gray29(): static { return new static(Color::GRAY29); } @@ -6102,9 +5494,8 @@ public static function gray29() /** * Color grey29. * - * @return static */ - public static function grey29() + public static function grey29(): static { return new static(Color::GREY29); } @@ -6112,9 +5503,8 @@ public static function grey29() /** * Color gray28. * - * @return static */ - public static function gray28() + public static function gray28(): static { return new static(Color::GRAY28); } @@ -6122,9 +5512,8 @@ public static function gray28() /** * Color grey28. * - * @return static */ - public static function grey28() + public static function grey28(): static { return new static(Color::GREY28); } @@ -6132,9 +5521,8 @@ public static function grey28() /** * Color gray27. * - * @return static */ - public static function gray27() + public static function gray27(): static { return new static(Color::GRAY27); } @@ -6142,9 +5530,8 @@ public static function gray27() /** * Color grey27. * - * @return static */ - public static function grey27() + public static function grey27(): static { return new static(Color::GREY27); } @@ -6152,9 +5539,8 @@ public static function grey27() /** * Color gray26. * - * @return static */ - public static function gray26() + public static function gray26(): static { return new static(Color::GRAY26); } @@ -6162,9 +5548,8 @@ public static function gray26() /** * Color grey26. * - * @return static */ - public static function grey26() + public static function grey26(): static { return new static(Color::GREY26); } @@ -6172,9 +5557,8 @@ public static function grey26() /** * Color gray25. * - * @return static */ - public static function gray25() + public static function gray25(): static { return new static(Color::GRAY25); } @@ -6182,9 +5566,8 @@ public static function gray25() /** * Color grey25. * - * @return static */ - public static function grey25() + public static function grey25(): static { return new static(Color::GREY25); } @@ -6192,9 +5575,8 @@ public static function grey25() /** * Color gray24. * - * @return static */ - public static function gray24() + public static function gray24(): static { return new static(Color::GRAY24); } @@ -6202,9 +5584,8 @@ public static function gray24() /** * Color grey24. * - * @return static */ - public static function grey24() + public static function grey24(): static { return new static(Color::GREY24); } @@ -6212,9 +5593,8 @@ public static function grey24() /** * Color gray23. * - * @return static */ - public static function gray23() + public static function gray23(): static { return new static(Color::GRAY23); } @@ -6222,9 +5602,8 @@ public static function gray23() /** * Color grey23. * - * @return static */ - public static function grey23() + public static function grey23(): static { return new static(Color::GREY23); } @@ -6232,9 +5611,8 @@ public static function grey23() /** * Color gray22. * - * @return static */ - public static function gray22() + public static function gray22(): static { return new static(Color::GRAY22); } @@ -6242,9 +5620,8 @@ public static function gray22() /** * Color grey22. * - * @return static */ - public static function grey22() + public static function grey22(): static { return new static(Color::GREY22); } @@ -6252,9 +5629,8 @@ public static function grey22() /** * Color gray21. * - * @return static */ - public static function gray21() + public static function gray21(): static { return new static(Color::GRAY21); } @@ -6262,9 +5638,8 @@ public static function gray21() /** * Color grey21. * - * @return static */ - public static function grey21() + public static function grey21(): static { return new static(Color::GREY21); } @@ -6272,9 +5647,8 @@ public static function grey21() /** * Color gray20. * - * @return static */ - public static function gray20() + public static function gray20(): static { return new static(Color::GRAY20); } @@ -6282,9 +5656,8 @@ public static function gray20() /** * Color grey20. * - * @return static */ - public static function grey20() + public static function grey20(): static { return new static(Color::GREY20); } @@ -6292,9 +5665,8 @@ public static function grey20() /** * Color gray19. * - * @return static */ - public static function gray19() + public static function gray19(): static { return new static(Color::GRAY19); } @@ -6302,9 +5674,8 @@ public static function gray19() /** * Color grey19. * - * @return static */ - public static function grey19() + public static function grey19(): static { return new static(Color::GREY19); } @@ -6312,9 +5683,8 @@ public static function grey19() /** * Color gray18. * - * @return static */ - public static function gray18() + public static function gray18(): static { return new static(Color::GRAY18); } @@ -6322,9 +5692,8 @@ public static function gray18() /** * Color grey18. * - * @return static */ - public static function grey18() + public static function grey18(): static { return new static(Color::GREY18); } @@ -6332,9 +5701,8 @@ public static function grey18() /** * Color gray17. * - * @return static */ - public static function gray17() + public static function gray17(): static { return new static(Color::GRAY17); } @@ -6342,9 +5710,8 @@ public static function gray17() /** * Color grey17. * - * @return static */ - public static function grey17() + public static function grey17(): static { return new static(Color::GREY17); } @@ -6352,9 +5719,8 @@ public static function grey17() /** * Color gray16. * - * @return static */ - public static function gray16() + public static function gray16(): static { return new static(Color::GRAY16); } @@ -6362,9 +5728,8 @@ public static function gray16() /** * Color grey16. * - * @return static */ - public static function grey16() + public static function grey16(): static { return new static(Color::GREY16); } @@ -6372,9 +5737,8 @@ public static function grey16() /** * Color gray15. * - * @return static */ - public static function gray15() + public static function gray15(): static { return new static(Color::GRAY15); } @@ -6382,9 +5746,8 @@ public static function gray15() /** * Color grey15. * - * @return static */ - public static function grey15() + public static function grey15(): static { return new static(Color::GREY15); } @@ -6392,9 +5755,8 @@ public static function grey15() /** * Color gray14. * - * @return static */ - public static function gray14() + public static function gray14(): static { return new static(Color::GRAY14); } @@ -6402,9 +5764,8 @@ public static function gray14() /** * Color grey14. * - * @return static */ - public static function grey14() + public static function grey14(): static { return new static(Color::GREY14); } @@ -6412,9 +5773,8 @@ public static function grey14() /** * Color gray13. * - * @return static */ - public static function gray13() + public static function gray13(): static { return new static(Color::GRAY13); } @@ -6422,9 +5782,8 @@ public static function gray13() /** * Color grey13. * - * @return static */ - public static function grey13() + public static function grey13(): static { return new static(Color::GREY13); } @@ -6432,9 +5791,8 @@ public static function grey13() /** * Color gray12. * - * @return static */ - public static function gray12() + public static function gray12(): static { return new static(Color::GRAY12); } @@ -6442,9 +5800,8 @@ public static function gray12() /** * Color grey12. * - * @return static */ - public static function grey12() + public static function grey12(): static { return new static(Color::GREY12); } @@ -6452,9 +5809,8 @@ public static function grey12() /** * Color gray11. * - * @return static */ - public static function gray11() + public static function gray11(): static { return new static(Color::GRAY11); } @@ -6462,9 +5818,8 @@ public static function gray11() /** * Color grey11. * - * @return static */ - public static function grey11() + public static function grey11(): static { return new static(Color::GREY11); } @@ -6472,9 +5827,8 @@ public static function grey11() /** * Color gray10. * - * @return static */ - public static function gray10() + public static function gray10(): static { return new static(Color::GRAY10); } @@ -6482,9 +5836,8 @@ public static function gray10() /** * Color grey10. * - * @return static */ - public static function grey10() + public static function grey10(): static { return new static(Color::GREY10); } @@ -6492,9 +5845,8 @@ public static function grey10() /** * Color gray9. * - * @return static */ - public static function gray9() + public static function gray9(): static { return new static(Color::GRAY9); } @@ -6502,9 +5854,8 @@ public static function gray9() /** * Color grey9. * - * @return static */ - public static function grey9() + public static function grey9(): static { return new static(Color::GREY9); } @@ -6512,9 +5863,8 @@ public static function grey9() /** * Color gray8. * - * @return static */ - public static function gray8() + public static function gray8(): static { return new static(Color::GRAY8); } @@ -6522,9 +5872,8 @@ public static function gray8() /** * Color grey8. * - * @return static */ - public static function grey8() + public static function grey8(): static { return new static(Color::GREY8); } @@ -6532,9 +5881,8 @@ public static function grey8() /** * Color gray7. * - * @return static */ - public static function gray7() + public static function gray7(): static { return new static(Color::GRAY7); } @@ -6542,9 +5890,8 @@ public static function gray7() /** * Color grey7. * - * @return static */ - public static function grey7() + public static function grey7(): static { return new static(Color::GREY7); } @@ -6552,9 +5899,8 @@ public static function grey7() /** * Color gray6. * - * @return static */ - public static function gray6() + public static function gray6(): static { return new static(Color::GRAY6); } @@ -6562,9 +5908,8 @@ public static function gray6() /** * Color grey6. * - * @return static */ - public static function grey6() + public static function grey6(): static { return new static(Color::GREY6); } @@ -6572,9 +5917,8 @@ public static function grey6() /** * Color gray5. * - * @return static */ - public static function gray5() + public static function gray5(): static { return new static(Color::GRAY5); } @@ -6582,9 +5926,8 @@ public static function gray5() /** * Color grey5. * - * @return static */ - public static function grey5() + public static function grey5(): static { return new static(Color::GREY5); } @@ -6592,9 +5935,8 @@ public static function grey5() /** * Color gray4. * - * @return static */ - public static function gray4() + public static function gray4(): static { return new static(Color::GRAY4); } @@ -6602,9 +5944,8 @@ public static function gray4() /** * Color grey4. * - * @return static */ - public static function grey4() + public static function grey4(): static { return new static(Color::GREY4); } @@ -6612,9 +5953,8 @@ public static function grey4() /** * Color gray3. * - * @return static */ - public static function gray3() + public static function gray3(): static { return new static(Color::GRAY3); } @@ -6622,9 +5962,8 @@ public static function gray3() /** * Color grey3. * - * @return static */ - public static function grey3() + public static function grey3(): static { return new static(Color::GREY3); } @@ -6632,9 +5971,8 @@ public static function grey3() /** * Color gray2. * - * @return static */ - public static function gray2() + public static function gray2(): static { return new static(Color::GRAY2); } @@ -6642,9 +5980,8 @@ public static function gray2() /** * Color grey2. * - * @return static */ - public static function grey2() + public static function grey2(): static { return new static(Color::GREY2); } @@ -6652,9 +5989,8 @@ public static function grey2() /** * Color gray1. * - * @return static */ - public static function gray1() + public static function gray1(): static { return new static(Color::GRAY1); } @@ -6662,9 +5998,8 @@ public static function gray1() /** * Color grey1. * - * @return static */ - public static function grey1() + public static function grey1(): static { return new static(Color::GREY1); } @@ -6672,9 +6007,8 @@ public static function grey1() /** * Color black. * - * @return static */ - public static function black() + public static function black(): static { return new static(Color::BLACK); } @@ -6682,9 +6016,8 @@ public static function black() /** * Color gray0. * - * @return static */ - public static function gray0() + public static function gray0(): static { return new static(Color::GRAY0); } @@ -6692,9 +6025,8 @@ public static function gray0() /** * Color grey0. * - * @return static */ - public static function grey0() + public static function grey0(): static { return new static(Color::GREY0); } @@ -6702,9 +6034,8 @@ public static function grey0() /** * Color opaque. * - * @return static */ - public static function opaque() + public static function opaque(): static { return new static(Color::OPAQUE); } @@ -6712,9 +6043,8 @@ public static function opaque() /** * Color none. * - * @return static */ - public static function none() + public static function none(): static { return new static(Color::NONE); } @@ -6722,9 +6052,8 @@ public static function none() /** * Color transparent. * - * @return static */ - public static function transparent() + public static function transparent(): static { return new static(Color::TRANSPARENT); } @@ -6734,9 +6063,8 @@ public static function transparent() * * @param string $hexColor The hexadecimal color. * - * @return static */ - public static function rgb($hexColor) + public static function rgb(string $hexColor): static { return new static(StringUtils::ensureStartsWith($hexColor, '#')); } diff --git a/src/Transformation/Qualifier/QualifierValue/Color/ColorValue.php b/src/Transformation/Qualifier/QualifierValue/Color/ColorValue.php index adde489..111196c 100644 --- a/src/Transformation/Qualifier/QualifierValue/Color/ColorValue.php +++ b/src/Transformation/Qualifier/QualifierValue/Color/ColorValue.php @@ -35,11 +35,11 @@ public function __construct($color) /** * Sets the color. * - * @param string|ColorValue|QualifierMultiValue|BaseQualifier $color The color. + * @param string|BaseQualifier|ColorValue|QualifierMultiValue $color The color. * * @return $this */ - public function color($color) + public function color(ColorValue|QualifierMultiValue|BaseQualifier|string $color): static { if ($color instanceof BaseQualifier) { $color = $color->getValue(); // for those who accidentally pass ColorQualifier instead of the value diff --git a/src/Transformation/Qualifier/QualifierValue/Color/ColorValueTrait.php b/src/Transformation/Qualifier/QualifierValue/Color/ColorValueTrait.php index c92ad5d..b0ec0ef 100644 --- a/src/Transformation/Qualifier/QualifierValue/Color/ColorValueTrait.php +++ b/src/Transformation/Qualifier/QualifierValue/Color/ColorValueTrait.php @@ -27,7 +27,7 @@ trait ColorValueTrait * * @return $this */ - public function color($color) + public function color(string $color): static { $this->setQualifierValue(ClassUtils::verifyInstance($color, ColorValue::class)); diff --git a/src/Transformation/Qualifier/QualifierValue/Color/Gradient.php b/src/Transformation/Qualifier/QualifierValue/Color/Gradient.php index 7cfb8a2..3f8f914 100644 --- a/src/Transformation/Qualifier/QualifierValue/Color/Gradient.php +++ b/src/Transformation/Qualifier/QualifierValue/Color/Gradient.php @@ -27,46 +27,42 @@ class Gradient extends BaseComponent /** * Base the gradient fade effect on the predominant colors in the image. */ - const PREDOMINANT_GRADIENT = 'predominant_gradient'; + public const PREDOMINANT_GRADIENT = 'predominant_gradient'; /** * Base the effect on the colors that contrast the predominant colors in the image. */ - const PREDOMINANT_GRADIENT_CONTRAST = 'predominant_gradient_contrast'; + public const PREDOMINANT_GRADIENT_CONTRAST = 'predominant_gradient_contrast'; /** * Base the gradient fade effect on the predominant colors in the border pixels of the image. */ - const BORDER_GRADIENT = 'border_gradient'; + public const BORDER_GRADIENT = 'border_gradient'; /** * Base the effect on the colors that contrast the predominant colors in the border pixels of the image. */ - const BORDER_GRADIENT_CONTRAST = 'border_gradient_contrast'; + public const BORDER_GRADIENT_CONTRAST = 'border_gradient_contrast'; /** * @var string $type The type of gradient fade. */ - protected $type; + protected string $type; /** * @var int $numberOfColors The number of predominant colors to use (2 or 4). */ - protected $numberOfColors; + protected int $numberOfColors; /** * @var string $direction The direction of fade. */ - protected $direction; + protected string $direction; /** * Gradient constructor. - * - * @param string $type - * @param int $numberOfColors - * @param string $direction */ - public function __construct($type = null, $numberOfColors = null, $direction = null) + public function __construct(?string $type = null, ?int $numberOfColors = null, ?string $direction = null) { parent::__construct(); @@ -80,9 +76,8 @@ public function __construct($type = null, $numberOfColors = null, $direction = n * * @param string $type The type of gradient fade. * - * @return Gradient */ - public function type($type) + public function type(string $type): static { $this->type = $type; @@ -94,9 +89,8 @@ public function type($type) * * @param int $numberOfColors The number of predominant colors to use (2 or 4). * - * @return Gradient */ - public function numberOfColors($numberOfColors) + public function numberOfColors(int $numberOfColors): static { $this->numberOfColors = $numberOfColors; @@ -108,11 +102,10 @@ public function numberOfColors($numberOfColors) * * @param string $direction The direction of fade. Use the constants defined in the GradientDirection class. * - * @return Gradient * - * @see \Cloudinary\Transformation\Argument\GradientDirection + * @see GradientDirection */ - public function direction($direction) + public function direction(string $direction): static { $this->direction = $direction; @@ -134,10 +127,10 @@ public function __toString() /** * Serializes to json. * - * @return mixed */ - public function jsonSerialize() + public function jsonSerialize(): array { // TODO: Implement jsonSerialize() method. + return []; } } diff --git a/src/Transformation/Qualifier/QualifierValue/Color/GradientDirection.php b/src/Transformation/Qualifier/QualifierValue/Color/GradientDirection.php index 29fb296..a6e7d48 100644 --- a/src/Transformation/Qualifier/QualifierValue/Color/GradientDirection.php +++ b/src/Transformation/Qualifier/QualifierValue/Color/GradientDirection.php @@ -24,29 +24,28 @@ class GradientDirection /** * Blend the colors horizontally. */ - const HORIZONTAL = 'horizontal'; + public const HORIZONTAL = 'horizontal'; /** * Blend the colors vertically. */ - const VERTICAL = 'vertical'; + public const VERTICAL = 'vertical'; /** * Blend the colors diagonally from top-left to bottom-right. */ - const DIAGONAL_DESC = 'diagonal_desc'; + public const DIAGONAL_DESC = 'diagonal_desc'; /** * Blend the colors diagonally from bottom-left to top-right. */ - const DIAGONAL_ASC = 'diagonal_asc'; + public const DIAGONAL_ASC = 'diagonal_asc'; /** * Blend the colors horizontally. * - * @return string */ - public static function horizontal() + public static function horizontal(): string { return self::HORIZONTAL; } @@ -54,9 +53,8 @@ public static function horizontal() /** * Blend the colors vertically. * - * @return string */ - public static function vertical() + public static function vertical(): string { return self::VERTICAL; } @@ -64,9 +62,8 @@ public static function vertical() /** * Blend the colors diagonally from top-left to bottom-right. * - * @return string */ - public static function diagonalDesc() + public static function diagonalDesc(): string { return self::DIAGONAL_DESC; } @@ -74,9 +71,8 @@ public static function diagonalDesc() /** * Blend the colors diagonally from bottom-left to top-right. * - * @return string */ - public static function diagonalAsc() + public static function diagonalAsc(): string { return self::DIAGONAL_ASC; } diff --git a/src/Transformation/Qualifier/QualifierValue/Color/Palette.php b/src/Transformation/Qualifier/QualifierValue/Color/Palette.php index 4e66e5a..7941233 100644 --- a/src/Transformation/Qualifier/QualifierValue/Color/Palette.php +++ b/src/Transformation/Qualifier/QualifierValue/Color/Palette.php @@ -21,15 +21,15 @@ */ class Palette extends QualifierMultiValue { - const VALUE_DELIMITER = '_'; - const MIN_ARGUMENTS = 1; + protected const VALUE_DELIMITER = '_'; + public const MIN_ARGUMENTS = 1; /** * Adds colors to the palette. * * @param array $colors The colors. Can be RGB, HEX, named color, etc */ - public function colors(...$colors) + public function colors(...$colors): void { $this->addValues(...$colors); } diff --git a/src/Transformation/Qualifier/QualifierValue/Effect/ForegroundObject.php b/src/Transformation/Qualifier/QualifierValue/Effect/ForegroundObject.php index d8172d4..bff29bc 100644 --- a/src/Transformation/Qualifier/QualifierValue/Effect/ForegroundObject.php +++ b/src/Transformation/Qualifier/QualifierValue/Effect/ForegroundObject.php @@ -17,26 +17,26 @@ */ class ForegroundObject extends BaseArgument { - const AIRPLANE = 'airplane'; - const BUS = 'bus'; - const DINING_TABLE = 'dining_table'; - const SHEEP = 'sheep'; - const BICYCLE = 'bicycle'; - const CAR = 'car'; - const DOG = 'dog'; - const SOFA = 'sofa'; - const BIRD = 'bird'; - const CAT = 'cat'; - const HORSE = 'horse'; - const TRAIN = 'train'; - const BOAT = 'boat'; - const CHAIR = 'chair'; - const PERSON = 'person'; - const TV = 'tv'; - const BOTTLE = 'bottle'; - const COW = 'cow'; - const POTTED_PLANT = 'potted_plant'; - const MOTORBIKE = 'motorbike'; + public const AIRPLANE = 'airplane'; + public const BUS = 'bus'; + public const DINING_TABLE = 'dining_table'; + public const SHEEP = 'sheep'; + public const BICYCLE = 'bicycle'; + public const CAR = 'car'; + public const DOG = 'dog'; + public const SOFA = 'sofa'; + public const BIRD = 'bird'; + public const CAT = 'cat'; + public const HORSE = 'horse'; + public const TRAIN = 'train'; + public const BOAT = 'boat'; + public const CHAIR = 'chair'; + public const PERSON = 'person'; + public const TV = 'tv'; + public const BOTTLE = 'bottle'; + public const COW = 'cow'; + public const POTTED_PLANT = 'potted_plant'; + public const MOTORBIKE = 'motorbike'; use ForegroundObjectTrait; } diff --git a/src/Transformation/Qualifier/QualifierValue/Effect/ForegroundObjectTrait.php b/src/Transformation/Qualifier/QualifierValue/Effect/ForegroundObjectTrait.php index 1cec170..156a254 100644 --- a/src/Transformation/Qualifier/QualifierValue/Effect/ForegroundObjectTrait.php +++ b/src/Transformation/Qualifier/QualifierValue/Effect/ForegroundObjectTrait.php @@ -20,9 +20,8 @@ trait ForegroundObjectTrait /** * ForegroundObject airplane. * - * @return static */ - public static function airplane() + public static function airplane(): static { return new static(ForegroundObject::AIRPLANE); } @@ -30,9 +29,8 @@ public static function airplane() /** * ForegroundObject bus. * - * @return static */ - public static function bus() + public static function bus(): static { return new static(ForegroundObject::BUS); } @@ -40,9 +38,8 @@ public static function bus() /** * ForegroundObject diningTable. * - * @return static */ - public static function diningTable() + public static function diningTable(): static { return new static(ForegroundObject::DINING_TABLE); } @@ -50,9 +47,8 @@ public static function diningTable() /** * ForegroundObject sheep. * - * @return static */ - public static function sheep() + public static function sheep(): static { return new static(ForegroundObject::SHEEP); } @@ -60,9 +56,8 @@ public static function sheep() /** * ForegroundObject bicycle. * - * @return static */ - public static function bicycle() + public static function bicycle(): static { return new static(ForegroundObject::BICYCLE); } @@ -70,9 +65,8 @@ public static function bicycle() /** * ForegroundObject car. * - * @return static */ - public static function car() + public static function car(): static { return new static(ForegroundObject::CAR); } @@ -80,9 +74,8 @@ public static function car() /** * ForegroundObject dog. * - * @return static */ - public static function dog() + public static function dog(): static { return new static(ForegroundObject::DOG); } @@ -90,9 +83,8 @@ public static function dog() /** * ForegroundObject sofa. * - * @return static */ - public static function sofa() + public static function sofa(): static { return new static(ForegroundObject::SOFA); } @@ -100,9 +92,8 @@ public static function sofa() /** * ForegroundObject bird. * - * @return static */ - public static function bird() + public static function bird(): static { return new static(ForegroundObject::BIRD); } @@ -110,9 +101,8 @@ public static function bird() /** * ForegroundObject cat. * - * @return static */ - public static function cat() + public static function cat(): static { return new static(ForegroundObject::CAT); } @@ -120,9 +110,8 @@ public static function cat() /** * ForegroundObject horse. * - * @return static */ - public static function horse() + public static function horse(): static { return new static(ForegroundObject::HORSE); } @@ -130,9 +119,8 @@ public static function horse() /** * ForegroundObject train. * - * @return static */ - public static function train() + public static function train(): static { return new static(ForegroundObject::TRAIN); } @@ -140,9 +128,8 @@ public static function train() /** * ForegroundObject boat. * - * @return static */ - public static function boat() + public static function boat(): static { return new static(ForegroundObject::BOAT); } @@ -150,9 +137,8 @@ public static function boat() /** * ForegroundObject chair. * - * @return static */ - public static function chair() + public static function chair(): static { return new static(ForegroundObject::CHAIR); } @@ -160,9 +146,8 @@ public static function chair() /** * ForegroundObject person. * - * @return static */ - public static function person() + public static function person(): static { return new static(ForegroundObject::PERSON); } @@ -170,9 +155,8 @@ public static function person() /** * ForegroundObject tv. * - * @return static */ - public static function tv() + public static function tv(): static { return new static(ForegroundObject::TV); } @@ -180,9 +164,8 @@ public static function tv() /** * ForegroundObject bottle. * - * @return static */ - public static function bottle() + public static function bottle(): static { return new static(ForegroundObject::BOTTLE); } @@ -190,9 +173,8 @@ public static function bottle() /** * ForegroundObject cow. * - * @return static */ - public static function cow() + public static function cow(): static { return new static(ForegroundObject::COW); } @@ -200,9 +182,8 @@ public static function cow() /** * ForegroundObject pottedPlant. * - * @return static */ - public static function pottedPlant() + public static function pottedPlant(): static { return new static(ForegroundObject::POTTED_PLANT); } @@ -210,9 +191,8 @@ public static function pottedPlant() /** * ForegroundObject motorbike. * - * @return static */ - public static function motorbike() + public static function motorbike(): static { return new static(ForegroundObject::MOTORBIKE); } diff --git a/src/Transformation/Qualifier/QualifierValue/GenericArgument.php b/src/Transformation/Qualifier/QualifierValue/GenericArgument.php index 122cc3d..a8ec1af 100644 --- a/src/Transformation/Qualifier/QualifierValue/GenericArgument.php +++ b/src/Transformation/Qualifier/QualifierValue/GenericArgument.php @@ -18,12 +18,15 @@ class GenericArgument extends GenericNamedArgument /** * GenericArgument constructor. * - * @param $name - * @param $value - * @param string $innerValueDelimiter + * @param string|null $name The name of the argument. + * @param mixed $value The value of the argument. + * @param string $innerValueDelimiter Inner value delimiter. */ - public function __construct($name, $value, $innerValueDelimiter = self::ARG_INNER_VALUE_DELIMITER) - { - parent::__construct($name, $value, null, $innerValueDelimiter); + public function __construct( + ?string $name, + mixed $value, + string $innerValueDelimiter = self::ARG_INNER_VALUE_DELIMITER + ) { + parent::__construct($name, $value, self::ARG_NAME_VALUE_DELIMITER, $innerValueDelimiter); } } diff --git a/src/Transformation/Qualifier/QualifierValue/GenericNamedArgument.php b/src/Transformation/Qualifier/QualifierValue/GenericNamedArgument.php index e3602bc..fc6af7f 100644 --- a/src/Transformation/Qualifier/QualifierValue/GenericNamedArgument.php +++ b/src/Transformation/Qualifier/QualifierValue/GenericNamedArgument.php @@ -18,16 +18,16 @@ class GenericNamedArgument extends BaseNamedArgument /** * GenericNamedArgument constructor. * - * @param $name - * @param $value - * @param string $nameValueDelimiter - * @param string $innerValueDelimiter + * @param string $name The name of the argument. + * @param mixed $value The value of the argument. + * @param string $nameValueDelimiter The delimiter between name and value. + * @param string $innerValueDelimiter Inner value delimiter. */ public function __construct( - $name, - $value, - $nameValueDelimiter = self::ARG_NAME_VALUE_DELIMITER, - $innerValueDelimiter = self::ARG_INNER_VALUE_DELIMITER + string $name, + mixed $value, + string $nameValueDelimiter = self::ARG_NAME_VALUE_DELIMITER, + string $innerValueDelimiter = self::ARG_INNER_VALUE_DELIMITER ) { parent::__construct(); @@ -40,11 +40,9 @@ public function __construct( /** * Sets the named argument value. * - * @param $value * - * @return static */ - public function setValue($value) + public function setValue($value): static { $this->argMultiValue = $value; diff --git a/src/Transformation/Qualifier/QualifierValue/LimitedGenericNamedArgument.php b/src/Transformation/Qualifier/QualifierValue/LimitedGenericNamedArgument.php index a8902ea..7410293 100644 --- a/src/Transformation/Qualifier/QualifierValue/LimitedGenericNamedArgument.php +++ b/src/Transformation/Qualifier/QualifierValue/LimitedGenericNamedArgument.php @@ -24,16 +24,14 @@ class LimitedGenericNamedArgument extends GenericNamedArgument * * @param string $name The name of the argument. * @param mixed $value The value of the argument. - * @param array $range The range including min and max values. - * @param string $nameValueDelimiter - * @param string $innerValueDelimiter + * @param ?array $range The range including min and max values. */ public function __construct( - $name, - $value, - $range = null, - $nameValueDelimiter = self::ARG_NAME_VALUE_DELIMITER, - $innerValueDelimiter = self::ARG_INNER_VALUE_DELIMITER + string $name, + mixed $value, + ?array $range = null, + string $nameValueDelimiter = self::ARG_NAME_VALUE_DELIMITER, + string $innerValueDelimiter = self::ARG_INNER_VALUE_DELIMITER ) { $this->setValidRange($range); @@ -43,13 +41,13 @@ public function __construct( /** * Sets a range for validation. * - * @param array $range The range including min and max values. + * @param ?array $range The range including min and max values. * * @return $this * * @internal */ - public function setValidRange($range) + public function setValidRange(?array $range): static { $this->range = $range; @@ -65,7 +63,7 @@ public function setValidRange($range) * * @internal */ - public function setValue($value) + public function setValue($value): static { if (is_numeric($value) && ! empty($this->range) && ($value < $this->range[0] || $value > $this->range[1])) { throw new OutOfRangeException("Value must be in range: [{$this->range[0]}, {$this->range[1]}]"); diff --git a/src/Transformation/Qualifier/QualifierValue/ListExpressionQualifierMultiValue.php b/src/Transformation/Qualifier/QualifierValue/ListExpressionQualifierMultiValue.php index 98a805d..8587da2 100644 --- a/src/Transformation/Qualifier/QualifierValue/ListExpressionQualifierMultiValue.php +++ b/src/Transformation/Qualifier/QualifierValue/ListExpressionQualifierMultiValue.php @@ -21,5 +21,5 @@ */ class ListExpressionQualifierMultiValue extends ExpressionQualifierMultiValue { - const VALUE_DELIMITER = ';'; + protected const VALUE_DELIMITER = ';'; } diff --git a/src/Transformation/Qualifier/QualifierValue/ListQualifierMultiValue.php b/src/Transformation/Qualifier/QualifierValue/ListQualifierMultiValue.php index dfc50ae..16e190a 100644 --- a/src/Transformation/Qualifier/QualifierValue/ListQualifierMultiValue.php +++ b/src/Transformation/Qualifier/QualifierValue/ListQualifierMultiValue.php @@ -21,5 +21,5 @@ */ class ListQualifierMultiValue extends QualifierMultiValue { - const VALUE_DELIMITER = ';'; + protected const VALUE_DELIMITER = ';'; } diff --git a/src/Transformation/Qualifier/QualifierValue/MatrixValue.php b/src/Transformation/Qualifier/QualifierValue/MatrixValue.php index 6d40699..a916097 100644 --- a/src/Transformation/Qualifier/QualifierValue/MatrixValue.php +++ b/src/Transformation/Qualifier/QualifierValue/MatrixValue.php @@ -17,7 +17,7 @@ */ class MatrixValue extends BaseArgument { - protected static $name = "matrix"; + protected static string $name = "matrix"; public function __construct(...$value) { diff --git a/src/Transformation/Qualifier/QualifierValue/Misc/IndexedArgument.php b/src/Transformation/Qualifier/QualifierValue/Misc/IndexedArgument.php index 2cee141..6631507 100644 --- a/src/Transformation/Qualifier/QualifierValue/Misc/IndexedArgument.php +++ b/src/Transformation/Qualifier/QualifierValue/Misc/IndexedArgument.php @@ -17,5 +17,5 @@ */ class IndexedArgument extends BaseArgument { - const ARG_INNER_VALUE_DELIMITER = '-'; + public const ARG_INNER_VALUE_DELIMITER = '-'; } diff --git a/src/Transformation/Qualifier/QualifierValue/Misc/PositiveFloatValue.php b/src/Transformation/Qualifier/QualifierValue/Misc/PositiveFloatValue.php index 16d2468..593d608 100644 --- a/src/Transformation/Qualifier/QualifierValue/Misc/PositiveFloatValue.php +++ b/src/Transformation/Qualifier/QualifierValue/Misc/PositiveFloatValue.php @@ -23,9 +23,8 @@ class PositiveFloatValue extends QualifierMultiValue * * @param array $arguments The qualifier. * - * @return static */ - public function setArguments(...$arguments) + public function setArguments(...$arguments): static { if (count($arguments) > 1) { throw new InvalidArgumentException('No more than 1 argument is expected'); diff --git a/src/Transformation/Qualifier/QualifierValue/Misc/RangeArgument.php b/src/Transformation/Qualifier/QualifierValue/Misc/RangeArgument.php index b1f50a7..4c44605 100644 --- a/src/Transformation/Qualifier/QualifierValue/Misc/RangeArgument.php +++ b/src/Transformation/Qualifier/QualifierValue/Misc/RangeArgument.php @@ -17,15 +17,15 @@ */ class RangeArgument extends BaseArgument { - const ARG_INNER_VALUE_DELIMITER = '-'; + public const ARG_INNER_VALUE_DELIMITER = '-'; /** * RangeArgument constructor. * - * @param int|string $start The start of the range. - * @param int|string $end The end of the range. + * @param int|string $start The start of the range. + * @param int|string|null $end The end of the range. */ - public function __construct($start, $end = null) + public function __construct($start, int|string|null $end = null) { parent::__construct($start, $end); } diff --git a/src/Transformation/Qualifier/QualifierValue/QualifierMultiValue.php b/src/Transformation/Qualifier/QualifierValue/QualifierMultiValue.php index cdc2158..7b4bc7d 100644 --- a/src/Transformation/Qualifier/QualifierValue/QualifierMultiValue.php +++ b/src/Transformation/Qualifier/QualifierValue/QualifierMultiValue.php @@ -26,42 +26,42 @@ class QualifierMultiValue extends BaseComponent /** * @var string VALUE_DELIMITER Serialisation delimiter in case value is an array. */ - const VALUE_DELIMITER = ':'; + protected const VALUE_DELIMITER = ':'; /** * @var string KEY_VALUE_DELIMITER Serialisation delimiter between the key and the value. */ - const KEY_VALUE_DELIMITER = '_'; + protected const KEY_VALUE_DELIMITER = '_'; /** * @var int MIN_ARGUMENTS Minimum number of arguments required for the qualifier. 0 == all optional. */ - const MIN_ARGUMENTS = 0; + public const MIN_ARGUMENTS = 0; /** * @var int MAX_ARGUMENTS Maximum number of arguments allowed for the qualifier. 0 == unlimited. */ - const MAX_ARGUMENTS = 0; + public const MAX_ARGUMENTS = 0; /** * @var array Array of validators to run during construction. */ - protected $validators = []; + protected array $validators = []; /** * @var array $argumentOrder Used for serialisation order .Can be defined in the derived class. */ - protected $argumentOrder = []; + protected array $argumentOrder = []; /** * @var array $arguments The arguments (unnamed). */ - protected $arguments = []; + protected array $arguments = []; /** * @var array $arguments The named arguments. */ - protected $namedArguments = []; + protected array $namedArguments = []; /** * QualifierMultiValue constructor. @@ -80,11 +80,10 @@ public function __construct(...$arguments) * * @param mixed $arguments The arguments to set. * - * @return static * * @internal */ - public function setArguments(...$arguments) + public function setArguments(...$arguments): static { $arguments = ArrayUtils::flatten($arguments, true); @@ -121,11 +120,10 @@ public function setArguments(...$arguments) * * @param mixed $values The values to add. * - * @return static * * @internal */ - public function addValues(...$values) + public function addValues(...$values): static { $this->arguments = array_merge($this->arguments, $values); @@ -141,22 +139,22 @@ public function addValues(...$values) * * @internal */ - public function setValue(?BaseComponent $value = null) + public function setValue(?BaseComponent $value = null): static { - return $this->setSimpleValue($value ? $value->getName() : null, $value); + return $this->setSimpleValue($value?->getName(), $value); } /** * Sets a simple unnamed value specified by name(for uniqueness) and the actual value. * - * @param string $name The name of the argument. - * @param BaseComponent|mixed $value The value of the argument. + * @param string|null $name The name of the argument. + * @param mixed|null $value The value of the argument. * * @return $this * * @internal */ - public function setSimpleValue($name, $value = null) + public function setSimpleValue(?string $name, mixed $value = null): static { ArrayUtils::addNonEmpty($this->arguments, $name, $value); @@ -168,11 +166,10 @@ public function setSimpleValue($name, $value = null) * * @param string $name The name of the argument. * - * @return mixed * * @internal */ - public function getSimpleValue($name) + public function getSimpleValue(string $name): mixed { return ArrayUtils::get($this->arguments, $name); } @@ -180,13 +177,13 @@ public function getSimpleValue($name) /** * Sets a named value. * - * @param BaseComponent|mixed $value The value to set. + * @param BaseComponent|null $value The value to set. * * @return $this * * @internal */ - public function setNamedValue(?BaseComponent $value = null) + public function setNamedValue(?BaseComponent $value = null): static { return $this->setSimpleNamedValue($value ? $value->getName() : null, $value); } @@ -200,7 +197,7 @@ public function setNamedValue(?BaseComponent $value = null) * * @internal */ - public function setNamedValues(BaseComponent ...$values) + public function setNamedValues(BaseComponent ...$values): static { foreach ($values as $index => $value) { if ($index === 0) { @@ -216,14 +213,14 @@ public function setNamedValues(BaseComponent ...$values) /** * Sets a simple named value specified by name (for uniqueness) and the actual value. * - * @param string $name The name of the argument. - * @param BaseComponent|mixed $value The value of the argument. + * @param string $name The name of the argument. + * @param mixed|null $value The value of the argument. * * @return $this * * @internal */ - public function setSimpleNamedValue($name, $value = null) + public function setSimpleNamedValue(string $name, mixed $value = null): static { ArrayUtils::addNonEmpty($this->namedArguments, $name, $value); @@ -239,7 +236,7 @@ public function setSimpleNamedValue($name, $value = null) * * @internal */ - public function setArgumentOrder($argumentOrder) + public function setArgumentOrder(array $argumentOrder): static { if (! empty($argumentOrder)) { $this->argumentOrder = $argumentOrder; @@ -277,9 +274,8 @@ public function __toString() /** * Serializes to json. * - * @return mixed */ - public function jsonSerialize() + public function jsonSerialize(): array { return ArrayUtils::flatten( ArrayUtils::safeFilter(ArrayUtils::mergeNonEmpty($this->arguments, $this->namedArguments)) diff --git a/src/Transformation/Qualifier/QualifierValue/Text/FontAntialias.php b/src/Transformation/Qualifier/QualifierValue/Text/FontAntialias.php index 1462c29..c12a8b8 100644 --- a/src/Transformation/Qualifier/QualifierValue/Text/FontAntialias.php +++ b/src/Transformation/Qualifier/QualifierValue/Text/FontAntialias.php @@ -18,39 +18,38 @@ class FontAntialias /** * Use a bi-level alpha mask. */ - const NONE = 'none'; + public const NONE = 'none'; /** * Perform single-color antialiasing. For example, using shades of gray for black text on a white background. */ - const GRAY = 'gray'; + public const GRAY = 'gray'; /** * Perform antialiasing by taking advantage of the order of subpixel elements on devices such as LCD panels. */ - const SUBPIXEL = 'subpixel'; + public const SUBPIXEL = 'subpixel'; /** * Some antialiasing is performed, but speed is prioritized over quality. */ - const FAST = 'fast'; + public const FAST = 'fast'; /** * Antialiasing that balances quality and performance. */ - const GOOD = 'good'; + public const GOOD = 'good'; /** * Renders at the highest quality, sacrificing speed if necessary. */ - const BEST = 'best'; + public const BEST = 'best'; /** * Use a bi-level alpha mask. * - * @return string */ - public static function none() + public static function none(): string { return self::NONE; } @@ -58,9 +57,8 @@ public static function none() /** * Perform single-color antialiasing. For example, using shades of gray for black text on a white background. * - * @return string */ - public static function gray() + public static function gray(): string { return self::GRAY; } @@ -68,9 +66,8 @@ public static function gray() /** * Perform antialiasing by taking advantage of the order of subpixel elements on devices such as LCD panels. * - * @return string */ - public static function subpixel() + public static function subpixel(): string { return self::SUBPIXEL; } @@ -78,9 +75,8 @@ public static function subpixel() /** * Some antialiasing is performed, but speed is prioritized over quality. * - * @return string */ - public static function fast() + public static function fast(): string { return self::FAST; } @@ -88,9 +84,8 @@ public static function fast() /** * Antialiasing that balances quality and performance. * - * @return string */ - public static function good() + public static function good(): string { return self::GOOD; } @@ -98,9 +93,8 @@ public static function good() /** * Renders at the highest quality, sacrificing speed if necessary. * - * @return string */ - public static function best() + public static function best(): string { return self::BEST; } diff --git a/src/Transformation/Qualifier/QualifierValue/Text/FontFamily.php b/src/Transformation/Qualifier/QualifierValue/Text/FontFamily.php index e1886db..e34a5b6 100644 --- a/src/Transformation/Qualifier/QualifierValue/Text/FontFamily.php +++ b/src/Transformation/Qualifier/QualifierValue/Text/FontFamily.php @@ -16,8 +16,8 @@ class FontFamily { // TODO: Populate the most common/supported fonts - const ARIAL = 'Arial'; - const VERDANA = 'Verdana'; - const IMPACT = 'Impact'; - const PARISIENNE = 'Parisienne'; + public const ARIAL = 'Arial'; + public const VERDANA = 'Verdana'; + public const IMPACT = 'Impact'; + public const PARISIENNE = 'Parisienne'; } diff --git a/src/Transformation/Qualifier/QualifierValue/Text/FontHinting.php b/src/Transformation/Qualifier/QualifierValue/Text/FontHinting.php index 6a58ccb..dc15cba 100644 --- a/src/Transformation/Qualifier/QualifierValue/Text/FontHinting.php +++ b/src/Transformation/Qualifier/QualifierValue/Text/FontHinting.php @@ -18,29 +18,28 @@ class FontHinting /** * Do not hint outlines. */ - const NONE = 'none'; + public const NONE = 'none'; /** * Hint outlines slightly to improve contrast while retaining good fidelity to the original shapes. */ - const SLIGHT = 'slight'; + public const SLIGHT = 'slight'; /** * Hint outlines with medium strength, providing a compromise between fidelity to the original shapes and contrast. */ - const MEDIUM = 'medium'; + public const MEDIUM = 'medium'; /** * Hint outlines to the maximize contrast. */ - const FULL = 'full'; + public const FULL = 'full'; /** * Do not hint outlines. * - * @return string */ - public static function none() + public static function none(): string { return self::NONE; } @@ -48,9 +47,8 @@ public static function none() /** * Hint outlines slightly to improve contrast while retaining good fidelity to the original shapes. * - * @return string */ - public static function slight() + public static function slight(): string { return self::SLIGHT; } @@ -58,9 +56,8 @@ public static function slight() /** * Hint outlines with medium strength, providing a compromise between fidelity to the original shapes and contrast. * - * @return string */ - public static function medium() + public static function medium(): string { return self::MEDIUM; } @@ -68,9 +65,8 @@ public static function medium() /** * Hint outlines to the maximize contrast. * - * @return string */ - public static function full() + public static function full(): string { return self::FULL; } diff --git a/src/Transformation/Qualifier/QualifierValue/Text/FontStyle.php b/src/Transformation/Qualifier/QualifierValue/Text/FontStyle.php index f76e218..3868e4b 100644 --- a/src/Transformation/Qualifier/QualifierValue/Text/FontStyle.php +++ b/src/Transformation/Qualifier/QualifierValue/Text/FontStyle.php @@ -15,15 +15,14 @@ */ class FontStyle { - const NORMAL = 'normal'; - const ITALIC = 'italic'; + public const NORMAL = 'normal'; + public const ITALIC = 'italic'; /** * Font style normal. * - * @return string */ - public static function normal() + public static function normal(): string { return self::NORMAL; } @@ -31,9 +30,8 @@ public static function normal() /** * Font style italic. * - * @return string */ - public static function italic() + public static function italic(): string { return self::ITALIC; } diff --git a/src/Transformation/Qualifier/QualifierValue/Text/FontWeight.php b/src/Transformation/Qualifier/QualifierValue/Text/FontWeight.php index eb21a69..f05aa34 100644 --- a/src/Transformation/Qualifier/QualifierValue/Text/FontWeight.php +++ b/src/Transformation/Qualifier/QualifierValue/Text/FontWeight.php @@ -15,26 +15,25 @@ */ class FontWeight { - const THIN = 'thin'; - const EXTRA_LIGHT = 'extralight'; - const LIGHT = 'light'; - const NORMAL = 'normal'; - const BOOK = 'book'; - const MEDIUM = 'medium'; - const DEMIBOLD = 'demibold'; - const SEMIBOLD = 'semibold'; - const BOLD = 'bold'; - const EXTRABOLD = 'extrabold'; - const ULTRABOLD = 'ultrabold'; - const BLACK = 'black'; - const HEAVY = 'heavy'; + public const THIN = 'thin'; + public const EXTRA_LIGHT = 'extralight'; + public const LIGHT = 'light'; + public const NORMAL = 'normal'; + public const BOOK = 'book'; + public const MEDIUM = 'medium'; + public const DEMIBOLD = 'demibold'; + public const SEMIBOLD = 'semibold'; + public const BOLD = 'bold'; + public const EXTRABOLD = 'extrabold'; + public const ULTRABOLD = 'ultrabold'; + public const BLACK = 'black'; + public const HEAVY = 'heavy'; /** * Font weight thin. * - * @return string */ - public static function thin() + public static function thin(): string { return self::THIN; } @@ -42,9 +41,8 @@ public static function thin() /** * Font weight extraLight. * - * @return string */ - public static function extraLight() + public static function extraLight(): string { return self::EXTRA_LIGHT; } @@ -52,9 +50,8 @@ public static function extraLight() /** * Font weight light. * - * @return string */ - public static function light() + public static function light(): string { return self::LIGHT; } @@ -62,9 +59,8 @@ public static function light() /** * Font weight normal. * - * @return string */ - public static function normal() + public static function normal(): string { return self::NORMAL; } @@ -72,9 +68,8 @@ public static function normal() /** * Font weight book. * - * @return string */ - public static function book() + public static function book(): string { return self::BOOK; } @@ -82,9 +77,8 @@ public static function book() /** * Font weight medium. * - * @return string */ - public static function medium() + public static function medium(): string { return self::MEDIUM; } @@ -92,9 +86,8 @@ public static function medium() /** * Font weight demibold. * - * @return string */ - public static function demibold() + public static function demibold(): string { return self::DEMIBOLD; } @@ -102,9 +95,8 @@ public static function demibold() /** * Font weight semibold. * - * @return string */ - public static function semibold() + public static function semibold(): string { return self::SEMIBOLD; } @@ -112,9 +104,8 @@ public static function semibold() /** * Font weight bold. * - * @return string */ - public static function bold() + public static function bold(): string { return self::BOLD; } @@ -122,9 +113,8 @@ public static function bold() /** * Font weight extrabold. * - * @return string */ - public static function extrabold() + public static function extrabold(): string { return self::EXTRABOLD; } @@ -132,9 +122,8 @@ public static function extrabold() /** * Font weight ultrabold. * - * @return string */ - public static function ultrabold() + public static function ultrabold(): string { return self::ULTRABOLD; } @@ -142,9 +131,8 @@ public static function ultrabold() /** * Font weight black. * - * @return string */ - public static function black() + public static function black(): string { return self::BLACK; } @@ -152,9 +140,8 @@ public static function black() /** * Font weight heavy. * - * @return string */ - public static function heavy() + public static function heavy(): string { return self::HEAVY; } diff --git a/src/Transformation/Qualifier/QualifierValue/Text/Stroke.php b/src/Transformation/Qualifier/QualifierValue/Text/Stroke.php index f12f76c..c92a988 100644 --- a/src/Transformation/Qualifier/QualifierValue/Text/Stroke.php +++ b/src/Transformation/Qualifier/QualifierValue/Text/Stroke.php @@ -20,18 +20,17 @@ class Stroke /** * Do not include an outline stroke. (Server default) */ - const NONE = 'none'; + public const NONE = 'none'; /** * Include an outline stroke. */ - const STROKE = 'stroke'; + public const STROKE = 'stroke'; /** * Do not include an outline stroke. (Server default) * - * @return string */ - public static function none() + public static function none(): string { return self::NONE; } @@ -39,9 +38,8 @@ public static function none() /** * Include an outline stroke. * - * @return string */ - public static function stroke() + public static function stroke(): string { return self::STROKE; } @@ -49,9 +47,8 @@ public static function stroke() /** * Include an outline stroke. * - * @return BorderQualifier */ - public static function solid($width, $color) + public static function solid($width, $color): BorderQualifier { return (new BorderQualifier())->style('solid')->width($width)->color($color); } diff --git a/src/Transformation/Qualifier/QualifierValue/Text/Text.php b/src/Transformation/Qualifier/QualifierValue/Text/Text.php index 24115b8..f821e35 100644 --- a/src/Transformation/Qualifier/QualifierValue/Text/Text.php +++ b/src/Transformation/Qualifier/QualifierValue/Text/Text.php @@ -18,16 +18,16 @@ */ class Text extends QualifierMultiValue { - const VALUE_DELIMITER = '_'; + protected const VALUE_DELIMITER = '_'; use TextTrait; /** * Text constructor * - * @param string $text + * @param string|null $text The text. */ - public function __construct($text = null) + public function __construct(?string $text = null) { parent::__construct(); diff --git a/src/Transformation/Qualifier/QualifierValue/Text/TextAlignment.php b/src/Transformation/Qualifier/QualifierValue/Text/TextAlignment.php index 8c51464..34ff1a8 100644 --- a/src/Transformation/Qualifier/QualifierValue/Text/TextAlignment.php +++ b/src/Transformation/Qualifier/QualifierValue/Text/TextAlignment.php @@ -18,42 +18,41 @@ class TextAlignment /** * Align text to the left. */ - const LEFT = 'left'; + public const LEFT = 'left'; /** * Align text to the center. */ - const CENTER = 'center'; + public const CENTER = 'center'; /** * Align text to the right. */ - const RIGHT = 'right'; + public const RIGHT = 'right'; /** * Align text to the right in a left-to-right language. * Align text to the left in a right-to-left language. */ - const END = 'end'; + public const END = 'end'; /** * Align text to the left in a left-to-right language. * Align text to the right in a right-to-left language. */ - const START = 'start'; + public const START = 'start'; /** * Space out words such that the first word on the line is along the left edge and the last word is along the * right edge. */ - const JUSTIFY = 'justify'; + public const JUSTIFY = 'justify'; /** * Align text to the left. * - * @return string */ - public static function left() + public static function left(): string { return self::LEFT; } @@ -61,9 +60,8 @@ public static function left() /** * Align text to the center. * - * @return string */ - public static function center() + public static function center(): string { return self::CENTER; } @@ -71,9 +69,8 @@ public static function center() /** * Align text to the right. * - * @return string */ - public static function right() + public static function right(): string { return self::RIGHT; } @@ -82,9 +79,8 @@ public static function right() * Align text to the right in a left-to-right language. * Align text to the left in a right-to-left language. * - * @return string */ - public static function end() + public static function end(): string { return self::END; } @@ -93,9 +89,8 @@ public static function end() * Align text to the left in a left-to-right language. * Align text to the right in a right-to-left language. * - * @return string */ - public static function start() + public static function start(): string { return self::START; } @@ -104,9 +99,8 @@ public static function start() * Space out words such that the first word on the line is along the left edge and the last word is along the * right edge. * - * @return string */ - public static function justify() + public static function justify(): string { return self::JUSTIFY; } diff --git a/src/Transformation/Qualifier/QualifierValue/Text/TextDecoration.php b/src/Transformation/Qualifier/QualifierValue/Text/TextDecoration.php index 102c531..f9c3c0f 100644 --- a/src/Transformation/Qualifier/QualifierValue/Text/TextDecoration.php +++ b/src/Transformation/Qualifier/QualifierValue/Text/TextDecoration.php @@ -15,15 +15,14 @@ */ class TextDecoration { - const UNDERLINE = 'underline'; - const STRIKETHROUGH = 'strikethrough'; + public const UNDERLINE = 'underline'; + public const STRIKETHROUGH = 'strikethrough'; /** * Text decoration underline. * - * @return string */ - public static function underline() + public static function underline(): string { return self::UNDERLINE; } @@ -31,9 +30,8 @@ public static function underline() /** * Text decoration strikethrough. * - * @return string */ - public static function strikethrough() + public static function strikethrough(): string { return self::STRIKETHROUGH; } diff --git a/src/Transformation/Qualifier/QualifierValue/Text/TextStyle.php b/src/Transformation/Qualifier/QualifierValue/Text/TextStyle.php index 77e5479..8c130f0 100644 --- a/src/Transformation/Qualifier/QualifierValue/Text/TextStyle.php +++ b/src/Transformation/Qualifier/QualifierValue/Text/TextStyle.php @@ -18,20 +18,20 @@ */ class TextStyle extends QualifierMultiValue { - const VALUE_DELIMITER = '_'; + protected const VALUE_DELIMITER = '_'; - const DEFAULT_FONT_WEIGHT = 'normal'; - const DEFAULT_FONT_STYLE = 'normal'; - const DEFAULT_TEXT_DECORATION = 'none'; - const DEFAULT_TEXT_ALIGNMENT = null; - const DEFAULT_STROKE = 'none'; + public const DEFAULT_FONT_WEIGHT = 'normal'; + public const DEFAULT_FONT_STYLE = 'normal'; + public const DEFAULT_TEXT_DECORATION = 'none'; + public const DEFAULT_TEXT_ALIGNMENT = null; + public const DEFAULT_STROKE = 'none'; use TextStyleTrait; /** * @var array $argumentOrder The order of the arguments. */ - protected $argumentOrder = [ + protected array $argumentOrder = [ 'font_family', 'font_size', 'font_weight', @@ -44,10 +44,10 @@ class TextStyle extends QualifierMultiValue /** * TextStyle constructor * - * @param string $fontFamily - * @param float|int $fontSize + * @param string|null $fontFamily Font family + * @param float|int|null $fontSize Font size */ - public function __construct($fontFamily = null, $fontSize = null) + public function __construct(?string $fontFamily = null, float|int|null $fontSize = null) { parent::__construct(); @@ -60,9 +60,8 @@ public function __construct($fontFamily = null, $fontSize = null) * * @param array $qualifiers The text style qualifiers. * - * @return TextStyle */ - public static function fromParams($qualifiers) + public static function fromParams(array $qualifiers): TextStyle { $style = new self(ArrayUtils::get($qualifiers, 'font_family'), ArrayUtils::get($qualifiers, 'font_size')); $style->importQualifiers($qualifiers); @@ -77,7 +76,7 @@ public static function fromParams($qualifiers) * * @internal */ - public function importQualifiers($qualifiers) + public function importQualifiers(array $qualifiers): void { $this->fontWeight(ArrayUtils::get($qualifiers, 'font_weight')); $this->fontStyle(ArrayUtils::get($qualifiers, 'font_style')); diff --git a/src/Transformation/Qualifier/QualifierValue/Text/TextStyleTrait.php b/src/Transformation/Qualifier/QualifierValue/Text/TextStyleTrait.php index 2726c11..80f122c 100644 --- a/src/Transformation/Qualifier/QualifierValue/Text/TextStyleTrait.php +++ b/src/Transformation/Qualifier/QualifierValue/Text/TextStyleTrait.php @@ -20,13 +20,12 @@ trait TextStyleTrait /** * Sets the font family of the text. * - * @param string $fontFamily The font family. Use the constants defined in the FontFamily class. + * @param ?string $fontFamily The font family. Use the constants defined in the FontFamily class. * - * @return static * - * @see \Cloudinary\Transformation\Argument\Text\FontFamily + * @see FontFamily */ - public function fontFamily($fontFamily) + public function fontFamily(?string $fontFamily): static { return $this->setStyleProperty('font_family', $fontFamily); } @@ -34,11 +33,10 @@ public function fontFamily($fontFamily) /** * Sets the font size of the text. * - * @param int|float $fontSize The font size. + * @param float|int|null $fontSize The font size. * - * @return static */ - public function fontSize($fontSize) + public function fontSize(float|int|null $fontSize): static { return $this->setStyleProperty('font_size', $fontSize); } @@ -48,11 +46,10 @@ public function fontSize($fontSize) * * @param mixed $fontWeight The font weight. Use the constants defined in the FontWeight class. * - * @return static * - * @see \Cloudinary\Transformation\Argument\Text\FontWeight + * @see FontWeight */ - public function fontWeight($fontWeight) + public function fontWeight(mixed $fontWeight): static { return $this->setStyleProperty('font_weight', $fontWeight, false, TextStyle::DEFAULT_FONT_WEIGHT); } @@ -62,11 +59,10 @@ public function fontWeight($fontWeight) * * @param mixed $fontStyle The font style. Use the constants defined in the FontStyle class. * - * @return static * - * @see \Cloudinary\Transformation\Argument\Text\FontStyle + * @see FontStyle */ - public function fontStyle($fontStyle) + public function fontStyle(mixed $fontStyle): static { return $this->setStyleProperty('font_style', $fontStyle, false, TextStyle::DEFAULT_FONT_STYLE); } @@ -76,11 +72,10 @@ public function fontStyle($fontStyle) * * @param mixed $textDecoration The text decoration. Use the constants defined in the TextDecoration class. * - * @return static * - * @see \Cloudinary\Transformation\Argument\Text\TextDecoration + * @see TextDecoration */ - public function textDecoration($textDecoration) + public function textDecoration(mixed $textDecoration): static { return $this->setStyleProperty('text_decoration', $textDecoration, false, TextStyle::DEFAULT_TEXT_DECORATION); } @@ -90,11 +85,10 @@ public function textDecoration($textDecoration) * * @param mixed $textAlignment The alignment of the text. Use the constants defined in the TextAlignment class. * - * @return static * - * @see \Cloudinary\Transformation\Argument\Text\TextAlignment + * @see TextAlignment */ - public function textAlignment($textAlignment) + public function textAlignment(mixed $textAlignment): static { return $this->setStyleProperty('text_alignment', $textAlignment, false, TextStyle::DEFAULT_TEXT_ALIGNMENT); } @@ -102,13 +96,12 @@ public function textAlignment($textAlignment) /** * Sets whether to include an outline stroke. * - * @param mixed $stroke The stroke determiner. Use the constants defined in the Stroke class. + * @param mixed|string $stroke The stroke determiner. Use the constants defined in the Stroke class. * - * @return static * - * @see \Cloudinary\Transformation\Argument\Text\Stroke + * @see Stroke */ - public function stroke($stroke = Stroke::STROKE) + public function stroke(mixed $stroke = Stroke::STROKE): static { return $this->setStyleProperty('stroke', $stroke, false, TextStyle::DEFAULT_STROKE); } @@ -118,9 +111,8 @@ public function stroke($stroke = Stroke::STROKE) * * @param mixed $letterSpacing The spacing between the letters in pixels. Can be positive or negative. * - * @return static */ - public function letterSpacing($letterSpacing) + public function letterSpacing(mixed $letterSpacing): static { return $this->setStyleProperty('letter_spacing', $letterSpacing, true); } @@ -130,9 +122,8 @@ public function letterSpacing($letterSpacing) * * @param mixed $lineSpacing The spacing between multiple lines in pixels. * - * @return static */ - public function lineSpacing($lineSpacing) + public function lineSpacing(mixed $lineSpacing): static { return $this->setStyleProperty('line_spacing', $lineSpacing, true); } @@ -143,11 +134,10 @@ public function lineSpacing($lineSpacing) * @param mixed $fontAntialias The font antialiasing method. Use the constants defined in the FontAntialias * class. * - * @return static * - * @see \Cloudinary\Transformation\Argument\Text\FontAntialias + * @see FontAntialias */ - public function fontAntialias($fontAntialias) + public function fontAntialias(mixed $fontAntialias): static { return $this->setStyleProperty('antialias', $fontAntialias, true); } @@ -157,11 +147,10 @@ public function fontAntialias($fontAntialias) * * @param mixed $fontHinting The type of font hinting. Use the constants defined in the FontHinting class. * - * @return static * - * @see \Cloudinary\Transformation\Argument\Text\FontHinting + * @see FontHinting */ - public function fontHinting($fontHinting) + public function fontHinting(mixed $fontHinting): static { return $this->setStyleProperty('hinting', $fontHinting, true); } @@ -170,16 +159,19 @@ public function fontHinting($fontHinting) * Internal setter for text style property. * * @param string $styleName The style name. - * @param string $value The style. + * @param ?string $value The style. * @param bool $named Indicates whether the property is a named property. - * @param null|string $defaultValue The default value of the property. Used for omitting values that are default. + * @param string|null $defaultValue The default value of the property. Used for omitting values that are default. * - * @return static * * @internal */ - public function setStyleProperty($styleName, $value, $named = false, $defaultValue = null) - { + public function setStyleProperty( + string $styleName, + ?string $value, + bool $named = false, + ?string $defaultValue = null + ): static { if ($value === $defaultValue) { return $this; } diff --git a/src/Transformation/Qualifier/QualifierValue/Text/TextTrait.php b/src/Transformation/Qualifier/QualifierValue/Text/TextTrait.php index 865cd6a..2719700 100644 --- a/src/Transformation/Qualifier/QualifierValue/Text/TextTrait.php +++ b/src/Transformation/Qualifier/QualifierValue/Text/TextTrait.php @@ -18,11 +18,10 @@ trait TextTrait /** * Sets the text. * - * @param string $text The text. + * @param ?string $text The text. * - * @return static */ - public function text($text) + public function text(?string $text): static { return $this->setText($text); } @@ -30,11 +29,9 @@ public function text($text) /** * @internal * - * @param $text * - * @return static */ - public function setText($text) + public function setText($text): static { return $this->setSimpleValue('text', $text); } diff --git a/src/Transformation/Qualifier/QualifiersAction.php b/src/Transformation/Qualifier/QualifiersAction.php index 4be74df..1fbc1c6 100644 --- a/src/Transformation/Qualifier/QualifiersAction.php +++ b/src/Transformation/Qualifier/QualifiersAction.php @@ -25,7 +25,7 @@ */ class QualifiersAction extends BaseAction { - const SIMPLE_QUALIFIERS = [ + protected const SIMPLE_QUALIFIERS = [ 'aspect_ratio' => null, 'background' => null, 'crop' => 'crop_mode', @@ -59,7 +59,7 @@ class QualifiersAction extends BaseAction 'video_sampling' => null, ]; - const COMPLEX_QUALIFIERS = [ + protected const COMPLEX_QUALIFIERS = [ 'angle' => null, 'border' => null, 'custom_function' => null, @@ -75,7 +75,7 @@ class QualifiersAction extends BaseAction 'video_codec' => null, ]; - const QUALIFIERS = self::COMPLEX_QUALIFIERS + self::SIMPLE_QUALIFIERS; + protected const QUALIFIERS = self::COMPLEX_QUALIFIERS + self::SIMPLE_QUALIFIERS; /** * Add qualifiers to the action. @@ -84,7 +84,7 @@ class QualifiersAction extends BaseAction * * @return $this */ - public function addQualifiers(...$qualifiers) + public function addQualifiers(...$qualifiers): static { $this->qualifiers = ArrayUtils::mergeNonEmpty($this->qualifiers, ...$qualifiers); @@ -112,11 +112,10 @@ public function __toString() * * @param array|BaseComponent $transformationAction The action to generate. * - * @return string */ - protected function generateTransformationAction($transformationAction) + protected function generateTransformationAction(BaseComponent|array $transformationAction): string { - $options = is_array($transformationAction) || $this->isTransformationComponent( + $options = is_array($transformationAction) || QualifiersAction::isTransformationComponent( $transformationAction ) ? $transformationAction : ['transformation' => $transformationAction]; @@ -127,15 +126,15 @@ protected function generateTransformationAction($transformationAction) /** * Generates transformation string using provided options. * - * @param string|array $options Transformation qualifiers and other options. + * @param array|string $options Transformation qualifiers and other options. * * Warning: $options are being destructively updated! * * @return string The resulting transformation string. */ - protected function generateTransformationString($options) + protected function generateTransformationString(array|string $options): string { - if (is_string($options) || $this->isTransformationComponent($options)) { + if (is_string($options) || QualifiersAction::isTransformationComponent($options)) { return (string)$options; } @@ -170,13 +169,12 @@ protected function generateTransformationString($options) * * @param array $options All options. * - * @return Action */ - protected function collectQualifiers($options) + protected function collectQualifiers(array $options): Action { $size = ArrayUtils::pop($options, 'size'); if ($size) { - list($options['width'], $options['height']) = explode('x', $size); + [$options['width'], $options['height']] = explode('x', $size); } $offset = new Range(ArrayUtils::pop($options, 'offset')); @@ -196,12 +194,11 @@ protected function collectQualifiers($options) /** * Factory method for building qualifiers from their names and values. * - * @param string $qualifierName The qualifier name. - * @param mixed $qualifierValue The qualifier value. + * @param string|null $qualifierName The qualifier name. + * @param mixed $qualifierValue The qualifier value. * - * @return BaseQualifier|BaseAction */ - protected function buildQualifier($qualifierName, $qualifierValue) + protected function buildQualifier(?string $qualifierName, mixed $qualifierValue): BaseAction|BaseQualifier|null { if (array_key_exists($qualifierName, self::SIMPLE_QUALIFIERS)) { $qualifierBuilderName = StringUtils::snakeCaseToCamelCase( @@ -227,7 +224,7 @@ protected function buildQualifier($qualifierName, $qualifierValue) case 'fps': return Fps::fromParams($qualifierValue); case 'overlay': - return LayerQualifierFactory::fromParams($qualifierValue, LayerStackPosition::OVERLAY); + return LayerQualifierFactory::fromParams($qualifierValue); case 'transformation': return Qualifier::namedTransformation(implode('.', ArrayUtils::build($qualifierValue))); case 'underlay': @@ -249,7 +246,7 @@ protected function buildQualifier($qualifierName, $qualifierValue) * * @return string Serialized variables */ - protected function collectVariables(&$options) + protected function collectVariables(array $options): string { $variables = ArrayUtils::get($options, 'variables', []); @@ -273,22 +270,24 @@ protected function collectVariables(&$options) } /** - * @param $candidate + * Checks whether the candidate is a transformation component. + * + * @param mixed $candidate The candidate to check. * - * @return bool */ - private function isTransformationComponent($candidate) + private static function isTransformationComponent(mixed $candidate): bool { return $candidate instanceof BaseComponent; } /** - * @param $candidate + * Checks whether the candidate is transformation. + * + * @param mixed $candidate The candidate to check. * - * @return bool */ - private function isTransformation($candidate) + private static function isTransformation(mixed $candidate): bool { - return is_array($candidate) || $this->isTransformationComponent($candidate); + return is_array($candidate) || QualifiersAction::isTransformationComponent($candidate); } } diff --git a/src/Transformation/Qualifier/Timeline/BaseOffsetQualifier.php b/src/Transformation/Qualifier/Timeline/BaseOffsetQualifier.php index 79b97a2..88df804 100644 --- a/src/Transformation/Qualifier/Timeline/BaseOffsetQualifier.php +++ b/src/Transformation/Qualifier/Timeline/BaseOffsetQualifier.php @@ -18,22 +18,22 @@ */ abstract class BaseOffsetQualifier extends BaseQualifier { - const RANGE_VALUE_RE = /** @lang PhpRegExp */ + protected const RANGE_VALUE_RE = /** @lang PhpRegExp */ '/^(?P(\d+\.)?\d+)(?P[%pP])?$/'; /** * @var bool Indicates whether to allow value 'auto'. */ - protected static $allowAuto = false; + protected static bool $allowAuto = false; /** * Normalizes a range value. * * @param string|float|mixed $value The value to normalize. * - * @return string|mixed The normalized value. + * @return string|null The normalized value. */ - private static function normRangeValue($value) + private static function normRangeValue(mixed $value): ?string { if ($value === null) { return null; @@ -70,7 +70,7 @@ private static function normRangeValue($value) * * @noinspection TypeUnsafeComparisonInspection */ - private static function normAutoRangeValue($value) + private static function normAutoRangeValue(mixed $value): mixed { if ($value == 'auto') { return $value; diff --git a/src/Transformation/Qualifier/Timeline/Duration.php b/src/Transformation/Qualifier/Timeline/Duration.php index 1593125..df1c460 100644 --- a/src/Transformation/Qualifier/Timeline/Duration.php +++ b/src/Transformation/Qualifier/Timeline/Duration.php @@ -18,5 +18,5 @@ class Duration extends BaseOffsetQualifier /** * @var string $key Serialization key. */ - protected static $key = 'du'; + protected static string $key = 'du'; } diff --git a/src/Transformation/Qualifier/Timeline/StartOffset.php b/src/Transformation/Qualifier/Timeline/StartOffset.php index 3e76c9e..66ae8de 100644 --- a/src/Transformation/Qualifier/Timeline/StartOffset.php +++ b/src/Transformation/Qualifier/Timeline/StartOffset.php @@ -18,5 +18,5 @@ class StartOffset extends BaseOffsetQualifier /** * @var bool Indicates whether to allow value 'auto'. */ - protected static $allowAuto = true; + protected static bool $allowAuto = true; } diff --git a/src/Transformation/Qualifier/Timeline/Timeline.php b/src/Transformation/Qualifier/Timeline/Timeline.php index 2295bb3..ef7c067 100644 --- a/src/Transformation/Qualifier/Timeline/Timeline.php +++ b/src/Transformation/Qualifier/Timeline/Timeline.php @@ -22,21 +22,21 @@ class Timeline extends BaseQualifier /** * @var VideoOffset $offset Determines which part of a video to keep when it is trimmed. */ - protected $offset; + protected VideoOffset $offset; /** - * @var Duration $duration The length of the part of the video to keep. + * @var ?Duration $duration The length of the part of the video to keep. */ - protected $duration; + protected ?Duration $duration; /** * Region constructor. * - * @param mixed $startOffset - * @param mixed $endOffset - * @param mixed $duration + * @param mixed $startOffset + * @param mixed|null $endOffset + * @param mixed|null $duration */ - public function __construct($startOffset = null, $endOffset = null, $duration = null) + public function __construct($startOffset = null, mixed $endOffset = null, mixed $duration = null) { parent::__construct(); @@ -51,15 +51,15 @@ public function __construct($startOffset = null, $endOffset = null, $duration = * representing the percentage of the video length (for example, "30%" or "30p"). * For information and examples see 'Trimming videos' in the Video Transformations guide. * - * @param mixed $startOffset The starting position of the part of the video to keep. - * @param mixed $endOffset The end position of the part of the video to keep. - * @param mixed $duration The length of the part of the video to keep. + * @param mixed|null $startOffset The starting position of the part of the video to keep. + * @param mixed|null $endOffset The end position of the part of the video to keep. + * @param mixed|null $duration The length of the part of the video to keep. * * @return Timeline * * https://cloudinary.com/documentation/video_manipulation_and_delivery#trimming_videos */ - public static function position($startOffset = null, $endOffset = null, $duration = null) + public static function position(mixed $startOffset = null, mixed $endOffset = null, mixed $duration = null): Timeline { return new self($startOffset, $endOffset, $duration); } @@ -73,7 +73,7 @@ public static function position($startOffset = null, $endOffset = null, $duratio * * @return $this */ - public function duration($duration) + public function duration(mixed $duration): static { $this->duration = ClassUtils::verifyInstance($duration, Duration::class); @@ -83,11 +83,11 @@ public function duration($duration) /** * Sets the start and end points of the video to keep. * - * @param VideoOffset|string $offset The start and end points of the video. + * @param string|VideoOffset $offset The start and end points of the video. * * @return $this */ - public function offset($offset) + public function offset(VideoOffset|string $offset): static { $this->offset = ClassUtils::verifyInstance($offset, VideoOffset::class); @@ -103,7 +103,7 @@ public function offset($offset) * * @return $this */ - public function startOffset($startOffset) + public function startOffset(mixed $startOffset): static { $this->offset->startOffset($startOffset); @@ -119,7 +119,7 @@ public function startOffset($startOffset) * * @return $this */ - public function endOffset($endOffset) + public function endOffset(mixed $endOffset): static { $this->offset->endOffset($endOffset); @@ -129,7 +129,7 @@ public function endOffset($endOffset) /** * Specify data which should be serialized to JSON */ - public function jsonSerialize() + public function jsonSerialize(): array { $arr = []; @@ -150,7 +150,7 @@ public function jsonSerialize() * * @internal */ - public function getStringQualifiers() + public function getStringQualifiers(): array { $flatQualifiers = []; foreach (ArrayUtils::safeFilter([$this->offset, $this->duration]) as $qualifier) { diff --git a/src/Transformation/Qualifier/Timeline/TimelineQualifierTrait.php b/src/Transformation/Qualifier/Timeline/TimelineQualifierTrait.php index f953960..d322608 100644 --- a/src/Transformation/Qualifier/Timeline/TimelineQualifierTrait.php +++ b/src/Transformation/Qualifier/Timeline/TimelineQualifierTrait.php @@ -26,9 +26,8 @@ trait TimelineQualifierTrait * float representing the time in seconds or a string representing the percentage of the * video length (for example, "30%" or "30p"). * - * @return StartOffset */ - public static function startOffset($startOffset) + public static function startOffset(mixed $startOffset): StartOffset { return ClassUtils::verifyInstance($startOffset, StartOffset::class); } @@ -40,9 +39,8 @@ public static function startOffset($startOffset) * float representing the time in seconds or a string representing the percentage of the * video length (for example, "30%" or "30p"). * - * @return EndOffset */ - public static function endOffset($endOffset) + public static function endOffset(mixed $endOffset): EndOffset { return ClassUtils::verifyInstance($endOffset, EndOffset::class); } @@ -54,9 +52,8 @@ public static function endOffset($endOffset) * representing the time in seconds or a string representing the percentage of the * video length (for example, "30%" or "30p"). * - * @return Duration */ - public static function duration($duration) + public static function duration(mixed $duration): Duration { return ClassUtils::verifyInstance($duration, Duration::class); } diff --git a/src/Transformation/Qualifier/Timeline/VideoOffset.php b/src/Transformation/Qualifier/Timeline/VideoOffset.php index 5c2dc6e..d871f2e 100644 --- a/src/Transformation/Qualifier/Timeline/VideoOffset.php +++ b/src/Transformation/Qualifier/Timeline/VideoOffset.php @@ -22,17 +22,16 @@ class VideoOffset extends BaseQualifier /** * @var int|float|string $startOffset The starting position of the part of the video to keep. */ - protected $startOffset; + protected string|int|float $startOffset; /** * @var int|float|string $endOffset The end position of the part of the video to keep. */ - protected $endOffset; + protected string|int|float $endOffset; /** * Offset constructor. * - * @param $rangeStr */ public function __construct($rangeStr = null) { @@ -57,7 +56,7 @@ public function __construct($rangeStr = null) * * @return $this */ - public function startOffset($startOffset) + public function startOffset(mixed $startOffset): static { if (! $startOffset instanceof StartOffset) { $startOffset = new StartOffset($startOffset); @@ -77,7 +76,7 @@ public function startOffset($startOffset) * * @return $this */ - public function endOffset($endOffset) + public function endOffset(mixed $endOffset): static { if (! $endOffset instanceof EndOffset) { $endOffset = new EndOffset($endOffset); @@ -95,7 +94,7 @@ public function endOffset($endOffset) * * @internal */ - public function getStringQualifiers() + public function getStringQualifiers(): array { return ArrayUtils::safeFilter([$this->startOffset, (string)$this->endOffset]); } @@ -113,10 +112,10 @@ public function __toString() /** * Serializes to json. * - * @return mixed */ - public function jsonSerialize() + public function jsonSerialize(): array { // TODO: Implement jsonSerialize() method. + return []; } } diff --git a/src/Transformation/Resize/Addon/ImaggaTrait.php b/src/Transformation/Resize/Addon/ImaggaTrait.php index 53ad077..c659b18 100644 --- a/src/Transformation/Resize/Addon/ImaggaTrait.php +++ b/src/Transformation/Resize/Addon/ImaggaTrait.php @@ -24,12 +24,11 @@ trait ImaggaTrait * * @see https://cloudinary.com/documentation/imagga_crop_and_scale_addon * - * @param int|float|string|null $width The required width of a transformed asset. - * @param int|float|null $height The required height of a transformed asset. + * @param float|int|string|null $width The required width of a transformed asset. + * @param float|int|null $height The required height of a transformed asset. * - * @return Imagga */ - public static function imaggaCrop($width = null, $height = null) + public static function imaggaCrop(float|int|string|null $width = null, float|int|null $height = null): Imagga { return static::createImagga(CropMode::IMAGGA_CROP, $width, $height); } @@ -39,24 +38,21 @@ public static function imaggaCrop($width = null, $height = null) * * @see https://cloudinary.com/documentation/imagga_crop_and_scale_addon * - * @param int|float|string|null $width The required width of a transformed asset. - * @param int|float|null $height The required height of a transformed asset. + * @param float|int|string|null $width The required width of a transformed asset. + * @param float|int|null $height The required height of a transformed asset. * - * @return Imagga */ - public static function imaggaScale($width = null, $height = null) + public static function imaggaScale(float|int|string|null $width = null, float|int|null $height = null): Imagga { return static::createImagga(CropMode::IMAGGA_SCALE, $width, $height); } /** - * @param mixed ...$args * - * @return Imagga * * @internal */ - protected static function createImagga(...$args) + protected static function createImagga(...$args): Imagga { return new Imagga(...$args); } diff --git a/src/Transformation/Resize/BaseResizeAction.php b/src/Transformation/Resize/BaseResizeAction.php index 2935780..c47e9de 100644 --- a/src/Transformation/Resize/BaseResizeAction.php +++ b/src/Transformation/Resize/BaseResizeAction.php @@ -12,7 +12,6 @@ use Cloudinary\ArrayUtils; use Cloudinary\ClassUtils; -use Cloudinary\Transformation\Expression\Expression; use Cloudinary\Transformation\Expression\ExpressionUtils; use Cloudinary\Transformation\Qualifier\Dimensions\Dimensions; use Cloudinary\Transformation\Qualifier\Dimensions\DimensionsTrait; @@ -27,18 +26,18 @@ abstract class BaseResizeAction extends BaseAction /** * @var string $name The resize action name. */ - protected static $name = 'resize'; + protected static string $name = 'resize'; use DimensionsTrait; /** * BaseResize constructor. * - * @param string|CropMode $cropMode The crop mode. - * @param int|string|Expression $width Optional. Width. - * @param int|string|Expression $height Optional. Height. + * @param string|CropMode $cropMode The crop mode. + * @param mixed $width Optional. Width. + * @param mixed $height Optional. Height. */ - public function __construct($cropMode, $width = null, $height = null) + public function __construct($cropMode, mixed $width = null, mixed $height = null) { parent::__construct(); @@ -52,9 +51,8 @@ public function __construct($cropMode, $width = null, $height = null) * * @param array $qualifiers The qualifiers. * - * @return static */ - public static function fromParams($qualifiers) + public static function fromParams(array $qualifiers): static { return new static( ArrayUtils::get($qualifiers, 'crop'), @@ -69,9 +67,8 @@ public static function fromParams($qualifiers) * * @param bool $ignoreAspectRatio Indicates whether to ignore aspect ratio or not * - * @return static */ - protected function ignoreAspectRatio($ignoreAspectRatio = true) + protected function ignoreAspectRatio(bool $ignoreAspectRatio = true): static { return $this->setFlag(Flag::ignoreAspectRatio(), $ignoreAspectRatio); } @@ -81,23 +78,21 @@ protected function ignoreAspectRatio($ignoreAspectRatio = true) * * @param string|FlagQualifier $resizeMode The resize mode. Can be set to: relative or regionRelative. * - * @return static * * @see ResizeMode::relative * @see ResizeMode::regionRelative */ - public function resizeMode($resizeMode) + public function resizeMode(FlagQualifier|string $resizeMode): static { return $this->setFlag($resizeMode); } /** * Modifies percentage-based width & height qualifiers of overlays and underlays (e.g., 1.0) to be relative to the - * overlaid region. Currently regions are only defined when using gravity 'face', 'faces' or 'custom'. + * overlaid region. Currently, regions are only defined when using gravity 'face', 'faces' or 'custom'. * - * @return static */ - public function regionRelative() + public function regionRelative(): static { return $this->setFlag(new FlagQualifier(Flag::REGION_RELATIVE)); } @@ -106,9 +101,8 @@ public function regionRelative() * Modifies percentage-based width & height qualifiers of overlays and underlays (e.g., 1.0) to be relative to the * containing image instead of the added layer. * - * @return static */ - public function relative() + public function relative(): static { return $this->setFlag(new FlagQualifier(Flag::RELATIVE)); } @@ -118,11 +112,10 @@ public function relative() * * @param Dimensions|mixed $value The dimensions. * - * @return static * * @internal */ - protected function setDimension($value) + protected function setDimension(mixed $value): static { if (! isset($this->qualifiers[Dimensions::getName()])) { $this->addQualifier(new Dimensions()); diff --git a/src/Transformation/Resize/Crop/Crop.php b/src/Transformation/Resize/Crop/Crop.php index 201ba78..95182cc 100644 --- a/src/Transformation/Resize/Crop/Crop.php +++ b/src/Transformation/Resize/Crop/Crop.php @@ -10,9 +10,6 @@ namespace Cloudinary\Transformation; -use Cloudinary\Transformation\CropMode; -use Cloudinary\Transformation\Expression\Expression; - /** * Class Crop */ @@ -27,15 +24,21 @@ class Crop extends BaseResizeAction /** * Crop constructor. * - * @param string|CropMode $cropMode - * @param int|string|Expression $width - * @param int|string|Expression $height - * @param mixed $gravity - * @param float|int|string $x - * @param float|int|string $y + * @param string|CropMode $cropMode + * @param mixed $width + * @param mixed $height + * @param mixed $gravity + * @param mixed $x + * @param mixed $y */ - public function __construct($cropMode, $width = null, $height = null, $gravity = null, $x = null, $y = null) - { + public function __construct( + string|CropMode $cropMode, + mixed $width = null, + mixed $height = null, + mixed $gravity = null, + mixed $x = null, + mixed $y = null + ) { parent::__construct($cropMode, $width, $height); $this->gravity($gravity); @@ -45,13 +48,11 @@ public function __construct($cropMode, $width = null, $height = null, $gravity = /** * Internal setter for the point value. * - * @param $value * - * @return static * * @internal */ - public function setPointValue($value) + public function setPointValue($value): static { if (! isset($this->qualifiers[AbsolutePosition::getName()])) { $this->addQualifier(Position::absolute()); diff --git a/src/Transformation/Resize/Crop/CropPad.php b/src/Transformation/Resize/Crop/CropPad.php index 695a491..2a96ec7 100644 --- a/src/Transformation/Resize/Crop/CropPad.php +++ b/src/Transformation/Resize/Crop/CropPad.php @@ -33,7 +33,7 @@ class CropPad extends Crop * @param mixed $gravity * @param string|Background|ColorValue $background */ - public function __construct($cropMode, $width = null, $height = null, $gravity = null, $background = null) + public function __construct($cropMode, $width = null, $height = null, mixed $gravity = null, $background = null) { if ($gravity === null) { $gravity = Gravity::auto(); @@ -47,11 +47,10 @@ public function __construct($cropMode, $width = null, $height = null, $gravity = /** * Sets the gravity to use when using the FILL_PAD crop mode. * - * @param $autoGravity * * @return $this */ - public function gravity($autoGravity) + public function gravity(mixed $autoGravity): static { if (! $autoGravity instanceof AutoGravity) { throw new InvalidArgumentException('CropPad only supports Auto Gravity'); diff --git a/src/Transformation/Resize/Crop/CropPadTrait.php b/src/Transformation/Resize/Crop/CropPadTrait.php index 95be1cf..abf0aaf 100644 --- a/src/Transformation/Resize/Crop/CropPadTrait.php +++ b/src/Transformation/Resize/Crop/CropPadTrait.php @@ -28,17 +28,20 @@ trait CropPadTrait * * Only supported in conjunction with Automatic cropping (Gravity::auto()) * - * @param int|float|string|null $width The required width of a transformed asset. - * @param int|float|null $height The required height of a transformed asset. - * @param FocalGravity|string $gravity Specifies which part of the original image to include. - * @param Background|ColorValue|string $background The background color of the image. + * @param float|int|string|null $width The required width of a transformed asset. + * @param float|int|null $height The required height of a transformed asset. + * @param string|AutoGravity|null $gravity Specifies which part of the original image to include. + * @param string|Background|ColorValue|null $background The background color of the image. * - * @return CropPad * * @see Gravity::auto */ - public static function autoPad($width = null, $height = null, $gravity = null, $background = null) - { + public static function autoPad( + float|int|string|null $width = null, + float|int|null $height = null, + string|AutoGravity|null $gravity = null, + Background|ColorValue|string|null $background = null + ): CropPad { return new CropPad(CropMode::AUTO_PAD, $width, $height, $gravity, $background); } } diff --git a/src/Transformation/Resize/Crop/CropTrait.php b/src/Transformation/Resize/Crop/CropTrait.php index e5e5878..fafcaaf 100644 --- a/src/Transformation/Resize/Crop/CropTrait.php +++ b/src/Transformation/Resize/Crop/CropTrait.php @@ -20,16 +20,20 @@ trait CropTrait /** * Extracts a region of the given width and height out of the original image. * - * @param int|float|string|null $width The required width of a transformed asset. - * @param int|float|null $height The required height of a transformed asset. - * @param Gravity $gravity Which part of the original image to include. - * @param int|float|X $x Horizontal position for custom-coordinates based cropping - * @param int|float|Y $y Vertical position for custom-coordinates based cropping + * @param mixed $width The required width of a transformed asset. + * @param mixed $height The required height of a transformed asset. + * @param mixed $gravity Which part of the original image to include. + * @param mixed $x Horizontal position for custom-coordinates based cropping + * @param mixed $y Vertical position for custom-coordinates based cropping * - * @return Crop */ - public static function crop($width = null, $height = null, $gravity = null, $x = null, $y = null) - { + public static function crop( + mixed $width = null, + mixed $height = null, + mixed $gravity = null, + mixed $x = null, + mixed $y = null + ): Crop { return static::createCrop(CropMode::CROP, $width, $height, $gravity, $x, $y); } @@ -38,16 +42,20 @@ public static function crop($width = null, $height = null, $gravity = null, $x = * coordinates, and must always be accompanied by the gravity qualifier set to one of the face detection or custom * values. * - * @param int|float|string|null $width The required width of a transformed asset. - * @param int|float|null $height The required height of a transformed asset. - * @param Gravity $gravity Which part of the original image to include. - * @param int|float|X $x Horizontal position for custom-coordinates based cropping - * @param int|float|Y $y Vertical position for custom-coordinates based cropping + * @param mixed $width The required width of a transformed asset. + * @param mixed $height The required height of a transformed asset. + * @param mixed $gravity Which part of the original image to include. + * @param mixed $x Horizontal position for custom-coordinates based cropping + * @param mixed $y Vertical position for custom-coordinates based cropping * - * @return Crop */ - public static function thumbnail($width = null, $height = null, $gravity = null, $x = null, $y = null) - { + public static function thumbnail( + mixed $width = null, + mixed $height = null, + mixed $gravity = null, + mixed $x = null, + mixed $y = null + ): Crop { return static::createCrop(CropMode::THUMBNAIL, $width, $height, $gravity, $x, $y); } @@ -58,25 +66,25 @@ public static function thumbnail($width = null, $height = null, $gravity = null, * If the requested dimensions are larger than the original image, the result is upscaled. * Use this mode in conjunction with the g (gravity) parameter. * - * @param int|float|string|null $width The required width of a transformed asset. - * @param int|float|null $height The required height of a transformed asset. - * @param Gravity $gravity Which part of the original image to include. + * @param mixed $width The required width of a transformed asset. + * @param mixed $height The required height of a transformed asset. + * @param AutoGravity|null $gravity Which part of the original image to include. * - * @return Crop */ - public static function auto($width = null, $height = null, $gravity = null) - { + public static function auto( + mixed $width = null, + mixed $height = null, + ?AutoGravity $gravity = null + ): Crop { return static::createCrop(CropMode::AUTO, $width, $height, $gravity); } /** * Creates Crop instance. * - * @param mixed ...$args * - * @return Crop */ - protected static function createCrop(...$args) + protected static function createCrop(...$args): Crop { return new Crop(...$args); } diff --git a/src/Transformation/Resize/Fill/Fill.php b/src/Transformation/Resize/Fill/Fill.php index f8fa1b2..6426707 100644 --- a/src/Transformation/Resize/Fill/Fill.php +++ b/src/Transformation/Resize/Fill/Fill.php @@ -10,7 +10,6 @@ namespace Cloudinary\Transformation; -use Cloudinary\Transformation\CropMode; use Cloudinary\Transformation\Expression\Expression; /** @@ -28,9 +27,9 @@ class Fill extends BaseResizeAction * @param string|CropMode $cropMode * @param int|string|Expression $width * @param int|string|Expression $height - * @param mixed $gravity + * @param mixed|null $gravity */ - public function __construct($cropMode, $width = null, $height = null, $gravity = null) + public function __construct($cropMode, $width = null, $height = null, mixed $gravity = null) { parent::__construct($cropMode, $width, $height); @@ -41,13 +40,12 @@ public function __construct($cropMode, $width = null, $height = null, $gravity = /** * Internal setter for offset. * - * @param $value * * @return $this * * @internal */ - public function setPointValue($value) + public function setPointValue(mixed $value): static { if (! isset($this->qualifiers[Point::getName()])) { $this->addQualifier(new Point()); diff --git a/src/Transformation/Resize/Fill/FillPad.php b/src/Transformation/Resize/Fill/FillPad.php index 4aa3ff0..a9df56c 100644 --- a/src/Transformation/Resize/Fill/FillPad.php +++ b/src/Transformation/Resize/Fill/FillPad.php @@ -11,8 +11,6 @@ namespace Cloudinary\Transformation; use Cloudinary\Transformation\Argument\ColorValue; -use Cloudinary\Transformation\Background; -use Cloudinary\Transformation\CropMode; use Cloudinary\Transformation\Expression\Expression; use InvalidArgumentException; @@ -29,15 +27,14 @@ class FillPad extends Fill /** * FillPad constructor. - * - * @param string|CropMode $cropMode - * @param int|string|Expression $width - * @param int|string|Expression $height - * @param mixed $gravity - * @param string|Background|ColorValue $background */ - public function __construct($cropMode, $width = null, $height = null, $gravity = null, $background = null) - { + public function __construct( + string|CropMode $cropMode, + mixed $width = null, + mixed $height = null, + mixed $gravity = null, + Background|ColorValue|string|null $background = null + ) { if ($gravity === null) { $gravity = Gravity::auto(); } @@ -50,11 +47,10 @@ public function __construct($cropMode, $width = null, $height = null, $gravity = /** * Sets the gravity to use when using the FILL_PAD crop mode. * - * @param $autoGravity * * @return $this */ - public function gravity($autoGravity) + public function gravity(mixed $autoGravity): static { if (! $autoGravity instanceof AutoGravity) { throw new InvalidArgumentException('FillPad only supports Auto Gravity'); @@ -68,11 +64,9 @@ public function gravity($autoGravity) /** * @internal * - * @param $value * - * @return static */ - public function setOffsetValue($value) + public function setOffsetValue($value): static { if (! isset($this->qualifiers[Offset::getName()])) { $this->addQualifier(new Offset()); diff --git a/src/Transformation/Resize/Fill/FillPadTrait.php b/src/Transformation/Resize/Fill/FillPadTrait.php index fd0a7c1..12b658d 100644 --- a/src/Transformation/Resize/Fill/FillPadTrait.php +++ b/src/Transformation/Resize/Fill/FillPadTrait.php @@ -28,17 +28,20 @@ trait FillPadTrait * * Only supported in conjunction with Automatic cropping (Gravity::auto()) * - * @param int|float|string|null $width The required width of a transformed asset. - * @param int|float|null $height The required height of a transformed asset. - * @param FocalGravity|string $gravity Specifies which part of the original image to include. - * @param string|ColorValue $background The background color of the image. + * @param float|int|string|null $width The required width of a transformed asset. + * @param float|int|null $height The required height of a transformed asset. + * @param string|FocalGravity|null $gravity Specifies which part of the original image to include. + * @param string|ColorValue|null $background The background color of the image. * - * @return FillPad * * @see Gravity::auto */ - public static function fillPad($width = null, $height = null, $gravity = null, $background = null) - { + public static function fillPad( + float|int|string|null $width = null, + float|int|null $height = null, + string|FocalGravity|null $gravity = null, + ColorValue|string|null $background = null + ): FillPad { return new FillPad(CropMode::FILL_PAD, $width, $height, $gravity, $background); } } diff --git a/src/Transformation/Resize/Fill/FillTrait.php b/src/Transformation/Resize/Fill/FillTrait.php index ac566f3..55cccbd 100644 --- a/src/Transformation/Resize/Fill/FillTrait.php +++ b/src/Transformation/Resize/Fill/FillTrait.php @@ -24,15 +24,17 @@ trait FillTrait * requested aspect ratio is different than the original, cropping will occur on the dimension that exceeds the * requested size after scaling. * - * @param int|float|string|null $width The required width of a transformed asset. - * @param int|float|null $height The required height of a transformed asset. - * @param Gravity $gravity Which part of the original image to include when the resulting image is + * @param float|int|string|null $width The required width of a transformed asset. + * @param float|int|null $height The required height of a transformed asset. + * @param GravityQualifier|null $gravity Which part of the original image to include when the resulting image is * smaller than the original or the proportions do not match. * - * @return Fill */ - public static function fill($width = null, $height = null, $gravity = null) - { + public static function fill( + float|int|string|null $width = null, + float|int|null $height = null, + ?GravityQualifier $gravity = null + ): Fill { return static::createFill(CropMode::FILL, $width, $height, $gravity); } @@ -45,30 +47,30 @@ public static function fill($width = null, $height = null, $gravity = null) * * This prevents upscaling. * - * @param int|float|string|null $width The required width of a transformed asset. - * @param int|float|null $height The required height of a transformed asset. - * @param Gravity $gravity Which part of the original image to include when the resulting image is + * @param float|int|string|null $width The required width of a transformed asset. + * @param float|int|null $height The required height of a transformed asset. + * @param GravityQualifier|null $gravity Which part of the original image to include when the resulting image is * smaller than the original or the proportions do not match. * - * @return Fill * * @see Fill::fill */ - public static function limitFill($width = null, $height = null, $gravity = null) - { + public static function limitFill( + float|int|string|null $width = null, + float|int|null $height = null, + ?GravityQualifier $gravity = null + ): Fill { return static::createFill(CropMode::LIMIT_FILL, $width, $height, $gravity); } /** * Creates Fill instance. * - * @param mixed ...$args * - * @return Fill * * @internal */ - protected static function createFill(...$args) + protected static function createFill(...$args): Fill { return new Fill(...$args); } diff --git a/src/Transformation/Resize/Generic/GenericResize.php b/src/Transformation/Resize/Generic/GenericResize.php index f0d6730..39ef149 100644 --- a/src/Transformation/Resize/Generic/GenericResize.php +++ b/src/Transformation/Resize/Generic/GenericResize.php @@ -30,7 +30,7 @@ class GenericResize extends BaseResizeAction * * @internal */ - public function setOffsetValue($value) + public function setOffsetValue($value): static { if (! isset($this->qualifiers[CompassPosition::getName()])) { $this->addQualifier(new CompassPosition()); diff --git a/src/Transformation/Resize/Generic/GenericResizeTrait.php b/src/Transformation/Resize/Generic/GenericResizeTrait.php index 4281832..d784e23 100644 --- a/src/Transformation/Resize/Generic/GenericResizeTrait.php +++ b/src/Transformation/Resize/Generic/GenericResizeTrait.php @@ -20,30 +20,27 @@ trait GenericResizeTrait /** * Generic resize builder. * - * @param string $resizeName Provide future (not supported in the current version) resize name. - * @param int|float|string|null $width The required width of a transformed asset. - * @param int|float|null $height The required height of a transformed asset. + * @param string $resizeName Provide future (not supported in the current version) resize name. + * @param mixed $width The required width of a transformed asset. + * @param mixed $height The required height of a transformed asset. * - * @return static */ public static function generic( - $resizeName, - $width = null, - $height = null - ) { + string $resizeName, + mixed $width = null, + mixed $height = null + ): static { return static::createGenericResize($resizeName, $width, $height); } /** * Creates GenericResize instance. * - * @param mixed ...$args * - * @return static * * @internal */ - protected static function createGenericResize(...$args) + protected static function createGenericResize(...$args): static { return new static(...$args); } diff --git a/src/Transformation/Resize/Pad/Pad.php b/src/Transformation/Resize/Pad/Pad.php index 281cbfe..97754b7 100644 --- a/src/Transformation/Resize/Pad/Pad.php +++ b/src/Transformation/Resize/Pad/Pad.php @@ -10,7 +10,6 @@ namespace Cloudinary\Transformation; -use Cloudinary\Transformation\Background; use Cloudinary\Transformation\Argument\ColorValue; use Cloudinary\Transformation\Expression\Expression; @@ -24,16 +23,14 @@ class Pad extends BaseResizeAction /** * Pad constructor. * - * @param $cropMode * @param int|null|string|Expression $width * @param int|null|string|Expression $height - * @param string|Background|ColorValue $background */ public function __construct( $cropMode, $width = null, $height = null, - $background = null + Background|ColorValue|string|null $background = null ) { parent::__construct($cropMode, $width, $height); diff --git a/src/Transformation/Resize/Pad/PadTrait.php b/src/Transformation/Resize/Pad/PadTrait.php index ba676fd..65214e6 100644 --- a/src/Transformation/Resize/Pad/PadTrait.php +++ b/src/Transformation/Resize/Pad/PadTrait.php @@ -29,17 +29,16 @@ trait PadTrait * If the proportions of the original image do not match the given width and height, * padding is added to the image to reach the required size * - * @param int|float|string|null $width The required width of a transformed asset. - * @param int|float|null $height The required height of a transformed asset. - * @param string|ColorValue $background Sets the background color of the image. + * @param float|int|string|null $width The required width of a transformed asset. + * @param float|int|null $height The required height of a transformed asset. + * @param mixed $background Sets the background color of the image. * - * @return Pad */ public static function pad( - $width = null, - $height = null, - $background = null - ) { + float|int|string|null $width = null, + float|int|null $height = null, + mixed $background = null + ): Pad { return static::createPad(CropMode::PAD, $width, $height, $background); } @@ -50,19 +49,18 @@ public static function pad( * * This mode doesn't scale up the image if your requested dimensions are bigger than the original image's. * - * @param int|float|string|null $width The required width of a transformed asset. - * @param int|float|null $height The required height of a transformed asset. - * @param string|ColorValue $background Sets the background color of the image. + * @param float|int|string|null $width The required width of a transformed asset. + * @param float|int|null $height The required height of a transformed asset. + * @param string|ColorValue|null $background Sets the background color of the image. * - * @return Pad * - * @see \Cloudinary\Transformation\Pad::pad + * @see Pad::pad */ public static function limitPad( - $width = null, - $height = null, - $background = null - ) { + float|int|string|null $width = null, + float|int|null $height = null, + ColorValue|string|null $background = null + ): Pad { return static::createPad(CropMode::LIMIT_PAD, $width, $height, $background); } @@ -73,30 +71,27 @@ public static function limitPad( * * This mode doesn't scale down the image if your requested dimensions are smaller than the original image's. * - * @param int|float|string|null $width The required width of a transformed asset. - * @param int|float|null $height The required height of a transformed asset. - * @param string|ColorValue $background Sets the background color of the image. + * @param float|int|string|null $width The required width of a transformed asset. + * @param float|int|null $height The required height of a transformed asset. + * @param string|ColorValue|null $background Sets the background color of the image. * - * @return Pad * - * @see \Cloudinary\Transformation\Pad::pad + * @see Pad::pad */ public static function minimumPad( - $width = null, - $height = null, - $background = null - ) { + float|int|string|null $width = null, + float|int|null $height = null, + ColorValue|string|null $background = null + ): Pad { return static::createPad(CropMode::MINIMUM_PAD, $width, $height, $background); } /** * Creates Pad instance. * - * @param mixed ...$args * - * @return Pad */ - protected static function createPad(...$args) + protected static function createPad(...$args): Pad { return new Pad(...$args); } @@ -108,7 +103,7 @@ protected static function createPad(...$args) * * @return $this */ - public function position(BasePosition $position) + public function position(BasePosition $position): static { return $this->addQualifier($position); } @@ -116,13 +111,12 @@ public function position(BasePosition $position) /** * Internal setter for offset. * - * @param $value * * @return $this * * @internal */ - public function setOffsetValue($value) + public function setOffsetValue($value): static { if (! isset($this->qualifiers[CompassPosition::getName()])) { $this->addQualifier(new CompassPosition()); diff --git a/src/Transformation/Resize/Parameter/CropMode.php b/src/Transformation/Resize/Parameter/CropMode.php index 8954642..e9af864 100644 --- a/src/Transformation/Resize/Parameter/CropMode.php +++ b/src/Transformation/Resize/Parameter/CropMode.php @@ -26,25 +26,25 @@ class CropMode extends BaseQualifier /** * @var string $name The name of the CropMode qualifier. */ - protected static $name = 'crop_mode'; + protected static string $name = 'crop_mode'; /** * @var string $key The key of the CropMode qualifier. */ - protected static $key = 'c'; + protected static string $key = 'c'; /** * The SCALE crop mode changes the size of the asset exactly to the given width and height without necessarily * retaining the original aspect ratio. All original parts are visible but might be stretched or shrunk. */ - const SCALE = 'scale'; + public const SCALE = 'scale'; /** * The FIT crop mode resizes the asset so that it takes up as much space as possible within a bounding box defined * by the given width and height qualifiers. The original aspect ratio is retained and all of the original asset * is visible. */ - const FIT = 'fit'; + public const FIT = 'fit'; /** * The LIMIT_FIT crop mode resizes the asset so that it takes up as much space as possible within a bounding box @@ -52,7 +52,7 @@ class CropMode extends BaseQualifier * (width and height). The asset is scaled down, the original aspect ratio is retained and all of the original * asset is visible. */ - const LIMIT_FIT = 'limit'; + public const LIMIT_FIT = 'limit'; /** * The MINIMUM_FIT crop mode resizes the asset so that it takes up as much space as possible within a bounding box @@ -60,14 +60,14 @@ class CropMode extends BaseQualifier * minimum (width and height). The asset is scaled up, the original aspect ratio is retained and all of the * original asset is visible. */ - const MINIMUM_FIT = 'mfit'; + public const MINIMUM_FIT = 'mfit'; /** * The PAD crop mode resizes the asset to fill the given width and height while retaining the original aspect ratio. * If the proportions of the original asset do not match the given width and height, padding is added to the asset * to reach the required size. */ - const PAD = 'pad'; + public const PAD = 'pad'; /** * The LIMIT_PAD crop mode resizes the asset to fill the given width and height while retaining the original aspect @@ -75,7 +75,7 @@ class CropMode extends BaseQualifier * down. If the proportions of the original asset do not match the given width and height, padding is added to the * asset to reach the required size. */ - const LIMIT_PAD = 'lpad'; + public const LIMIT_PAD = 'lpad'; /** * The MINIMUM_PAD crop mode resizes the asset to fill the given width and height while retaining the original @@ -83,7 +83,7 @@ class CropMode extends BaseQualifier * scaled up. If the proportions of the original asset do not match the given width and height, padding is added * to the asset to reach the required size. */ - const MINIMUM_PAD = 'mpad'; + public const MINIMUM_PAD = 'mpad'; /** * The FILL crop mode creates an asset with the exact given width and height without distorting the asset. This @@ -91,7 +91,7 @@ class CropMode extends BaseQualifier * ratio is different than the original, cropping will occur on the dimension that exceeds the requested size after * scaling. */ - const FILL = 'fill'; + public const FILL = 'fill'; /** * The LIMIT_FILL crop mode creates an asset with the exact given width and height without distorting the asset, @@ -99,38 +99,38 @@ class CropMode extends BaseQualifier * the given width and height without distorting the asset, and then the dimension that exceeds the request is * cropped. If the original dimensions are both smaller than the requested size, it is not resized at all. */ - const LIMIT_FILL = 'lfill'; + public const LIMIT_FILL = 'lfill'; /** * The FILL_PAD crop mode tries to prevent a "bad crop" by first attempting to use the fill mode, but adds padding * if it is determined that more of the original asset needs to be included in the final asset. Only supported in * conjunction with automatic cropping (g_auto). */ - const FILL_PAD = 'fill_pad'; + public const FILL_PAD = 'fill_pad'; /** * The CROP crop mode extracts a given width and height out of the original asset. The original proportions are * retained and so is the size of the graphics. */ - const CROP = 'crop'; + public const CROP = 'crop'; /** * The THUMBNAIL crop mode generates a thumbnail using face detection in combination with the 'face' or 'faces' * gravity. */ - const THUMBNAIL = 'thumb'; + public const THUMBNAIL = 'thumb'; /** * The AUTO crop mode automatically determines the best crop based on the gravity and specified dimensions. */ - const AUTO = 'auto'; + public const AUTO = 'auto'; /** * The AUTO_PAD crop mode tries to prevent a "bad crop" by first attempting to use the auto cropping mode, * but adding some padding if the algorithm determines that more of the original image needs to be included in the * final image. */ - const AUTO_PAD = 'auto_pad'; + public const AUTO_PAD = 'auto_pad'; /** * The IMAGGA_CROP crop mode crops your image based on automatically calculated areas of interest within each @@ -138,7 +138,7 @@ class CropMode extends BaseQualifier * * @see https://cloudinary.com/documentation/imagga_crop_and_scale_addon#smartly_crop_images */ - const IMAGGA_CROP = 'imagga_crop'; + public const IMAGGA_CROP = 'imagga_crop'; /** * The IMAGGA_SCALE crop mode scales your image based on automatically calculated areas of interest within each @@ -146,5 +146,5 @@ class CropMode extends BaseQualifier * * @see https://cloudinary.com/documentation/imagga_crop_and_scale_addon#smartly_scale_images */ - const IMAGGA_SCALE = 'imagga_scale'; + public const IMAGGA_SCALE = 'imagga_scale'; } diff --git a/src/Transformation/Resize/Parameter/CropModeTrait.php b/src/Transformation/Resize/Parameter/CropModeTrait.php index 9556ae5..525c38b 100644 --- a/src/Transformation/Resize/Parameter/CropModeTrait.php +++ b/src/Transformation/Resize/Parameter/CropModeTrait.php @@ -21,9 +21,8 @@ trait CropModeTrait * * All original parts are visible but might be stretched or shrunk. * - * @return CropMode */ - public static function scale() + public static function scale(): CropMode { return new CropMode(CropMode::SCALE); } @@ -34,9 +33,8 @@ public static function scale() * * The original aspect ratio is retained and all of the original asset is visible. * - * @return CropMode */ - public static function fit() + public static function fit(): CropMode { return new CropMode(CropMode::FIT); } @@ -47,9 +45,8 @@ public static function fit() * * The asset is scaled down, the original aspect ratio is retained and all of the original asset is visible. * - * @return CropMode */ - public static function limitFit() + public static function limitFit(): CropMode { return new CropMode(CropMode::LIMIT_FIT); } @@ -60,9 +57,8 @@ public static function limitFit() * * The asset is scaled up, the original aspect ratio is retained and all of the original asset is visible. * - * @return CropMode */ - public static function minimumFit() + public static function minimumFit(): CropMode { return new CropMode(CropMode::MINIMUM_FIT); } @@ -73,9 +69,8 @@ public static function minimumFit() * If the proportions of the original asset do not match the given width and height, padding is added to the asset * to reach the required size. * - * @return CropMode */ - public static function pad() + public static function pad(): CropMode { return new CropMode(CropMode::PAD); } @@ -87,9 +82,8 @@ public static function pad() * The asset is scaled down. If the proportions of the original asset do not match the given width and height, * padding is added to the asset to reach the required size. * - * @return CropMode */ - public static function limitPad() + public static function limitPad(): CropMode { return new CropMode(CropMode::LIMIT_PAD); } @@ -101,9 +95,8 @@ public static function limitPad() * The asset is scaled up. If the proportions of the original asset do not match the given width and height, * padding is added to the asset to reach the required size. * - * @return CropMode */ - public static function minimumPad() + public static function minimumPad(): CropMode { return new CropMode(CropMode::MINIMUM_PAD); } @@ -115,9 +108,8 @@ public static function minimumPad() * aspect ratio is different than the original, cropping will occur on the dimension that exceeds the requested * size after scaling. * - * @return CropMode */ - public static function fill() + public static function fill(): CropMode { return new CropMode(CropMode::FILL); } @@ -130,9 +122,8 @@ public static function fill() * that exceeds the request is cropped. If the original dimensions are both smaller than the requested size, it is * not resized at all. * - * @return CropMode */ - public static function limitFill() + public static function limitFill(): CropMode { return new CropMode(CropMode::LIMIT_FILL); } @@ -143,9 +134,8 @@ public static function limitFill() * * Only supported in conjunction with automatic cropping (g_auto). * - * @return CropMode */ - public static function fillPad() + public static function fillPad(): CropMode { return new CropMode(CropMode::FILL_PAD); } @@ -155,9 +145,8 @@ public static function fillPad() * * The original proportions are retained and so is the size of the graphics. * - * @return CropMode */ - public static function crop() + public static function crop(): CropMode { return new CropMode(CropMode::CROP); } @@ -165,9 +154,8 @@ public static function crop() /** * Generates a thumbnail using face detection in combination with the 'face' or 'faces' gravity. * - * @return CropMode */ - public static function thumbnail() + public static function thumbnail(): CropMode { return new CropMode(CropMode::THUMBNAIL); } @@ -177,11 +165,10 @@ public static function thumbnail() * * For details, see the Imagga Crop and Scale add-on documentation. * - * @return CropMode * * @see https://cloudinary.com/documentation/imagga_crop_and_scale_addon#smartly_crop_images */ - public static function imaggaCrop() + public static function imaggaCrop(): CropMode { return new CropMode(CropMode::IMAGGA_CROP); } @@ -191,11 +178,10 @@ public static function imaggaCrop() * * For details, see the Imagga Crop and Scale add-on documentation. * - * @return CropMode * * @see https://cloudinary.com/documentation/imagga_crop_and_scale_addon#smartly_scale_images */ - public static function imaggaScale() + public static function imaggaScale(): CropMode { return new CropMode(CropMode::IMAGGA_SCALE); } @@ -203,11 +189,9 @@ public static function imaggaScale() /** * For future compatibility. * - * @param $cropModeName * - * @return CropMode */ - public static function generic($cropModeName) + public static function generic($cropModeName): CropMode { return new CropMode($cropModeName); } diff --git a/src/Transformation/Resize/Parameter/ResizeModeTrait.php b/src/Transformation/Resize/Parameter/ResizeModeTrait.php index 59a6c10..04c727c 100644 --- a/src/Transformation/Resize/Parameter/ResizeModeTrait.php +++ b/src/Transformation/Resize/Parameter/ResizeModeTrait.php @@ -21,9 +21,8 @@ trait ResizeModeTrait * Modifies percentage-based width & height qualifiers of overlays and underlays (e.g., 1.0) to be relative to the * overlaid region. Currently regions are only defined when using gravity 'face', 'faces' or 'custom'. * - * @return FlagQualifier */ - public static function regionRelative() + public static function regionRelative(): FlagQualifier { return new FlagQualifier(Flag::REGION_RELATIVE); } @@ -32,9 +31,8 @@ public static function regionRelative() * Modifies percentage-based width & height qualifiers of overlays and underlays (e.g., 1.0) to be relative to the * containing image instead of the added layer. * - * @return FlagQualifier */ - public static function relative() + public static function relative(): FlagQualifier { return new FlagQualifier(Flag::RELATIVE); } diff --git a/src/Transformation/Resize/Parameter/ResizeQualifierTrait.php b/src/Transformation/Resize/Parameter/ResizeQualifierTrait.php index 98e9129..4ff5602 100644 --- a/src/Transformation/Resize/Parameter/ResizeQualifierTrait.php +++ b/src/Transformation/Resize/Parameter/ResizeQualifierTrait.php @@ -22,11 +22,10 @@ trait ResizeQualifierTrait * * @param string $cropModeName The crop mode. Use the constants defined in the CropMode class. * - * @return CropMode * - * @see \Cloudinary\Transformation\CropMode + * @see CropMode */ - public static function cropMode($cropModeName) + public static function cropMode(string $cropModeName): CropMode { return new CropMode($cropModeName); } @@ -37,9 +36,8 @@ public static function cropMode($cropModeName) * * @param float $zoom The zoom factor. (Default: 1.0) * - * @return Zoom */ - public static function zoom($zoom) + public static function zoom(float $zoom): Zoom { return new Zoom($zoom); } diff --git a/src/Transformation/Resize/Parameter/ZoomTrait.php b/src/Transformation/Resize/Parameter/ZoomTrait.php index 80b0e5e..d89a8f2 100644 --- a/src/Transformation/Resize/Parameter/ZoomTrait.php +++ b/src/Transformation/Resize/Parameter/ZoomTrait.php @@ -23,9 +23,8 @@ trait ZoomTrait * * @param float $zoom The zoom factor. (Default: 1.0) * - * @return static */ - public function zoom($zoom) + public function zoom(float $zoom): static { return $this->addQualifier(ClassUtils::verifyInstance($zoom, Zoom::class)); } diff --git a/src/Transformation/Resize/ResizeFactory.php b/src/Transformation/Resize/ResizeFactory.php index ce387e6..16d81ba 100644 --- a/src/Transformation/Resize/ResizeFactory.php +++ b/src/Transformation/Resize/ResizeFactory.php @@ -20,24 +20,24 @@ class ResizeFactory /** * @var array $resizeTypes Supported types of the resize. */ - private static $resizeTypes = ['Scale', 'Crop', 'Pad', 'Fill', 'FillPad', 'Imagga']; // TODO: load this dynamically + private static array $resizeTypes = ['Scale', 'Crop', 'Pad', 'Fill', 'FillPad', 'Imagga']; // TODO: load this dynamically /** * @var array $resizeModes Supported resize(crop) modes. */ - private static $resizeModes; + private static array $resizeModes; /** * Populates resize (crop) modes. */ - private static function populateModes() + private static function populateModes(): void { foreach (self::$resizeTypes as $type) { $typeClass = __NAMESPACE__ . "\\$type"; $currTypeModes = get_class_methods($typeClass); - foreach ($currTypeModes as $currModeName => $currModeVal) { + foreach ($currTypeModes as $currModeVal) { self::$resizeModes[$currModeVal] = $type; } } @@ -46,13 +46,12 @@ private static function populateModes() /** * Creates a Resize instance from mode name. * - * @param CropMode|string $mode The resize(crop) mode. - * @param mixed $width Optional. Width. - * @param mixed $height Optional. Height. + * @param string|CropMode $mode The resize(crop) mode. + * @param mixed|null $width Optional. Width. + * @param mixed|null $height Optional. Height. * - * @return BaseResizeAction */ - public static function createResize($mode, $width = null, $height = null) + public static function createResize(CropMode|string $mode, mixed $width = null, mixed $height = null): BaseResizeAction { if (empty(self::$resizeModes)) { self::populateModes(); diff --git a/src/Transformation/Resize/Scale/Scale.php b/src/Transformation/Resize/Scale/Scale.php index ea833dd..4a352cd 100644 --- a/src/Transformation/Resize/Scale/Scale.php +++ b/src/Transformation/Resize/Scale/Scale.php @@ -26,9 +26,9 @@ class Scale extends BaseResizeAction * * @return $this * - * @see \Cloudinary\Transformation\LiquidRescaling + * @see LiquidRescaling */ - public function liquidRescaling() + public function liquidRescaling(): static { /** @noinspection TypeUnsafeComparisonInspection */ if ($this->qualifiers[CropMode::getName()]->getValue() != CropMode::SCALE) { diff --git a/src/Transformation/Resize/Scale/ScaleTrait.php b/src/Transformation/Resize/Scale/ScaleTrait.php index 2c5f0cd..b56b9da 100644 --- a/src/Transformation/Resize/Scale/ScaleTrait.php +++ b/src/Transformation/Resize/Scale/ScaleTrait.php @@ -21,13 +21,12 @@ trait ScaleTrait * Change the size of the image exactly to the given width and height without necessarily retaining the original * aspect ratio: all original image parts are visible but might be stretched or shrunk. * - * @param int|float|string|null $width The required width of a transformed asset. - * @param int|float|null $height The required height of a transformed asset. - * @param int|float|array $aspectRatio Resizes the asset to a new aspect ratio. + * @param mixed $width The required width of a transformed asset. + * @param mixed $height The required height of a transformed asset. + * @param mixed $aspectRatio Resizes the asset to a new aspect ratio. * - * @return Scale */ - public static function scale($width = null, $height = null, $aspectRatio = null) + public static function scale(mixed $width = null, mixed $height = null, mixed $aspectRatio = null): Scale { return static::createScale(CropMode::SCALE, $width, $height, $aspectRatio); } @@ -36,14 +35,16 @@ public static function scale($width = null, $height = null, $aspectRatio = null) * The image is resized so that it takes up as much space as possible within a bounding box defined by the given * width and height qualifiers. The original aspect ratio is retained and all of the original image is visible. * - * @param int|float|string|null $width The required width of a transformed asset. - * @param int|float|null $height The required height of a transformed asset. - * @param int|float|array $aspectRatio Resizes the asset to a new aspect ratio. + * @param mixed $width The required width of a transformed asset. + * @param mixed $height The required height of a transformed asset. + * @param mixed $aspectRatio Resizes the asset to a new aspect ratio. * - * @return Scale */ - public static function fit($width = null, $height = null, $aspectRatio = null) - { + public static function fit( + mixed $width = null, + mixed $height = null, + mixed $aspectRatio = null + ): Scale { return static::createScale(CropMode::FIT, $width, $height, $aspectRatio); } @@ -53,16 +54,18 @@ public static function fit($width = null, $height = null, $aspectRatio = null) * box defined by the given width and height qualifiers. The original aspect ratio is retained and all of the * original image is visible. * - * @param int|float|string $width The required width of a transformed asset. - * @param int|float $height The required height of a transformed asset. - * @param int|float|array $aspectRatio Resizes the asset to a new aspect ratio. + * @param mixed $width The required width of a transformed asset. + * @param mixed $height The required height of a transformed asset. + * @param mixed $aspectRatio Resizes the asset to a new aspect ratio. * - * @return Scale * * @see Scale::fit */ - public static function limitFit($width = null, $height = null, $aspectRatio = null) - { + public static function limitFit( + mixed $width = null, + mixed $height = null, + mixed $aspectRatio = null + ): Scale { return static::createScale(CropMode::LIMIT_FIT, $width, $height, $aspectRatio); } @@ -72,27 +75,27 @@ public static function limitFit($width = null, $height = null, $aspectRatio = nu * box defined by the given width and height qualifiers. The original aspect ratio is retained and all of the * original image is visible. * - * @param int|float|string|null $width The required width of a transformed asset. - * @param int|float|null $height The required height of a transformed asset. - * @param int|float|array $aspectRatio Resizes the asset to a new aspect ratio. + * @param mixed $width The required width of a transformed asset. + * @param mixed $height The required height of a transformed asset. + * @param mixed $aspectRatio Resizes the asset to a new aspect ratio. * - * @return Scale * * @see Scale::fit */ - public static function minimumFit($width = null, $height = null, $aspectRatio = null) - { + public static function minimumFit( + mixed $width = null, + mixed $height = null, + mixed $aspectRatio = null + ): Scale { return static::createScale(CropMode::MINIMUM_FIT, $width, $height, $aspectRatio); } /** - * @param mixed ...$args * - * @return Scale * * @internal */ - protected static function createScale(...$args) + protected static function createScale(...$args): Scale { return new Scale(...$args); } diff --git a/src/Transformation/Resize/TransformationResizeTrait.php b/src/Transformation/Resize/TransformationResizeTrait.php index 5c4cf4f..07c13f5 100644 --- a/src/Transformation/Resize/TransformationResizeTrait.php +++ b/src/Transformation/Resize/TransformationResizeTrait.php @@ -24,9 +24,8 @@ trait TransformationResizeTrait * * @param BaseResizeAction $resize The resize action * - * @return static */ - public function resize(BaseResizeAction $resize) + public function resize(BaseResizeAction $resize): static { return $this->addAction($resize); } @@ -39,9 +38,8 @@ public function resize(BaseResizeAction $resize) * @param int|float|null $height The required height of a transformed asset. * @param int|float|array $aspectRatio Resizes the asset to a new aspect ratio. * - * @return static */ - public function scale($width = null, $height = null, $aspectRatio = null) + public function scale($width = null, $height = null, $aspectRatio = null): static { return $this->resize(Scale::scale($width, $height, $aspectRatio)); } @@ -55,9 +53,8 @@ public function scale($width = null, $height = null, $aspectRatio = null) * @param int|float|X $x Horizontal position for custom-coordinates based cropping * @param int|float|Y $y Vertical position for custom-coordinates based cropping * - * @return static */ - public function crop($width = null, $height = null, $gravity = null, $x = null, $y = null) + public function crop($width = null, $height = null, $gravity = null, $x = null, $y = null): static { return $this->resize(Crop::crop($width, $height, $gravity, $x, $y)); } @@ -74,9 +71,8 @@ public function crop($width = null, $height = null, $gravity = null, $x = null, * @param Gravity $gravity Which part of the original image to include when the resulting image is * smaller than the original or the proportions do not match. * - * @return static */ - public function fill($width = null, $height = null, $gravity = null) + public function fill($width = null, $height = null, $gravity = null): static { return $this->resize(Fill::fill($width, $height, $gravity)); } @@ -88,9 +84,8 @@ public function fill($width = null, $height = null, $gravity = null) * @param int|float|string|null $width The required width of a transformed asset. * @param int|float|null $height The required height of a transformed asset. * - * @return static */ - public function genericResize($name, $width = null, $height = null) + public function genericResize($name, $width = null, $height = null): static { return $this->resize(GenericResize::generic($name, $width, $height)); } diff --git a/src/Transformation/Rotation/Angle.php b/src/Transformation/Rotation/Angle.php index aa6f801..ebf8ea2 100644 --- a/src/Transformation/Rotation/Angle.php +++ b/src/Transformation/Rotation/Angle.php @@ -22,7 +22,7 @@ */ class Angle extends BaseQualifier implements RotationDegreeInterface, RotationModeInterface { - const VALUE_CLASS = Degree::class; + protected const VALUE_CLASS = Degree::class; use AngleTrait; use RotationModeTrait; @@ -32,19 +32,17 @@ class Angle extends BaseQualifier implements RotationDegreeInterface, RotationMo * * @param int|string|array $degree The rotation angle degree. */ - public function setAngle(...$degree) + public function setAngle(...$degree): void { $this->setQualifierValue(Degree::byAngle(...$degree)); } /** - * @param $value - * - * @return Angle + * Creates a new instance using provided qualifier. */ - public static function fromParams($value) + public static function fromParams(mixed $value): static { - return new self(...ArrayUtils::build($value)); + return new static(...ArrayUtils::build($value)); } /** @@ -52,13 +50,12 @@ public static function fromParams($value) * * @param int|array $degree Given degrees or mode. * - * @return Angle * * @internal */ - public static function createWithDegree(...$degree) + public static function createWithDegree(...$degree): static { - return new self(...$degree); + return new static(...$degree); } /** @@ -66,12 +63,11 @@ public static function createWithDegree(...$degree) * * @param string|RotationMode|array $mode Given mode. * - * @return Angle * * @internal */ - public static function createWithMode(...$mode) + public static function createWithMode(...$mode): static { - return new self(...$mode); + return new static(...$mode); } } diff --git a/src/Transformation/Rotation/AngleQualifierTrait.php b/src/Transformation/Rotation/AngleQualifierTrait.php index 3121ead..06107ae 100644 --- a/src/Transformation/Rotation/AngleQualifierTrait.php +++ b/src/Transformation/Rotation/AngleQualifierTrait.php @@ -22,9 +22,8 @@ trait AngleQualifierTrait * * @param int|string|array|mixed $degree The rotation degree and/or mode. * - * @return Angle */ - public static function angle(...$degree) + public static function angle(...$degree): Angle { return new Angle(...$degree); } diff --git a/src/Transformation/Rotation/AngleTrait.php b/src/Transformation/Rotation/AngleTrait.php index f970fb1..28aaf89 100644 --- a/src/Transformation/Rotation/AngleTrait.php +++ b/src/Transformation/Rotation/AngleTrait.php @@ -20,9 +20,8 @@ trait AngleTrait /** * Rotate image 90 degrees clockwise. * - * @return static */ - public static function deg90() + public static function deg90(): static { return static::createWithDegree(Degree::DEG_90); } @@ -30,9 +29,8 @@ public static function deg90() /** * Rotate image 180 degrees. * - * @return static */ - public static function deg180() + public static function deg180(): static { return static::createWithDegree(Degree::DEG_180); } @@ -40,9 +38,8 @@ public static function deg180() /** * Rotate image 90 degrees counterclockwise. * - * @return static */ - public static function deg270() + public static function deg270(): static { return static::createWithDegree(Degree::DEG_270); } @@ -52,9 +49,8 @@ public static function deg270() * * @param int|array $degree Given degrees. (Range: 0 to 360, Default: 0). * - * @return static */ - public static function byAngle(...$degree) + public static function byAngle(...$degree): static { return static::createWithDegree(...$degree); } diff --git a/src/Transformation/Rotation/Degree.php b/src/Transformation/Rotation/Degree.php index e3320c6..06e3563 100644 --- a/src/Transformation/Rotation/Degree.php +++ b/src/Transformation/Rotation/Degree.php @@ -24,25 +24,24 @@ */ class Degree extends ExpressionQualifierMultiValue implements RotationDegreeInterface { - const VALUE_DELIMITER = '.'; + protected const VALUE_DELIMITER = '.'; use AngleTrait; - const DEG_90 = '90'; - const DEG_180 = '180'; - const DEG_270 = '270'; + public const DEG_90 = '90'; + public const DEG_180 = '180'; + public const DEG_270 = '270'; /** * Creates the instance. * * @param int|array $degree Given degrees or mode. * - * @return Degree * * @internal */ - public static function createWithDegree(...$degree) + public static function createWithDegree(...$degree): static { - return new self(...$degree); + return new static(...$degree); } } diff --git a/src/Transformation/Rotation/Rotate.php b/src/Transformation/Rotation/Rotate.php index 0f2eef0..4240721 100644 --- a/src/Transformation/Rotation/Rotate.php +++ b/src/Transformation/Rotation/Rotate.php @@ -47,7 +47,7 @@ public function __construct(...$degree) * * @param mixed $degree The degrees of the angle. */ - public function setAngle(...$degree) + public function setAngle(...$degree): void { $this->addQualifier(Degree::byAngle(...$degree)); } @@ -57,11 +57,10 @@ public function setAngle(...$degree) * * @param mixed $degree The degree of the angle. * - * @return Rotate */ - public static function createWithDegree(...$degree) + public static function createWithDegree(...$degree): static { - return new self(Angle::byAngle(...$degree)); + return new static(Angle::byAngle(...$degree)); } /** @@ -69,10 +68,9 @@ public static function createWithDegree(...$degree) * * @param mixed $mode The rotation mode. * - * @return Rotate */ - public static function createWithMode(...$mode) + public static function createWithMode(...$mode): static { - return new self(Angle::mode(...$mode)); + return new static(Angle::mode(...$mode)); } } diff --git a/src/Transformation/Rotation/RotationDegreeInterface.php b/src/Transformation/Rotation/RotationDegreeInterface.php index f8997f7..d015ae0 100644 --- a/src/Transformation/Rotation/RotationDegreeInterface.php +++ b/src/Transformation/Rotation/RotationDegreeInterface.php @@ -20,9 +20,8 @@ interface RotationDegreeInterface * * @param int|array $degree Given degrees or mode. * - * @return self * * @internal */ - public static function createWithDegree(...$degree); + public static function createWithDegree(...$degree): RotationDegreeInterface; } diff --git a/src/Transformation/Rotation/RotationMode.php b/src/Transformation/Rotation/RotationMode.php index a8e12ba..8d6a3ce 100644 --- a/src/Transformation/Rotation/RotationMode.php +++ b/src/Transformation/Rotation/RotationMode.php @@ -24,27 +24,26 @@ */ class RotationMode extends QualifierMultiValue implements RotationModeInterface { - const VALUE_DELIMITER = '.'; + protected const VALUE_DELIMITER = '.'; use RotationModeTrait; - const AUTO_RIGHT = 'auto_right'; - const AUTO_LEFT = 'auto_left'; - const VERTICAL_FLIP = 'vflip'; - const HORIZONTAL_FLIP = 'hflip'; - const IGNORE = 'ignore'; + public const AUTO_RIGHT = 'auto_right'; + public const AUTO_LEFT = 'auto_left'; + public const VERTICAL_FLIP = 'vflip'; + public const HORIZONTAL_FLIP = 'hflip'; + public const IGNORE = 'ignore'; /** * Creates the instance. * * @param string|RotationMode|array $mode Given mode. * - * @return RotationMode * * @internal */ - public static function createWithMode(...$mode) + public static function createWithMode(...$mode): static { - return new self(...$mode); + return new static(...$mode); } } diff --git a/src/Transformation/Rotation/RotationModeInterface.php b/src/Transformation/Rotation/RotationModeInterface.php index 51f7ad9..80036be 100644 --- a/src/Transformation/Rotation/RotationModeInterface.php +++ b/src/Transformation/Rotation/RotationModeInterface.php @@ -22,9 +22,8 @@ interface RotationModeInterface * * @param string|RotationMode|array $mode Given mode. * - * @return self * * @internal */ - public static function createWithMode(...$mode); + public static function createWithMode(...$mode): RotationModeInterface; } diff --git a/src/Transformation/Rotation/RotationModeTrait.php b/src/Transformation/Rotation/RotationModeTrait.php index b354bda..3b8be7e 100644 --- a/src/Transformation/Rotation/RotationModeTrait.php +++ b/src/Transformation/Rotation/RotationModeTrait.php @@ -20,9 +20,8 @@ trait RotationModeTrait /** * Rotate image 90 degrees clockwise only if the requested aspect ratio does not match the image's aspect ratio. * - * @return static */ - public static function autoRight() + public static function autoRight(): static { return static::createWithMode(RotationMode::AUTO_RIGHT); } @@ -31,9 +30,8 @@ public static function autoRight() * Rotate image 90 degrees counterclockwise only if the requested aspect ratio does not match the image's aspect * ratio. * - * @return static */ - public static function autoLeft() + public static function autoLeft(): static { return static::createWithMode(RotationMode::AUTO_LEFT); } @@ -41,9 +39,8 @@ public static function autoLeft() /** * Vertical mirror flip of the image. * - * @return static */ - public static function verticalFlip() + public static function verticalFlip(): static { return static::createWithMode(RotationMode::VERTICAL_FLIP); } @@ -51,9 +48,8 @@ public static function verticalFlip() /** * Horizontal mirror flip of the image. * - * @return static */ - public static function horizontalFlip() + public static function horizontalFlip(): static { return static::createWithMode(RotationMode::HORIZONTAL_FLIP); } @@ -62,9 +58,8 @@ public static function horizontalFlip() * By default, the image is automatically rotated according to the EXIF data stored by the camera when the image * was taken. Set the angle to 'ignore' if you do not want the image to be automatically rotated. * - * @return static */ - public static function ignore() + public static function ignore(): static { return static::createWithMode(RotationMode::IGNORE); } @@ -74,9 +69,8 @@ public static function ignore() * * @param string|RotationMode|array $mode Given rotation mode. * - * @return static */ - public static function mode(...$mode) + public static function mode(...$mode): static { return static::createWithMode(...$mode); } diff --git a/src/Transformation/Shape/CornerRadius.php b/src/Transformation/Shape/CornerRadius.php index 940ed1a..61d61ca 100644 --- a/src/Transformation/Shape/CornerRadius.php +++ b/src/Transformation/Shape/CornerRadius.php @@ -17,29 +17,29 @@ */ class CornerRadius extends BaseQualifier { - const VALUE_CLASS = Corners::class; + protected const VALUE_CLASS = Corners::class; use CornerRadiusTrait; use CornersTrait; - const MAX = 'max'; + public const MAX = 'max'; /** * @var string $key Serialization key. */ - protected static $key = 'r'; + protected static string $key = 'r'; /** * Sets a simple unnamed value specified by name (for uniqueness) and the actual value. * - * @param string $name The name of the argument. - * @param BaseComponent|mixed $value The value of the argument. + * @param string $name The name of the argument. + * @param mixed|null $value The value of the argument. * * @return $this * * @internal */ - public function setSimpleValue($name, $value = null) + public function setSimpleValue(string $name, mixed $value = null): static { $this->value->setSimpleValue($name, $value); diff --git a/src/Transformation/Shape/CornerRadiusQualifierTrait.php b/src/Transformation/Shape/CornerRadiusQualifierTrait.php index e0c9e48..494435e 100644 --- a/src/Transformation/Shape/CornerRadiusQualifierTrait.php +++ b/src/Transformation/Shape/CornerRadiusQualifierTrait.php @@ -22,11 +22,10 @@ trait CornerRadiusQualifierTrait * * @param array $value The radius of the corner(s). See CornerRadius class for details. * - * @return CornerRadius * * @see CornerRadius */ - public static function cornerRadius(...$value) + public static function cornerRadius(...$value): CornerRadius { return new CornerRadius(...$value); } diff --git a/src/Transformation/Shape/CornerRadiusTrait.php b/src/Transformation/Shape/CornerRadiusTrait.php index 0bccbbe..9c992a4 100644 --- a/src/Transformation/Shape/CornerRadiusTrait.php +++ b/src/Transformation/Shape/CornerRadiusTrait.php @@ -20,9 +20,8 @@ trait CornerRadiusTrait /** * Generates an asset with a circular crop using the 'max' radius value. * - * @return static */ - public static function max() + public static function max(): static { return static::createWithRadius(CornerRadius::MAX); } @@ -37,9 +36,8 @@ public static function max() * * @param array $values * - * @return static */ - public static function byRadius(...$values) + public static function byRadius(...$values): static { return static::createWithRadius(...$values); } @@ -49,11 +47,10 @@ public static function byRadius(...$values) * * @param array $values * - * @return static * * @internal */ - protected static function createWithRadius(...$values) + protected static function createWithRadius(...$values): CornerRadius|static { return new CornerRadius(...$values); } diff --git a/src/Transformation/Shape/Corners.php b/src/Transformation/Shape/Corners.php index 541ba3f..1a81414 100644 --- a/src/Transformation/Shape/Corners.php +++ b/src/Transformation/Shape/Corners.php @@ -15,24 +15,24 @@ */ class Corners extends ExpressionQualifierMultiValue { - const MAX_ARGUMENTS = 4; + public const MAX_ARGUMENTS = 4; use CornersTrait; /** * @var array $argumentOrder The order of the arguments. */ - protected $argumentOrder = ['topLeft', 'topRight', 'bottomRight', 'bottomLeft']; + protected array $argumentOrder = ['topLeft', 'topRight', 'bottomRight', 'bottomLeft']; /** * Corners constructor. * * @param int|string|array $topLeft Top-left corner radius. - * @param int $topRight Top-right corner radius. - * @param int $bottomRight Bottom-right corner radius. - * @param int $bottomLeft Bottom-left corner radius. + * @param int|null $topRight Top-right corner radius. + * @param int|null $bottomRight Bottom-right corner radius. + * @param int|null $bottomLeft Bottom-left corner radius. */ - public function __construct($topLeft, $topRight = null, $bottomRight = null, $bottomLeft = null) + public function __construct($topLeft, ?int $topRight = null, ?int $bottomRight = null, ?int $bottomLeft = null) { if (is_array($topLeft)) { $corners = array_pad($topLeft, 4, null); diff --git a/src/Transformation/Shape/CornersTrait.php b/src/Transformation/Shape/CornersTrait.php index 1f3ae08..e939a5f 100644 --- a/src/Transformation/Shape/CornersTrait.php +++ b/src/Transformation/Shape/CornersTrait.php @@ -22,9 +22,8 @@ trait CornersTrait * * @param int $radius Radius length in pixels * - * @return static */ - public function topLeft($radius) + public function topLeft(int $radius): static { $this->setSimpleValue('topLeft', $radius); @@ -36,9 +35,8 @@ public function topLeft($radius) * * @param int|null $radius Radius length in pixels * - * @return static */ - public function topRight($radius) + public function topRight(?int $radius): static { $this->setSimpleValue('topRight', $radius); @@ -50,9 +48,8 @@ public function topRight($radius) * * @param int|null $radius Radius length in pixels * - * @return static */ - public function bottomRight($radius) + public function bottomRight(?int $radius): static { $this->setSimpleValue('bottomRight', $radius); @@ -64,9 +61,8 @@ public function bottomRight($radius) * * @param int|null $radius Radius length in pixels * - * @return static */ - public function bottomLeft($radius) + public function bottomLeft(?int $radius): static { $this->setSimpleValue('bottomLeft', $radius); @@ -78,9 +74,8 @@ public function bottomLeft($radius) * * @param int $radius Radius length in pixels * - * @return static */ - public function setRadius($radius) + public function setRadius(int $radius): static { $this->topLeft($radius); $this->topRight(null); @@ -96,9 +91,8 @@ public function setRadius($radius) * @param int $topLeftBottomRight Radius for top-left and bottom-right corners * @param int $topRightBottomLeft Radius for top-right and bottom-left corners * - * @return static */ - public function setSymmetricRadius($topLeftBottomRight, $topRightBottomLeft) + public function setSymmetricRadius(int $topLeftBottomRight, int $topRightBottomLeft): static { $this->topLeft($topLeftBottomRight); $this->topRight($topRightBottomLeft); @@ -115,9 +109,8 @@ public function setSymmetricRadius($topLeftBottomRight, $topRightBottomLeft) * @param int $topRightBottomLeft Radius for top-right and bottom-left corners * @param int $bottomRight Radius for bottom-right corner * - * @return static */ - public function setPartiallySymmetricRadius($topLeft, $topRightBottomLeft, $bottomRight) + public function setPartiallySymmetricRadius(int $topLeft, int $topRightBottomLeft, int $bottomRight): static { $this->topLeft($topLeft); $this->topRight($topRightBottomLeft); diff --git a/src/Transformation/Shape/Distort.php b/src/Transformation/Shape/Distort.php index 60684c6..77b83fd 100644 --- a/src/Transformation/Shape/Distort.php +++ b/src/Transformation/Shape/Distort.php @@ -20,17 +20,13 @@ class Distort extends EffectQualifier /** * DistortArc constructor. * - * @param PointValue|array|int|string $topLeft - * @param PointValue|array|int|string $topRight - * @param PointValue|array|int|string $bottomRight - * @param PointValue|array|int|string $bottomLeft - * @param mixed ...$args Additional arguments + * @param mixed ...$args Additional arguments */ public function __construct( - $topLeft = null, - $topRight = null, - $bottomRight = null, - $bottomLeft = null, + int|array|string|PointValue|null $topLeft = null, + int|array|string|PointValue|null $topRight = null, + int|array|string|PointValue|null $bottomRight = null, + int|array|string|PointValue|null $bottomLeft = null, ...$args ) { parent::__construct(ReshapeQualifier::DISTORT); diff --git a/src/Transformation/Shape/ReshapeQualifier.php b/src/Transformation/Shape/ReshapeQualifier.php index 8c43500..b929160 100644 --- a/src/Transformation/Shape/ReshapeQualifier.php +++ b/src/Transformation/Shape/ReshapeQualifier.php @@ -15,8 +15,8 @@ */ class ReshapeQualifier extends EffectQualifier { - const DISTORT = 'distort'; - const DISTORT_ARC = 'distort:arc'; - const TRIM = 'trim'; - const SHEAR = 'shear'; + public const DISTORT = 'distort'; + public const DISTORT_ARC = 'distort:arc'; + public const TRIM = 'trim'; + public const SHEAR = 'shear'; } diff --git a/src/Transformation/Shape/ReshapeTrait.php b/src/Transformation/Shape/ReshapeTrait.php index 5c5e652..34d0669 100644 --- a/src/Transformation/Shape/ReshapeTrait.php +++ b/src/Transformation/Shape/ReshapeTrait.php @@ -27,13 +27,12 @@ trait ReshapeTrait * * @param array $args The new coordinates of the image's corners. * - * @see \Cloudinary\Transformation\Distort + * @see Distort * - * @return Distort * * @see https://cloudinary.com/documentation/image_transformations#image_shape_changes_and_distortion_effects */ - public static function distort(...$args) + public static function distort(...$args): Distort { return ClassUtils::verifyVarArgsInstance($args, Distort::class); } @@ -47,11 +46,10 @@ public static function distort(...$args) * frown). Negative values curve the image downwards (like a smile). * * - * @return EffectAction * * @see https://cloudinary.com/documentation/image_transformations#image_shape_changes_and_distortion_effects */ - public static function distortArc($degree) + public static function distortArc(mixed $degree): EffectAction { if ($degree instanceof EffectAction) { return $degree; @@ -66,14 +64,13 @@ public static function distortArc($degree) * Specify a color other than the color of the corner pixels using the colorOverride() method of the * \Cloudinary\Transformation\TrimEffect class. * - * @param int $tolerance The tolerance level for color similarity. (Range: 0 to 100, Server default: 10) + * @param int|null $tolerance The tolerance level for color similarity. (Range: 0 to 100, Server default: 10) * - * @return TrimEffect * - * @see \Cloudinary\Transformation\TrimEffect + * @see TrimEffect * */ - public static function trim($tolerance = null) + public static function trim(?int $tolerance = null): TrimEffect { return ClassUtils::forceInstance($tolerance, TrimEffect::class); } @@ -81,14 +78,13 @@ public static function trim($tolerance = null) /** * Skews the image according to the two specified values in degrees. * - * @param float $skewX The angle of skew on the x-axis in degrees. - * @param float $skewY The angle of skew on the y-axis in degrees. + * @param float|int|null $skewX The angle of skew on the x-axis in degrees. + * @param float|int|null $skewY The angle of skew on the y-axis in degrees. * - * @return Shear - * @see \Cloudinary\Transformation\Shear + * @see Shear * */ - public static function shear($skewX = null, $skewY = null) + public static function shear(float|int|null $skewX = null, float|int|null $skewY = null): Shear { return new Shear($skewX, $skewY); } @@ -96,15 +92,16 @@ public static function shear($skewX = null, $skewY = null) /** * Trims pixels according to the transparency levels of a given overlay image. * - * @param string|BaseSource $source The public ID of the image overlay. - * @param Position|AbsolutePosition $position The position of the overlay with respect to the base image. + * @param string|BaseSource $source The public ID of the image overlay. + * @param AbsolutePosition|Position|null $position The position of the overlay with respect to the base image. * - * @return CutByImage * - * @see \Cloudinary\Transformation\CutByImage + * @see CutByImage */ - public static function cutByImage($source, $position = null) - { + public static function cutByImage( + BaseSource|string $source, + Position|AbsolutePosition|null $position = null + ): CutByImage { return new CutByImage($source, $position); } } diff --git a/src/Transformation/Shape/RoundCorners.php b/src/Transformation/Shape/RoundCorners.php index 9e548b2..1e2fa3d 100644 --- a/src/Transformation/Shape/RoundCorners.php +++ b/src/Transformation/Shape/RoundCorners.php @@ -32,7 +32,6 @@ class RoundCorners extends BaseAction /** * RoundCorners constructor. * - * @param mixed ...$qualifiers */ public function __construct(...$qualifiers) { @@ -42,26 +41,25 @@ public function __construct(...$qualifiers) /** * Sets the corner radius. * - * @param int|string|array|mixed $values The corner(s) radius. + * @param int|array|CornerRadius $radius The corner(s) radius. * - * @return static */ - public function setRadius(...$values) + public function setRadius(int|array|CornerRadius $radius): static { - return $this->addQualifier(ClassUtils::verifyVarArgsInstance($values, CornerRadius::class)); + return $this->addQualifier(ClassUtils::verifyVarArgsInstance($radius, CornerRadius::class)); } /** * Sets a simple unnamed value specified by name (for uniqueness) and the actual value. * - * @param string $name The name of the argument. - * @param BaseComponent|mixed $value The value of the argument. + * @param string $name The name of the argument. + * @param mixed|null $value The value of the argument. * * @return $this * * @internal */ - public function setSimpleValue($name, $value = null) + public function setSimpleValue(string $name, mixed $value = null): static { $this->qualifiers[CornerRadius::getName()]->setSimpleValue($name, $value); @@ -73,11 +71,10 @@ public function setSimpleValue($name, $value = null) * * @param int|string|array|mixed $radius The corner(s) radius. * - * @return static * * @internal */ - protected static function createWithRadius(...$radius) + protected static function createWithRadius(...$radius): static { return new static(CornerRadius::byRadius(...$radius)); } diff --git a/src/Transformation/Shape/Shear.php b/src/Transformation/Shape/Shear.php index 934a0bf..d29f04e 100644 --- a/src/Transformation/Shape/Shear.php +++ b/src/Transformation/Shape/Shear.php @@ -18,15 +18,12 @@ class Shear extends EffectQualifier /** * @var array $valueOrder The order of the values. */ - protected $valueOrder = [0, 'skew_x', 'skew_y']; + protected array $valueOrder = [0, 'skew_x', 'skew_y']; /** * Shear constructor. - * - * @param float $skewX - * @param float $skewY */ - public function __construct($skewX = null, $skewY = null) + public function __construct(float|int|null $skewX = null, float|int|null $skewY = null) { parent::__construct(ReshapeQualifier::SHEAR); @@ -37,11 +34,10 @@ public function __construct($skewX = null, $skewY = null) /** * Sets the angle of skew on the x-axis. * - * @param float $value The angle of skew on the x-axis in degrees. + * @param float|int|null $value The angle of skew on the x-axis in degrees. * - * @return Shear */ - public function skewX($value) + public function skewX(float|int|null $value): static { $this->value->setSimpleValue('skew_x', $value); @@ -51,11 +47,10 @@ public function skewX($value) /** * Sets the angle of skew on the y-axis. * - * @param float $value The angle of skew on the y-axis in degrees. + * @param float|int|null $value The angle of skew on the y-axis in degrees. * - * @return Shear */ - public function skewY($value) + public function skewY(float|int|null $value): static { $this->value->setSimpleValue('skew_y', $value); diff --git a/src/Transformation/Shape/TrimEffect.php b/src/Transformation/Shape/TrimEffect.php index 463b73b..77404aa 100644 --- a/src/Transformation/Shape/TrimEffect.php +++ b/src/Transformation/Shape/TrimEffect.php @@ -18,19 +18,18 @@ * * @api * - * @see \Cloudinary\Transformation\ReshapeTrait::trim() + * @see ReshapeTrait::trim */ class TrimEffect extends LimitedEffectQualifier { /** * @var array $valueOrder The order of the values. */ - protected $valueOrder = [0, 'color_similarity', 'color_override']; + protected array $valueOrder = [0, 'color_similarity', 'color_override']; /** * Trim constructor. * - * @param $colorSimilarity */ public function __construct($colorSimilarity = null) { @@ -44,9 +43,8 @@ public function __construct($colorSimilarity = null) * * @param int $colorSimilarity The tolerance level for color similarity. (Range: 0 to 100, Server default: 10) * - * @return TrimEffect */ - public function colorSimilarity($colorSimilarity) + public function colorSimilarity(int $colorSimilarity): static { $this->value->setSimpleValue('color_similarity', $colorSimilarity); @@ -59,9 +57,8 @@ public function colorSimilarity($colorSimilarity) * * @param string $colorOverride The color to trim as a named color or an RGB/A hex code. * - * @return TrimEffect */ - public function colorOverride($colorOverride) + public function colorOverride(string $colorOverride): static { $this->value->setSimpleValue('color_override', ClassUtils::verifyInstance($colorOverride, ColorValue::class)); diff --git a/src/Transformation/SourceBasedEffectAction.php b/src/Transformation/SourceBasedEffectAction.php index 5463065..4327b3e 100644 --- a/src/Transformation/SourceBasedEffectAction.php +++ b/src/Transformation/SourceBasedEffectAction.php @@ -23,23 +23,23 @@ abstract class SourceBasedEffectAction extends EffectAction { /** - * @var BaseSource $source The source of the layer. + * @var ?BaseSource $source The source of the layer. */ - protected $source; + protected ?BaseSource $source; /** - * @var Position $position Layer position. + * @var ?BasePosition $position Layer position. */ - protected $position; + protected ?BasePosition $position; /** * BaseLayerContainer constructor. * * @param EffectQualifier|string $effect The effect name. - * @param BaseSource|string $source The source. - * @param Position $position Layer position. + * @param BaseSource|string|null $source The source. + * @param BasePosition|null $position Layer position. */ - public function __construct($effect, $source = null, $position = null) + public function __construct($effect, BaseSource|string|null $source = null, ?BasePosition $position = null) { parent::__construct($effect); @@ -50,11 +50,10 @@ public function __construct($effect, $source = null, $position = null) /** * Sets the source. * - * @param BaseSource|string $source The source. + * @param BaseSource|string|null $source The source. * - * @return static */ - public function source($source) + public function source(BaseSource|string|null $source): static { $this->source = ClassUtils::verifyInstance($source, BaseSource::class, ImageSource::class); @@ -64,11 +63,10 @@ public function source($source) /** * Sets the position of the layer. * - * @param BasePosition $position The position. + * @param BasePosition|null $position The position. * - * @return static */ - public function position($position = null) + public function position(?BasePosition $position = null): static { $this->position = ClassUtils::verifyInstance($position, BasePosition::class, AbsolutePosition::class); @@ -94,10 +92,10 @@ public function position($position = null) * * @internal */ - protected function getSubActionQualifiers() + protected function getSubActionQualifiers(): array { $sourceQualifiers = $this->source ? $this->source->getStringQualifiers() : []; - $sourceTransformation = $this->source ? $this->source->getTransformation() : null; + $sourceTransformation = $this->source?->getTransformation(); $positionQualifiers = $this->position ? $this->position->getStringQualifiers() : []; $additionalQualifiers = $this->getStringQualifiers(); @@ -120,18 +118,16 @@ public function __toString() $subActions = $this->getSubActionQualifiers(); return ArrayUtils::implodeUrl([ - ArrayUtils::implodeActionQualifiers(...$subActions['source']), - $subActions['transformation'], - ArrayUtils::implodeActionQualifiers(...$subActions['additional']), - ]); + ArrayUtils::implodeActionQualifiers(...$subActions['source']), + $subActions['transformation'], + ArrayUtils::implodeActionQualifiers(...$subActions['additional']), + ]); } /** * Serializes to json. - * - * @return mixed */ - public function jsonSerialize() + public function jsonSerialize(): array { return [ 'source' => $this->source, diff --git a/src/Transformation/Variable/Variable.php b/src/Transformation/Variable/Variable.php index ddb3b96..ebc52c6 100644 --- a/src/Transformation/Variable/Variable.php +++ b/src/Transformation/Variable/Variable.php @@ -27,7 +27,7 @@ */ class Variable extends GenericQualifier { - const VALUE_CLASS = VariableValue::class; + protected const VALUE_CLASS = VariableValue::class; const AS_FLOAT = 'to_f'; const AS_INTEGER = 'to_i'; @@ -37,9 +37,8 @@ class Variable extends GenericQualifier * @param string $name The name of the variable. * @param mixed $value The value of the variable. * - * @return Variable */ - public static function set($name, $value) + public static function set(string $name, mixed $value): Variable { return new self($name, $value); } @@ -50,9 +49,8 @@ public static function set($name, $value) * @param string $name The name of the variable. * @param mixed $publicId The referenced asset public id. * - * @return Variable */ - public static function setAssetReference($name, $publicId) + public static function setAssetReference(string $name, mixed $publicId): Variable { return new self($name, UVal::assetReference($publicId)); } @@ -63,9 +61,8 @@ public static function setAssetReference($name, $publicId) * @param string $name The name of the variable. * @param mixed $contextKey The context key. * - * @return Variable */ - public static function setFromContext($name, $contextKey) + public static function setFromContext(string $name, mixed $contextKey): Variable { return new self($name, UVal::context($contextKey)); } @@ -76,9 +73,8 @@ public static function setFromContext($name, $contextKey) * @param string $name The name of the variable. * @param mixed $metadataKey The metadata key. * - * @return Variable */ - public static function setFromMetadata($name, $metadataKey) + public static function setFromMetadata(string $name, mixed $metadataKey): Variable { return new self($name, UVal::metadata($metadataKey)); } @@ -90,7 +86,7 @@ public static function setFromMetadata($name, $metadataKey) * * @return $this */ - public function asFloat($asFloat = true) + public function asFloat(bool $asFloat = true): static { if ($asFloat) { $this->value->addValues(self::AS_FLOAT); @@ -106,7 +102,7 @@ public function asFloat($asFloat = true) * * @return $this */ - public function asInteger($asInteger = true) + public function asInteger(bool $asInteger = true): static { if ($asInteger) { $this->value->addValues(self::AS_INTEGER); @@ -118,19 +114,18 @@ public function asInteger($asInteger = true) /** * Sets the variable name as the qualifier key. * - * @param string $name The name of the variable. + * @param string $genericKey The name of the variable. * - * @return Variable */ - public function setKey($name) + public function setKey(string $genericKey): static { - $name = StringUtils::ensureStartsWith($name, '$'); + $genericKey = StringUtils::ensureStartsWith($genericKey, '$'); - if (empty($name) || ! self::isVariable($name)) { + if (empty($genericKey) || ! self::isVariable($genericKey)) { throw new InvalidArgumentException('Invalid variable name'); } - parent::setKey($name); + parent::setKey($genericKey); return $this; } @@ -140,9 +135,8 @@ public function setKey($name) * * @param $value * - * @return static */ - public function setQualifierValue(...$value) + public function setQualifierValue(...$value): static { if (count($value) === 1) { if (is_string($value[0])) { @@ -161,9 +155,8 @@ public function setQualifierValue(...$value) /** * Returns the variable name. * - * @return string */ - public function getVariableName() + public function getVariableName(): string { return $this->genericKey; } @@ -173,9 +166,8 @@ public function getVariableName() * * @param string $candidate Variable name candidate. * - * @return bool */ - public static function isVariable($candidate) + public static function isVariable(string $candidate): bool { return (boolean)preg_match('/^\$[a-zA-Z]\w*$/', $candidate); } @@ -183,11 +175,9 @@ public static function isVariable($candidate) /** * Serializes to json. * - * @return mixed */ - public function jsonSerialize() + public function jsonSerialize(): array { - /** @noinspection IsEmptyFunctionUsageInspection */ if (empty($this->getValue())) { return []; } diff --git a/src/Transformation/Video/Argument/Range/MinMaxRange.php b/src/Transformation/Video/Argument/Range/MinMaxRange.php index 34c61d4..71dfdd0 100644 --- a/src/Transformation/Video/Argument/Range/MinMaxRange.php +++ b/src/Transformation/Video/Argument/Range/MinMaxRange.php @@ -15,20 +15,17 @@ */ class MinMaxRange extends QualifierMultiValue { - const VALUE_DELIMITER = '-'; + public const VALUE_DELIMITER = '-'; /** * @var array $argumentOrder The order of the arguments. */ - protected $argumentOrder = ['min', 'max']; + protected array $argumentOrder = ['min', 'max']; /** * MinMaxRange constructor. - * - * @param int $min - * @param int $max */ - public function __construct($min, $max = null) + public function __construct(int|float|string|null $min, int|float|string|null $max = null) { parent::__construct(); @@ -39,11 +36,11 @@ public function __construct($min, $max = null) /** * Sets the minimum value. * - * @param int $min The minimum value. + * @param int|float|string|null $min The minimum value. * * @return $this */ - public function min($min) + public function min(int|float|string|null $min): static { return $this->setSimpleValue('min', $min); } @@ -51,11 +48,11 @@ public function min($min) /** * Sets the maximum value. * - * @param int $max The maximum value. + * @param int|float|string|null $max The maximum value. * * @return $this */ - public function max($max) + public function max(int|float|string|null $max): static { return $this->setSimpleValue('max', $max); } diff --git a/src/Transformation/Video/Argument/Range/PreviewDuration.php b/src/Transformation/Video/Argument/Range/PreviewDuration.php index 824eab0..06b3520 100644 --- a/src/Transformation/Video/Argument/Range/PreviewDuration.php +++ b/src/Transformation/Video/Argument/Range/PreviewDuration.php @@ -22,5 +22,5 @@ class PreviewDuration extends BaseNamedArgument /** * @var string The name of the argument. */ - protected static $name = 'duration'; + protected static string $name = 'duration'; } diff --git a/src/Transformation/Video/Argument/Range/Range.php b/src/Transformation/Video/Argument/Range/Range.php index 96d334d..5c3349e 100644 --- a/src/Transformation/Video/Argument/Range/Range.php +++ b/src/Transformation/Video/Argument/Range/Range.php @@ -19,42 +19,41 @@ */ class Range implements ComponentInterface { - const RANGE_RE = '/^(\d+\.)?\d+[%pP]?\.\.(\d+\.)?\d+[%pP]?$/'; + protected const RANGE_RE = '/^(\d+\.)?\d+[%pP]?\.\.(\d+\.)?\d+[%pP]?$/'; /** * @var int The start offset of the range. */ - public $startOffset; + public mixed $startOffset = null; /** * @var int The end offset of the range. */ - public $endOffset; + public mixed $endOffset = null; /** * Range constructor. * - * @param mixed $range + * @param mixed|null $range */ - public function __construct($range = null) + public function __construct(mixed $range = null) { if ($range === null) { return; } - list($this->startOffset, $this->endOffset) = self::splitRange($range); + [$this->startOffset, $this->endOffset] = self::splitRange($range); } /** * Internal helper method for splitting the range string. * - * @param string|array $range The range to split. + * @param array|string $range The range to split. * - * @return array|null * * @internal */ - private static function splitRange($range) + private static function splitRange(array|string $range): ?array { if (is_array($range) && count($range) === 2) { return $range; @@ -79,11 +78,9 @@ public function __toString() /** * Serializes to json. - * - * @return mixed */ - public function jsonSerialize() + public function jsonSerialize(): array { - // TODO: Implement jsonSerialize() method. + return []; } } diff --git a/src/Transformation/Video/Edit/Concatenate.php b/src/Transformation/Video/Edit/Concatenate.php index f677f3d..07b4017 100644 --- a/src/Transformation/Video/Edit/Concatenate.php +++ b/src/Transformation/Video/Edit/Concatenate.php @@ -36,9 +36,8 @@ public function __construct($source = null) * * @param mixed $source The video source. * - * @return VideoSource */ - public static function videoSource($source) + public static function videoSource(mixed $source): VideoSource { return ClassUtils::verifyInstance($source, VideoSource::class); } @@ -48,9 +47,8 @@ public static function videoSource($source) * * @param mixed $source The audio source. * - * @return AudioSource */ - public static function audioSource($source) + public static function audioSource(mixed $source): AudioSource { return ClassUtils::verifyInstance($source, AudioSource::class); } @@ -60,9 +58,8 @@ public static function audioSource($source) * * @param mixed $source The image source. * - * @return ImageSource */ - public static function imageSource($source) + public static function imageSource(mixed $source): ImageSource { return ClassUtils::verifyInstance($source, ImageSource::class); } @@ -71,11 +68,10 @@ public static function imageSource($source) /** * Indicates whether to concatenate the video before the original video. * - * @param bool $prepend * * @return $this */ - public function prepend($prepend = true) + public function prepend(bool $prepend = true): static { $timeline = Timeline::position(0); if (! $prepend) { @@ -94,7 +90,7 @@ public function prepend($prepend = true) * * @return $this */ - public function transition($source) + public function transition(mixed $source): static { $this->source->addTransformation(ClassUtils::verifyInstance($source, Transition::class)); // When using a transition video, splice flag should be omitted. @@ -114,7 +110,7 @@ public function transition($source) * * @return $this */ - public function duration($duration) + public function duration(mixed $duration): static { $this->source->addQualifier(ClassUtils::verifyInstance($duration, Duration::class)); diff --git a/src/Transformation/Video/Edit/VideoEditBuilderTrait.php b/src/Transformation/Video/Edit/VideoEditBuilderTrait.php index 58ca991..7e62b38 100644 --- a/src/Transformation/Video/Edit/VideoEditBuilderTrait.php +++ b/src/Transformation/Video/Edit/VideoEditBuilderTrait.php @@ -22,15 +22,14 @@ trait VideoEditBuilderTrait /** * Trims a video (and discards the rest). * - * @param mixed $startOffset - * @param mixed $endOffset - * @param mixed $duration + * @param mixed|null $startOffset + * @param mixed|null $endOffset + * @param mixed|null $duration * - * @return Timeline * * @see https://cloudinary.com/documentation/video_manipulation_and_delivery#trimming_videos */ - public static function trim($startOffset = null, $endOffset = null, $duration = null) + public static function trim(mixed $startOffset = null, mixed $endOffset = null, mixed $duration = null): Timeline { return ClassUtils::forceVarArgsInstance([$startOffset, $endOffset, $duration], Timeline::class); } @@ -38,13 +37,12 @@ public static function trim($startOffset = null, $endOffset = null, $duration = /** * Concatenates another video or image. * - * @param VideoSource|string $videoSource The source to concatenate. + * @param string|VideoSource $videoSource The source to concatenate. * - * @return Concatenate * * @see https://cloudinary.com/documentation/video_manipulation_and_delivery#concatenating_videos */ - public static function concatenate($videoSource) + public static function concatenate(string|VideoSource $videoSource): Concatenate { return ClassUtils::verifyInstance($videoSource, Concatenate::class); } @@ -53,11 +51,10 @@ public static function concatenate($videoSource) * Generates an excerpt of the video based on Cloudinary's AI-powered preview algorithm, which identifies the * most interesting video chunks from a video and uses these to generate a video preview. * - * @param int $duration The duration of the excerpt in seconds (Server default: 5 seconds). + * @param int|null $duration The duration of the excerpt in seconds (Server default: 5 seconds). * - * @return Preview */ - public static function preview($duration = null) + public static function preview(?int $duration = null): Preview { return ClassUtils::forceInstance($duration, Preview::class); } @@ -69,11 +66,10 @@ public static function preview($duration = null) * * @param int|Volume $level The percentage change of volume (Range: -100 to 400). * - * @return EffectAction * - * @see \Cloudinary\Transformation\Volume + * @see Volume */ - public static function volume($level) + public static function volume(Volume|int $level): EffectAction { return EffectAction::fromEffectQualifier(ClassUtils::verifyInstance($level, Volume::class)); } diff --git a/src/Transformation/Video/Transcode/Audio/AudioCodec.php b/src/Transformation/Video/Transcode/Audio/AudioCodec.php index 5e8af16..ba3388d 100644 --- a/src/Transformation/Video/Transcode/Audio/AudioCodec.php +++ b/src/Transformation/Video/Transcode/Audio/AudioCodec.php @@ -25,29 +25,28 @@ class AudioCodec extends BaseQualifier /** * Removes the audio channel. */ - const NONE = 'none'; + public const NONE = 'none'; /** * Sets the audio codec to aac (mp4 or flv only). */ - const AAC = 'aac'; + public const AAC = 'aac'; /** * Sets the audio codec to vorbis (ogv or webm only). */ - const VORBIS = 'vorbis'; + public const VORBIS = 'vorbis'; /** * Sets the audio codec to mp3 (mp4 or flv only). */ - const MP3 = 'mp3'; + public const MP3 = 'mp3'; /** * Removes the audio channel * - * @return AudioCodec */ - public static function none() + public static function none(): AudioCodec { return new static(static::NONE); } @@ -55,9 +54,8 @@ public static function none() /** * mp4 or flv only * - * @return AudioCodec */ - public static function aac() + public static function aac(): AudioCodec { return new static(static::AAC); } @@ -65,9 +63,8 @@ public static function aac() /** * ogv or webm only * - * @return AudioCodec */ - public static function vorbis() + public static function vorbis(): AudioCodec { return new static(static::VORBIS); } @@ -75,9 +72,8 @@ public static function vorbis() /** * mp4 or flv only * - * @return AudioCodec */ - public static function mp3() + public static function mp3(): AudioCodec { return new static(static::MP3); } diff --git a/src/Transformation/Video/Transcode/Audio/AudioFrequency.php b/src/Transformation/Video/Transcode/Audio/AudioFrequency.php index c6f1ecb..b182a56 100644 --- a/src/Transformation/Video/Transcode/Audio/AudioFrequency.php +++ b/src/Transformation/Video/Transcode/Audio/AudioFrequency.php @@ -23,32 +23,31 @@ */ class AudioFrequency extends BaseQualifier { - const FREQ8000 = 8000; - const FREQ11025 = 11025; - const FREQ16000 = 16000; - const FREQ22050 = 22050; - const FREQ32000 = 32000; - const FREQ37800 = 37800; - const FREQ44056 = 44056; - const FREQ44100 = 44100; - const FREQ47250 = 47250; - const FREQ48000 = 48000; - const FREQ88200 = 88200; - const FREQ96000 = 96000; - const FREQ176400 = 176400; - const FREQ192000 = 192000; + public const FREQ8000 = 8000; + public const FREQ11025 = 11025; + public const FREQ16000 = 16000; + public const FREQ22050 = 22050; + public const FREQ32000 = 32000; + public const FREQ37800 = 37800; + public const FREQ44056 = 44056; + public const FREQ44100 = 44100; + public const FREQ47250 = 47250; + public const FREQ48000 = 48000; + public const FREQ88200 = 88200; + public const FREQ96000 = 96000; + public const FREQ176400 = 176400; + public const FREQ192000 = 192000; /* * Initial audio frequency */ - const IAF = 'iaf'; + public const IAF = 'iaf'; /** * Audio Frequency 8000. * - * @return AudioFrequency */ - public static function freq8000() + public static function freq8000(): AudioFrequency { return self::createAudioFrequency(self::FREQ8000); } @@ -56,9 +55,8 @@ public static function freq8000() /** * Audio Frequency 11025. * - * @return AudioFrequency */ - public static function freq11025() + public static function freq11025(): AudioFrequency { return self::createAudioFrequency(self::FREQ11025); } @@ -66,9 +64,8 @@ public static function freq11025() /** * Audio Frequency 16000. * - * @return AudioFrequency */ - public static function freq16000() + public static function freq16000(): AudioFrequency { return self::createAudioFrequency(self::FREQ16000); } @@ -76,9 +73,8 @@ public static function freq16000() /** * Audio Frequency 22050. * - * @return AudioFrequency */ - public static function freq22050() + public static function freq22050(): AudioFrequency { return self::createAudioFrequency(self::FREQ22050); } @@ -86,9 +82,8 @@ public static function freq22050() /** * Audio Frequency 32000. * - * @return AudioFrequency */ - public static function freq32000() + public static function freq32000(): AudioFrequency { return self::createAudioFrequency(self::FREQ32000); } @@ -96,9 +91,8 @@ public static function freq32000() /** * Audio Frequency 37800. * - * @return AudioFrequency */ - public static function freq37800() + public static function freq37800(): AudioFrequency { return self::createAudioFrequency(self::FREQ37800); } @@ -106,9 +100,8 @@ public static function freq37800() /** * Audio Frequency 44056. * - * @return AudioFrequency */ - public static function freq44056() + public static function freq44056(): AudioFrequency { return self::createAudioFrequency(self::FREQ44056); } @@ -116,9 +109,8 @@ public static function freq44056() /** * Audio Frequency 44100. * - * @return AudioFrequency */ - public static function freq44100() + public static function freq44100(): AudioFrequency { return self::createAudioFrequency(self::FREQ44100); } @@ -126,9 +118,8 @@ public static function freq44100() /** * Audio Frequency 47250. * - * @return AudioFrequency */ - public static function freq47250() + public static function freq47250(): AudioFrequency { return self::createAudioFrequency(self::FREQ47250); } @@ -136,9 +127,8 @@ public static function freq47250() /** * Audio Frequency 48000. * - * @return AudioFrequency */ - public static function freq48000() + public static function freq48000(): AudioFrequency { return self::createAudioFrequency(self::FREQ48000); } @@ -146,9 +136,8 @@ public static function freq48000() /** * Audio Frequency 88200. * - * @return AudioFrequency */ - public static function freq88200() + public static function freq88200(): AudioFrequency { return self::createAudioFrequency(self::FREQ88200); } @@ -156,9 +145,8 @@ public static function freq88200() /** * Audio Frequency 96000. * - * @return AudioFrequency */ - public static function freq96000() + public static function freq96000(): AudioFrequency { return self::createAudioFrequency(self::FREQ96000); } @@ -166,9 +154,8 @@ public static function freq96000() /** * Audio Frequency 176400. * - * @return AudioFrequency */ - public static function freq176400() + public static function freq176400(): AudioFrequency { return self::createAudioFrequency(self::FREQ176400); } @@ -176,9 +163,8 @@ public static function freq176400() /** * Audio Frequency 192000. * - * @return AudioFrequency */ - public static function freq192000() + public static function freq192000(): AudioFrequency { return self::createAudioFrequency(self::FREQ192000); } @@ -187,9 +173,8 @@ public static function freq192000() * Retain the original audio frequency of the video. * This applies when using vc_auto where the audio frequency defaults to 48kHz. * - * @return AudioFrequency */ - public static function iaf() + public static function iaf(): AudioFrequency { return self::createAudioFrequency(self::IAF); } @@ -199,9 +184,8 @@ public static function iaf() * * @param int|string $qualifier The audio frequency. * - * @return AudioFrequency */ - protected static function createAudioFrequency($qualifier) + protected static function createAudioFrequency(int|string $qualifier): AudioFrequency { return new self($qualifier); } diff --git a/src/Transformation/Video/Transcode/Audio/AudioQualifierTrait.php b/src/Transformation/Video/Transcode/Audio/AudioQualifierTrait.php index e7f4dec..2b8ecf6 100644 --- a/src/Transformation/Video/Transcode/Audio/AudioQualifierTrait.php +++ b/src/Transformation/Video/Transcode/Audio/AudioQualifierTrait.php @@ -22,11 +22,10 @@ trait AudioQualifierTrait * * @param string $audioCodec The audio codec or "none". Use the constants defined in the AudioCodec class. * - * @return AudioCodec * - * @see \Cloudinary\Transformation\AudioCodec + * @see AudioCodec */ - public static function audioCodec($audioCodec) + public static function audioCodec(string $audioCodec): AudioCodec { return new AudioCodec($audioCodec); } @@ -36,11 +35,10 @@ public static function audioCodec($audioCodec) * * @param string $audioFrequency The audio frequency. Use the constants defined in the AudioFrequency class. * - * @return AudioFrequency * - * @see \Cloudinary\Transformation\AudioFrequency + * @see AudioFrequency */ - public static function audioFrequency($audioFrequency) + public static function audioFrequency(string $audioFrequency): AudioFrequency { return new AudioFrequency($audioFrequency); } diff --git a/src/Transformation/Video/Transcode/BitRate.php b/src/Transformation/Video/Transcode/BitRate.php index 8a2afa2..121a371 100644 --- a/src/Transformation/Video/Transcode/BitRate.php +++ b/src/Transformation/Video/Transcode/BitRate.php @@ -23,15 +23,15 @@ */ class BitRate extends BaseQualifier { - const CONSTANT = 'constant'; + protected const CONSTANT = 'constant'; /** * BitRate constructor. * - * @param int|string $bitRate - * @param null|string $type + * @param int|string|null $bitRate The bitrate to set. + * @param string|null $type The type of bitrate. */ - public function __construct($bitRate, $type = null) + public function __construct(int|string|null $bitRate, ?string $type = null) { parent::__construct(); @@ -41,12 +41,12 @@ public function __construct($bitRate, $type = null) /** * Sets the bitrate. * - * @param int|string $bitRate The bitrate in bits per second. The value supports "k" and "m "for kilobits + * @param int|string|null $bitRate The bitrate in bits per second. The value supports "k" and "m "for kilobits * and megabits respectively. * * @return $this */ - public function bitRate($bitRate) + public function bitRate(int|string|null $bitRate): static { $this->value->setSimpleValue('bit_rate', $bitRate); @@ -56,12 +56,12 @@ public function bitRate($bitRate) /** * The type of bitrate. * - * @param string $bitRateType The type of bitrate. If "constant" is specified, the video plays with a constant + * @param ?string $bitRateType The type of bitrate. If "constant" is specified, the video plays with a constant * bitrate (CBR). * * @return $this */ - public function type($bitRateType) + public function type(?string $bitRateType): static { $this->value->setSimpleValue('bit_rate_type', $bitRateType); @@ -73,7 +73,7 @@ public function type($bitRateType) * * @return $this */ - public function constant() + public function constant(): static { $this->type(self::CONSTANT); diff --git a/src/Transformation/Video/Transcode/Codec/VideoCodec.php b/src/Transformation/Video/Transcode/Codec/VideoCodec.php index 3208598..df9fbf7 100644 --- a/src/Transformation/Video/Transcode/Codec/VideoCodec.php +++ b/src/Transformation/Video/Transcode/Codec/VideoCodec.php @@ -26,18 +26,18 @@ class VideoCodec extends BaseQualifier { use VideoCodecTrait; - const AUTO = 'auto'; - const VP9 = 'vp9'; - const VP8 = 'vp8'; - const PRO_RES = 'prores'; // Apple ProRes 422 HQ - const H264 = 'h264'; - const H265 = 'h265'; - const THEORA = 'theora'; + public const AUTO = 'auto'; + public const VP9 = 'vp9'; + public const VP8 = 'vp8'; + public const PRO_RES = 'prores'; // Apple ProRes 422 HQ + public const H264 = 'h264'; + public const H265 = 'h265'; + public const THEORA = 'theora'; /** * @var array $valueOrder The order of the values. */ - protected $valueOrder = ['codec', 'profile', 'level']; + protected array $valueOrder = ['codec', 'profile', 'level']; /** * VideoCodec constructor. @@ -58,7 +58,7 @@ public function __construct($codec) * * @return $this */ - public function codec($codec) + public function codec(string $codec): static { $this->value->setSimpleValue('codec', $codec); @@ -68,13 +68,13 @@ public function codec($codec) /** * Sets codec profile. * - * @param string $profile The profile. Use the constants defined in the VideoCodecProfile class. + * @param string|null $profile The profile. Use the constants defined in the VideoCodecProfile class. * * @return $this * * @see VideoCodecProfile */ - public function profile($profile) + public function profile(?string $profile): static { $this->value->setSimpleValue('profile', $profile); @@ -84,13 +84,14 @@ public function profile($profile) /** * Sets codec level. * - * @param string $level The codec level. Use the constants defined in the VideoCodecLevel class. + * @param string|null $level The codec level. Use the constants defined in the VideoCodecLevel class. + * * * @return $this * * @see VideoCodecLevel */ - public function level($level) + public function level(?string $level): static { $this->value->setSimpleValue('level', $level); @@ -100,11 +101,10 @@ public function level($level) /** * Creates a new VideoCodec instance from an array of qualifiers. * - * @param array $qualifiers The video codec qualifiers. + * @param array|string $qualifiers The video codec qualifiers. * - * @return VideoCodec */ - public static function fromParams($qualifiers) + public static function fromParams(array|string $qualifiers): VideoCodec { if (is_array($qualifiers)) { $codec = ArrayUtils::get($qualifiers, 'codec'); diff --git a/src/Transformation/Video/Transcode/Codec/VideoCodecLevel.php b/src/Transformation/Video/Transcode/Codec/VideoCodecLevel.php index 6afb3a9..3033b98 100644 --- a/src/Transformation/Video/Transcode/Codec/VideoCodecLevel.php +++ b/src/Transformation/Video/Transcode/Codec/VideoCodecLevel.php @@ -21,21 +21,20 @@ */ class VideoCodecLevel { - const VCL_30 = '3.0'; - const VCL_31 = '3.1'; - const VCL_40 = '4.0'; - const VCL_41 = '4.1'; - const VCL_42 = '4.2'; - const VCL_50 = '5.0'; - const VCL_51 = '5.1'; - const VCL_52 = '5.2'; + public const VCL_30 = '3.0'; + public const VCL_31 = '3.1'; + public const VCL_40 = '4.0'; + public const VCL_41 = '4.1'; + public const VCL_42 = '4.2'; + public const VCL_50 = '5.0'; + public const VCL_51 = '5.1'; + public const VCL_52 = '5.2'; /** * Video codec level 3.0. * - * @return string */ - public static function vcl30() + public static function vcl30(): string { return self::VCL_30; } @@ -43,9 +42,8 @@ public static function vcl30() /** * Video codec level 3.1. * - * @return string */ - public static function vcl31() + public static function vcl31(): string { return self::VCL_31; } @@ -53,9 +51,8 @@ public static function vcl31() /** * Video codec level 4.0. * - * @return string */ - public static function vcl40() + public static function vcl40(): string { return self::VCL_40; } @@ -63,9 +60,8 @@ public static function vcl40() /** * Video codec level 4.1. * - * @return string */ - public static function vcl41() + public static function vcl41(): string { return self::VCL_41; } @@ -73,9 +69,8 @@ public static function vcl41() /** * Video codec level 4.2. * - * @return string */ - public static function vcl42() + public static function vcl42(): string { return self::VCL_42; } @@ -83,9 +78,8 @@ public static function vcl42() /** * Video codec level 5.0. * - * @return string */ - public static function vcl50() + public static function vcl50(): string { return self::VCL_50; } @@ -93,9 +87,8 @@ public static function vcl50() /** * Video codec level 5.1. * - * @return string */ - public static function vcl51() + public static function vcl51(): string { return self::VCL_51; } @@ -103,9 +96,8 @@ public static function vcl51() /** * Video codec level 5.2. * - * @return string */ - public static function vcl52() + public static function vcl52(): string { return self::VCL_52; } diff --git a/src/Transformation/Video/Transcode/Codec/VideoCodecProfile.php b/src/Transformation/Video/Transcode/Codec/VideoCodecProfile.php index 341677a..ee243fd 100644 --- a/src/Transformation/Video/Transcode/Codec/VideoCodecProfile.php +++ b/src/Transformation/Video/Transcode/Codec/VideoCodecProfile.php @@ -21,16 +21,15 @@ */ class VideoCodecProfile { - const BASELINE = 'baseline'; - const MAIN = 'main'; - const HIGH = 'high'; + public const BASELINE = 'baseline'; + public const MAIN = 'main'; + public const HIGH = 'high'; /** * Video codec profile baseline. * - * @return string */ - public static function baseline() + public static function baseline(): string { return self::BASELINE; } @@ -38,9 +37,8 @@ public static function baseline() /** * Video codec profile main. * - * @return string */ - public static function main() + public static function main(): string { return self::MAIN; } @@ -48,9 +46,8 @@ public static function main() /** * Video codec profile high. * - * @return string */ - public static function high() + public static function high(): string { return self::HIGH; } diff --git a/src/Transformation/Video/Transcode/Codec/VideoCodecTrait.php b/src/Transformation/Video/Transcode/Codec/VideoCodecTrait.php index e2a473f..c46d681 100644 --- a/src/Transformation/Video/Transcode/Codec/VideoCodecTrait.php +++ b/src/Transformation/Video/Transcode/Codec/VideoCodecTrait.php @@ -20,9 +20,8 @@ trait VideoCodecTrait /** * Auto video codec. * - * @return VideoCodec */ - public static function auto() + public static function auto(): VideoCodec { return new VideoCodec(VideoCodec::AUTO); } @@ -30,9 +29,8 @@ public static function auto() /** * Video codec vp8. * - * @return VideoCodec */ - public static function vp8() + public static function vp8(): VideoCodec { return new VideoCodec(VideoCodec::VP8); } @@ -40,9 +38,8 @@ public static function vp8() /** * Video codec vp9. * - * @return VideoCodec */ - public static function vp9() + public static function vp9(): VideoCodec { return new VideoCodec(VideoCodec::VP9); } @@ -50,9 +47,8 @@ public static function vp9() /** * Video codec proRes (Apple ProRes 422 HQ). * - * @return VideoCodec */ - public static function proRes() + public static function proRes(): VideoCodec { return new VideoCodec(VideoCodec::PRO_RES); } @@ -60,12 +56,8 @@ public static function proRes() /** * Video codec h264. * - * @param string $profile - * @param string $level - * - * @return VideoCodec */ - public static function h264($profile = null, $level = null) + public static function h264(?string $profile = null, ?string $level = null): VideoCodec { return (new VideoCodec(VideoCodec::H264))->profile($profile)->level($level); } @@ -73,9 +65,8 @@ public static function h264($profile = null, $level = null) /** * Video codec h265. * - * @return VideoCodec */ - public static function h265() + public static function h265(): VideoCodec { return new VideoCodec(VideoCodec::H265); } @@ -83,9 +74,8 @@ public static function h265() /** * Video codec theora. * - * @return VideoCodec */ - public static function theora() + public static function theora(): VideoCodec { return new VideoCodec(VideoCodec::THEORA); } diff --git a/src/Transformation/Video/Transcode/Fps.php b/src/Transformation/Video/Transcode/Fps.php index e411c96..cb327ac 100644 --- a/src/Transformation/Video/Transcode/Fps.php +++ b/src/Transformation/Video/Transcode/Fps.php @@ -27,20 +27,17 @@ */ class Fps extends BaseQualifier { - const VALUE_CLASS = MinMaxRange::class; + protected const VALUE_CLASS = MinMaxRange::class; /** * @var string $key Serialization key. */ - protected static $key = 'fps'; + protected static string $key = 'fps'; /** * FPS constructor. - * - * @param mixed $min - * @param mixed $max */ - public function __construct($min = null, $max = null) + public function __construct($min = null, mixed $max = null) { parent::__construct($min, $max); } @@ -48,11 +45,11 @@ public function __construct($min = null, $max = null) /** * Sets the minimum frame rate. * - * @param int $min The minimum frame rate in frames per second. + * @param int|float|string|null $min The minimum frame rate in frames per second. * * @return $this */ - public function min($min) + public function min(int|float|string|null $min): static { $this->value->min($min); @@ -62,11 +59,11 @@ public function min($min) /** * Sets the maximum frame rate. * - * @param int $max The maximum frame rate in frames per second. + * @param int|float|string|null $max The maximum frame rate in frames per second. * * @return $this */ - public function max($max) + public function max(int|float|string|null $max): static { $this->value->max($max); @@ -76,14 +73,13 @@ public function max($max) /** * Creates a new instance using provided qualifiers array. * - * @param string|array $qualifiers The qualifiers. + * @param array|string $qualifiers The qualifiers. * - * @return Fps */ - public static function fromParams($qualifiers) + public static function fromParams(array|string $qualifiers): Fps { $qualifiers = ArrayUtils::build($qualifiers); - return (new static(...$qualifiers)); + return new static(...$qualifiers); } } diff --git a/src/Transformation/Video/Transcode/KeyframeInterval.php b/src/Transformation/Video/Transcode/KeyframeInterval.php index 120f1e0..6bc0ebe 100644 --- a/src/Transformation/Video/Transcode/KeyframeInterval.php +++ b/src/Transformation/Video/Transcode/KeyframeInterval.php @@ -17,5 +17,5 @@ */ class KeyframeInterval extends BaseQualifier { - const VALUE_CLASS = PositiveFloatValue::class; + protected const VALUE_CLASS = PositiveFloatValue::class; } diff --git a/src/Transformation/Video/Transcode/StreamingProfile.php b/src/Transformation/Video/Transcode/StreamingProfile.php index 8b1ba7d..f2f945f 100644 --- a/src/Transformation/Video/Transcode/StreamingProfile.php +++ b/src/Transformation/Video/Transcode/StreamingProfile.php @@ -23,20 +23,19 @@ */ class StreamingProfile extends BaseQualifier { - const SP_4K = '4k'; - const FULL_HD = 'full_hd'; - const HD = 'hd'; - const SD = 'sd'; - const FULL_HD_WIFI = 'full_hd_wifi'; - const FULL_HD_LEAN = 'full_hd_lean'; - const HD_LEAN = 'hd_lean'; + public const SP_4K = '4k'; + public const FULL_HD = 'full_hd'; + public const HD = 'hd'; + public const SD = 'sd'; + public const FULL_HD_WIFI = 'full_hd_wifi'; + public const FULL_HD_LEAN = 'full_hd_lean'; + public const HD_LEAN = 'hd_lean'; /** * Streaming profile 4k. * - * @return string */ - public static function sp4k() + public static function sp4k(): string { return self::SP_4K; } @@ -44,9 +43,8 @@ public static function sp4k() /** * Streaming profile full hd. * - * @return string */ - public static function fullHd() + public static function fullHd(): string { return self::FULL_HD; } @@ -54,9 +52,8 @@ public static function fullHd() /** * Streaming profile hd. * - * @return string */ - public static function hd() + public static function hd(): string { return self::HD; } @@ -64,9 +61,8 @@ public static function hd() /** * Streaming profile sd. * - * @return string */ - public static function sd() + public static function sd(): string { return self::SD; } @@ -74,9 +70,8 @@ public static function sd() /** * Streaming profile full hd wifi. * - * @return string */ - public static function fullHdWifi() + public static function fullHdWifi(): string { return self::FULL_HD_WIFI; } @@ -84,9 +79,8 @@ public static function fullHdWifi() /** * Streaming profile full hd lean. * - * @return string */ - public static function fullHdLean() + public static function fullHdLean(): string { return self::FULL_HD_LEAN; } @@ -94,9 +88,8 @@ public static function fullHdLean() /** * Streaming profile hd lean. * - * @return string */ - public static function hdLean() + public static function hdLean(): string { return self::HD_LEAN; } diff --git a/src/Transformation/Video/Transcode/ToAnimated/ToAnimatedActionTrait.php b/src/Transformation/Video/Transcode/ToAnimated/ToAnimatedActionTrait.php index 7e941c9..008d74a 100644 --- a/src/Transformation/Video/Transcode/ToAnimated/ToAnimatedActionTrait.php +++ b/src/Transformation/Video/Transcode/ToAnimated/ToAnimatedActionTrait.php @@ -32,9 +32,8 @@ trait ToAnimatedActionTrait * String - The number of seconds between each frame to sample from the original video. * e.g. 2.3s takes one frame every 2.3 seconds. * - * @return static */ - public function sampling($value) + public function sampling(int|string $value): static { return $this->addQualifier(ClassUtils::verifyInstance($value, VideoSampling::class)); } @@ -42,15 +41,13 @@ public function sampling($value) /** * Sets the delay between frames of an animated image in milliseconds. * - * @param Delay|int $delay * - * @return static * * @deprecated use Animated::edit()->delay($delay) instead. * * @see AnimatedEdit */ - public function delay($delay) + public function delay(Delay|int $delay): static { return $this->addQualifier(ClassUtils::verifyInstance($delay, Delay::class)); } @@ -58,11 +55,10 @@ public function delay($delay) /** * Sets the animated image format. * - * @param AnimatedFormat|string $format The format. + * @param string|AnimatedFormat $format The format. * - * @return static */ - public function format($format) + public function format(AnimatedFormat|string $format): static { return $this->importAction(ClassUtils::verifyInstance($format, AnimatedFormat::class)); } diff --git a/src/Transformation/Video/Transcode/TranscodeTrait.php b/src/Transformation/Video/Transcode/TranscodeTrait.php index 1c9de23..2f704f4 100644 --- a/src/Transformation/Video/Transcode/TranscodeTrait.php +++ b/src/Transformation/Video/Transcode/TranscodeTrait.php @@ -22,13 +22,12 @@ trait TranscodeTrait /** * Controls the video codec. * - * @param VideoCodec|string $codec The video codec. + * @param string|VideoCodec $codec The video codec. * - * @return BitRate * - * @see \Cloudinary\Transformation\BitRate + * @see BitRate */ - public static function videoCodec($codec) + public static function videoCodec(string|VideoCodec $codec): BitRate { return ClassUtils::verifyInstance($codec, VideoCodec::class); } @@ -36,13 +35,11 @@ public static function videoCodec($codec) /** * Converts a video to animated image. * - * @param $animatedImageFormat * - * @return ToAnimatedAction * - * @see \Cloudinary\Transformation\BitRate + * @see BitRate */ - public static function toAnimated($animatedImageFormat = null) + public static function toAnimated($animatedImageFormat = null): ToAnimatedAction { return ClassUtils::forceInstance($animatedImageFormat, ToAnimatedAction::class); } diff --git a/src/Transformation/Video/Transcode/VideoQualifierTrait.php b/src/Transformation/Video/Transcode/VideoQualifierTrait.php index 740c336..38a22fb 100644 --- a/src/Transformation/Video/Transcode/VideoQualifierTrait.php +++ b/src/Transformation/Video/Transcode/VideoQualifierTrait.php @@ -28,14 +28,13 @@ trait VideoQualifierTrait * uses a variable bitrate (VBR), with this value indicating the maximum bitrate. * The value can be an integer e.g. 120000, or a string supporting "k" and "m" * (kilobits and megabits respectively) e.g. 250k or 2m. - * @param null|string $type The type of bitrate. If "constant" is specified, the video plays with a constant + * @param string|null $type The type of bitrate. If "constant" is specified, the video plays with a constant * bitrate (CBR). Use the constant defined in the BitRate class. * - * @return BitRate * - * @see \Cloudinary\Transformation\BitRate + * @see BitRate */ - public static function bitRate($bitRate, $type = null) + public static function bitRate(int|string $bitRate, ?string $type = null): BitRate { return new BitRate($bitRate, $type); } @@ -44,12 +43,11 @@ public static function bitRate($bitRate, $type = null) * Controls the range of acceptable FPS (Frames Per Second) to ensure that video (even when optimized) is * delivered with an expected FPS level (helps with sync to audio). * - * @param int|null $min The minimum frame rate. - * @param int|null $max The maximum frame rate. + * @param int|string|null $min The minimum frame rate. + * @param int|string|null $max The maximum frame rate. * - * @return Fps */ - public static function fps($min = null, $max = null) + public static function fps(int|string|null $min = null, int|string|null $max = null): Fps { return new Fps($min, $max); } @@ -61,9 +59,8 @@ public static function fps($min = null, $max = null) * @param int|null $min The minimum frame rate. * @param int|null $max The maximum frame rate. * - * @return Fps */ - public static function fpsRange($min = null, $max = null) + public static function fpsRange(?int $min = null, ?int $max = null): Fps { return static::fps($min, $max); } @@ -71,11 +68,10 @@ public static function fpsRange($min = null, $max = null) /** * Sets the keyframe interval of the delivered video. * - * @param int $interval The keyframe interval in seconds. + * @param float|int|string $interval The keyframe interval in seconds. * - * @return KeyframeInterval */ - public static function keyframeInterval($interval) + public static function keyframeInterval(float|int|string $interval): KeyframeInterval { return new KeyframeInterval($interval); } @@ -89,12 +85,9 @@ public static function keyframeInterval($interval) * * @param string $streamingProfile The streaming profile. * - * @return StreamingProfile - * - * @see \Cloudinary\Api\Admin\StreamingProfilesTrait * @see https://cloudinary.com/documentation/video_manipulation_and_delivery#predefined_streaming_profiles */ - public static function streamingProfile($streamingProfile) + public static function streamingProfile(string $streamingProfile): StreamingProfile { return ClassUtils::verifyInstance($streamingProfile, StreamingProfile::class); } @@ -112,9 +105,8 @@ public static function streamingProfile($streamingProfile) * String - The number of seconds between each frame to sample from the original video. * e.g. 2.3s takes one frame every 2.3 seconds. * - * @return VideoSampling */ - public static function videoSampling($value) + public static function videoSampling(int|string $value): VideoSampling { return new VideoSampling($value); } diff --git a/src/Transformation/Video/VideoSpecificTransformationTrait.php b/src/Transformation/Video/VideoSpecificTransformationTrait.php index 4cb9460..0330fef 100644 --- a/src/Transformation/Video/VideoSpecificTransformationTrait.php +++ b/src/Transformation/Video/VideoSpecificTransformationTrait.php @@ -26,11 +26,10 @@ trait VideoSpecificTransformationTrait * * @param Timeline $range Specify the range of the video to leave. * - * @return static * * @see https://cloudinary.com/documentation/video_manipulation_and_delivery#trimming_videos */ - public function trim(Timeline $range) + public function trim(Timeline $range): static { return $this->addAction($range); } @@ -40,11 +39,10 @@ public function trim(Timeline $range) * * @param int|string $radius The radius of the corners in pixels. * - * @return static * * @see https://cloudinary.com/documentation/video_manipulation_and_delivery#rounding_corners_and_creating_circular_videos */ - public function roundCorners($radius) + public function roundCorners(int|string $radius): static { return $this->addAction(ClassUtils::verifyInstance($radius, RoundCorners::class)); } @@ -52,16 +50,18 @@ public function roundCorners($radius) /** * Adds another video, text, image as an overlay over the container video. * - * @param BaseSource|string $videoLayer The overlay. - * @param BasePosition|null $position The position of the overlay. - * @param Timeline|null $timeline The timeline position of the overlay. + * @param string|BaseSourceContainer|BaseSource $videoLayer The overlay. + * @param BasePosition|null $position The position of the overlay. + * @param Timeline|null $timeline The timeline position of the overlay. * - * @return static * * @see https://cloudinary.com/documentation/video_manipulation_and_delivery#adding_video_overlays */ - public function overlay($videoLayer, $position = null, $timeline = null) - { + public function overlay( + BaseSource|BaseSourceContainer|string $videoLayer, + ?BasePosition $position = null, + ?Timeline $timeline = null + ): static { return $this->addAction( ClassUtils::verifyInstance( $videoLayer, @@ -76,28 +76,29 @@ public function overlay($videoLayer, $position = null, $timeline = null) /** * Concatenates another video or image. * - * @param VideoSource|string $videoSource The source of the video to concatenate. + * @param string|Concatenate|BaseSource $videoLayer The source of the video/audio to concatenate. * - * @return static * * @see https://cloudinary.com/documentation/video_manipulation_and_delivery#concatenating_videos */ - public function concatenate($videoSource) + public function concatenate(Concatenate|BaseSource|string $videoLayer): static { - return $this->addAction(ClassUtils::verifyInstance($videoSource, Concatenate::class)); + return $this->addAction(ClassUtils::verifyInstance($videoLayer, Concatenate::class)); } /** * Applies the video as a cutter for the main video. * - * @param VideoSource|string $videoLayer The cutter video layer. + * @param string|VideoSource $videoLayer The cutter video layer. * @param BasePosition|null $position The position of the cutter. * @param Timeline|null $timeline The timeline position of the cutter. * - * @return static */ - public function cutter($videoLayer, $position = null, $timeline = null) - { + public function cutter( + string|VideoSource $videoLayer, + ?BasePosition $position = null, + ?Timeline $timeline = null + ): static { return $this->addAction( (new VideoOverlay($videoLayer, $position, $timeline))->cutter() ); @@ -108,9 +109,8 @@ public function cutter($videoLayer, $position = null, $timeline = null) * * @param string $subtitlesId The subtitles file public ID. * - * @return static */ - public function addSubtitles($subtitlesId) + public function addSubtitles(string $subtitlesId): static { return $this->overlay(VideoSource::subtitles($subtitlesId)); } @@ -118,11 +118,10 @@ public function addSubtitles($subtitlesId) /** * Transcodes the video (or audio) to another format / adjusts encoding properties. * - * @param AudioCodec|VideoCodec|AudioFrequency|mixed $transcode The new format or encoding property. + * @param AudioCodec|AudioFrequency|ToAnimatedAction|VideoCodec|Fps $transcode The new format or encoding property. * - * @return static */ - public function transcode($transcode) + public function transcode(AudioCodec|ToAnimatedAction|AudioFrequency|VideoCodec|Fps $transcode): static { return $this->addAction($transcode); } @@ -131,12 +130,11 @@ public function transcode($transcode) * Controls the range of acceptable FPS (Frames Per Second) to ensure that video (even when optimized) * is delivered with an expected fps level (helps with sync to audio). * - * @param float|int|string $min The minimum frame rate. + * @param float|int|string|Fps $min The minimum frame rate. * @param float|int|string|null $max The maximum frame rate. * - * @return static */ - public function fps($min, $max = null) + public function fps(float|int|string|Fps $min, float|int|string|null $max = null): static { return $this->addAction(ClassUtils::verifyInstance($min, Fps::class, null, $max)); } @@ -144,11 +142,10 @@ public function fps($min, $max = null) /** * Explicitly sets the keyframe interval of the delivered video. * - * @param float $interval Positive float number in seconds. + * @param mixed $interval Positive float number in seconds. * - * @return static */ - public function keyframeInterval($interval) + public function keyframeInterval(mixed $interval): static { return $this->addAction(ClassUtils::verifyInstance($interval, KeyframeInterval::class)); } @@ -156,16 +153,15 @@ public function keyframeInterval($interval) /** * Controls the video bitrate. * - * @param int|string $bitRate The number of bits used to represent the video data per second. By default the video + * @param int|string $bitRate The number of bits used to represent the video data per second. By default the video * uses a variable bitrate (VBR), with this value indicating the maximum bitrate. * Can be an integer e.g. 120000, or a string supporting "k" and "m" * (kilobits and megabits respectively) e.g. 250k or 2m. - * @param string $type The type of bitrate. If "constant" is specified, the video plays with a constant + * @param string|null $type The type of bitrate. If "constant" is specified, the video plays with a constant * bitrate (CBR). Use the constant defined in the BitRate class. * - * @return static */ - public function bitRate($bitRate, $type = null) + public function bitRate(int|string $bitRate, ?string $type = null): static { return $this->addAction(ClassUtils::verifyInstance($bitRate, BitRate::class, null, $type)); } @@ -179,13 +175,11 @@ public function bitRate($bitRate, $type = null) * * @param string $streamingProfile The streaming profile. * - * @return static * * @see https://cloudinary.com/documentation/video_manipulation_and_delivery#predefined_streaming_profiles * - * @see \Cloudinary\Api\Admin\StreamingProfilesTrait */ - public function streamingProfile($streamingProfile) + public function streamingProfile(string $streamingProfile): static { return $this->addAction(ClassUtils::verifyInstance($streamingProfile, StreamingProfile::class)); } @@ -203,9 +197,8 @@ public function streamingProfile($streamingProfile) * String - The number of seconds between each frame to sample from the original video. * e.g. 2.3s takes one frame every 2.3 seconds. * - * @return static */ - public function videoSampling($value) + public function videoSampling(int|string $value): static { return $this->addAction(ClassUtils::verifyInstance($value, VideoSampling::class)); } @@ -215,9 +208,8 @@ public function videoSampling($value) * * @param mixed $videoEdit The video edit action. * - * @return static */ - public function videoEdit($videoEdit) + public function videoEdit(mixed $videoEdit): static { return $this->addAction($videoEdit); } diff --git a/src/Transformation/Video/VideoTransformationInterface.php b/src/Transformation/Video/VideoTransformationInterface.php index a82de9a..e2b5857 100644 --- a/src/Transformation/Video/VideoTransformationInterface.php +++ b/src/Transformation/Video/VideoTransformationInterface.php @@ -22,67 +22,68 @@ interface VideoTransformationInterface extends CommonTransformationInterface * * @param Timeline $range The part of the video to keep. * - * @return static * - * @see \Cloudinary\Transformation\Timeline + * @see Timeline */ - public function trim(Timeline $range); + public function trim(Timeline $range): static; /** * Rounds the corners of a video. * * @param int|string $radius The radius of the corners in pixels. * - * @return static */ - public function roundCorners($radius); + public function roundCorners(int|string $radius): static; /** * Adds another video, text or image as an overlay over the container video. * - * @param BaseSource|string $videoLayer The overlay. + * @param string|BaseSource $videoLayer The overlay. * @param BasePosition|null $position The position of the overlay. * @param Timeline|null $timeline The timeline position of the overlay. * - * @return static */ - public function overlay($videoLayer, $position = null, $timeline = null); + public function overlay( + BaseSource|string $videoLayer, + ?BasePosition $position = null, + ?Timeline $timeline = null + ): static; /** * Concatenates another video or image. * - * @param Concatenate|VideoSource|string $videoLayer The layer to concatenate. + * @param string|Concatenate|VideoSource $videoLayer The layer to concatenate. * - * @return static */ - public function concatenate($videoLayer); + public function concatenate(Concatenate|string|VideoSource $videoLayer): static; /** * Applies the video as a cutter for the main video. * - * @param VideoSource|string $videoLayer The cutter video layer. + * @param string|VideoSource $videoLayer The cutter video layer. * @param BasePosition|null $position The position of the cutter. * @param Timeline|null $timeline The timeline position of the cutter. * - * @return static */ - public function cutter($videoLayer, $position = null, $timeline = null); + public function cutter( + string|VideoSource $videoLayer, + ?BasePosition $position = null, + ?Timeline $timeline = null + ): static; /** * Adds subtitles to the video. * * @param string $subtitlesId The subtitles file public ID. * - * @return mixed */ - public function addSubtitles($subtitlesId); + public function addSubtitles(string $subtitlesId): mixed; /** * Transcodes the video (or audio) to another format. * - * @param AudioCodec|VideoCodec|AudioFrequency|ToAnimatedAction $transcode The new format. + * @param AudioCodec|AudioFrequency|ToAnimatedAction|VideoCodec $transcode The new format. * - * @return static */ - public function transcode($transcode); + public function transcode(AudioCodec|ToAnimatedAction|AudioFrequency|VideoCodec $transcode): static; } diff --git a/src/Utils/ArrayUtils.php b/src/Utils/ArrayUtils.php index 5c5ee16..4a99037 100644 --- a/src/Utils/ArrayUtils.php +++ b/src/Utils/ArrayUtils.php @@ -10,6 +10,8 @@ namespace Cloudinary; +use ArrayObject; + /** * Class ArrayUtils * @@ -25,7 +27,7 @@ class ArrayUtils * * @return array Resulting array */ - public static function mapAssoc($callback, $array) + public static function mapAssoc(callable $callback, array $array): array { $r = []; foreach ($array as $key => $value) { @@ -40,11 +42,11 @@ public static function mapAssoc($callback, $array) * * @param array|mixed $array An array to join * @param string $outer Outer delimiter (between pairs) - * @param string $inner Inner delimiter (between key and value), if not provided $outer is used + * @param string|null $inner Inner delimiter (between key and value), if not provided $outer is used * - * @return string Resulting string + * @return string|null Resulting string */ - public static function implodeAssoc($array, $outer = '', $inner = null) + public static function implodeAssoc(mixed $array, string $outer = '', ?string $inner = null): ?string { if (! is_array($array)) { return $array === null ? null : (string)$array; @@ -77,15 +79,18 @@ static function ($k, $v) use ($inner) { * * @param array|mixed $array An array to join * @param string $outer Outer delimiter (between pairs) - * @param string $inner Inner delimiter (between key and value), if not provided $outer is used + * @param string|null $inner Inner delimiter (between key and value), if not provided $outer is used * @param bool $innerIsSafe Whether to omit escaping of the inner delimiter * - * @return string * * @see ArrayUtils::implodeAssoc */ - public static function safeImplodeAssoc($array, $outer = '', $inner = null, $innerIsSafe = false) - { + public static function safeImplodeAssoc( + mixed $array, + string $outer = '', + ?string $inner = null, + bool $innerIsSafe = false + ): ?string { if (! is_array($array)) { return $array === null ? null : (string)$array; } @@ -115,10 +120,6 @@ static function ($k, $v) use ($inner, $innerIsSafe) { * * Strange signature comes from the built-in implode function that has a similar signature. * - * @param string $glue - * @param array $pieces - * @param string $filterCallback - * @param int $flag * * @return string The resulting string * @@ -127,11 +128,11 @@ static function ($k, $v) use ($inner, $innerIsSafe) { * @see implode */ public static function implodeFiltered( - $glue, + string $glue, array $pieces, - $filterCallback = __NAMESPACE__ . '\ArrayUtils::safeFilterFunc', - $flag = 0 - ) { + string $filterCallback = __NAMESPACE__ . '\ArrayUtils::safeFilterFunc', + int $flag = 0 + ): string { return self::safeImplode($glue, self::safeFilter($pieces, $filterCallback, $flag)); } @@ -140,12 +141,9 @@ public static function implodeFiltered( * * In addition fixes serialisation of float values. * - * @param $glue - * @param array $pieces * - * @return string */ - public static function safeImplode($glue, array $pieces) + public static function safeImplode($glue, array $pieces): string { array_walk( $pieces, @@ -160,19 +158,14 @@ static function (&$value) { /** * Implodes array values with escaping the glue character. * - * @param string $glue - * @param array $pieces * - * @return string */ - public static function escapedImplode($glue, array $pieces) + public static function escapedImplode(string $glue, array $pieces): string { return implode( $glue, array_map( - static function ($value) use ($glue) { - return StringUtils::escapeUnsafeChars($value, $glue); - }, + static fn($value) => StringUtils::escapeUnsafeChars($value, $glue), $pieces ) ); @@ -185,12 +178,11 @@ static function ($value) use ($glue) { * * @param mixed|array $value The value to filter * - * @return int * * @see strlen * @see empty */ - protected static function safeFilterFunc($value) + protected static function safeFilterFunc(mixed $value): bool|int { if (is_array($value)) { foreach ($value as $val) { @@ -214,20 +206,17 @@ protected static function safeFilterFunc($value) * * Uses "strlen" filter function by default, which treats non-null values (e.g. 0, false, etc) as non-empty. * - * @param array $input * @param callback|string $callback - * @param int $flag * - * @return array * * @see array_filter * @see strlen */ public static function safeFilter( array $input, - $callback = __NAMESPACE__ . '\ArrayUtils::safeFilterFunc', - $flag = 0 - ) { + callable|string $callback = __NAMESPACE__ . '\ArrayUtils::safeFilterFunc', + int $flag = 0 + ): array { return array_filter($input, $callback, $flag); } @@ -236,12 +225,11 @@ public static function safeFilter( * * In case some of the missing/extra keys, the keys are sorted using alphabetic order. Ordered keys come first. * - * @param array $array The associate array to order. + * @param ?array $array The associate array to order. * @param array $orderArray The desired order of the keys. * - * @return array */ - public static function sortByArray($array, $orderArray = []) + public static function sortByArray(?array $array, array $orderArray = []): ?array { if (! is_array($array)) { return $array; @@ -255,13 +243,12 @@ public static function sortByArray($array, $orderArray = []) /** * Commonly used util for building Cloudinary URL * - * @param array $urlParts * * @return string The resulting string * * @internal */ - public static function implodeUrl(array $urlParts) + public static function implodeUrl(array $urlParts): string { return self::implodeFiltered('/', $urlParts); } @@ -275,7 +262,7 @@ public static function implodeUrl(array $urlParts) * * @internal */ - public static function implodeActionQualifiers(...$qualifiers) + public static function implodeActionQualifiers(...$qualifiers): string { $serializedQualifiers = array_map('strval', $qualifiers); @@ -293,7 +280,7 @@ public static function implodeActionQualifiers(...$qualifiers) * * @internal */ - public static function implodeQualifierValues(...$qualifierValues) + public static function implodeQualifierValues(...$qualifierValues): string { return self::implodeFiltered(':', $qualifierValues); } @@ -301,14 +288,13 @@ public static function implodeQualifierValues(...$qualifierValues) /** * Gets a key from an array if exists, otherwise returns default. * - * @param array $array The data array. - * @param string|int|array $key The key. Can be a simple key(string|int), an index array that allows accessing - * nested values - * @param mixed|null $default The default value for the case when the key is not found. + * @param ArrayObject|array $array The data array. + * @param int|array|string $key The key. Can be a simple key(string|int), an index array that allows accessing + * nested values + * @param mixed|null $default The default value for the case when the key is not found. * - * @return mixed */ - public static function get($array, $key, $default = null) + public static function get(ArrayObject|array $array, int|array|string $key, mixed $default = null): mixed { if (is_array($key)) { $currLevel = &$array; @@ -327,7 +313,7 @@ public static function get($array, $key, $default = null) return $array[$key]; } - if ($array instanceof \ArrayObject && $array->offsetExists($key)) { + if ($array instanceof ArrayObject && $array->offsetExists($key)) { return $array[$key]; } @@ -338,13 +324,12 @@ public static function get($array, $key, $default = null) * Pops a key from an array if exists, otherwise returns default * * @param array $array Data array - * @param string|int|array $key key can be a simple key(string|int) or an array that allows accessing nested + * @param int|array|string $key key can be a simple key(string|int) or an array that allows accessing nested * values * @param mixed|null $default Default value for the case when key is not found * - * @return mixed */ - public static function pop(&$array, $key, $default = null) + public static function pop(array &$array, int|array|string $key, mixed $default = null): mixed { $val = self::get($array, $key, $default); unset($array[$key]); @@ -355,12 +340,12 @@ public static function pop(&$array, $key, $default = null) /** * Returns a subset of associative array whitelisted by an array of keys * - * @param array $array Source array (associative or not) + * @param ?array $array Source array (associative or not) * @param array $keys Simple array of keys to keep * - * @return array Resulting array + * @return ?array Resulting array */ - public static function whitelist($array, $keys) + public static function whitelist(?array $array, array $keys): ?array { // When providing non array(for example null), return it as is if (! is_array($array)) { @@ -377,12 +362,12 @@ public static function whitelist($array, $keys) /** * Returns a subset of associative array with excluded keys specified by an array of keys * - * @param array $array Source array (associative or not) + * @param ?array $array Source array (associative or not) * @param array $blacklistedKeys Simple array of keys to be excluded * - * @return array Resulting array + * @return ?array Resulting array */ - public static function blacklist($array, $blacklistedKeys) + public static function blacklist(?array $array, array $blacklistedKeys): ?array { // When providing non array (for example null), return it as is if (! is_array($array)) { @@ -401,9 +386,8 @@ public static function blacklist($array, $blacklistedKeys) * * @param mixed $value The input value to wrap * - * @return array */ - public static function build($value) + public static function build(mixed $value): array { if ($value === null) { return []; @@ -425,17 +409,12 @@ public static function build($value) * * @param bool $onlyAssoc Set to true to flatten only associative arrays * - * @return null|string|array * * @see ArrayUtils::build */ - public static function flatten($array, $onlyAssoc = false) + public static function flatten(mixed $array, bool $onlyAssoc = false): array|string|null { - if (empty($array) || ! is_array($array) || count($array) > 1) { - return $array; - } - - if ($onlyAssoc && ! self::isAssoc($array[0])) { + if (empty($array) || ! is_array($array) || count($array) > 1 || $onlyAssoc && ! self::isAssoc($array[0])) { return $array; } @@ -445,11 +424,11 @@ public static function flatten($array, $onlyAssoc = false) /** * Determines whether an array is associative or not * - * @param array $array Input array + * @param mixed $array Input array * * @return bool true if associative, otherwise false */ - public static function isAssoc($array) + public static function isAssoc(mixed $array): bool { if (! is_array($array)) { return false; @@ -469,7 +448,7 @@ public static function isAssoc($array) * * @internal */ - public static function prependAssoc(&$arr, $key, $val) + public static function prependAssoc(array &$arr, mixed $key, mixed $val): array { $arr = array_reverse($arr, true); $arr[$key] = $val; @@ -489,7 +468,7 @@ public static function prependAssoc(&$arr, $key, $val) * @internal * */ - public static function appendNonEmpty(&$arr, $val) + public static function appendNonEmpty(array &$arr, mixed $val): array { if (! empty($val)) { $arr [] = $val; @@ -501,15 +480,15 @@ public static function appendNonEmpty(&$arr, $val) /** * Adds key-value pair to the associative array if the value is not empty * - * @param array $arr The input array. - * @param string|int $key The key. - * @param mixed $val The appended value. + * @param array $arr The input array. + * @param int|string|null $key The key. + * @param mixed $val The appended value. * * @return array The resulting array * * @internal */ - public static function addNonEmpty(&$arr, $key, $val) + public static function addNonEmpty(array &$arr, int|string|null $key, mixed $val): array { if (! empty($val) || is_int($val) || is_float($val) || is_bool($val)) { $arr[$key] = $val; @@ -521,17 +500,21 @@ public static function addNonEmpty(&$arr, $key, $val) /** * Adds key-value pair to the associative array where value is taken from source array using the same key. * - * @param array &$resultingArr The target array. - * @param mixed $key The key to add - * @param array $sourceArray The source array - * @param mixed $defaultValue Fallback value, in case the key does not exist or is empty + * @param array & $resultingArr The target array. + * @param mixed $key The key to add + * @param array $sourceArray The source array + * @param mixed|null $defaultValue Fallback value, in case the key does not exist or is empty * * @return array The resulting array * * @internal */ - public static function addNonEmptyFromOther(&$resultingArr, $key, $sourceArray, $defaultValue = null) - { + public static function addNonEmptyFromOther( + array &$resultingArr, + mixed $key, + array $sourceArray, + mixed $defaultValue = null + ): array { return self::addNonEmpty($resultingArr, $key, self::get($sourceArray, $key, $defaultValue)); } @@ -545,7 +528,7 @@ public static function addNonEmptyFromOther(&$resultingArr, $key, $sourceArray, * @internal * */ - public static function mergeNonEmpty(...$arrays) + public static function mergeNonEmpty(...$arrays): array { $result = []; @@ -570,13 +553,13 @@ public static function mergeNonEmpty(...$arrays) * @return array The new array with the inserted key */ public static function insertAt( - $array, - $searchKey, - $insertKey, - $insertValue, - $insertAfter = true, - $appendIfNotFound = true - ) { + array $array, + mixed $searchKey, + mixed $insertKey, + mixed $insertValue, + bool $insertAfter = true, + bool $appendIfNotFound = true + ): array { $result = []; foreach ($array as $key => $value) { @@ -605,7 +588,7 @@ public static function insertAt( * @param mixed $key The key. * @param mixed $defaultValue The default value. */ - public static function setDefaultValue(array &$array, $key, $defaultValue) + public static function setDefaultValue(array &$array, mixed $key, mixed $defaultValue): void { if (! isset($array[$key]) || ! self::safeFilterFunc($array[$key])) { $array[$key] = $defaultValue; @@ -621,7 +604,7 @@ public static function setDefaultValue(array &$array, $key, $defaultValue) * * @internal */ - public static function convertToAssoc($array) + public static function convertToAssoc(array $array): array { $result = []; foreach ($array as $k => $v) { @@ -642,7 +625,7 @@ public static function convertToAssoc($array) * * @return array Recursive copy of the source array */ - public static function deepCopy($array) + public static function deepCopy(array $array): array { if (! is_array($array)) { return $array; @@ -665,11 +648,9 @@ public static function deepCopy($array) /** * Indicates whether all parameters are non-empty * - * @param mixed ...$params * - * @return bool */ - public static function all(...$params) + public static function all(...$params): bool { foreach ($params as $param) { if (empty($param)) { @@ -681,16 +662,15 @@ public static function all(...$params) } /** - * Case insensitive version of in_array + * Case-insensitive version of in_array * * @param mixed $needle The searched value. * @param array $haystack The array. * - * @return bool */ - public static function inArrayI($needle, $haystack) + public static function inArrayI(mixed $needle, array $haystack): bool { - return in_array(strtolower($needle), array_map('strtolower', $haystack), false); + return in_array(strtolower($needle), array_map('strtolower', $haystack)); } /** @@ -700,7 +680,7 @@ public static function inArrayI($needle, $haystack) * * @param array &$array The input array to convert. */ - public static function convertBoolToIntStrings(&$array) + public static function convertBoolToIntStrings(array &$array): void { array_walk( $array, diff --git a/src/Utils/ClassUtils.php b/src/Utils/ClassUtils.php index 092c53a..6a34dee 100644 --- a/src/Utils/ClassUtils.php +++ b/src/Utils/ClassUtils.php @@ -25,11 +25,10 @@ class ClassUtils * * @param object $instance The instance object * - * @return string */ - public static function getClassName($instance) + public static function getClassName(object $instance): string { - return self::getBaseName(get_class($instance)); + return self::getBaseName($instance::class); } /** @@ -39,9 +38,10 @@ public static function getClassName($instance) * * @return string class base name */ - public static function getBaseName($className) + public static function getBaseName(string $className): string { - if ($pos = strrpos($className, '\\')) { + $pos = strrpos($className, '\\'); + if ($pos) { return substr($className, $pos + 1); } @@ -56,14 +56,14 @@ public static function getBaseName($className) * * @return array of class constants */ - public static function getConstants($instance, $exclusions = []) + public static function getConstants(object|string $instance, array $exclusions = []): array { $constants = []; try { $reflectionClass = new ReflectionClass($instance); $constants = array_values($reflectionClass->getConstants()); - } catch (ReflectionException $e) { + } catch (ReflectionException) { //TODO: log it? } @@ -81,16 +81,19 @@ public static function getConstants($instance, $exclusions = []) * If $notSureIfT is a string, then $t will be a new Transformation initialized with the value of $notSureIfT. * In case $notSureIfT is already an instance of CommonTransformation, it is returned as is. * - * @param mixed $object The value to verify - * @param string $baseClass Base class name - * @param string $instanceClass Instance class to create in case $object is not derivative of the $baseClass. + * @param mixed $object The value to verify + * @param string $baseClass Base class name + * @param string|null $instanceClass Instance class to create in case $object is not derivative of the $baseClass. * $baseClass is used in case it is not provided. - * @param array $params Additional parameters for the constructor + * @param array $params Additional parameters for the constructor * - * @return mixed */ - public static function forceInstance($object, $baseClass, $instanceClass = null, ...$params) - { + public static function forceInstance( + mixed $object, + string $baseClass, + ?string $instanceClass = null, + ...$params + ): mixed { if (! $object instanceof $baseClass) { $instanceClass = $instanceClass ?: $baseClass; $object = new $instanceClass($object, ...$params); @@ -104,16 +107,19 @@ public static function forceInstance($object, $baseClass, $instanceClass = null, * * @param object|mixed $object The value to verify * @param string $baseClass Base class name - * @param string $instanceClass Instance class to create in case $object is not derivative of the $baseClass. + * @param string|null $instanceClass Instance class to create in case $object is not derivative of the $baseClass. * $baseClass is used in case it is not provided. * @param array $params Additional parameters for the constructor * - * @return mixed * * @see ClassUtils::forceInstance */ - public static function verifyInstance($object, $baseClass, $instanceClass = null, ...$params) - { + public static function verifyInstance( + mixed $object, + string $baseClass, + ?string $instanceClass = null, + ...$params + ): mixed { if ($object === null) { // no propagation of null objects return null; } @@ -124,17 +130,18 @@ public static function verifyInstance($object, $baseClass, $instanceClass = null /** * Variable arguments version of the ClassUtils::forceInstance. * - * @param array $varArgs Arguments to verify - * @param string $baseClass Base class name - * @param string $instanceClass Instance class to create in case $object is not derivative of the $baseClass. - * $baseClass is used in case it is not provided. + * @param mixed $varArgs Arguments to verify + * @param string $baseClass Base class name + * @param string|null $instanceClass Instance class to create in case $object is not derivative of the $baseClass. + * $baseClass is used in case it is not provided. * - * @return mixed * * @see ClassUtils::verifyInstance */ - public static function forceVarArgsInstance(array $varArgs, $baseClass, $instanceClass = null) + public static function forceVarArgsInstance(mixed $varArgs, string $baseClass, ?string $instanceClass = null): mixed { + $varArgs = ArrayUtils::build($varArgs); + // When passing array instead of varargs, unwrap it and proceed if (count($varArgs) === 1 && is_array($varArgs[0])) { $varArgs = $varArgs[0]; @@ -155,17 +162,19 @@ public static function forceVarArgsInstance(array $varArgs, $baseClass, $instanc /** * Variable arguments version of the ClassUtils::verifyInstance. * - * @param array $varArgs Arguments to verify - * @param string $baseClass Base class name - * @param string $instanceClass Instance class to create in case $object is not derivative of the $baseClass. - * $baseClass is used in case it is not provided. + * @param mixed $varArgs Arguments to verify + * @param string $baseClass Base class name + * @param string|null $instanceClass Instance class to create in case $object is not derivative of the $baseClass. + * $baseClass is used in case it is not provided. * - * @return mixed * * @see ClassUtils::verifyInstance */ - public static function verifyVarArgsInstance(array $varArgs, $baseClass, $instanceClass = null) - { + public static function verifyVarArgsInstance( + mixed $varArgs, + string $baseClass, + ?string $instanceClass = null + ): mixed { // No args, nothing to verify if (empty($varArgs)) { return null; diff --git a/src/Utils/JsonUtils.php b/src/Utils/JsonUtils.php index 2e162a5..2c1c074 100644 --- a/src/Utils/JsonUtils.php +++ b/src/Utils/JsonUtils.php @@ -25,13 +25,12 @@ class JsonUtils * * @param string $string The input string. * - * @return bool */ - public static function isJsonString($string) + public static function isJsonString(string $string): bool { - return (is_string($string) - && is_array(json_decode($string, true)) //TODO: improve performance - && (json_last_error() === JSON_ERROR_NONE)); + return is_string($string) + && is_array(json_decode($string, true)) //TODO: improve performance + && json_last_error() === JSON_ERROR_NONE; } /** @@ -42,13 +41,12 @@ public static function isJsonString($string) * @param int $depth Maximum depth. * @param int $options Additional options. * - * @return mixed * * @throws InvalidArgumentException * * @see json_decode */ - public static function decode($json, $assoc = true, $depth = 512, $options = 0) + public static function decode(mixed $json, bool $assoc = true, int $depth = 512, int $options = 0): mixed { if (is_array($json)) { // Already a json array, skip decoding. return $json; @@ -69,7 +67,6 @@ public static function decode($json, $assoc = true, $depth = 512, $options = 0) * @param mixed $value The value to encode. * @param int $options Additional options. * - * @param int $depth * * @return false|string * @@ -77,7 +74,7 @@ public static function decode($json, $assoc = true, $depth = 512, $options = 0) * * @see json_encode */ - public static function encode($value, $options = 0, $depth = 512) + public static function encode(mixed $value, int $options = 0, int $depth = 512): bool|string { $result = json_encode($value, $options, $depth); @@ -93,11 +90,10 @@ public static function encode($value, $options = 0, $depth = 512) * * @param JsonSerializable|mixed $jsonSerializable The serializable to serialize. * - * @return mixed * - * @see \JsonSerializable::jsonSerialize + * @see JsonSerializable::jsonSerialize */ - public static function jsonSerialize($jsonSerializable) + public static function jsonSerialize(mixed $jsonSerializable): mixed { if ($jsonSerializable === null) { return []; diff --git a/src/Utils/StringUtils.php b/src/Utils/StringUtils.php index f1a5dbc..bdc1527 100644 --- a/src/Utils/StringUtils.php +++ b/src/Utils/StringUtils.php @@ -17,7 +17,7 @@ */ class StringUtils { - const MAX_STRING_LENGTH = 255; + public const MAX_STRING_LENGTH = 255; /** * Converts camelCase to snake_case. @@ -25,9 +25,8 @@ class StringUtils * @param string $input The input string. * @param string $separator Optional custom separator. * - * @return string */ - public static function camelCaseToSnakeCase($input, $separator = '_') + public static function camelCaseToSnakeCase(string $input, string $separator = '_'): string { return strtolower(preg_replace('/(? ':', '%2F' => '/']; @@ -224,7 +205,7 @@ public static function smartEscape($str) * * @return string|string[]|null */ - public static function encodeDot($string) + public static function encodeDot(string $string): array|string|null { return str_replace('.', '%2E', $string); } @@ -233,11 +214,11 @@ public static function encodeDot($string) * Escapes characters. * * @param string $string The input string. - * @param string|array $unsafeChars The list of the characters to escape. + * @param array|string $unsafeChars The list of the characters to escape. * * @return string|string[]|null */ - public static function escapeUnsafeChars($string, $unsafeChars) + public static function escapeUnsafeChars(string $string, array|string $unsafeChars): array|string|null { if (empty($unsafeChars)) { return $string; @@ -261,7 +242,7 @@ public static function escapeUnsafeChars($string, $unsafeChars) * * @internal */ - public static function base64UrlEncode($data) + public static function base64UrlEncode(mixed $data): string { return strtr(base64_encode($data), '+/', '-_'); } @@ -275,7 +256,7 @@ public static function base64UrlEncode($data) * * @see parse_str */ - public static function parseQueryString($query) + public static function parseQueryString(string $query): array { $params = []; if (! empty($query)) { diff --git a/src/Utils/TransformationUtils.php b/src/Utils/TransformationUtils.php index c818fda..04734a0 100644 --- a/src/Utils/TransformationUtils.php +++ b/src/Utils/TransformationUtils.php @@ -21,11 +21,10 @@ class TransformationUtils /** * Converts a float value to the string representation. * - * @param mixed $value * * @return mixed|string */ - public static function floatToString($value) + public static function floatToString(mixed $value): mixed { if (! is_float($value)) { return $value; @@ -39,9 +38,8 @@ public static function floatToString($value) $locale = localeconv(); $string = (string)$value; - $string = str_replace($locale['decimal_point'], '.', $string); - return $string; + return str_replace($locale['decimal_point'], '.', $string); } /** @@ -49,9 +47,8 @@ public static function floatToString($value) * * @param mixed $value Candidate to convert. If not boolean, returned as is * - * @return string */ - public static function boolToIntString($value) + public static function boolToIntString(mixed $value): ?string { return self::boolToString($value, '1', '0'); } @@ -60,9 +57,8 @@ public static function boolToIntString($value) * * @param mixed $value Candidate to convert. If not boolean, returned as is * - * @return string */ - public static function boolToString($value, $trueString = 'true', $falseString = 'false') + public static function boolToString(mixed $value, $trueString = 'true', $falseString = 'false'): ?string { return is_bool($value) ? ($value ? $trueString : $falseString) : $value; } @@ -73,9 +69,8 @@ public static function boolToString($value, $trueString = 'true', $falseString = * * @param int $bytes The input value to convert. * - * @return int */ - public static function bytesToKB($bytes) + public static function bytesToKB(int $bytes): int { return (int)ceil($bytes / 1024); } @@ -85,9 +80,8 @@ public static function bytesToKB($bytes) * * @param int $number The number to format * - * @return string */ - public static function formatSigned($number) + public static function formatSigned(int $number): string { return $number > 0 ? "+$number" : (string)$number; } diff --git a/tests/TransformationTestCase.php b/tests/TransformationTestCase.php index 2c13807..bff2d58 100644 --- a/tests/TransformationTestCase.php +++ b/tests/TransformationTestCase.php @@ -49,7 +49,7 @@ abstract class TransformationTestCase extends TestCase * @param mixed $actual * @param string $message */ - public static function assertStrEquals($expected, $actual, $message = '') + public static function assertStrEquals(mixed $expected, mixed $actual, string $message = ''): void { self::assertEquals((string)$expected, (string)$actual, $message); } @@ -67,11 +67,11 @@ public static function assertStrEquals($expected, $actual, $message = '') */ protected static function generateDataProvider( $array, - $prefixValue = '', - $suffixValue = '', - $prefixMethod = '', - $suffixMethod = '' - ) { + string $prefixValue = '', + string $suffixValue = '', + string $prefixMethod = '', + string $suffixMethod = '' + ): array { return array_map( static function ($value) use ($prefixValue, $suffixValue, $prefixMethod, $suffixMethod) { return [ diff --git a/tests/Unit/Transformation/Common/ActionFromQualifiersTest.php b/tests/Unit/Transformation/Common/ActionFromQualifiersTest.php index 5f323ec..88c5826 100644 --- a/tests/Unit/Transformation/Common/ActionFromQualifiersTest.php +++ b/tests/Unit/Transformation/Common/ActionFromQualifiersTest.php @@ -34,7 +34,7 @@ final class ActionFromQualifiersTest extends TransformationTestCase * * @return array[] */ - public function customFunctionDataProvider() + public function customFunctionDataProvider(): array { return [ 'Should support custom function from string' => [ @@ -69,7 +69,7 @@ public function customFunctionDataProvider() * * @return array[] */ - public function borderDataProvider() + public function borderDataProvider(): array { return [ 'Border as a string' => ['bo_1px_solid_blue', ['border' => '1px_solid_blue']], @@ -86,7 +86,7 @@ public function borderDataProvider() * * @return array[] */ - public function flagsDataProvider() + public function flagsDataProvider(): array { return [ 'Should support flags as a string' => [ @@ -109,7 +109,7 @@ public function flagsDataProvider() * * @return array[] */ - public function effectDataProvider() + public function effectDataProvider(): array { return [ 'Should support an effect as a string' => [ @@ -136,7 +136,7 @@ public function effectDataProvider() * * @return array[] */ - public function keyframeIntervalDataProvider() + public function keyframeIntervalDataProvider(): array { return [ 'Keyframe interval as a positive integer' => ['ki_10.0', ['keyframe_interval' => 10]], @@ -153,7 +153,7 @@ public function keyframeIntervalDataProvider() * * @return array[] */ - public function audioDataProvider() + public function audioDataProvider(): array { return [ 'Audio codec as a string value' => ['ac_acc', ['audio_codec' => 'acc']], @@ -168,7 +168,7 @@ public function audioDataProvider() * * @return array[] */ - public function videoSamplingDataProvider() + public function videoSamplingDataProvider(): array { return [ 'Video sampling as an integer' => ['vs_20', ['video_sampling' => 20]], @@ -181,7 +181,7 @@ public function videoSamplingDataProvider() * * @return array[] */ - public function startOffsetDataProvider() + public function startOffsetDataProvider(): array { return [ 'Start offset as a float' => ['so_2.63', ['start_offset' => 2.63]], @@ -197,7 +197,7 @@ public function startOffsetDataProvider() * * @return array[] */ - public function endOffsetDataProvider() + public function endOffsetDataProvider(): array { return [ 'End offset as a float' => ['eo_2.63', ['end_offset' => 2.63]], @@ -212,7 +212,7 @@ public function endOffsetDataProvider() * * @return array[] */ - public function durationParameterDataProvider() + public function durationParameterDataProvider(): array { return [ 'Duration parameter as a float' => ['du_2.63', ['duration' => 2.63]], @@ -227,7 +227,7 @@ public function durationParameterDataProvider() * * @return array[] */ - public function offsetDataProvider() + public function offsetDataProvider(): array { return [ 'Offset as a string separated by two points' => [ @@ -258,7 +258,7 @@ public function offsetDataProvider() * * @return array[] */ - public function operatorsDataProvider() + public function operatorsDataProvider(): array { return [ 'Should support and translate operators: ^, * and variables: initial_width, initial_height, crop' => [ @@ -298,7 +298,7 @@ public function operatorsDataProvider() * * @return array[] */ - public function userVariableDataProvider() + public function userVariableDataProvider(): array { return [ 'Normalize expression should not convert user variables' => [ @@ -366,7 +366,7 @@ public function userVariableDataProvider() * * @return array[] */ - public function gravityDataProvider() + public function gravityDataProvider(): array { return [ 'Should support gravity with x, y, radius, quality, prefix and opacity parameters' => [ @@ -401,7 +401,7 @@ public function gravityDataProvider() * * @return array[] */ - public function qualityDataProvider() + public function qualityDataProvider(): array { return [ 'Quality as an integer' => [ @@ -428,7 +428,7 @@ public function qualityDataProvider() * * @return array[] */ - public function radiusDataProvider() + public function radiusDataProvider(): array { return [ 'Radius as an integer' => ['r_10', ['radius' => 10]], @@ -459,7 +459,7 @@ public function radiusDataProvider() * * @return array[] */ - public function transformationDataProvider() + public function transformationDataProvider(): array { return [ 'Should support a named transformation' => ['t_blip', ['transformation' => 'blip']], @@ -503,7 +503,7 @@ public function transformationDataProvider() * * @return array[] */ - public function backgroundDataProvider() + public function backgroundDataProvider(): array { return [ 'Should support a background as a constant' => [ @@ -522,7 +522,7 @@ public function backgroundDataProvider() * * @return array[] */ - public function generalQualifiersActionDataProvider() + public function generalQualifiersActionDataProvider(): array { return [ 'Should support size using width and height parameters' => [ @@ -635,10 +635,10 @@ public function generalQualifiersActionDataProvider() * @dataProvider gravityDataProvider * @dataProvider backgroundDataProvider * - * @param $transformation - * @param $options + * @param string $transformation The transformation string to assert. + * @param array $options The transformation options to test. */ - public function testQualifiersAction($transformation, $options) + public function testQualifiersAction(string $transformation, array $options) { self::assertEquals($transformation, (string)new QualifiersAction($options)); } @@ -648,7 +648,7 @@ public function testQualifiersAction($transformation, $options) * * @return array */ - public function layersQualifiersDataProvider() + public function layersQualifiersDataProvider(): array { return [ 'public_id' => [['public_id' => 'logo'], 'logo'], @@ -658,7 +658,7 @@ public function layersQualifiersDataProvider() 'video' => [['resource_type' => 'video', 'public_id' => 'cat'], 'video:cat'], 'fetch video' => [ ['resource_type' => 'video', 'url' => self::FETCH_VIDEO_URL], - 'video:fetch:' . self::B64_FETCH_VIDEO_URL + 'video:fetch:' . self::B64_FETCH_VIDEO_URL, ], 'text' => [ ['public_id' => 'logo', 'text' => 'Hello World, Nice to meet you?'], @@ -757,7 +757,7 @@ public function testLayerQualifierFactory($qualifiers, $expected) * * @return array */ - public function layerQualifierFactoryExpectExceptionDataProvider() + public function layerQualifierFactoryExpectExceptionDataProvider(): array { return [ 'Underlay require a public id for non text for image layer' => [ diff --git a/tests/Unit/Transformation/Common/EffectTest.php b/tests/Unit/Transformation/Common/EffectTest.php index d69c674..2640816 100644 --- a/tests/Unit/Transformation/Common/EffectTest.php +++ b/tests/Unit/Transformation/Common/EffectTest.php @@ -416,7 +416,7 @@ public function testGradientFade() self::assertEquals( 'e_gradient_fade:symmetric', - (string)Effect::gradientFade(GradientFade::symmetric()) + (string)Effect::gradientFade(null, GradientFade::symmetric()) ); self::assertEquals( @@ -502,7 +502,7 @@ public function testShear() * * @return array */ - public function artisticFilterDataProvider() + public function artisticFilterDataProvider(): array { return [ ['al_dente', 'alDente'], @@ -537,7 +537,7 @@ public function artisticFilterDataProvider() * @param string $filter * @param string $method */ - public function testArtisticFilter($filter, $method) + public function testArtisticFilter(string $filter, string $method) { self::assertEquals( 'e_art:' . $filter, diff --git a/tests/Unit/Transformation/Common/QualifiersTest.php b/tests/Unit/Transformation/Common/QualifiersTest.php index f853065..0a292b7 100644 --- a/tests/Unit/Transformation/Common/QualifiersTest.php +++ b/tests/Unit/Transformation/Common/QualifiersTest.php @@ -32,7 +32,7 @@ final class QualifiersTest extends TestCase * * @return array */ - public function colorConstantsDataProvider() + public function colorConstantsDataProvider(): array { $reflectionClass = new ReflectionClass(Color::class); $colors = ($reflectionClass->getConstants()); @@ -60,7 +60,7 @@ static function ($color) { * * @param string $color */ - public function testColorConstants($color) + public function testColorConstants(string $color) { self::assertEquals( $color, diff --git a/tests/Unit/Transformation/Common/RotateTest.php b/tests/Unit/Transformation/Common/RotateTest.php index da80cd0..8290da5 100644 --- a/tests/Unit/Transformation/Common/RotateTest.php +++ b/tests/Unit/Transformation/Common/RotateTest.php @@ -95,7 +95,7 @@ public function testAngle() * * @return array[] */ - public function angleMethodsDataProvider() + public function angleMethodsDataProvider(): array { return [ [ @@ -141,7 +141,7 @@ public function angleMethodsDataProvider() * @param string $mode * @param string $method */ - public function testAngleMethods($mode, $method) + public function testAngleMethods(string $mode, string $method) { self::assertEquals( "a_$mode", diff --git a/tests/Unit/Transformation/Common/TransformationVariableTest.php b/tests/Unit/Transformation/Common/TransformationVariableTest.php index 7cdfb4f..af05b8a 100644 --- a/tests/Unit/Transformation/Common/TransformationVariableTest.php +++ b/tests/Unit/Transformation/Common/TransformationVariableTest.php @@ -42,7 +42,7 @@ final class TransformationVariableTest extends TransformationTestCase protected static $floatExpression1; protected static $floatExpression1Str; - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { parent::setUpBeforeClass(); // TODO: Change the autogenerated stub @@ -118,7 +118,7 @@ public function testTransformationVariables() * @param $component * @param string $messages */ - private function assertComponentEquals($expectedStr, $component, $messages = '') + private function assertComponentEquals($expectedStr, $component, string $messages = ''): void { self::assertEquals($expectedStr, (string)$component, $messages); } diff --git a/tests/Unit/Transformation/Common/UsageTest.php b/tests/Unit/Transformation/Common/UsageTest.php index 3d5df6e..1445991 100644 --- a/tests/Unit/Transformation/Common/UsageTest.php +++ b/tests/Unit/Transformation/Common/UsageTest.php @@ -192,7 +192,7 @@ public function testCrop() * @return array * @throws ReflectionException */ - public function objectGravityDataProvider() + public function objectGravityDataProvider(): array { $classes = [ AccessoryObjectGravityInterface::class, @@ -227,7 +227,7 @@ public function objectGravityDataProvider() * @param string $value * @param string $method */ - public function testObjectGravityMethods($value, $method) + public function testObjectGravityMethods(string $value, string $method) { self::assertEquals( "c_thumb,g_$value,h_5,w_8", @@ -453,7 +453,7 @@ public function testBorder() * * @return string[][] */ - public function formatDataProvider() + public function formatDataProvider(): array { return [ [Format::AUTO, 'auto'], @@ -506,7 +506,7 @@ public function formatDataProvider() * @param string $format * @param string $method */ - public function testFormat($format, $method) + public function testFormat(string $format, string $method) { self::assertEquals( 'f_' . $format, diff --git a/tests/Unit/Transformation/Expression/ExpressionTest.php b/tests/Unit/Transformation/Expression/ExpressionTest.php index 757c94f..05f4354 100644 --- a/tests/Unit/Transformation/Expression/ExpressionTest.php +++ b/tests/Unit/Transformation/Expression/ExpressionTest.php @@ -67,7 +67,7 @@ public function testRelationalExpression() $re = new ExpressionComponent( PVar::initialAspectRatio(), RelationalOperator::LessThanOrEqual(), - UVal::float(17) + UVal::int(17) ); self::assertEquals('iar_lte_17', (string)$re); @@ -164,9 +164,9 @@ public function testRawExpression() * @dataProvider normalizationDataProvider * * @param mixed $input Value to normalize - * @param null|string $expectedOutput Expected normalized output + * @param string|null $expectedOutput Expected normalized output */ - public function testExpressionNormalization($input, $expectedOutput) + public function testExpressionNormalization(mixed $input, ?string $expectedOutput) { $actual = ExpressionUtils::normalize($input); self::assertEquals($expectedOutput, $actual); @@ -177,7 +177,7 @@ public function testExpressionNormalization($input, $expectedOutput) * * @return array[] */ - public static function normalizationDataProvider() + public static function normalizationDataProvider(): array { return [ 'null is not affected' => [null, null], diff --git a/tests/Unit/Transformation/Video/Audio/VideoAudioTest.php b/tests/Unit/Transformation/Video/Audio/VideoAudioTest.php index 33c9eb7..bdbf7b5 100644 --- a/tests/Unit/Transformation/Video/Audio/VideoAudioTest.php +++ b/tests/Unit/Transformation/Video/Audio/VideoAudioTest.php @@ -128,7 +128,7 @@ public function testKeyframeInterval() * * @return array[] */ - public function exceptionsKeyframeIntervalDataProvider() + public function exceptionsKeyframeIntervalDataProvider(): array { return [ [ @@ -156,7 +156,7 @@ public function exceptionsKeyframeIntervalDataProvider() * @param string $exceptionMessage * @param array $args */ - public function testExceptionsKeyframeInterval($exceptionClass, $exceptionMessage, $args) + public function testExceptionsKeyframeInterval(string $exceptionClass, string $exceptionMessage, array $args) { $this->expectException($exceptionClass); $this->expectExceptionMessage($exceptionMessage);