@param EventInspection   $inspection
@param EventInspection[] $possibleParents

@return EventInspection|null
355430
private function findParentInspection(EventInspection $inspection, array $possibleParents)
    {
        $parentInspections = array_filter(
            $possibleParents,
            function (EventInspection $parent) use ($inspection) {
                return $this->isParent($parent, $inspection);
            }
        );

        return reset($parentInspections) ?: null; // `false` is for pussies.
    }
780805
public function clickFirstVisibleElementOfType($selectorString)
    {
        $page = $this->getSession()->getPage();
        /** @var NodeElement[] $nodes */
        $nodes = $page->findAll('css', $selectorString);
        foreach ($nodes as $node) {
            if ($node->isVisible()) {
                $node->click();
                return;
            }
        }

        throw new ExpectationException(
            "No visible {$selectorString} element found.",
            $this->getSession()->getDriver()
        );
    }
121524
protected function _evaluateCondition($condition, Event $event)
    {
        if (!isset($this->_options[$condition])) {
            return $condition !== 'unless';
        }
        if (!is_callable($this->_options[$condition])) {
            throw new RuntimeException(self::class . ' the `' . $condition . '` condition is not a callable!');
        }

        return $this->_options[$condition]($event);
    }
543881
protected function expandAggregateInspectionData(InspectionInterface $inspection)
    {
        if ($inspection instanceof AggregateInspection) {
            return array_map(
                function (InspectionInterface $inspection) {
                    return [
                        static::PARAM_INSPECTION       => $inspection,
                        static::PARAM_INSPECTION_DATA  => $this->expandAggregateInspectionData($inspection),
                        static::PARAM_INSPECTION_CLASS => get_class($inspection),
                    ];
                },
                $inspection->getInspectionData()
            );
        }

        return $inspection->getInspectionData();
    }
141083
public function it_fails_if_a_collection_doesnt_have_a_matching_event() {
        $events = DomainEvents::make([]);

        expect($events)->shouldNotContainEvent(
            new EventStub(3, 2, 1)
        );

        $events = DomainEvents::make([
            new EventStub(3, 2, 1),
        ]);

        expect($events)->shouldNotContainEvent(
            new EventStub(4, 4, 4)
        );
    }
1071579
private function printFooterOnAfterEvent(Formatter $formatter, ScenarioLikeTested $event, $eventName)
    {
        if ($this->afterEventName !== $eventName || !$event instanceof AfterTested) {
            return;
        }

        if ($this->setupPrinter) {
            $this->setupPrinter->printTeardown($formatter, $event->getTeardown());
        }

        $this->scenarioPrinter->printFooter($formatter, $event->getTestResult());
    }
859212
public function onCreatePropertyCondition(CreatePropertyConditionEvent $event)
    {
        if (!$this->scopeMatcher->currentScopeIsFrontend()) {
            return;
        }

        $meta = $event->getData();

        if ('conditionpropertyvalueis' !== $meta['type']) {
            return;
        }

        $metaModel = $event->getMetaModel();
        $attribute = $metaModel->getAttributeById($meta['attr_id']);
        if (!($attribute instanceof Checkbox)) {
            return;
        }

        if ((bool) $meta['value']) {
            $event->setInstance(new PropertyTrueCondition($attribute->getColName()));
            return;
        }
        $event->setInstance(new PropertyFalseCondition($attribute->getColName()));
    }
884413
private function visitQuery(Collection $collection, VisitorInterface $subVisitor): ?array
    {
        if (!$collection->hasQuery()) {
            return null;
        }

        return $subVisitor->visit($collection->getQuery());
    }
138853
private CmsGalleryTreeEntry lookForParent(CmsGalleryTreeEntry possibleParent, String targetPath) {

        if (targetPath.startsWith(possibleParent.getPath())) {
            return possibleParent;
        }
        if (possibleParent.getParent() != null) {
            return lookForParent(possibleParent.getParent(), targetPath);
        }
        return null;
    }
