Skip to content

Commit 946b9b7

Browse files
authored
Merge pull request #6 from jobcloud/feat/FIAP-197/fix-deprecations
feat(FIAP-197): fix deprecations
2 parents 3182975 + cd8fbe4 commit 946b9b7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+376
-295
lines changed

composer.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,19 @@
1414
"email": "peter.pl7@gmail.com"
1515
}
1616
],
17+
"repositories": [
18+
{"type": "vcs", "no-api": true, "url": "git@github.com:jobcloud/zendpdf.git"}
19+
],
1720
"require": {
18-
"zendframework/zendpdf": "~2.0.0"
21+
"ext-mbstring": "*",
22+
"jobcloud/zendpdf": "^2.0.3"
1923
},
2024
"require-dev": {
2125
"imagine/imagine": ">=0.2.0,<0.6.0",
22-
"phpunit/phpunit": "^9.6.7"
26+
"phpunit/phpunit": "^8.5.33"
2327
},
28+
"prefer-stable": true,
29+
"minimum-stability": "dev",
2430
"suggest": {
2531
"imagine/imagine": "If you want to use image generating (required version: >=v0.2.6)"
2632
},

docker/.env

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
COMPOSE_PROJECT_NAME=jobcloud-phppdf
2+
XDEBUG_REMOTE_HOST=localhost
3+
#XDEBUG_REMOTE_HOST=docker.for.mac.localhost

docker/Dockerfile

Lines changed: 0 additions & 47 deletions
This file was deleted.

docker/docker-compose.dev.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
version: '3.9'
2+
services:
3+
php:
4+
container_name: jobcloud-phppdf-php
5+
hostname: jobcloud-phppdf-php
6+
build:
7+
dockerfile: php/Dockerfile
8+
context: ./
9+
args:
10+
USER_ID: ${USER_ID}
11+
ports:
12+
- '8080:80'
13+
tty: true
14+
volumes:
15+
- ../:/var/www/html
16+
- ~/.bash_aliases:/home/www-data/.bash_aliases:rw
17+
- ~/.bash_history:/home/www-data/.bash_history:rw
18+
secrets:
19+
- ssh_host_key
20+
environment:
21+
XDEBUG_CONFIG: remote_host=${XDEBUG_REMOTE_HOST}
22+
PHP_IDE_CONFIG: serverName=php
23+
secrets:
24+
ssh_host_key:
25+
file: ~/.ssh/id_rsa

docker/docker-compose.yml

Lines changed: 0 additions & 12 deletions
This file was deleted.

docker/php/Dockerfile

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
FROM php:8.1-alpine3.18
2+
3+
ARG USER_ID
4+
5+
# PHP: Copy configuration files & remove dist files
6+
RUN mkdir /phpIni
7+
COPY php/files/bin/ /usr/local/bin/
8+
9+
# SYS: Install required packages
10+
RUN apk --no-cache upgrade && \
11+
apk --no-cache add bash git sudo openssh autoconf gcc g++ make gettext sudo shadow
12+
13+
RUN if [ -n "$USER_ID" ] && [ "$USER_ID" -lt 60001 ]; then \
14+
usermod -u ${USER_ID} -o www-data; \
15+
fi
16+
17+
# USER: set /bin/bash and allow www-data to become root
18+
RUN usermod -s /bin/bash www-data && \
19+
echo 'www-data ALL=(ALL) NOPASSWD: ALL' > '/etc/sudoers.d/www-data'
20+
21+
# USER: copy home
22+
COPY --chown=www-data:www-data php/files/user-home /home/www-data
23+
24+
# USER: add ssh key and fix permission of the ssh directory
25+
RUN ln -s /run/secrets/ssh_host_key /home/www-data/.ssh/id_rsa && \
26+
chmod 700 /home/www-data/.ssh && \
27+
chmod 400 /home/www-data/.ssh/config
28+
29+
# PHP: Install php extensions
30+
RUN pecl channel-update pecl.php.net
31+
32+
# COMPOSER: install binary
33+
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer
34+
35+
USER www-data
36+
37+
WORKDIR /var/www/html

