@param string|string[]|null $filterSetNames Imagine filter set names
@param int                  $width          Width
@param int                  $height         Height
@param string               $entityClass    Image entity class

@return string|null
356201
public function describeSize($filterSetNames = null, $width = 0, $height = 0, $entityClass = null)
    {
        if (null === $filterSetNames) {
            $filterSetNames = !empty($entityClass) ? $this->getEntityFilterSets($entityClass) : [];
        }
        if (!is_array($filterSetNames)) {
            $filterSetNames = (array)$filterSetNames;
        }

        list($descriptionWidth, $descriptionHeight) = $this->getMaxSize($filterSetNames);

        if ($width > 0) {
            $descriptionWidth = $width;
        }
        if ($height > 0) {
            $descriptionHeight = $height;
        }
        if ($descriptionWidth > 0 && $descriptionHeight > 0) {
            return $this->translator->trans('size.description', [
                '%width%'  => $descriptionWidth,
                '%height%' => $descriptionHeight,
            ], 'darvin_image');
        }

        return null;
    }
591145
private FilterList getExtPropertyFilters(EntityMetadata m, FilterList filterList)
    {
        Filter filter = getFilter(m.getTableName());
        if (filter != null)
        {
            if (filterList == null)
            {
                filterList = new FilterList();
            }
            filterList.addFilter(filter);
        }
        return filterList;
    }
632975
protected synchronized void filter(ValueSet filterValueSet) {
        boolean explicitBufferEmpty = this.explicitBuffer.isEmpty();
        boolean scanBufferEmpty = this.scanBuffer.isEmpty();
        if (filterValueSet != null && !filterValueSet.isEmpty() && (!explicitBufferEmpty || !scanBufferEmpty)) {
            Iterator it = filterValueSet.iterator();
            while (it.hasNext()) {
                Object o = it.next();
                if (!explicitBufferEmpty && this.explicitBuffer.containsKey(o)) {
                    it.remove();
                } else if (!scanBufferEmpty && this.scanBuffer.contains(o)) {
                    it.remove();
                }
            }
        }
    }
608678
@SuppressWarnings("unchecked")
    private void loadFilters(Map<String, FilterConfiguration> filters, Environment environment) throws ClassNotFoundException {
        if (filters != null) {
            for (Map.Entry<String, FilterConfiguration> filterEntry : filters.entrySet()) {
                FilterConfiguration filter = filterEntry.getValue();

                // Create filter holder
                FilterHolder filterHolder = new FilterHolder((Class<? extends Filter>) Class.forName(filter.getClazz()));

                // Set name of filter
                filterHolder.setName(filterEntry.getKey());
                
                // Set params
                if (filter.getParam() != null) {
                    for (Map.Entry<String, String> entry : filter.getParam().entrySet()) {
                        filterHolder.setInitParameter(entry.getKey(), entry.getValue());
                    }
                }

                // Add filter
                environment.getApplicationContext().addFilter(filterHolder, filter.getUrl(), EnumSet.of(DispatcherType.REQUEST));
            }
        }
    }
1279257
public static String updateSetColumns(Class<?> entityClass, String entityName, boolean notNull, boolean notEmpty) {
        StringBuilder sql = new StringBuilder();
        sql.append("<set>");
        //获取全部列
        Set<EntityColumn> columnSet = EntityHelper.getColumns(entityClass);
        //对乐观锁的支持
        EntityColumn versionColumn = null;
        // 逻辑删除列
        EntityColumn logicDeleteColumn = null;
        //当某个列有主键策略时，不需要考虑他的属性是否为空，因为如果为空，一定会根据主键策略给他生成一个值
        for (EntityColumn column : columnSet) {
            if (column.getEntityField().isAnnotationPresent(Version.class)) {
                if (versionColumn != null) {
                    throw new VersionException(entityClass.getCanonicalName() + " 中包含多个带有 @Version 注解的字段，一个类中只能存在一个带有 @Version 注解的字段!");
                }
                versionColumn = column;
            }
            if (column.getEntityField().isAnnotationPresent(LogicDelete.class)) {
                if (logicDeleteColumn != null) {
                    throw new LogicDeleteException(entityClass.getCanonicalName() + " 中包含多个带有 @LogicDelete 注解的字段，一个类中只能存在一个带有 @LogicDelete 注解的字段!");
                }
                logicDeleteColumn = column;
            }
            if (!column.isId() && column.isUpdatable()) {
                if (column == versionColumn) {
                    Version version = versionColumn.getEntityField().getAnnotation(Version.class);
                    String versionClass = version.nextVersion().getCanonicalName();
                    sql.append("<bind name=\"").append(column.getProperty()).append("Version\" value=\"");
                    //version = ${@tk.mybatis.mapper.version@nextVersionClass("versionClass", version)}
                    sql.append("@tk.mybatis.mapper.version.VersionUtil@nextVersion(")
                        .append("@").append(versionClass).append("@class, ");
                    if (StringUtil.isNotEmpty(entityName)) {
                        sql.append(entityName).append(".");
                    }
                    sql.append(column.getProperty()).append(")\"/>");
                    sql.append(column.getColumn()).append(" = #{").append(column.getProperty()).append("Version},");
                } else if (column == logicDeleteColumn) {
                    sql.append(logicDeleteColumnEqualsValue(column, false)).append(",");
                } else if (notNull) {
                    sql.append(SqlHelper.getIfNotNull(entityName, column, column.getColumnEqualsHolder(entityName) + ",", notEmpty));
                } else {
                    sql.append(column.getColumnEqualsHolder(entityName) + ",");
                }
            }
        }
        sql.append("</set>");
        return sql.toString();
    }
