Skip to content

Commit 9ef12f9

Browse files
committed
Initial commit
0 parents  commit 9ef12f9

File tree

14 files changed

+504
-0
lines changed

14 files changed

+504
-0
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/.php_cs
2+
/.php_cs.cache
3+
/composer.lock
4+
/phpunit.xml
5+
/vendor/

.php_cs.dist

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?php
2+
3+
$header = <<<'EOF'
4+
This file is part of PHP CS Fixer.
5+
6+
(c) Fabien Potencier <[email protected]>
7+
Dariusz Rumiński <[email protected]>
8+
9+
This source file is subject to the MIT license that is bundled
10+
with this source code in the file LICENSE.
11+
EOF;
12+
13+
$config = PhpCsFixer\Config::create()
14+
->setRiskyAllowed(true)
15+
->setRules([
16+
'@PHP56Migration' => true,
17+
'@Symfony' => true,
18+
'@Symfony:risky' => true,
19+
'align_multiline_comment' => true,
20+
'array_syntax' => ['syntax' => 'long'],
21+
'blank_line_before_statement' => true,
22+
'combine_consecutive_unsets' => true,
23+
// one should use PHPUnit methods to set up expected exception instead of annotations
24+
'general_phpdoc_annotation_remove' => ['annotations' => ['expectedException', 'expectedExceptionMessage', 'expectedExceptionMessageRegExp']],
25+
'header_comment' => ['header' => $header],
26+
'heredoc_to_nowdoc' => true,
27+
'list_syntax' => ['syntax' => 'long'],
28+
'method_argument_space' => ['ensure_fully_multiline' => true],
29+
'no_extra_consecutive_blank_lines' => ['tokens' => ['break', 'continue', 'extra', 'return', 'throw', 'use', 'parenthesis_brace_block', 'square_brace_block', 'curly_brace_block']],
30+
'no_null_property_initialization' => true,
31+
'no_short_echo_tag' => true,
32+
'no_unreachable_default_argument_value' => true,
33+
'no_useless_else' => true,
34+
'no_useless_return' => true,
35+
'ordered_class_elements' => true,
36+
'ordered_imports' => true,
37+
'php_unit_strict' => true,
38+
'php_unit_test_class_requires_covers' => true,
39+
'phpdoc_add_missing_param_annotation' => true,
40+
'phpdoc_order' => true,
41+
'phpdoc_types_order' => true,
42+
'semicolon_after_instruction' => true,
43+
'single_line_comment_style' => true,
44+
'strict_comparison' => true,
45+
'strict_param' => true,
46+
])
47+
->setFinder(
48+
PhpCsFixer\Finder::create()
49+
->exclude('tests/Fixtures')
50+
->in(__DIR__)
51+
)
52+
;
53+
54+
// special handling of fabbot.io service if it's using too old PHP CS Fixer version
55+
try {
56+
PhpCsFixer\FixerFactory::create()
57+
->registerBuiltInFixers()
58+
->registerCustomFixers($config->getCustomFixers())
59+
->useRuleSet(new PhpCsFixer\RuleSet($config->getRules()));
60+
} catch (PhpCsFixer\ConfigurationException\InvalidConfigurationException $e) {
61+
$config->setRules([]);
62+
}
63+
64+
return $config;

.travis.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
language: php
2+
3+
sudo: false
4+
5+
git:
6+
depth: 1
7+
8+
cache:
9+
directories:
10+
- $HOME/.composer
11+
12+
env:
13+
global:
14+
- DEFAULT_COMPOSER_FLAGS="--no-interaction --no-progress"
15+
- COMPOSER_FLAGS=""
16+
17+
before_install:
18+
# turn off XDebug
19+
- phpenv config-rm xdebug.ini || return 0
20+
21+
# Composer: boost installation
22+
- composer global show -ND 2>&1 | grep "hirak/prestissimo" || travis_retry composer global require $DEFAULT_COMPOSER_FLAGS hirak/prestissimo
23+
24+
jobs:
25+
include:
26+
-
27+
stage: Static Code Analysis
28+
php: 7.1
29+
env: COMPOSER_FLAGS="--no-dev --prefer-stable"
30+
install:
31+
- travis_retry composer update -d dev-tools $DEFAULT_COMPOSER_FLAGS
32+
- composer info -d dev-tools -D | sort
33+
34+
- travis_retry composer update $DEFAULT_COMPOSER_FLAGS $COMPOSER_FLAGS
35+
- composer info -D | sort
36+
script:
37+
- ./check_trailing_spaces.sh || travis_terminate 1
38+
- ./dev-tools/vendor/bin/phpmd src,tests text phpmd.xml || travis_terminate 1
39+
- ./dev-tools/vendor/bin/composer-require-checker check composer.json || travis_terminate 1
40+
- ./dev-tools/vendor/bin/php-cs-fixer fix -v
41+
42+
- &STANDARD_TEST_JOB
43+
stage: Test
44+
php: 5.4
45+
install:
46+
- travis_retry composer update $DEFAULT_COMPOSER_FLAGS $COMPOSER_FLAGS
47+
- composer info -D | sort
48+
script:
49+
- vendor/bin/phpunit --verbose
50+
51+
-
52+
<<: *STANDARD_TEST_JOB
53+
php: 5.3
54+
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest"
55+
dist: precise
56+
57+
-
58+
<<: *STANDARD_TEST_JOB
59+
php: 5.5
60+
61+
-
62+
<<: *STANDARD_TEST_JOB
63+
php: 5.6
64+
65+
-
66+
<<: *STANDARD_TEST_JOB
67+
php: 7.0
68+
69+
-
70+
<<: *STANDARD_TEST_JOB
71+
php: 7.1
72+
73+
-
74+
<<: *STANDARD_TEST_JOB
75+
php: nightly
76+
env: SYMFONY_DEPRECATIONS_HELPER=weak

LICENSE

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Copyright (c) 2012-2017 Fabien Potencier
2+
Dariusz Rumiński
3+
4+
Permission is hereby granted, free of charge, to any person obtaining a copy
5+
of this software and associated documentation files (the "Software"), to deal
6+
in the Software without restriction, including without limitation the rights
7+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
copies of the Software, and to permit persons to whom the Software is furnished
9+
to do so, subject to the following conditions:
10+
11+
The above copyright notice and this permission notice shall be included in all
12+
copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+
THE SOFTWARE.

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# AccessibleObject
2+
3+
`AccessibleObject` is small class allowing you to easily access internals of any object.
4+
In general, it's bad practice to do so.
5+
While we strongly discourage you to using it, it may be helpful in debugging or testing old, sad, legacy projects.
6+
7+
# Example
8+
9+
```PHP
10+
<?php
11+
class Foo
12+
{
13+
private $bar = 'baz';
14+
}
15+
16+
$object = new Foo();
17+
echo $object->bar; // PHP Fatal error: Uncaught Error: Cannot access private property Foo::$bar
18+
19+
$accessibleObject = new AccessibleObject($object);
20+
echo $accessibleObject->bar; // 'baz'
21+
```

check_trailing_spaces.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
# copied from https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/v2.4.0/check_trailing_spaces.sh
4+
5+
files_with_trailing_spaces=$(find . -type f -not -path "./.git/*" -not -path "./dev-tools/vendor/*" -not -path "./vendor/*" -not -path "./tests/Fixtures/*" -exec egrep -nH " $" {} \;)
6+
7+
if [[ $files_with_trailing_spaces ]]
8+
then
9+
echo -e "\e[97;41mTrailing spaces detected:\e[0m"
10+
e=$(printf '\033')
11+
echo "${files_with_trailing_spaces}" | sed -E "s/^\.\/([^:]+):([0-9]+):(.*[^ ])( +)$/${e}[0;31m - in ${e}[0;33m\1${e}[0;31m at line ${e}[0;33m\2\n ${e}[0;31m>${e}[0m \3${e}[41m\4${e}[0m/"
12+
13+
exit 1
14+
fi
15+
16+
echo -e "\e[0;32mNo trailing spaces detected.\e[0m"

composer.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"name": "php-cs-fixer/accessible-object",
3+
"type": "application",
4+
"description": "A library to reveal object internals.",
5+
"license": "MIT",
6+
"authors": [
7+
{
8+
"name": "Fabien Potencier",
9+
"email": "[email protected]"
10+
},
11+
{
12+
"name": "Dariusz Rumiński",
13+
"email": "[email protected]"
14+
}
15+
],
16+
"require": {
17+
"php": "^5.3 || ^7.0"
18+
},
19+
"require-dev": {
20+
"phpunit/phpunit": "^4.8.35 || ^5.4.3",
21+
"symfony/phpunit-bridge": "^3.2.2"
22+
},
23+
"conflict": {
24+
"hhvm": "*"
25+
},
26+
"config": {
27+
"optimize-autoloader": true,
28+
"sort-packages": true
29+
},
30+
"autoload": {
31+
"psr-4": { "PhpCsFixer\\AccessibleObject\\": "src/" }
32+
},
33+
"autoload-dev": {
34+
"psr-4": { "PhpCsFixer\\AccessibleObject\\Tests\\": "tests/" }
35+
}
36+
}

dev-tools/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/composer.lock
2+
/vendor/

dev-tools/composer.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"require": {
3+
"php": "^7.0"
4+
},
5+
"require-dev": {
6+
"friendsofphp/php-cs-fixer": "^2.4",
7+
"maglnet/composer-require-checker": "^0.1.5",
8+
"mi-schi/phpmd-extension": "^4.2",
9+
"phpmd/phpmd": "^2.6"
10+
},
11+
"conflict": {
12+
"hhvm": "*"
13+
},
14+
"config": {
15+
"optimize-autoloader": true,
16+
"sort-packages": true
17+
}
18+
}

phpmd.xml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="friendsofphp/php-cs-fixer"
3+
xmlns="http://pmd.sf.net/ruleset/1.0.0"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
6+
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd"
7+
>
8+
<rule ref="rulesets/controversial.xml/CamelCaseClassName" />
9+
<rule ref="rulesets/controversial.xml/CamelCaseMethodName" />
10+
<rule ref="rulesets/controversial.xml/CamelCaseParameterName" />
11+
<rule ref="rulesets/controversial.xml/CamelCasePropertyName" />
12+
<rule ref="rulesets/controversial.xml/CamelCaseVariableName" />
13+
14+
<rule ref="rulesets/design.xml/DevelopmentCodeFragment" />
15+
<rule ref="rulesets/design.xml/EvalExpression" />
16+
<rule ref="rulesets/design.xml/ExitExpression" />
17+
<rule ref="rulesets/design.xml/GotoStatement" />
18+
19+
<rule ref="rulesets/naming.xml/ConstantNamingConventions" />
20+
21+
<rule ref="../../../../../mi-schi/phpmd-extension/rulesets/cleancode.xml/DataStructureMethods" />
22+
<rule ref="../../../../../mi-schi/phpmd-extension/rulesets/cleancode.xml/SwitchStatement" />
23+
24+
<rule ref="../../../../../mi-schi/phpmd-extension/rulesets/naming.xml/CommentDescription">
25+
<properties>
26+
<property name="percent" value="70" />
27+
</properties>
28+
</rule>
29+
</ruleset>

0 commit comments

Comments
 (0)