From 3f45db7aa4f5ff402e28842ae6efdef5044333ae Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Gertz?= Date: Sun, 8 Aug 2021 14:33:41 +0200 Subject: [PATCH] New tree layout Add strict types Improve documentation Cleanup --- Filter/JPackFilter.php | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/Filter/JPackFilter.php b/Filter/JPackFilter.php index ca4555d..6715596 100644 --- a/Filter/JPackFilter.php +++ b/Filter/JPackFilter.php @@ -1,10 +1,22 @@ - + * + * 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\Source; +/** + * {@inheritdoc} + */ class JPackFilter implements FilterInterface { //Default bin private $bin; @@ -18,9 +30,12 @@ class JPackFilter implements FilterInterface { //Twig template line private $line; - //Configure the object - //XXX: can be clean, shrink, obfuscate or best - public function __construct($fileName, $line, $bin = 'jpack', $compress = 'best') { + /** + * Setup jpack filter + * + * @xxx compress can be clean, shrink, obfuscate or best + */ + public function __construct(Source $fileName, int $line, string $bin = 'jpack', string $compress = 'best') { //Set fileName $this->fileName = $fileName; @@ -53,7 +68,10 @@ class JPackFilter implements FilterInterface { } } - public function process($content) { + /** + * {@inheritdoc} + */ + public function process(string $content): string { //Create descriptors $descriptorSpec = array( 0 => array('pipe', 'r'), @@ -64,7 +82,7 @@ class JPackFilter implements FilterInterface { //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); -- 2.41.0