Skip to content

Commit

Permalink
Merge branch 'chore/ci' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
etki committed Jan 10, 2018
2 parents 8f98178 + c9ac697 commit 0679fe7
Show file tree
Hide file tree
Showing 10 changed files with 207 additions and 14 deletions.
111 changes: 111 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
parameters:
jabba:
version: &jabba_version 0.9.2
cache_key: &jabba_cache_key v1-jabba-0.9.2
java:
version: &java_version zulu@1.9.0
allure:
version: &allure_version 2.5.0
cache_key: &allure_cache_key v1-allure-2.5.0
composer:
cache_key: &composer_cache_key v1-composer-{{ checksum "composer.json" }}
docker:
image:
php: &php_docker_image circleci/php:5.6
version: 2
jobs:
build:
docker:
- image: *php_docker_image
working_directory: /tmp/workspace
environment:
JABBA_VERSION: *jabba_version
JAVA_VERSION: *java_version
ALLURE_VERSION: *allure_version
steps:
- checkout
- restore_cache:
key: *jabba_cache_key
- run:
name: 'Setup: Install Jabba & Java'
command: |
set -euxo pipefail
sudo ln -sf ~/.jabba/bin/jabba /usr/local/bin/jabba
[ ! -d ~/.jabba ] || exit 0
curl -sL https://github.com/shyiko/jabba/raw/master/install.sh | bash && . ~/.jabba/jabba.sh
jabba install $JAVA_VERSION
- save_cache:
key: *jabba_cache_key
paths:
- ~/.jabba
- restore_cache:
key: *allure_cache_key
- run:
name: 'Setup: Install Allure'
command: |
set -euxo pipefail
sudo ln -sf ~/allure/bin/allure /usr/local/bin/allure
[ ! $(which allure) ] || exit 0
curl -L "https://dl.bintray.com/qameta/generic/io/qameta/allure/allure/$ALLURE_VERSION/allure-$ALLURE_VERSION.zip" > /tmp/allure.zip
unzip /tmp/allure.zip -d /tmp/allure
mkdir -p ~/allure
sudo mv /tmp/allure/*/* ~/allure
- save_cache:
key: *allure_cache_key
paths:
- ~/allure
- run:
name: 'Setup: Install PHP Extensions'
command: sudo docker-php-ext-install bcmath
- restore_cache:
key: *composer_cache_key
- run:
name: 'Setup: Composer Install'
command: composer install --no-progress
- save_cache:
key: *composer_cache_key
paths:
- vendor
- run:
name: 'Setup: Enabling XDebug'
command: sudo docker-php-ext-enable xdebug
- run:
name: 'Setup: Configure PHP'
command: |
echo 'memory_limit = -1' | sudo tee -a /usr/local/etc/php/php.ini
echo 'date.timezone = UTC' | sudo tee -a /usr/local/etc/php/php.ini
- run:
name: 'Setup: Build Codeception Actors'
command: bin/codecept build
- run:
name: 'Setup: Ensure /src exists'
command: mkdir -p src
- run:
name: 'Lint: Syntax'
command: "[ -z \"$(find src -name '*.php')\" ] || bin/parallel-lint -j $(nproc) src"
when: always
- run:
name: 'Lint: Formatting'
command: bin/phpcs --standard=PSR2 src
when: always
- run:
name: 'Lint: Complexity'
command: bin/phpmd src text tests/Support/PHPMD/ruleset.xml
when: always
- run:
name: Test
command: bin/codecept run --coverage --coverage-xml --coverage-html
- run:
name: 'Test: Publish Coverage'
command: bin/php-coveralls
- run:
name: 'Report: Generate'
command: |
export JAVA_HOME="$(jabba which $JAVA_VERSION)"
allure generate --clean --output tests/Report/Allure -- tests/Metadata/Allure
- store_artifacts:
path: tests/Report
when: always
- store_test_results:
path: tests/Metadata
when: always
2 changes: 2 additions & 0 deletions .coveralls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
coverage_clover: tests/Report/coverage.xml
json_path: tests/Metadata/coveralls.json
17 changes: 17 additions & 0 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
build:
environment:
php: 7.1
elasticsearch: true
tests:
before:
- bin/codecept build
override:
- command: bin/codecept run --coverage --coverage-xml --coverage-html
coverage:
file: tests/Report/coverage.xml
format: php-clover
checks:
php: true
filter:
paths:
- src/*
23 changes: 19 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# WIP note

This is a work-in-progress project, it is not ready yet

# AmaTeam\TreeAccess

[![Packagist](https://img.shields.io/packagist/v/ama-team/tree-access.svg?style=flat-square)](https://packagist.org/packages/ama-team/tree-access)
[![CircleCI/master](https://img.shields.io/circleci/project/github/ama-team/php-tree-access/master.svg?style=flat-square)](https://circleci.com/gh/ama-team/php-tree-access/tree/master)
[![Coveralls/master](https://img.shields.io/coveralls/github/ama-team/php-tree-access/master.svg?style=flat-square)](https://coveralls.io/github/ama-team/php-tree-access?branch=master)
[![Scrutinizer/master](https://img.shields.io/scrutinizer/g/ama-team/php-tree-access/master.svg?style=flat-square)](https://scrutinizer-ci.com/g/ama-team/php-tree-access?branch=master)

This tiny project allows to read, enumerate and write properties /
elements in a nested tree consisting of arrays and objects.

Expand Down Expand Up @@ -50,3 +51,17 @@ node).

As of 0.1.x, possible performance optimizations are sacrificed for
simplicity.

## Contributing

Feel free to send PR to **dev** branch

## Dev branch state

[![CircleCI/dev](https://img.shields.io/circleci/project/github/ama-team/php-tree-access/dev.svg?style=flat-square)](https://circleci.com/gh/ama-team/php-tree-access/tree/dev)
[![Coveralls/dev](https://img.shields.io/coveralls/github/ama-team/php-tree-access/dev.svg?style=flat-square)](https://coveralls.io/github/ama-team/php-tree-access?branch=dev)
[![Scrutinizer/dev](https://img.shields.io/scrutinizer/g/ama-team/php-tree-access/dev.svg?style=flat-square)](https://scrutinizer-ci.com/g/ama-team/php-tree-access?branch=dev)

## Licensing

MIT License / AMA Team, 2018
8 changes: 6 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,14 @@
"bin-dir": "bin"
},
"require": {
"psr/simple-cache": "^1.0",
"php": ">= 5.6",
"allure-framework/allure-codeception": "^1.2"
},
"require-dev": {
"codeception/codeception": "^2.3"
"codeception/codeception": "^2.3",
"jakub-onderka/php-parallel-lint": "^0.9.2",
"phpmd/phpmd": "^2.6",
"squizlabs/php_codesniffer": "^3.2",
"php-coveralls/php-coveralls": "^2.0"
}
}
2 changes: 2 additions & 0 deletions src/Metadata/PropertyMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class PropertyMetadata implements PropertyMetadataInterface
* @param bool $virtual
* @param null|string $setter
* @param null|string $getter
*
* @SuppressWarnings(PHPMD.BooleanArgumentFlag)
*/
public function __construct(
$name,
Expand Down
2 changes: 2 additions & 0 deletions src/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class Node implements NodeInterface
* @param mixed $value
* @param bool $readable
* @param bool $writable
*
* @SuppressWarnings(PHPMD.BooleanArgumentFlag)
*/
public function __construct(
array $path,
Expand Down
14 changes: 8 additions & 6 deletions src/Type/ObjectAccessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ public function __construct(ManagerInterface $metadataManger = null)
* @param object $object
* @param string $property
* @return NodeInterface
*
* @SuppressWarnings(PHPMD.ElseExpression)
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
public function read(&$object, $property)
{
Expand All @@ -44,7 +47,7 @@ public function read(&$object, $property)
$native = $metadata && !$metadata->isVirtual();
if ($standard || $native) {
$value = $object->$property;
} else if ($metadata && $metadata->getGetter() !== null) {
} elseif ($metadata && $metadata->getGetter() !== null) {
$getter = $metadata->getGetter();
$value = $getter ? call_user_func([$object, $getter]) : null;
} else {
Expand Down Expand Up @@ -72,14 +75,13 @@ public function write(&$object, $property, $value)
if ($standard || $native) {
$object->$property = $value;
return new Node([$property], $value);
} else if ($metadata && $metadata->getSetter() !== null) {
} elseif ($metadata && $metadata->getSetter() !== null) {
call_user_func([$object, $metadata->getSetter()], $value);
return new Node([$property], $value);
} else {
$template = 'Can\'t access property `%s` on target of class `%s`';
$message = sprintf($template, $property, get_class($object));
throw new IllegalTargetException([$property], $message);
}
$template = 'Can\'t access property `%s` on target of class `%s`';
$message = sprintf($template, $property, get_class($object));
throw new IllegalTargetException([$property], $message);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use PHPUnit\Framework\Assert;
use stdClass;

class EnumerationTest extends Unit
class NodesEnumerationTest extends Unit
{
public function dataProvider()
{
Expand All @@ -37,7 +37,7 @@ public function dataProvider()
public function testEnumeration($structure, $path, $expectation)
{
$accessor = TreeAccess::createAccessorBuilder()->build();
$nodes = $accessor->enumerate($structure, $path);
$nodes = $accessor->enumerateNodes($structure, $path);
$methods = ['getValue', 'getPath', 'isWritable', 'isReadable'];
/**
* @var string $name
Expand Down
38 changes: 38 additions & 0 deletions tests/Support/PHPMD/ruleset.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0"?>
<ruleset name="My first PHPMD rule set"
xmlns="http://pmd.sf.net/ruleset/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
<description>
Default rules overrides
</description>

<rule ref="rulesets/cleancode.xml">
<exclude name="StaticAccess"/>
</rule>

<rule ref="rulesets/codesize.xml"/>

<rule ref="rulesets/controversial.xml"/>

<rule ref="rulesets/design.xml">
<exclude name="CouplingBetweenObjects"/>
</rule>
<rule ref="rulesets/design.xml/CouplingBetweenObjects">
<properties>
<property name="minimum" value="15"/>
</properties>
</rule>

<rule ref="rulesets/naming.xml">
<exclude name="ShortVariable"/>
</rule>
<rule ref="rulesets/naming.xml/ShortVariable">
<properties>
<property name="exceptions" value="id"/>
</properties>
</rule>

<rule ref="rulesets/unusedcode.xml"/>
</ruleset>

0 comments on commit 0679fe7

Please sign in to comment.