Skip to content

PHP 8.3 and 8.4 #74

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 1.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
root = true

[*]
end_of_line = LF
indent_style = space
indent_size = 4
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[{.phpstan/,phpstan}*.neon]
indent_style = tab

[*.{sh,bash,zsh}]
indent_style = tab
35 changes: 18 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,34 @@
name: CI

on:
push:
pull_request:
push: ~
pull_request: ~

jobs:
lint:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
- run: composer install
- run: vendor/bin/phpcs
- run: vendor/bin/psalm
PHPUnit:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
strategy:
matrix:
php:
- 7.4
- 7.3
- 7.2
- 7.1
- 7.0
- 5.6
- 5.5
- 5.4
- 5.3
- '8.3'
- '8.4'
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
- run: sudo apt-get -y install graphviz
- run: composer install
- run: vendor/bin/phpunit --coverage-text
if: ${{ matrix.php >= 7.3 }}
- run: vendor/bin/phpunit --coverage-text -c phpunit.xml.legacy
if: ${{ matrix.php < 7.3 }}
- run: vendor/bin/phpunit
22 changes: 22 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,24 @@
### Common
/.cache/
/reports/


### Composer
/vendor
/composer.lock
/graphp-graphviz-*.tar
/graphp-graphviz-*.tar.gz
/graphp-graphviz-*.tar.bz2
/graphp-graphviz-*.zip


### PHPCS
/phpcs.xml


### PSalm
/psalm.neon


### PHPUnit
/phpunit.xml
28 changes: 22 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,33 @@
"name": "graphp/graphviz",
"type": "library",
"description": "GraphViz graph drawing for the mathematical graph/network library GraPHP.",
"keywords": ["GraphViz", "graph drawing", "graph image", "dot output", "GraPHP"],
"keywords": [
"GraphViz",
"graph drawing",
"graph image",
"dot output",
"GraPHP"
],
"homepage": "https://github.com/graphp/graphviz",
"license": "MIT",
"autoload": {
"psr-4": {"Graphp\\GraphViz\\": "src/"}
},
"require": {
"php": ">=5.3.0",
"php": ">=8.3",
"graphp/graph": "^1@dev"
},
"require-dev": {
"phpunit/phpunit": "^9.3 || ^5.7 || ^4.8.35"
"phpunit/phpunit": "^11.5",
"psalm/plugin-phpunit": "^0.19.5",
"squizlabs/php_codesniffer": "^3.13",
"vimeo/psalm": "^6.13"
},
"autoload": {
"psr-4": {
"Graphp\\GraphViz\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Graphp\\GraphViz\\Tests\\": "tests/src/"
}
}
}
9 changes: 7 additions & 2 deletions examples/01-simple.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
<?php

declare(strict_types=1);

use Graphp\Graph\Graph;
use Graphp\GraphViz\GraphViz;

require __DIR__ . '/../vendor/autoload.php';

$graph = new Graphp\Graph\Graph();
$graph = new Graph();

$blue = $graph->createVertex();
$blue->setAttribute('id', 'blue');
Expand All @@ -15,5 +20,5 @@
$edge = $graph->createEdgeDirected($blue, $red);
$edge->setAttribute('graphviz.color', 'grey');

$graphviz = new Graphp\GraphViz\GraphViz();
$graphviz = new GraphViz();
$graphviz->display($graph);
17 changes: 9 additions & 8 deletions examples/02-html.php
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
<?php

declare(strict_types=1);

// $ php -S localhost:8080 examples/02-html.php

use Graphp\Graph\Graph;
use Graphp\GraphViz\GraphViz;

require __DIR__ . '/../vendor/autoload.php';

$graph = new Graphp\Graph\Graph();
$graph = new Graph();
$graph->setAttribute('graphviz.graph.rankdir', 'LR');

$hello = $graph->createVertex()->setAttribute('id', 'hello');
$world = $graph->createVertex()->setAttribute('id', 'wörld');
$graph->createEdgeDirected($hello, $world);

$graphviz = new Graphp\GraphViz\GraphViz();
$graphviz = new GraphViz();
$graphviz->setFormat('svg');

echo '<!DOCTYPE html>
<html>
<html lang="en">
<head>
<title>hello wörld</title>
<body>
' . $graphviz->createImageHtml($graph) . '
</body>
</html>
';
<body>', $graphviz->createImageHtml($graph), '</body></html>';
5 changes: 4 additions & 1 deletion examples/11-uml-html.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
<?php