196279
public static String updateSetColumnsIgnoreVersion(Class<?> entityClass, String entityName, boolean notNull, boolean notEmpty) {
        StringBuilder sql = new StringBuilder();
        sql.append("<set>");
        //获取全部列
        Set<EntityColumn> columnSet = EntityHelper.getColumns(entityClass);
        // 逻辑删除列
        EntityColumn logicDeleteColumn = null;
        //当某个列有主键策略时，不需要考虑他的属性是否为空，因为如果为空，一定会根据主键策略给他生成一个值
        for (EntityColumn column : columnSet) {
            if (column.getEntityField().isAnnotationPresent(LogicDelete.class)) {
                if (logicDeleteColumn != null) {
                    throw new LogicDeleteException(entityClass.getCanonicalName() + " 中包含多个带有 @LogicDelete 注解的字段，一个类中只能存在一个带有 @LogicDelete 注解的字段!");
                }
                logicDeleteColumn = column;
            }
            if (!column.isId() && column.isUpdatable()) {
                if(column.getEntityField().isAnnotationPresent(Version.class)){
                    //ignore
                } else if (column == logicDeleteColumn) {
                    sql.append(logicDeleteColumnEqualsValue(column, false)).append(",");
                } else if (notNull) {
                    sql.append(SqlHelper.getIfNotNull(entityName, column, column.getColumnEqualsHolder(entityName) + ",", notEmpty));
                } else {
                    sql.append(column.getColumnEqualsHolder(entityName) + ",");
                }
            }
        }
        sql.append("</set>");
        return sql.toString();
    }
1371452
protected function getQueryFilter($params)
    {
        if (empty($params['FilterClass'])) {
            return null;
        }
        $filterClass = $params['FilterClass'];
        if (!is_subclass_of($filterClass, CMSSiteTreeFilter::class)) {
            throw new InvalidArgumentException("Invalid filter class passed: {$filterClass}");
        }
        return $filterClass::create($params);
    }
906829
public function findFiltered(array $filters)
    {
        /* @var Unit[] $units */
        if (!isset($filters['domain']) || is_null($filters['domain']) || empty($filters['domain'])) {
            $units = $this->findAll();
        } else {
            $units = $this->findByDomain($filters['domain']);
        }

        foreach ($units as $k => $u) {
            $filterEmpty = isset($filters['empty']) && $filters['empty'];
            $filterKey = isset($filters['key']) && strlen(trim($filters['key'])) > 0 ? trim($filters['key']) : null;
            $filterValue = isset($filters['value']) && strlen(trim($filters['value'])) > 0 ? trim($filters['value']) : null;
            if (empty($filters['locale'])) {
                $filters['locale'] = $this->getLocaleList();
            }

            if ($filterKey && strpos($u->getKey(), $filterKey) === false) {
                unset($units[$k]);
                continue;
            }

            $nonEmptyCount = 0;
            $valueCount = 0;
            foreach ($u->getTranslations() as $t) {
                // Remove translations not required
                if (!in_array($t->getLocale(), $filters['locale'])) {
                    unset($u[$t->getLocale()]);
                    continue;
                }

                // Count empty or match values
                $value = $t->getValue();
                if ($value !== null && strlen($value) > 0) {
                    ++$nonEmptyCount;
                }
                if ($filterValue && strpos($value, $filterValue) !== false) {
                    ++$valueCount;
                }
            }

            // For empty filtering, remove unit with non empty translations
            if ($filterEmpty && $nonEmptyCount >= count($filters['locale'])) {
                unset($units[$k]);
                continue;
            }

            // For value filtering, remove unit when there is no match
            if ($filterValue && $valueCount == 0) {
                unset($units[$k]);
                continue;
            }
        }

        return $units;
    }
545211
public function scan($classes, $namespaceTablenames=true, $morphClassAbbreviations=true)
    {
        $this->namespaceTablenames = $namespaceTablenames;
        $this->morphClassAbbreviations = $morphClassAbbreviations;

        $metadata = [];

        foreach ($classes as $class) {
            $entityMetadata = $this->parseClass($class);

            if ($entityMetadata) {
                $metadata[$class] = $entityMetadata;
            }
        }

        // validate pivot tables
        $this->validator->validatePivotTables($metadata);

        // generate morphable classes
        $this->generateMorphableClasses($metadata);

        return $metadata;
    }
199979
public function getResourceSet(
        QueryType $queryType,
        ResourceSet $resourceSet,
        $filterInfo = null,
        $orderBy = null,
        $top = null,
        $skip = null
    ) {
        $result = new QueryResult();

        $entityClassName = $resourceSet->getResourceType()->getInstanceType()->name;
        $entityName = $this->getEntityName($entityClassName);
        $tableName = $this->getTableName($entityName);

        $option = null;
        if ($queryType == QueryType::ENTITIES_WITH_COUNT()){
            //tell mysql we want to know the count prior to the LIMIT 
            //$option = 'SQL_CALC_FOUND_ROWS';
        }

        $where = $filterInfo ? ' WHERE ' . $filterInfo->getExpressionAsString() : '';

        $order = $orderBy ? ' ORDER BY ' . $this->getOrderByExpressionAsString($orderBy) : '';

        $sqlCount = 'SELECT COUNT(*) FROM ' . $tableName . $where;
        if ($queryType == QueryType::ENTITIES() || $queryType == QueryType::ENTITIES_WITH_COUNT()) {
            $sql = 'SELECT ' . $option . ' * FROM ' . $tableName . $where . $order
                    . ($top ? ' LIMIT ' . $top : '') . ($skip ? ' OFFSET ' . $skip : '');
            $data = $this->queryAll($sql);
            
            if ($queryType == QueryType::ENTITIES_WITH_COUNT()){
                //get those found rows
                //$result->count = $this->queryScalar('SELECT FOUND_ROWS()');
                $result->count = $this->queryScalar($sqlCount);
            }

            $result->results = array_map($entityClassName . '::fromRecord', $data);
        }
        elseif ($queryType == QueryType::COUNT()) {
            $result->count = QueryResult::adjustCountForPaging(
                $this->queryScalar($sqlCount), $top, $skip);
        }

        return $result;
    }
320068
public function getColumns($table, $filters = null)
    {
        //Argument 1 must be a string
        Argument::i()->test(1, 'string');
        
        $query = $this->utility();
        
        if (is_array($filters)) {
            foreach ($filters as $i => $filter) {
                //array('post_id=%s AND post_title IN %s', 123, array('asd'));
                $format = array_shift($filter);
                $filter = $this->bind($filter);
                $filters[$i] = vsprintf($format, $filter);
            }
        }
        
        $query->showColumns($table, $filters);
        return $this->query($query, $this->getBinds());
    }
1170940
function filter(callable $cb) {
		$rowset = clone $this;
		$rowset->index = 0;
		$rowset->rows = array_filter($this->rows, $cb);
		return $rowset;
	}
1058131
public function filter($filter)
    {
        preg_match_all("/(#\w+)/", $filter, $entityNames);
        preg_match_all("/(:\w+)/", $filter, $positions);

        $entityName = is_array($entityNames[0]) && isset($entityNames[0][0]) ? ltrim($entityNames[0][0], '#') : null;
        $position   = is_array($positions[0]) && isset($positions[0][0]) ? $positions[0][0] : null;

        $i = 0;

        $filtered = [];

        foreach ($this->entities as $name => $entity) {
            if ($i === 0 && ($entityName === $name || $entityName === null) && ($position === ':first' || $position === ':highest' || $position === null)) {
                $filtered[] = $entity;
            }

            if ($position === ':any' && ($entityName === $name || $entityName === null)) {
                $filtered[] = $entity;
            }

            if ($i + 1 === $this->entities->count() && ($entityName === $name || $entityName === null) && ($position === ':last' || $position === ':lowest')) {
                $filtered[] = $entity;
            }

            $i++;
        }

        $this->filtered = $filtered;

        return $this;
    }
475616
protected function applyFilters(&$propertyData, array $filterClasses)
    {
        /** @var FilterInterface $filter */
        foreach ($filterClasses as $filterClass => $filterClassArguments) {
            $filter = new $filterClass(...$filterClassArguments);
            $propertyData = $filter->apply($propertyData);
        }
        
        return $propertyData;
    }
1024342
protected function find_image_size_from_width( $sizes, $width ) {
		foreach ( $sizes as $name => $size ) {
			if ( $width === $size['width'] ) {
				return $name;
			}
		}
		return null;
	}
88978
public function filterNamespace( $namespaceName) {
        $FilteredClasses = [];
        foreach( $this->loadedClasses as $loadedClass){
            if( 0 == substr_compare( $loadedClass, $namespaceName, 0, strlen( $namespaceName))){
                $FilteredClasses[] = $loadedClass;
            }
        }
        $this->loadedClasses = $FilteredClasses;
    }
962157
public void setFilterOr( final Properties nameValuePairs )
    {
        if ( nameValuePairs == null )
        {
            throw new NullPointerException();
        }

        final Map<String, String> newMap = new HashMap<>();
        for ( Enumeration enumer = nameValuePairs.propertyNames(); enumer.hasMoreElements(); )
        {
            final String name = ( String ) enumer.nextElement();
            newMap.put( name, nameValuePairs.getProperty( name ) );
        }
        setFilterOr( newMap );
    }