1195969
public static function checkOrSet($option, $array, $possibleValues)
    {
        if (!isset($array[$option])) {
            $array[$option] = $possibleValues[0];

            return $array;
        }

        $ignoredOptions = ['team', 'foreignKeyName'];

        if (!in_array($option, $ignoredOptions) && !in_array($array[$option], $possibleValues, true)) {
            throw new InvalidArgumentException();
        }

        return $array;
    }
268261
@Override
    public <T extends Inspection> T getInspectionForHitNumber(int hitNumber) {
        return (T) getInspectionsForHitNumber(hitNumber).get(0);
    }
1368920
public function beforeFind(Event $event, Query $query, ArrayObject $options, $primary) {
		$query->formatResults(function (CollectionInterface $results) {
			return $results->map(function ($row) {
				if (!$row instanceOf Entity) {
					return $row;
				}

				$this->decodeItems($row);
				return $row;
			});
		});
	}
1263988
public function getChilds($idParent, $ordering = 'ASC')
    {
        if ($childs = $this->qb
            ->select($this->table . '.*')
            ->from($this->table)
            ->from($this->table . ' AS node')
            ->whereBetween('node.record_left', [$this->table . '.record_left', $this->table . '.record_right'])
            ->where([
                $this->table . '.id' => $id,
            ])
            ->get()) {
            if ($childs->count()) {
                return $childs;
            }
        }

        return false;
    }
1156382
private function findErrorClassUsingParentException($rawException)
    {
        foreach ($this->exceptionMap as $rawExceptionClass => $errorClass) {
            if ($rawException instanceof $rawExceptionClass) {
                return $errorClass;
            }
        }

        return null;
    }
1113583
public boolean select(Viewer viewer, Object parentElement, Object element) {
		
		if(hasFilter(FILTER_FIELDS) && isField(element) )
		{
			return false;
		}
		
		if(hasFilter(FILTER_NONPUBLIC) && isNonPublic(element)){
			return false;
		}
		
		if(hasFilter(FILTER_LOCALTYPES) && isLocalType(element)){
			return false;
		}
		
		if(hasFilter(FILTER_STATIC) && isStatic(element)){
			return false;
		}
		
//		try {
//			if (element instanceof IMember) {
//				
//
//				if (hasFilter(FILTER_FIELDS) && memberType == IJavaElement.FIELD) {
//					return false;
//				}
//
//				if (hasFilter(FILTER_LOCALTYPES) && memberType == IJavaElement.TYPE && isLocalType((IType) member)) {
//					return false;
//				}
//
//				if (member.getElementName().startsWith("<")) { // filter out <clinit> //$NON-NLS-1$
//					return false;
//				}
//				int flags= member.getFlags();
//				if (hasFilter(FILTER_STATIC) && (Flags.isStatic(flags) || isFieldInInterfaceOrAnnotation(member)) && memberType != IJavaElement.TYPE) {
//					return false;
//				}
//				if (hasFilter(FILTER_NONPUBLIC) && !Flags.isPublic(flags) && !isMemberInInterfaceOrAnnotation(member) && !isTopLevelType(member) && !isEnumConstant(member)) {
//					return false;
//				}
//			}
//		} catch (JavaModelException e) {
//			// ignore
//		}
		return true;
	}
760884
private function findSibling(Collection $elements, SortableInterface $current, $next = false)
    {
        if ($next) {
            $sibling = $elements->filter(function (SortableInterface $s) use ($current) {
                return $s->getPosition() > $current->getPosition();
            })->first();
        } else {
            $sibling = $elements->filter(function (SortableInterface $s) use ($current) {
                return $s->getPosition() < $current->getPosition();
            })->last();
        }

        return $sibling ?: null;
    }
1215202
private function parentIsFromProvider($conjunction, $parentProviderName)
    {
        if (!empty($this->expression)) {
            $this->expression[] = $conjunction;
        }

        $index              = \count($this->variables);
        $this->expression[] = \sprintf(self::PARENT_IS_FROM_PROVIDER_EXPRESSION, $index);
        $this->variables[]  = $parentProviderName;
        $this->compiled     = null;

        return $this;
    }