Skip to content

Commit

Permalink
skip property promotion when property is different
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Feb 20, 2025
1 parent ade6b3a commit 9580421
Show file tree
Hide file tree
Showing 9 changed files with 131 additions and 71 deletions.
10 changes: 8 additions & 2 deletions src/fields/data/ColorData.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
*/
class ColorData extends BaseObject implements Serializable, \Stringable
{
/**
* @var string The color’s hex value
*/
private string $_hex;

/**
* @var array
* @see _hsl()
Expand All @@ -37,11 +42,12 @@ class ColorData extends BaseObject implements Serializable, \Stringable
/**
* Constructor.
*
* @param string $_hex hex color value, beginning with `#`. (Shorthand is not supported, e.g. `#f00`.)
* @param string $hex hex color value, beginning with `#`. (Shorthand is not supported, e.g. `#f00`.)
* @param array $config name-value pairs that will be used to initialize the object properties
*/
public function __construct(private string $_hex, array $config = [])
public function __construct(string $hex, array $config = [])
{
$this->_hex = $hex;
parent::__construct($config);
}

Expand Down
18 changes: 15 additions & 3 deletions src/gql/base/MutationResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,27 @@
*/
abstract class MutationResolver extends Component
{
/**
* @var array Data that might be useful during mutation resolution.
*/
private array $_resolutionData;

/**
* @var callable[] Value normalizers stored by argument name
*/
private array $_valueNormalizers = [];

/**
* Construct a mutation resolver and store the resolution data as well as normalizers, if any provided.
*
* @param array $_resolutionData Resolver data
* @param array $_valueNormalizers Data normalizers
* @param array $data Resolver data
* @param array $valueNormalizers Data normalizers
* @param array $config
*/
public function __construct(private array $_resolutionData = [], private array $_valueNormalizers = [], array $config = [])
public function __construct(array $data = [], array $valueNormalizers = [], array $config = [])
{
$this->_resolutionData = $data;
$this->_valueNormalizers = $valueNormalizers;
parent::__construct($config);
}

Expand Down
10 changes: 8 additions & 2 deletions src/search/SearchQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
*/
class SearchQuery
{
/**
* @var string
*/
private string $_query;

/**
* @var array
* @phpstan-var array{subLeft:bool,subRight:bool,exclude:bool,exact:bool}
Expand All @@ -31,12 +36,13 @@ class SearchQuery
/**
* Constructor
*
* @param string $_query
* @param string $query
* @param array $defaultTermOptions
* @phpstan-param array{subLeft?:bool,subRight?:bool,exclude?:bool,exact?:bool} $defaultTermOptions
*/
public function __construct(private string $_query, array $defaultTermOptions = [])
public function __construct(string $query, array $defaultTermOptions = [])
{
$this->_query = $query;
$this->_defaultTermOptions = $defaultTermOptions + [
'subLeft' => false,
'subRight' => true,
Expand Down
18 changes: 15 additions & 3 deletions src/test/console/CommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ class CommandTest
public const SELECT = 'select';
public const OUTPUT_COMMAND = 'outputCommand';

/**
* @var ConsoleTest
*/
protected ConsoleTest $test;

/**
* @var bool
*/
protected bool $ignoreStdout = false;

/**
* @var int
*/
Expand Down Expand Up @@ -72,14 +82,16 @@ class CommandTest
/**
* CommandTest constructor.
*
* @param ConsoleTest $test
* @param ConsoleTest $consoleTest
* @param string $command
* @param array $parameters
* @param bool $ignoreStdout
* @param bool $ignoreStdOut
* @throws InvalidConfigException
*/
public function __construct(protected ConsoleTest $test, protected string $command, protected array $parameters = [], protected bool $ignoreStdout = false)
public function __construct(ConsoleTest $consoleTest, protected string $command, protected array $parameters = [], bool $ignoreStdOut = false)
{
$this->ignoreStdout = $ignoreStdOut;
$this->test = $consoleTest;
$this->setupController();
}

Expand Down
10 changes: 8 additions & 2 deletions src/test/mockclasses/ToString.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,19 @@
*/
class ToString implements \Stringable
{
/**
* @var string
*/
private string $_string;

/**
* ToString constructor.
*
* @param string $_string
* @param string $string
*/
public function __construct(private string $_string)
public function __construct(string $string)
{
$this->_string = $string;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/web/assets/garnish/dist/garnish.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/web/assets/garnish/dist/garnish.js.map

Large diffs are not rendered by default.

131 changes: 74 additions & 57 deletions src/web/assets/garnish/src/BaseDrag.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export default Base.extend(
scrollProperty: null,
scrollAxis: null,
scrollDist: null,
scrollProxy: null,
scrollFrame: null,

_: null,
Expand Down Expand Up @@ -73,12 +72,27 @@ export default Base.extend(
startDragging: function () {
this.onBeforeDragStart();
this.dragging = true;
this.setScrollContainer();
this.onDragStart();

// Mute activate events
Garnish.activateEventsMuted = true;
},

setScrollContainer: function () {
this._.$scrollContainer = this.$targetItem.scrollParent();
if (
this._.$scrollContainer[0] === Garnish.$doc[0] ||
this._.$scrollContainer[0] === Garnish.$bod[0]
) {
this._.$scrollContainer = Garnish.$win;
}
},

isScrollingWindow: function () {
return this._.$scrollContainer[0] === Garnish.$win[0];
},

/**
* Drag
*/
Expand All @@ -88,79 +102,82 @@ export default Base.extend(
this.drag._scrollProperty = null;

if (this.settings.axis !== Garnish.X_AXIS) {
// Scrolling up?
this.drag._winScrollTop = Garnish.$win.scrollTop();
this.drag._minMouseScrollY =
this.drag._winScrollTop + Garnish.BaseDrag.windowScrollTargetSize;
if (this.isScrollingWindow()) {
this.drag._minMouseScrollY = Garnish.$win.scrollTop();
this.drag._maxMouseScrollY =
this.drag._minMouseScrollY + Garnish.$win.height();
} else {
this.drag._minMouseScrollY = this._.$scrollContainer.offset().top;
this.drag._maxMouseScrollY =
this.drag._minMouseScrollY +
this._.$scrollContainer.outerHeight();
}

this.drag._minMouseScrollY += Garnish.BaseDrag.windowScrollTargetSize;
this.drag._maxMouseScrollY -= Garnish.BaseDrag.windowScrollTargetSize;

if (this.mouseY < this.drag._minMouseScrollY) {
// Scrolling up
this.drag._scrollProperty = 'scrollTop';
this.drag._scrollAxis = 'Y';
this.drag._scrollDist = Math.round(
(this.mouseY - this.drag._minMouseScrollY) / 2
);
} else {
// Scrolling down?
this.drag._maxMouseScrollY =
this.drag._winScrollTop +
Garnish.$win.height() -
Garnish.BaseDrag.windowScrollTargetSize;

if (this.mouseY > this.drag._maxMouseScrollY) {
this.drag._scrollProperty = 'scrollTop';
this.drag._scrollAxis = 'Y';
this.drag._scrollDist = Math.round(
(this.mouseY - this.drag._maxMouseScrollY) / 2
);
}
} else if (this.mouseY > this.drag._maxMouseScrollY) {
// Scrolling down
this.drag._scrollProperty = 'scrollTop';
this.drag._scrollAxis = 'Y';
this.drag._scrollDist = Math.round(
(this.mouseY - this.drag._maxMouseScrollY) / 2
);
}
}

if (
!this.drag._scrollProperty &&
this.settings.axis !== Garnish.Y_AXIS
) {
// Scrolling left?
this.drag._winScrollLeft = Garnish.$win.scrollLeft();
this.drag._minMouseScrollX =
this.drag._winScrollLeft + Garnish.BaseDrag.windowScrollTargetSize;
if (this.isScrollingWindow()) {
this.drag._minMouseScrollX = Garnish.$win.scrollLeft();
this.drag._maxMouseScrollX =
this.drag._minMouseScrollX + Garnish.$win.width();
} else {
this.drag._minMouseScrollX = this._.$scrollContainer.offset().left;
this.drag._maxMouseScrollX =
this.drag._minMouseScrollX + this._.$scrollContainer.outerWidth();
}

this.drag._minMouseScrollX += Garnish.BaseDrag.windowScrollTargetSize;
this.drag._maxMouseScrollX -= Garnish.BaseDrag.windowScrollTargetSize;

if (this.mouseX < this.drag._minMouseScrollX) {
// Scrolling left
this.drag._scrollProperty = 'scrollLeft';
this.drag._scrollAxis = 'X';
this.drag._scrollDist = Math.round(
(this.mouseX - this.drag._minMouseScrollX) / 2
);
} else {
// Scrolling right?
this.drag._maxMouseScrollX =
this.drag._winScrollLeft +
Garnish.$win.width() -
Garnish.BaseDrag.windowScrollTargetSize;

if (this.mouseX > this.drag._maxMouseScrollX) {
this.drag._scrollProperty = 'scrollLeft';
this.drag._scrollAxis = 'X';
this.drag._scrollDist = Math.round(
(this.mouseX - this.drag._maxMouseScrollX) / 2
);
}
} else if (this.mouseX > this.drag._maxMouseScrollX) {
// Scrolling right
this.drag._scrollProperty = 'scrollLeft';
this.drag._scrollAxis = 'X';
this.drag._scrollDist = Math.round(
(this.mouseX - this.drag._maxMouseScrollX) / 2
);
}
}

if (this.drag._scrollProperty) {
// Are we starting to scroll now?
if (!this.scrollProperty) {
if (!this.scrollProxy) {
this.scrollProxy = this._scrollWindow.bind(this);
}

if (this.scrollFrame) {
Garnish.cancelAnimationFrame(this.scrollFrame);
this.scrollFrame = null;
}

this.scrollFrame = Garnish.requestAnimationFrame(this.scrollProxy);
this.scrollFrame = Garnish.requestAnimationFrame(() => {
this._scrollWindow();
});
}

this.scrollProperty = this.drag._scrollProperty;
Expand Down Expand Up @@ -440,37 +457,37 @@ export default Base.extend(
* Scroll Window
*/
_scrollWindow: function () {
this._.scrollPos = Garnish.$scrollContainer[this.scrollProperty]();
this._.scrollPos = this._.$scrollContainer[this.scrollProperty]();
this._.scrollTargetPos = this._.scrollPos + this.scrollDist;
if (this._.scrollTargetPos < 0) {
this._.scrollTargetPos = 0;
} else {
this._.$scrollContainer =
Garnish.$scrollContainer[0] === Garnish.$win[0]
? Garnish.$bod
: Garnish.$scrollContainer;
if (this.scrollAxis === 'Y') {
this._.scrollMax =
this._.$scrollContainer[0].clientHeight -
Garnish.$scrollContainer.height();
this._.$scrollContainer[0].scrollHeight -
this._.$scrollContainer.outerHeight();
} else {
this._.scrollMax =
this._.$scrollContainer[0].clientWidth -
Garnish.$scrollContainer.width();
this._.$scrollContainer[0].scrollWidth -
this._.$scrollContainer.outerWidth();
}
if (this._.scrollTargetPos > this._.scrollMax) {
this._.scrollTargetPos = this._.scrollMax;
}
}
Garnish.$scrollContainer[this.scrollProperty](this._.scrollTargetPos);
this._.$scrollContainer[this.scrollProperty](this._.scrollTargetPos);

this['mouse' + this.scrollAxis] -=
this._.scrollPos - Garnish.$scrollContainer[this.scrollProperty]();
this['realMouse' + this.scrollAxis] = this['mouse' + this.scrollAxis];
if (this.isScrollingWindow()) {
this['mouse' + this.scrollAxis] -=
this._.scrollPos - Garnish.$win[this.scrollProperty]();
this['realMouse' + this.scrollAxis] = this['mouse' + this.scrollAxis];
}

this.drag();
this.scrollFrame = Garnish.requestAnimationFrame(() => {
this._scrollWindow();
});

this.scrollFrame = Garnish.requestAnimationFrame(this.scrollProxy);
this.drag(true);
},

/**
Expand Down
1 change: 1 addition & 0 deletions src/web/assets/garnish/src/Drag.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export default BaseDrag.extend(
);

this.dragging = true;
this.setScrollContainer();
this.onDragStart();

// Mute activate events
Expand Down

0 comments on commit 9580421

Please sign in to comment.