Skip to content

SimpleSelector::notEmpty() can never return true; deprecate it in favour of isBlank() #138

Open

Description

@gravitypdf-bot

Problem

QueryPath\CSS\SimpleSelector::notEmpty() joins its checks with &&, so it only returns true when the element, ID, classes, combinator, attributes, pseudo-classes and pseudo-elements are all set, which a simple selector can't have (it has at most one ID, and the combinator is usually unset). It is never true in practice, and nothing in src/ or tests/ calls it.

isBlank() is the working inverse and is what the engine uses (PseudoClass::relativeSelector()).

Proposal

It's public, so for 4.x: mark notEmpty() @deprecated in favour of ! isBlank(), and either fix it to be ! $this->isBlank() (also counting the combinator if that's intended) or leave it as is. Remove it in 5.0.

Found in the /simplify pass on #119 / #125.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions