Skip to content

Commit 2227dd1

Browse files
authored
Merge pull request #14 from petrknap/chores
Chores
2 parents 96d5192 + 6904ad7 commit 2227dd1

File tree

8 files changed

+86
-18
lines changed

8 files changed

+86
-18
lines changed

.gitattributes

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
tests export-ignore
2+
Dockerfile export-ignore
3+
bin export-ignore
4+
.github export-ignore
5+
.molireali export-ignore

.github/pull_request_template.md

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
- [ ] This pull request does not contain any breaking change.
2+
- [ ] I asked [the AI](https://copilot.microsoft.com/) to briefly summarize, use and improve the feature(s), and I'm okay with the output:
3+
<!-- ⇅ remove it if it doesn't make sense ⇅ -->
4+
<!-- ↓ here belongs the AI inputs (>>) and outputs (>) ↓ -->
5+
>> Could you briefly summarize the following code for me?
6+
>> ```python
7+
>> class Tiger:
8+
>> def __init__(self, name):
9+
>> self.name = name
10+
>>
11+
>> def roar(self):
12+
>> print(f"{self.name} lets out a powerful roar!")
13+
>> ```
14+
>
15+
> This code defines a Python class named `Tiger` with a constructor that initializes the tiger's name, and a `roar` method that prints a message including the tiger's name. Simple and elegant, just like a tiger! 🐅
16+
>
17+
>> Could you show me how to use it?
18+
>
19+
> Sure, here's how to create and use a `Tiger` object with the class you have:
20+
> ```python
21+
> # Create an instance of Tiger
22+
> my_tiger = Tiger("Gopal")
23+
>
24+
> # Call the roar method
25+
> my_tiger.roar()
26+
> ```
27+
>
28+
> When you run this code, it will output:
29+
> ```
30+
> Gopal lets out a powerful roar!
31+
> ```
32+
>
33+
> That's how you bring your Tiger to life! 🎉
34+
>
35+
>> Is there any way to do it better?
36+
>
37+
> Absolutely. You could add error handling, additional methods, or even inheritance. Here's an enhanced version:
38+
> ```python
39+
> class Tiger:
40+
> def __init__(self, name):
41+
> self.name = name
42+
>
43+
> def roar(self):
44+
> print(f"{self.name} lets out a powerful roar!")
45+
>
46+
> def introduce(self):
47+
> print(f"Meet {self.name}, the majestic tiger!")
48+
>
49+
> # Usage
50+
> my_tiger = Tiger("Gopal")
51+
> my_tiger.introduce() # Output: Meet Gopal, the majestic tiger!
52+
> my_tiger.roar() # Output: Gopal lets out a powerful roar!
53+
> ```
54+
>
55+
> Now your tiger can introduce itself, too. 🐯📢
56+
<!-- ↑ this is an example, replace it ↑ -->

.molireali

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ composer PetrKnap\\Binary
33
dockerfile php 8.1-cli
44
docker-scripts petrknap/php-binary
55
donation
6+
github-templates
67
github-workflow docker "composer ci-script"
78
github-workflow linter-docker
89
github-workflow linter-php 8.1

Dockerfile

+1-6
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,10 @@ RUN apt-get update \
66
&& apt-get install -y --no-install-recommends \
77
git \
88
unzip \
9-
&& php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
10-
&& php -r "copy('https://composer.github.io/installer.sig', 'composer-setup.php.sig');" \
11-
&& php -r "if (trim(hash_file('SHA384', 'composer-setup.php')) === trim(file_get_contents('composer-setup.php.sig'))) { echo 'Installer verified' . PHP_EOL; exit(0); } else { echo 'Installer corrupt' . PHP_EOL; unlink('composer-setup.php'); unlink('composer-setup.php.sig'); exit(-1); }" \
12-
&& php composer-setup.php \
13-
&& php -r "unlink('composer-setup.php'); unlink('composer-setup.php.sig');" \
14-
&& mv composer.phar /usr/local/bin/composer \
159
&& apt-get clean \
1610
&& rm -rf /var/lib/apt/lists/* \
1711
;
12+
COPY --from=composer:2 /usr/bin/composer /usr/local/bin/composer
1813
# endregion
1914

2015
# region included composer-library

composer.json

+14-7
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,28 @@
4646
"ext-mbstring": "*",
4747
"ext-zlib": "*",
4848
"nunomaduro/phpinsights": "^2.11",
49-
"phpstan/phpstan": "^1.10",
49+
"phpstan/phpstan": "^1.12",
5050
"phpunit/phpunit": "^10.5",
5151
"squizlabs/php_codesniffer": "^3.7"
5252
},
5353
"scripts": {
5454
"test": "phpunit --colors=always --testdox tests",
55-
"validate": [
56-
"composer outdated \"petrknap/*\" --major-only --strict --ansi --no-interaction",
55+
"ci-script": [
56+
"@check-implementation",
57+
"@check-requirements",
58+
"@test-implementation"
59+
],
60+
"check-implementation": [
5761
"phpcs --colors --standard=PSR12 --exclude=Generic.Files.LineLength src tests",
58-
"phpstan analyse --level max src",
59-
"phpstan analyse --level 5 tests",
62+
"phpstan analyse --level max src --ansi --no-interaction",
63+
"phpstan analyse --level 5 tests --ansi --no-interaction",
6064
"phpinsights analyse src --ansi --no-interaction"
6165
],
62-
"ci-script": [
63-
"@validate",
66+
"check-requirements": [
67+
"composer update \"petrknap/*\"",
68+
"composer outdated \"petrknap/*\" --major-only --strict --ansi --no-interaction"
69+
],
70+
"test-implementation": [
6471
"@test"
6572
]
6673
},

src/BinariableTrait.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@
44

55
namespace PetrKnap\Binary;
66

7+
/**
8+
* @psalm-require-implements BinariableInterface
9+
*/
710
trait BinariableTrait
811
{
912
/**
1013
* Unfortunately PHP uses string for binary data, so the magic clashes.
1114
*/
1215
public function __toString(): string
1316
{
14-
/** @var BinariableInterface $this */
1517
$binary = $this->toBinary();
1618
trigger_error(
1719
'Returned binary string',

src/Coder/Zlib.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ final class Zlib extends Coder
1818
public const LEVEL = -1;
1919
public const MAX_LENGTH = 0;
2020

21+
private int $encoding;
22+
private int $level;
23+
private int $maxLength;
24+
2125
public function __construct()
2226
{
2327
self::checkRequirements(
@@ -31,10 +35,6 @@ functions: [
3135
);
3236
}
3337

34-
private int $encoding;
35-
private int $level;
36-
private int $maxLength;
37-
3838
public function encode(string $decoded, ?int $encoding = null, ?int $level = null): string
3939
{
4040
$this->encoding = $encoding ?? self::ENCODING;

src/Serializer/SelfSerializerTrait.php

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
/**
1010
* If your {@see self::__construct()} argument is an instance of {@see SelfSerializerInterface} then
1111
* accept it as a union type `YourClass|string` and call {@see SelfSerializerInterface::fromBinary()} if it is a string.
12+
*
13+
* @psalm-require-implements SelfSerializerInterface
1214
*/
1315
trait SelfSerializerTrait
1416
{

0 commit comments

Comments
 (0)