declare(strict_types=1);

use Graphp\Graph\Graph;
use Graphp\GraphViz\GraphViz;

require __DIR__ . '/../vendor/autoload.php';

$graph = new Graphp\Graph\Graph();
$graph = new Graph();

$a = $graph->createVertex()->setAttribute('id', 'Entity');
$a->setAttribute('graphviz.shape', 'none');
Expand Down
5 changes: 4 additions & 1 deletion examples/12-uml-records.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
<?php

declare(strict_types=1);

use Graphp\Graph\Graph;
use Graphp\GraphViz\GraphViz;

require __DIR__ . '/../vendor/autoload.php';

$graph = new Graphp\Graph\Graph();
$graph = new Graph();

$a = $graph->createVertex()->setAttribute('id', 'Entity');
$a->setAttribute('graphviz.shape', 'record');
Expand Down
5 changes: 4 additions & 1 deletion examples/13-record-ports.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
<?php

declare(strict_types=1);

use Graphp\Graph\Graph;
use Graphp\GraphViz\GraphViz;

require __DIR__ . '/../vendor/autoload.php';

$graph = new Graphp\Graph\Graph();
$graph = new Graph();

$a = $graph->createVertex();
$a->setAttribute('graphviz.shape', 'Mrecord');
Expand Down
12 changes: 12 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0"?>
<ruleset
name="Custom"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/squizlabs/php_codesniffer/phpcs.xsd">

<file>./examples/</file>
<file>./src/</file>
<file>./tests/src/</file>

<rule ref="PSR2"/>
</ruleset>
43 changes: 32 additions & 11 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,19 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
cacheDirectory="./.cache/phpunit/"
displayDetailsOnTestsThatTriggerErrors="true"
displayDetailsOnTestsThatTriggerWarnings="true"
displayDetailsOnTestsThatTriggerDeprecations="true"
displayDetailsOnPhpunitDeprecations="true"
colors="true">

<source>
<include>
<directory>./src</directory>
</include>
</source>

<!-- PHPUnit configuration file with new format for PHPUnit 9.3+ -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
cacheResult="false">
<testsuites>
<testsuite name="GraphViz Test Suite">
<directory>./tests/</directory>
<testsuite name="unit">
<directory>./tests/src/Unit/</directory>
</testsuite>
</testsuites>

<logging>
<testdoxHtml outputFile="./reports/human/result/testdox.html" />
<testdoxText outputFile="./reports/human/result/testdox.txt" />

<junit outputFile="./reports/machine/result/junit.xml" />
</logging>

<coverage>
<include>
<directory>./src</directory>
</include>
<report>
<html outputDirectory="./reports/human/coverage/html/" />

<xml outputDirectory="./reports/machine/coverage/xml" />
<clover outputFile="./reports/machine/coverage/clover.xml" />
<php outputFile="./reports/machine/coverage/php.php" />
</report>
</coverage>
</phpunit>
18 changes: 0 additions & 18 deletions phpunit.xml.legacy

This file was deleted.

18 changes: 18 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0"?>
<psalm
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:noNamespaceSchemaLocation="./vendor/vimeo/psalm/config.xsd"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
cacheDirectory="./.cache/psalm/">

<plugins>
<pluginClass class="Psalm\PhpUnitPlugin\Plugin" />
</plugins>

<projectFiles>
<directory name="./examples/" />
<directory name="./src/" />
<directory name="./tests/src/" />
</projectFiles>
</psalm>
11 changes: 8 additions & 3 deletions src/Dot.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
<?php

declare(strict_types=1);

namespace Graphp\GraphViz;

use Graphp\Graph\Graph;

/**
* @api
*/
class Dot
{
private $graphviz;
private GraphViz $graphviz;

public function __construct(GraphViz $graphviz = null)
public function __construct(?GraphViz $graphviz = null)
{
if ($graphviz === null) {
$graphviz = new GraphViz();
Expand All @@ -17,7 +22,7 @@ public function __construct(GraphViz $graphviz = null)
$this->graphviz = $graphviz;
}

public function getOutput(Graph $graph)
public function getOutput(Graph $graph): string
{
return $this->graphviz->createScript($graph);
}
Expand Down
Loading