Skip to content

Commit

Permalink
Podpora pouze PHP 7.4 a 8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
MilanPala committed Oct 11, 2020
1 parent e0d8d9c commit 5729e9d
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 34 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
composer.lock
vendor/
20 changes: 6 additions & 14 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
language: php
php:
- 7.1
- 7.2
- 7.3
- 7.4
language: minimal
env:
- PHP_VERSION=7.4-dev
- PHP_VERSION=8.0-dev

script:
- vendor/bin/phpstan analyse -l 5 src
- docker run --rm -it -v "$PWD":/var/www/html peckadesign/php:${PHP_VERSION} vendor/bin/phpstan analyse -l 7 src/

before_script:
- travis_retry composer install --no-interaction --prefer-dist

sudo: false

cache:
directories:
- $HOME/.composer/cache
- docker run --rm -it -v "$PWD":/var/www/html peckadesign/php:${PHP_VERSION} composer install --no-interaction --prefer-dist
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@
}
],
"require": {
"tracy/tracy": "~2.4.18"
"php": "7.4.* || 8.0.*",
"tracy/tracy": ">= 2.4.18"
},
"require-dev": {
"phpstan/phpstan": "0.12.11"
"phpstan/phpstan": "0.12.*"
},
"autoload": {
"psr-0": {
Expand Down
33 changes: 18 additions & 15 deletions src/Pd/Diagnostics/DatabaseInfoPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,20 @@
*/
class DatabaseInfoPanel implements Tracy\IBarPanel
{
/** @var string[] $databaseParams [{key => val}] */
private $databaseParams;
/** @var array<string, string> */
private array $databaseParams;

/** @var string[] */
private $possibleDbNameKeys = array('dbname', 'database');
/** @var array<string> */
private array $possibleDbNameKeys = ['dbname', 'database'];

/** @var IDatabaseInfoPanelStyleHandler|NULL */
private $styleCallback;
private ?IDatabaseInfoPanelStyleHandler$styleCallback;

/**
* @param string[] $databaseParams All database parameters in [{key => val}] format
* @param string|NULL $customDbNameKey Custom key of DB name value
* @param IDatabaseInfoPanelStyleHandler $styleCallback Handler with formating of DB name label in panel
* @param array<string, string> $databaseParams All database parameters in [{key => val}] format
* @param string|null $customDbNameKey Custom key of DB name value
* @param IDatabaseInfoPanelStyleHandler|null $styleCallback Handler with formating of DB name label in panel
*/
public function __construct(array $databaseParams, $customDbNameKey = NULL, IDatabaseInfoPanelStyleHandler $styleCallback = NULL)
public function __construct(array $databaseParams, ?string $customDbNameKey = NULL, ?IDatabaseInfoPanelStyleHandler $styleCallback = NULL)
{
$this->setDatabaseParams($databaseParams);

Expand All @@ -34,14 +33,17 @@ public function __construct(array $databaseParams, $customDbNameKey = NULL, IDat
}


private function setDatabaseParams(array $databaseParams)
/**
* @param array<string, string> $databaseParams
*/
private function setDatabaseParams(array $databaseParams): void
{
if (array_key_exists('password', $databaseParams)) unset($databaseParams['password']);
$this->databaseParams = $databaseParams;
}


private function getDatabaseName()
private function getDatabaseName(): string
{
foreach ($this->possibleDbNameKeys as $key) {
if (array_key_exists($key, $this->databaseParams)) return $this->databaseParams[$key];
Expand All @@ -50,7 +52,7 @@ private function getDatabaseName()
}


public function getTab()
public function getTab(): string
{
if ($this->styleCallback) $style = ' style="' . $this->styleCallback->getStyle($this->getDatabaseName(), $this->databaseParams) . '"';
else $style = '';
Expand All @@ -62,10 +64,11 @@ public function getTab()
}


public function getPanel()
public function getPanel(): string
{
ob_start();
include __DIR__ . '/DatabaseInfoPanel.phtml';
return ob_get_clean();
return (string) ob_get_clean();
}

}
6 changes: 3 additions & 3 deletions src/Pd/Diagnostics/IDatabaseInfoPanelStyleHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
interface IDatabaseInfoPanelStyleHandler
{
/**
* @var string $databaseName Database name
* @var string[] $databaseParams All database parameters
* @param string $databaseName Database name
* @param array<string, string> $databaseParams All database parameters
* @return string Content of DB name label style atribut
*/
public function getStyle($databaseName, $databaseParams);
public function getStyle(string $databaseName, array $databaseParams): string;
}

0 comments on commit 5729e9d

Please sign in to comment.