]> Raphaël G. Git Repositories - packbundle/commitdiff
New tree layout
authorRaphaël Gertz <git@rapsys.eu>
Sun, 8 Aug 2021 12:34:37 +0000 (14:34 +0200)
committerRaphaël Gertz <git@rapsys.eu>
Sun, 8 Aug 2021 12:34:37 +0000 (14:34 +0200)
Add strict types
Improve documentation
Cleanup

Filter/CPackFilter.php

index ca38c3be37033ade64bffe8fb8b0b29e69cf5ddf..853e94acba213933eea52ae3c3bdc1c25b01ce7c 100644 (file)
@@ -1,10 +1,22 @@
-<?php
+<?php declare(strict_types=1);
 
 
-namespace Rapsys\PackBundle\Twig\Filter;
+/*
+ * This file is part of the Rapsys PackBundle package.
+ *
+ * (c) Raphaël Gertz <symfony@rapsys.eu>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Rapsys\PackBundle\Filter;
 
 
-use Rapsys\PackBundle\Twig\Filter\FilterInterface;
 use Twig\Error\Error;
 use Twig\Error\Error;
+use Twig\Source;
 
 
+/**
+ * {@inheritdoc}
+ */
 class CPackFilter implements FilterInterface {
        //Default bin
        private $bin;
 class CPackFilter implements FilterInterface {
        //Default bin
        private $bin;
@@ -18,9 +30,12 @@ class CPackFilter implements FilterInterface {
        //Twig template line
        private $line;
 
        //Twig template line
        private $line;
 
-       //Configure the object
-       //XXX: compress can be minify or pretty
-       public function __construct($fileName, $line, $bin = 'cpack', $compress = 'minify') {
+       /**
+        * Setup cpack filter
+        *
+        * @xxx compress can be minify or pretty
+        */
+       public function __construct(Source $fileName, int $line, string $bin = 'cpack', string $compress = 'minify') {
                //Set fileName
                $this->fileName = $fileName;
 
                //Set fileName
                $this->fileName = $fileName;
 
@@ -47,7 +62,10 @@ class CPackFilter implements FilterInterface {
                }
        }
 
                }
        }
 
-       public function process($content) {
+       /**
+        * {@inheritdoc}
+        */
+       public function process(string $content): string {
                //Create descriptors
                $descriptorSpec = array(
                        0 => array('pipe', 'r'),
                //Create descriptors
                $descriptorSpec = array(
                        0 => array('pipe', 'r'),
@@ -58,7 +76,7 @@ class CPackFilter implements FilterInterface {
                //Open process
                if (is_resource($proc = proc_open($this->bin, $descriptorSpec, $pipes))) {
                        //Set stderr as non blocking
                //Open process
                if (is_resource($proc = proc_open($this->bin, $descriptorSpec, $pipes))) {
                        //Set stderr as non blocking
-                       stream_set_blocking($pipes[2], 0);
+                       stream_set_blocking($pipes[2], false);
 
                        //Send content to stdin
                        fwrite($pipes[0], $content);
 
                        //Send content to stdin
                        fwrite($pipes[0], $content);