Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The parameter identical of the method isAttributeChanged in class BaseActiveRecord has no effect when its value is false. #297

Open
niqingyang opened this issue Feb 15, 2024 · 2 comments

Comments

@niqingyang
Copy link
Contributor

What steps will reproduce the problem?

The parameter identical of the method isAttributeChanged in class BaseActiveRecord has no effect when its value is false.

/**
  * Returns a value indicating whether the named attribute has been changed.
  *
  * @param string $name The name of the attribute.
  * @param bool $identical Whether the comparison of new and old value is made for identical values using `===`,
  * defaults to `true`. Otherwise `==` is used for comparison.
  *
  * @return bool Whether the attribute has been changed.
  */
public function isAttributeChanged(string $name, bool $identical = true): bool
{
    if (isset($this->attributes[$name], $this->oldAttributes[$name])) {
        if ($identical) {
            return $this->attributes[$name] !== $this->oldAttributes[$name];
        }

        return $this->attributes[$name] !== $this->oldAttributes[$name]; // !== in this line of code should be replaced with !=
    }

    return isset($this->attributes[$name]) || isset($this->oldAttributes[$name]);
}

What is the expected result?

The method implementation is consistent with the description, use == for comparison when the parameter identical is false

What do you get instead?

Method implementation is inconsistent with description

Additional info

Q A
Version 1.0.?
PHP version 8.2
Operating system MacOS
@Tigrov
Copy link
Member

Tigrov commented Feb 16, 2024

Related issue #285

@niqingyang
Copy link
Contributor Author

👌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants