Transient filter.

@since 160530 Update utils.

@param \StdClass|mixed $report Report details.

@return \StdClass|mixed Report details.
760498
public function onGetSiteTransientUpdatePlugins($report)
    {
        if ($this->App->Config->§specs['§in_wp']) {
            return $report; // Not applicable.
        } // i.e., Available inside WordPress already.
        // i.e., The project is hosted by WordPress.org.

        if ($this->App->Config->§specs['§type'] !== 'plugin') {
            return $report; // Not applicable.
        } // i.e., Applies only to plugin instances.

        if (!is_object($report)) { // e.g., Does not exist yet?
            $report = (object) []; // Force object instance.
        }
        if (!isset($report->response) || !is_array($report->response)) {
            $report->response = []; // Force an array value.
        }
        $plugin_url      = $this->s::brandUrl('/changelog');
        $plugin_slug     = $this->App->Config->©brand['§product_slug'];
        $plugin_basename = plugin_basename($this->App->Config->§specs['§file']);
        $latest_version  = $this->latestVersion(); // Latest available.

        if (version_compare($latest_version, $this->App::VERSION, '>')) {
            if (($latest_package = $this->latestPackage())) {
                $report->response[$plugin_basename] = (object) [
                    'id'          => -1,
                    'slug'        => $plugin_slug,
                    'plugin'      => $plugin_basename,
                    'url'         => $plugin_url,
                    'new_version' => $latest_version,
                    'package'     => $latest_package,
                    'tested'      => WP_VERSION,
                ];
            } // ↑ If we can acquire latest package also.
        }
        return $report; // With possible update for this app.
    }
178396
public function filter($value)
    {
        if (is_int($value)) {
            return (string) $value;
        }
        if (! (is_float($value) || is_string($value))) {
            return $value;
        }
        $value = (string) $value;

        if (!StringUtils::hasPcreUnicodeSupport()) {
            // POSIX named classes are not supported, use alternative 0-9 match
            $pattern = '/[^0-9]/';
        } elseif (extension_loaded('mbstring')) {
            // Filter for the value with mbstring
            $pattern = '/[^[:digit:]]/';
        } else {
            // Filter for the value without mbstring
            $pattern = '/[\p{^N}]/';
        }

        return preg_replace($pattern, '', $value);
    }
620769
public function of($reportType)
    {
        $this->validateReportType($reportType);

        $this->reportDefinitionFields = $this->reportDefinitionService->getReportFields($reportType);

        $this->obj = $this->createObj($this->reportDefinitionFields);

        return $this;
    }
435635
protected function addressbookQueryReport($report)
    {
        $depth = $this->server->getHTTPDepth(0);

        if (0 == $depth) {
            $candidateNodes = [
                $this->server->tree->getNodeForPath($this->server->getRequestUri()),
            ];
            if (!$candidateNodes[0] instanceof ICard) {
                throw new ReportNotSupported('The addressbook-query report is not supported on this url with Depth: 0');
            }
        } else {
            $candidateNodes = $this->server->tree->getChildren($this->server->getRequestUri());
        }

        $contentType = $report->contentType;
        if ($report->version) {
            $contentType .= '; version='.$report->version;
        }

        $vcardType = $this->negotiateVCard(
            $contentType
        );

        $validNodes = [];
        foreach ($candidateNodes as $node) {
            if (!$node instanceof ICard) {
                continue;
            }

            $blob = $node->get();
            if (is_resource($blob)) {
                $blob = stream_get_contents($blob);
            }

            if (!$this->validateFilters($blob, $report->filters, $report->test)) {
                continue;
            }

            $validNodes[] = $node;

            if ($report->limit && $report->limit <= count($validNodes)) {
                // We hit the maximum number of items, we can stop now.
                break;
            }
        }

        $result = [];
        foreach ($validNodes as $validNode) {
            if (0 == $depth) {
                $href = $this->server->getRequestUri();
            } else {
                $href = $this->server->getRequestUri().'/'.$validNode->getName();
            }

            list($props) = $this->server->getPropertiesForPath($href, $report->properties, 0);

            if (isset($props[200]['{'.self::NS_CARDDAV.'}address-data'])) {
                $props[200]['{'.self::NS_CARDDAV.'}address-data'] = $this->convertVCard(
                    $props[200]['{'.self::NS_CARDDAV.'}address-data'],
                    $vcardType,
                    $report->addressDataProperties
                );
            }
            $result[] = $props;
        }

        $prefer = $this->server->getHTTPPrefer();

        $this->server->httpResponse->setStatus(207);
        $this->server->httpResponse->setHeader('Content-Type', 'application/xml; charset=utf-8');
        $this->server->httpResponse->setHeader('Vary', 'Brief,Prefer');
        $this->server->httpResponse->setBody($this->server->generateMultiStatus($result, 'minimal' === $prefer['return']));
    }
1095828
public function filter($value)
    {
        $chain = clone $this->filters;

        $valueFiltered = $value;
        foreach ($chain as $filter) {
            $valueFiltered = call_user_func($filter, $valueFiltered);
        }

        return $valueFiltered;
    }
494455
private function createObj($reportDefinitionFields)
    {
        $obj = new \stdClass();

        foreach ($reportDefinitionFields as $reportDefinitionField) {
            $name = $reportDefinitionField->getFieldName();
            $obj->$name = [
                'type' => $reportDefinitionField->getFieldType(),
                'values' => ($reportDefinitionField->getEnumValues() !== null) ? $reportDefinitionField->getEnumValues() : null,
            ];

        }

        return $obj;
    }
341309
private static function filterDocument($document)
    {
        if ($document instanceof Stream || $document instanceof SplFileObject) {
            return $document;
        }

        throw new TypeError(sprintf(
            '%s::parse expects parameter 1 to be a %s or a SplFileObject object, %s given',
            self::class,
            Stream::class,
            is_object($document) ? get_class($document) : gettype($document)
        ));
    }
41211
public function filter($value) {
        
        //Validate
        if(!is_numeric($value) && $this->options["validate"]) {
            return Filter::ERR_INVALID;
        }
        $value = (double)$value;
        
        // Validate Values to Min/Max/Decimals
        if( (!$this->options["adjust"] && $value < $this->options["min"]) ||
            (!$this->options["adjust"] && $value > $this->options["max"]) ) {
            return Filter::ERR_INVALID;
        }

        //Validate decimal count
        if($this->options["decimals"] !== false && $this->options["round"] === false) {
            $decimalcount = strpos($value,".") !== false ? strlen($value) - strpos($value,".") - 1 : 0;
            if($decimalcount != $this->options["decimals"])
                return Filter::ERR_INVALID;
        }

        // Adjust values to Min/Max
        if($this->options["adjust"] && $this->options["min"] !== false) {
            $value = max($this->options["min"], $value);
        }
        if($this->options["adjust"] && $this->options["max"] !== false) {
            $value = min($this->options["max"], $value);
        }
        
        //Round/Floor if needed
        if($this->options["decimals"] !== false && $this->options["round"] !== false) {
            switch($this->options["round"]) {
                case self::SI_NUMBER_CEIL:    $value = ceil($value * pow(10,$this->options["decimals"])) / pow(10,$this->options["decimals"]);    break;
                case self::SI_NUMBER_FLOOR:   $value = self::floor($value, $this->options["decimals"]);    break;
                case self::SI_NUMBER_ROUND:   $value = round($value, $this->options["decimals"]);    break;
            }
        }
        
        return $value;        
    }
629261
public function filter($value)
    {
	    if (is_string($value))
	        return new DateTime('@'.strtotime($value));
	    if ($value instanceof DateTime)
		    return $value;
	    if (is_int($value))
		    return new DateTime('@'.$value);
	    return null;
    }
964725
protected void selectFormDefaultPortlet(final F report) {
        final Set<AggregatedPortletMapping> portlets = this.getPortlets();
        if (!portlets.isEmpty()) {
            report.getPortlets().add(portlets.iterator().next().getFname());
        }
    }
1138835
public function filter($value)
    {
        if (null === $value) {
            return null;
        }
        $this->checkValueIsValidOrThrowException($value);
        $matcher = key($value);
        $this->validateMatcherOrThrowException($matcher);
        $this->validateValueOrThrowException($value[$matcher]);

        return new Condition($matcher, $value[$matcher]);
    }
210780
protected function processReportParameters (Report $report)
    {
        // NOTE: Remove parameters which have NULL values, etc
        $globalParameters = $this->resetEmptyParameters();
        $reportParameters = $report->resetEmptyParameters();

        // NOTE: Report parameters will over-write the global Starter parameters
        $mergedParameters = array_merge($globalParameters, $reportParameters);

        $parameters = '';
        if (!empty($mergedParameters)) {
            $parameters = '-P ';
            foreach ($mergedParameters as $name => $value) {
                $value = is_numeric($value) ? $value : "'$value'";
                $parameters .= "$name=$value ";
            }
        }

        return $parameters;
    }
212942
public function writeReport(Report $report): void
    {
        $count = 0;

        $this->output->writeln('');
        $this->output->writeln('<comment>CHECKSTYLE REPORT</comment>');

        $styleMap = [
            Issue::SEVERITY_ERROR   => 'error',
            Issue::SEVERITY_WARNING => 'comment',
            Issue::SEVERITY_INFO    => 'info',
        ];

        foreach ($report->getFiles() as $file) {
            $this->output->writeln("=> <comment>{$file->getFilename()}</comment>.");
            foreach ($file->getIssues() as $issue) {
                $count++;

                $style = $styleMap[$issue->getSeverity()];

                $this->output->writeln(
                    sprintf(
                        '<comment>%4d <%s>%s</%s></comment>',
                        $issue->getLine() ?? 0,
                        $style,
                        $issue->getMessage(),
                        $style
                    )
                );
            }
        }

        $summary = [];

        foreach ($styleMap as $severity => $style) {
            $severityCount = $report->countIssuesBySeverity($severity);
            if ($severityCount > 0) {
                $summary[] = "<comment>$severityCount</comment> {$severity}s";
            }
        }

        $this->output->writeln("");
        $this->output->writeln('<comment>SUMMARY</comment>');
        $this->output->write("<info><comment>$count</comment> issues in total.</info>");

        if ($count > 0) {
            $this->output->writeln(" (" . implode(', ', $summary) . ")");
        }
    }
205961
public function renderReportOutput(\JasperClient\Client\Report $report) {
        //Check that the report is in html format
        if ('html' !== $report->getFormat()) {
            return '';
        }

        //Render the report viewer twig
        return $this->container->get('templating')->render(
            'MesdJasperReportBundle:Report:report.html.twig', array(
                    'report' => $report
                )
            );
    }
1089481
def parse_report(self, current_type, report_data):
        """"""

        fmt = self.known_formats[current_type]
        return fmt(report_data)
376882
public function renderReport(Report $report)
    {
        $this->output->writeln('');

        $groupByFile = [];
        /** @var RuleViolation $violation */
        foreach ($report->getRuleViolations() as $violation) {
            $groupByFile[$violation->getFileName()][] = $violation;
        }

        /** @var ProcessingError $error */
        foreach ($report->getErrors() as $error) {
            $groupByFile[$error->getFile()][] = $error;
        }
        foreach ($groupByFile as $file => $problems) {
            $violationCount = 0;
            $errorCount     = 0;

            $table = new Table($this->output);
            $table->setStyle('borderless');
            foreach ($problems as $problem) {
                if ($problem instanceof RuleViolation) {
                    $table->addRow([$problem->getBeginLine(), '<comment>VIOLATION</comment>', $problem->getDescription()]);
                    ++$violationCount;
                }
                if ($problem instanceof ProcessingError) {
                    $table->addRow(['-', '<error>ERROR</error>', $problem->getMessage()]);
                    ++$errorCount;
                }
            }

            $this->output->writeln([
                sprintf('<fg=white;options=bold>FILE: %s</>', str_replace($this->basePath.'/', '', $file)),
                sprintf('<fg=white;options=bold>FOUND %d ERRORS AND %d VIOLATIONS</>', $errorCount, $violationCount),
            ]);
            $table->render();
            $this->output->writeln('');
        }
    }
677029
public void setReport(Report report) {
		this.report = report;
		if (this.report.getQuery() != null) {
			this.report.getQuery().setDialect(dialect);
		}
	}