docker/php/files/bin/php-ext-disable

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
if [ $# -eq 0 ]
4+
then
5+
echo "Please pass a php module name"
6+
exit
7+
fi
8+
9+
for phpmod in "$@"
10+
do
11+
rm -f /usr/local/etc/php/conf.d/*$phpmod*.ini
12+
done

docker/php/files/bin/php-ext-enable

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
if [[ ${#} -eq 0 ]] ; then
4+
echo -e "\\nPHP module name required!\\n"
5+
exit 1
6+
fi
7+
8+
for phpmod in "${@}" ; do
9+
10+
files=($(find /phpIni -type f -iname "*${phpmod}*.ini" -exec ls -1 '{}' +))
11+
12+
for i in "${files[@]}" ; do
13+
ln -s "${i}" /usr/local/etc/php/conf.d
14+
done
15+
16+
if [[ ${#files[@]} -eq 0 ]] ; then
17+
docker-php-ext-enable "${phpmod}"
18+
fi
19+
20+
done

docker/php/files/user-home/.bashrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
alias cls='printf "\033c"'
2+
3+
export PS1='\[\e[1;32m\]\h\[\e[0m\] \[\e[1;37m\]\w\[\e[0m\] \[\e[1;32m\]\u\[\e[0m\] \[\e[1;37m\]\$\[\e[0m\] '
4+
5+
if [ -f ~/.bash_aliases ]; then
6+
. ~/.bash_aliases
7+
fi
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Host *
2+
StrictHostKeyChecking no
3+
UserKnownHostsFile /dev/null
4+
IdentityFile /run/secrets/ssh_host_key

lib/PHPPdf/Core/AbstractUnitConverter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ abstract protected function convertPtUnit($value);
5050

5151
public function convertPercentageValue($percent, $value)
5252
{
53-
if(strpos($percent, '%') !== false)
53+
if(str_contains($percent, '%'))
5454
{
5555
$percent = (double) $percent;
5656
$percent = $value*$percent / 100;

lib/PHPPdf/Core/AttributeBag.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@
88

99
namespace PHPPdf\Core;
1010

11+
use ReturnTypeWillChange;
12+
1113
/**
1214
* Bag of attributes
1315
*
1416
* @author Piotr Śliwa <peter.pl7@gmail.com>
1517
*/
16-
class AttributeBag implements \Countable, \Serializable
18+
class AttributeBag implements \Countable
1719
{
1820
private $elements = array();
1921

@@ -39,6 +41,7 @@ public function add($name, $value)
3941
return $this;
4042
}
4143

44+
#[ReturnTypeWillChange]
4245
public function count()
4346
{
4447
return count($this->elements);
@@ -92,4 +95,4 @@ public function unserialize($serialized)
9295
{
9396
$this->elements = \unserialize($serialized);
9497
}
95-
}
98+
}

lib/PHPPdf/Core/Boundary.php

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,18 @@
88

99
namespace PHPPdf\Core;
1010

