-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
2,580 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.idea | ||
.local |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
ARG PHP_VER | ||
|
||
FROM php:${PHP_VER}-fpm-alpine | ||
LABEL authors="PrInSt.pl" | ||
|
||
ENV PS0="\u@\h:\w\\$ " | ||
ENV PS1="\u:\w\\$ " | ||
|
||
ARG PROJECT_DIR | ||
ENV PROJECT_DIR ${PROJECT_DIR:-/opt/project} | ||
|
||
RUN apk update --force-refresh \ | ||
&& apk upgrade --force-refresh --no-cache \ | ||
&& apk add nano util-linux-misc | ||
|
||
RUN mkdir ${PROJECT_DIR} | ||
|
||
WORKDIR ${PROJECT_DIR} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: prinstpl_php_array_vs_object_benchmark | ||
|
||
services: | ||
php_74: | ||
build: | ||
args: | ||
- PHP_VER=7.4 | ||
- PROJECT_DIR=${PROJECT_DIR:-/opt/project} | ||
context: . | ||
dockerfile: Dockerfile | ||
cpu_count: 1 | ||
volumes: | ||
- ./src:${PROJECT_DIR:-/opt/project}:ro | ||
php_80: | ||
build: | ||
args: | ||
- PHP_VER=8.0 | ||
- PROJECT_DIR=${PROJECT_DIR:-/opt/project} | ||
context: . | ||
dockerfile: Dockerfile | ||
cpu_count: 1 | ||
volumes: | ||
- ./src:${PROJECT_DIR:-/opt/project}:ro | ||
php_81: | ||
build: | ||
args: | ||
- PHP_VER=8.1 | ||
- PROJECT_DIR=${PROJECT_DIR:-/opt/project} | ||
context: . | ||
dockerfile: Dockerfile | ||
cpu_count: 1 | ||
volumes: | ||
- ./src:${PROJECT_DIR:-/opt/project}:ro | ||
php_82: | ||
build: | ||
args: | ||
- PHP_VER=8.2 | ||
- PROJECT_DIR=${PROJECT_DIR:-/opt/project} | ||
context: . | ||
dockerfile: Dockerfile | ||
cpu_count: 1 | ||
volumes: | ||
- ./src:${PROJECT_DIR:-/opt/project}:ro | ||
php_83: | ||
build: | ||
args: | ||
- PHP_VER=8.3 | ||
- PROJECT_DIR=${PROJECT_DIR:-/opt/project} | ||
context: . | ||
dockerfile: Dockerfile | ||
cpu_count: 1 | ||
volumes: | ||
- ./src:${PROJECT_DIR:-/opt/project}:ro |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
abstract class AbstractMultiGetterClass extends AbstractSingleGetterClass { | ||
public function getAll(): array | ||
{ | ||
return [ | ||
$this->getInfo(), | ||
$this->getFirst(), | ||
$this->getSecond(), | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
abstract class AbstractSingleGetterClass { | ||
public function getInfo(): ?string | ||
{ | ||
return $this->info; | ||
} | ||
|
||
public function getFirst(): ?string | ||
{ | ||
return $this->first; | ||
} | ||
|
||
public function getSecond(): ?int | ||
{ | ||
return $this->second; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
class ConstructorClass extends PlainClass { | ||
public function __construct( | ||
?string $info = null, | ||
?string $first = null, | ||
?int $second = null | ||
) { | ||
$this->info = $info; | ||
$this->first = $first; | ||
$this->second = $second; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
class PlainClass extends AbstractMultiGetterClass { | ||
use MultiGetterTrait; | ||
|
||
public ?string $info = null; | ||
public ?string $first = null; | ||
public ?int $second = null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
readonly class ReadonlyConstructorClass | ||
{ | ||
use MultiGetterTrait; | ||
|
||
public function __construct( | ||
public ?string $info = null, | ||
public ?string $first = null, | ||
public ?int $second = null | ||
) {} | ||
|
||
public function getInfo(): ?string | ||
{ | ||
return $this->info; | ||
} | ||
|
||
public function getFirst(): ?string | ||
{ | ||
return $this->first; | ||
} | ||
|
||
public function getSecond(): ?int | ||
{ | ||
return $this->second; | ||
} | ||
|
||
public function getAll(): array | ||
{ | ||
return [ | ||
$this->getInfo(), | ||
$this->getFirst(), | ||
$this->getSecond(), | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
class SetterMultipleClass extends PlainClass { | ||
public function set( | ||
?string $info = null, | ||
?string $first = null, | ||
?int $second = null | ||
): void { | ||
$this->info = $info; | ||
$this->first = $first; | ||
$this->second = $second; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
class SetterSingleNoReturnDefClass extends PlainClass { | ||
|
||
public function setInfo(?string $info = null) | ||
{ | ||
$this->info = $info; | ||
} | ||
|
||
public function setFirst(?string $first = null) | ||
{ | ||
$this->first = $first; | ||
} | ||
|
||
public function setSecond(?int $second = null) | ||
{ | ||
$this->second = $second; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
class SetterSingleReturnClass extends PlainClass { | ||
public function setInfo(?string $info = null): self | ||
{ | ||
$this->info = $info; | ||
|
||
return $this; | ||
} | ||
|
||
public function setFirst(?string $first = null): self | ||
{ | ||
$this->first = $first; | ||
|
||
return $this; | ||
} | ||
|
||
public function setSecond(?int $second = null): self | ||
{ | ||
$this->second = $second; | ||
|
||
return $this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
class SetterSingleVoidClass extends PlainClass { | ||
public function setInfo(?string $info = null): void | ||
{ | ||
$this->info = $info; | ||
} | ||
|
||
public function setFirst(?string $first = null): void | ||
{ | ||
$this->first = $first; | ||
} | ||
|
||
public function setSecond(?int $second = null): void | ||
{ | ||
$this->second = $second; | ||
} | ||
} |
Oops, something went wrong.