Skip to content
Merged
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
19 changes: 19 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# editorconfig.org

root = true

[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 2

[*.{diff,md}]
trim_trailing_whitespace = false

[*.{php,xml,json}]
indent_size = 4
30 changes: 30 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: PHP Tests

on: push

jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
php: [7.3, 7.4, 8.0, 8.1]

name: 'PHP ${{ matrix.php }}'
steps:
- uses: actions/checkout@master

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: xdebug
extensions: curl, dom, gd, json, mbstring, openssl, pdo_mysql, tokenizer, zip
tools: phpunit, composer:v2
ini-values: display_errors=E_ALL

- name: Install Composer dependencies
run: composer install

- name: Run Composer tests
run: composer test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ phpmd.xml
.idea
tests/tmp/*
!tests/tmp/.gitkeep
.phpunit.result.cache
7 changes: 2 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,10 @@ language: php

matrix:
include:
- php: 5.6
env: CHECKS=yes PU4=yes
- php: 7.0
- php: 7.1
- php: 7.2
- php: 7.3
- php: 7.4
- php: 8.0
- php: 8.1

sudo: false

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2015 Oleg Grigoriev
Copyright (c) 2022 Sami Mazouz Copyright (c) 2015 Oleg Grigoriev

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
The library for work with Source Map files from PHP.

[![Latest Stable Version](https://img.shields.io/packagist/v/axy/sourcemap.svg?style=flat-square)](https://packagist.org/packages/axy/sourcemap)
[![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%205.4-8892BF.svg?style=flat-square)](https://php.net/)
[![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%207.3-8892BF.svg?style=flat-square)](https://php.net/)
[![Build Status](https://img.shields.io/travis/axypro/sourcemap/master.svg?style=flat-square)](https://travis-ci.org/axypro/sourcemap)
[![Coverage Status](https://coveralls.io/repos/axypro/sourcemap/badge.svg?branch=master&service=github)](https://coveralls.io/github/axypro/sourcemap?branch=master)
[![License](https://poser.pugx.org/axy/sourcemap/license)](LICENSE)
Expand Down
21 changes: 17 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,27 @@
}
],
"require": {
"php": ">=5.4.0",
"php": ">=7.3",
"ext-json": "*",
"axy/errors": "~1.0.1",
"axy/codecs-base64vlq": "~1.0.0"
"axy/errors": "^3.0",
"axy/codecs-base64vlq": "^2.0"
},
"require-dev": {
"phpunit/phpunit": "^9.0"
},
"autoload": {
"psr-4": {
"axy\\sourcemap\\": ""
"axy\\sourcemap\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"axy\\sourcemap\\tests\\": "tests/"
}
},
"scripts": {
"test": "phpunit -c phpunit.xml.dist",
"md": "phpmd --exclude vendor . text phpmd.xml.dist",
"cs": "phpcs --standard=PSR2 --encoding=utf-8 --ignore=vendor ."
}
}
1 change: 0 additions & 1 deletion cs.sh
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env sh

/usr/bin/env phpcs --standard=PSR2 --encoding=utf-8 --ignore=vendor .

20 changes: 0 additions & 20 deletions index.php

This file was deleted.

Empty file modified phpmd.sh
100755 → 100644
Empty file.
28 changes: 14 additions & 14 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit backupGlobals="false"
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="tests/bootstrap.php"
beStrictAboutTestsThatDoNotTestAnything="false"
>
<testsuites>
<testsuite name="Base Test Suite">
<directory suffix="Test.php">./tests/</directory>
</testsuite>
</testsuites>

<filter>
<blacklist>
<directory>./vendor/</directory>
</blacklist>
</filter>
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./src</directory>
</include>
</coverage>
<testsuites>
<testsuite name="Base Test Suite">
<directory suffix="Test.php">./tests/</directory>
</testsuite>
</testsuites>
</phpunit>

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
34 changes: 27 additions & 7 deletions parents/Interfaces.php → src/parents/Interfaces.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

namespace axy\sourcemap\parents;

use Traversable;

/**
* Partition of the SourceMap class (interfaces implementations)
*/
Expand All @@ -14,22 +16,23 @@ abstract class Interfaces extends Magic implements \IteratorAggregate, \ArrayAcc
/**
* {@inheritdoc}
*/
public function getIterator()
public function getIterator(): Traversable
{
return new \ArrayIterator($this->getData());
}

/**
* {@inheritdoc}
*/
public function offsetExists($offset)
public function offsetExists($offset): bool
{
return $this->__isset($offset);
}

/**
* {@inheritdoc}
*/
#[\ReturnTypeWillChange]
public function offsetGet($offset)
{
return $this->__get($offset);
Expand All @@ -38,22 +41,23 @@ public function offsetGet($offset)
/**
* {@inheritdoc}
*/
public function offsetSet($offset, $value)
public function offsetSet($offset, $value): void
{
$this->__set($offset, $value);
}

/**
* {@inheritdoc}
*/
public function offsetUnset($offset)
public function offsetUnset($offset): void
{
$this->__unset($offset);
}

/**
* {@inheritdoc}
*/
#[\ReturnTypeWillChange]
public function jsonSerialize()
{
return $this->getData();
Expand All @@ -64,9 +68,7 @@ public function jsonSerialize()
*/
public function serialize()
{
$data = $this->getData();
$data['mappings_serialized'] = $this->context->getMappings();
return serialize($data);
return serialize($this->__serialize());
}

/**
Expand All @@ -76,4 +78,22 @@ public function unserialize($serialized)
{
$this->__construct(unserialize($serialized));
}

/**
* {@inheritdoc}
*/
public function __serialize(): array
{
$data = $this->getData();
$data['mappings_serialized'] = $this->context->getMappings();
return $data;
}

/**
* {@inheritdoc}
*/
public function __unserialize(array $serialized): void
{
$this->__construct($serialized);
}
}
2 changes: 1 addition & 1 deletion parents/Magic.php → src/parents/Magic.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public function __toString()
/**
* {@inheritdoc}
*/
public function count()
public function count(): int
{
return count($this->getData());
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 4 additions & 2 deletions tests/PosMapTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
/**
* coversDefaultClass axy\sourcemap\PosMap
*/
class PosMapTest extends \PHPUnit_Framework_TestCase
class PosMapTest extends \PHPUnit\Framework\TestCase
{
/**
* covers ::__construct
Expand Down Expand Up @@ -116,11 +116,13 @@ public function providerCreate()

/**
* covers ::__construct
* @expectedException \InvalidArgumentException
*
* @return \axy\sourcemap\PosMap
*/
public function testCreateInvalidArgument()
{
$this->expectException(\InvalidArgumentException::class);

return new PosMap(3);
}

Expand Down
9 changes: 0 additions & 9 deletions tests/bootstrap.php

This file was deleted.

11 changes: 7 additions & 4 deletions tests/classSourceMap/AddTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

namespace axy\sourcemap\tests\classSourceMap;

use axy\sourcemap\errors\IncompleteData;
use axy\sourcemap\errors\InvalidIndexed;
use axy\sourcemap\SourceMap;
use axy\sourcemap\PosMap;
use axy\sourcemap\PosGenerated;
Expand All @@ -15,7 +17,7 @@
/**
* coversDefaultClass axy\sourcemap\SourceMap
*/
class AddTest extends \PHPUnit_Framework_TestCase
class AddTest extends \PHPUnit\Framework\TestCase
{
/**
* @var array
Expand All @@ -37,7 +39,7 @@ class AddTest extends \PHPUnit_Framework_TestCase
/**
* {@inheritdoc}
*/
public function setUp()
public function setUp(): void
{
$this->map = new SourceMap($this->data);
}
Expand Down Expand Up @@ -156,8 +158,9 @@ public function testAddPositionArray()
public function testErrorIncompleteData($position, $error = true)
{
if ($error) {
$this->setExpectedException('axy\sourcemap\errors\IncompleteData');
$this->expectException(IncompleteData::class);
}

$this->map->addPosition($position);
}

Expand Down Expand Up @@ -221,7 +224,7 @@ public function providerErrorIncompleteData()
public function testErrorInvalidIndexed($position, $error = true)
{
if ($error) {
$this->setExpectedException('axy\sourcemap\errors\InvalidIndexed');
$this->expectException(InvalidIndexed::class);
}
$this->map->addPosition($position);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/classSourceMap/BlockTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
/**
* coversDefaultClass axy\sourcemap\SourceMap
*/
class BlockTest extends \PHPUnit_Framework_TestCase
class BlockTest extends \PHPUnit\Framework\TestCase
{
/**
* @var array
Expand Down Expand Up @@ -40,7 +40,7 @@ class BlockTest extends \PHPUnit_Framework_TestCase
/**
* {@inheritdoc}
*/
public function setUp()
public function setUp(): void
{
$this->posList = [];
$this->map = new SourceMap();
Expand Down
2 changes: 1 addition & 1 deletion tests/classSourceMap/ChangeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
/**
* coversDefaultClass axy\sourcemap\SourceMap
*/
class ChangeTest extends \PHPUnit_Framework_TestCase
class ChangeTest extends \PHPUnit\Framework\TestCase
{
public function testFileRename()
{
Expand Down
Loading