11-
use PHPPdf\Exception\OutOfBoundsException;
12-
use PHPPdf\Exception\BadMethodCallException;
13-
use PHPPdf\Exception\InvalidArgumentException;
11+
use PHPPdf\Exception\OutOfBoundsException;
12+
use PHPPdf\Exception\BadMethodCallException;
13+
use PHPPdf\Exception\InvalidArgumentException;
1414
use PHPPdf\Exception\LogicException;
15-
15+
use ReturnTypeWillChange;
16+
1617
/**
1718
* Set of ordered points whom determine boundary and shape of node element.
1819
*
1920
* @author Piotr Śliwa <peter.pl7@gmail.com>
2021
*/
21-
class Boundary implements \Countable, \Iterator, \ArrayAccess, \Serializable
22+
class Boundary implements \Countable, \Iterator, \ArrayAccess
2223
{
2324
private $points = array();
2425
private $numberOfPoints = 0;
@@ -169,11 +170,13 @@ private function getPointBetween(Point $point1, Point $point2)
169170
/**
170171
* @return integer Number of points in boundary
171172
*/
173+
#[ReturnTypeWillChange]
172174
public function count()
173175
{
174176
return $this->numberOfPoints;
175177
}
176178

179+
#[ReturnTypeWillChange]
177180
public function current()
178181
{
179182
$points = $this->getPoints();
@@ -183,6 +186,8 @@ public function current()
183186
/**
184187
* @return array Array of Point objects
185188
*/
189+
190+
#[ReturnTypeWillChange]
186191
public function getPoints()
187192
{
188193
return $this->points;
@@ -193,21 +198,25 @@ public function getPoint($i)
193198
return $this->offsetGet($i);
194199
}
195200

201+
#[ReturnTypeWillChange]
196202
public function key()
197203
{
198204
return $this->current;
199205
}
200206

207+
#[ReturnTypeWillChange]
201208
public function next()
202209
{
203210
$this->current++;
204211
}
205212

213+
#[ReturnTypeWillChange]
206214
public function rewind()
207215
{
208216
$this->current = 0;
209217
}
210218

219+
#[ReturnTypeWillChange]
211220
public function valid()
212221
{
213222
$points = $this->getPoints();
@@ -314,11 +323,13 @@ public function isClosed()
314323
return $this->closed;
315324
}
316325

326+
#[ReturnTypeWillChange]
317327
public function offsetExists($offset)
318328
{
319329
return (is_int($offset) && $offset < $this->numberOfPoints);
320330
}
321331

332+
#[ReturnTypeWillChange]
322333
public function offsetGet($offset)
323334
{
324335
if(!$this->offsetExists($offset))
@@ -329,11 +340,13 @@ public function offsetGet($offset)
329340
return $this->points[$offset];
330341
}
331342

343+
#[ReturnTypeWillChange]
332344
public function offsetSet($offset, $value)
333345
{
334346
throw new BadMethodCallException('You can not set point directly.');
335347
}
336348

349+
#[ReturnTypeWillChange]
337350
public function offsetUnset($offset)
338351
{
339352
throw new BadMethodCallException('You can not unset point directly.');

lib/PHPPdf/Core/ComplexAttribute/ComplexAttributeFactory.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
namespace PHPPdf\Core\ComplexAttribute;
1010

11-
use PHPPdf\Exception\InvalidArgumentException;
11+
use PHPPdf\Exception\InvalidArgumentException;
1212

1313
use PHPPdf\Core\ComplexAttribute\Exception\DefinitionNotFoundException;
1414

@@ -20,7 +20,7 @@
2020
*
2121
* @author Piotr Śliwa <peter.pl7@gmail.com>
2222
*/
23-
class ComplexAttributeFactory implements \Serializable
23+
class ComplexAttributeFactory
2424
{
2525
private $definitions = array();
2626
private $constructors = array();
@@ -251,11 +251,11 @@ public function serialize()
251251

252252
public function unserialize($serialized)
253253
{
254-
$definitions = \unserialize($serialized);
254+
$definitions = unserialize($serialized);
255255

256256
foreach($definitions as $name => $className)
257257
{
258258
$this->addDefinition($name, $className);
259259
}
260260
}
261-
}
261+
}

lib/PHPPdf/Core/DrawingTaskHeap.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,16 @@ class DrawingTaskHeap extends \SplHeap
1919
{
2020
private $elements = 0;
2121

22-
public function insert($value)
22+
public function insert($value): bool
2323
{
2424
$value->setOrder($this->elements++);
2525
parent::insert($value);
26+
27+
return true;
2628
}
2729

28-
public function compare($value1, $value2)
30+
public function compare($value1, $value2): int
2931
{
3032
return $value1->compareTo($value2);
3133
}
32-
}
34+
}

0 commit comments

Comments
 (0)