├── phpunit.xml.dist ├── LICENSE ├── src └── Coduo │ └── ToString │ └── StringConverter.php ├── README.md ├── composer.json ├── tests └── Coduo │ └── ToString │ └── Unit │ └── StringConverterTest.php ├── CHANGELOG.md └── .php-cs-fixer.php /phpunit.xml.dist: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | ./tests/ 11 | 12 | 13 | 14 | 15 | 16 | ./src/ 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014-2021 Michal Dabrowski, Norbert Orzechowicz 2 | 3 | Permission is hereby granted, free of charge, to any person 4 | obtaining a copy of this software and associated documentation 5 | files (the "Software"), to deal in the Software without 6 | restriction, including without limitation the rights to use, 7 | copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the 9 | Software is furnished to do so, subject to the following 10 | conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 17 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 19 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 20 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /src/Coduo/ToString/StringConverter.php: -------------------------------------------------------------------------------- 1 | value = $value; 18 | } 19 | 20 | public function __toString() 21 | { 22 | $type = \gettype($this->value); 23 | 24 | switch ($type) { 25 | case 'boolean': 26 | return $this->castBooleanToString(); 27 | case 'object': 28 | return $this->castObjectToString(); 29 | case 'array': 30 | return \sprintf('Array(%d)', \count($this->value)); 31 | case 'resource': 32 | return \sprintf('Resource(%s)', \get_resource_type($this->value)); 33 | case 'float': 34 | case 'double': 35 | default: 36 | return (string) $this->value; 37 | } 38 | } 39 | 40 | /** 41 | * @return string 42 | */ 43 | private function castBooleanToString() 44 | { 45 | return ($this->value) ? 'true' : 'false'; 46 | } 47 | 48 | /** 49 | * @return string 50 | */ 51 | private function castObjectToString() 52 | { 53 | return (\method_exists($this->value, '__toString')) 54 | ? (string) $this->value 55 | : '\\' . \get_class($this->value); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PHP To String 2 | 3 | Simple library that converts PHP values into strings. 4 | 5 | Status: 6 | 7 | ![Build Status](https://github.com/coduo/php-to-string/workflows/Tests/badge.svg?branch=3.x) 8 | [![Latest Stable Version](https://poser.pugx.org/coduo/php-to-string/v/stable)](https://packagist.org/packages/coduo/php-to-string) 9 | [![Total Downloads](https://poser.pugx.org/coduo/php-to-string/downloads)](https://packagist.org/packages/coduo/php-to-string) 10 | [![Latest Unstable Version](https://poser.pugx.org/coduo/php-to-string/v/unstable)](https://packagist.org/packages/coduo/php-to-string) 11 | [![License](https://poser.pugx.org/coduo/php-to-string/license)](https://packagist.org/packages/coduo/php-to-string) 12 | 13 | Simple library that allows you to cast any php value into string 14 | 15 | ## Installation 16 | 17 | ``` 18 | composer require coduo/php-to-string 19 | ``` 20 | 21 | ## Usage 22 | 23 | Supported types: 24 | 25 | * string 26 | * integer 27 | * float/double 28 | * object 29 | * callable 30 | * array 31 | * resource 32 | 33 | ```php 34 | use Coduo\ToString\StringConverter; 35 | 36 | $string = new StringConverter('foo'); 37 | echo $string; // "foo" 38 | 39 | $double = new StringConverter(1.12312); 40 | echo $double; // "1.12312" 41 | 42 | $integer = new StringConverter(1); 43 | echo $integer; // "1" 44 | 45 | $datetime = new StringConverter(new \DateTime()); 46 | echo $datetime; // "\DateTime" 47 | 48 | $array = new StringConverter(['foo', 'bar', 'baz']); 49 | echo $array; // "Array(3)" 50 | 51 | $res = fopen(sys_get_temp_dir() . "/foo", "w"); 52 | $resource = new StringConverter($res); 53 | echo $resource; // "Resource(stream)" 54 | 55 | ``` 56 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "coduo/php-to-string", 3 | "type": "library", 4 | "description": "Simple library that converts PHP value into strings", 5 | "keywords": ["string", "php", "to string", "to"], 6 | "license": "MIT", 7 | "authors": [ 8 | { 9 | "name": "Michał Dąbrowski", 10 | "email": "dabrowski@brillante.pl" 11 | }, 12 | { 13 | "name": "Norbert Orzechowicz", 14 | "email": "norbert@orzechowicz.pl" 15 | } 16 | ], 17 | "require": { 18 | "php": ">=7.2" 19 | }, 20 | "autoload": { 21 | "psr-4": { 22 | "Coduo\\ToString\\" : "src/Coduo/ToString" 23 | } 24 | }, 25 | "autoload-dev": { 26 | "psr-4": { 27 | "Coduo\\ToString\\": "tests/Coduo/ToString" 28 | } 29 | }, 30 | "suggest": { 31 | "ext-intl": "Required if you are going to use humanizer with locales different than en_EN" 32 | }, 33 | "scripts": { 34 | "build": [ 35 | "@static:analyze", 36 | "@test" 37 | ], 38 | "cs:php:fix": [ 39 | "tools/vendor/bin/php-cs-fixer fix --using-cache=no" 40 | ], 41 | "test" : [ 42 | "tools/vendor/bin/phpunit" 43 | ], 44 | "static:analyze": [ 45 | "tools/vendor/bin/php-cs-fixer fix --dry-run" 46 | ], 47 | "post-install-cmd": [ 48 | "@tools:install" 49 | ], 50 | "post-update-cmd": [ 51 | "@tools:install" 52 | ], 53 | "tools:install": [ 54 | "composer install --working-dir=./tools" 55 | ] 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /tests/Coduo/ToString/Unit/StringConverterTest.php: -------------------------------------------------------------------------------- 1 | assertSame('Array(2)', $converter->__toString()); 16 | } 17 | 18 | public function test_convert_boolean_to_string() : void 19 | { 20 | $converter = new StringConverter(true); 21 | $this->assertSame('true', $converter->__toString()); 22 | } 23 | 24 | public function test_convert_closure_to_string() : void 25 | { 26 | $converter = new StringConverter(function () { 27 | return 'test'; 28 | }); 29 | $this->assertSame('\Closure', $converter->__toString()); 30 | } 31 | 32 | public function test_convert_double_to_string_for_specific_locale() : void 33 | { 34 | $converter = new StringConverter(1000.10002); 35 | $this->assertSame('1000.10002', $converter->__toString()); 36 | } 37 | 38 | public function test_convert_float_to_string() : void 39 | { 40 | $converter = new StringConverter(1.1); 41 | $this->assertSame('1.1', $converter->__toString()); 42 | } 43 | 44 | public function test_convert_integer_to_string() : void 45 | { 46 | $converter = new StringConverter(20); 47 | $this->assertSame('20', $converter->__toString()); 48 | } 49 | 50 | public function test_convert_object_std_class_to_string() : void 51 | { 52 | $converter = new StringConverter(new \stdClass); 53 | $this->assertSame('\stdClass', $converter->__toString()); 54 | } 55 | 56 | public function test_convert_object_with_too_string_to_string() : void 57 | { 58 | $converter = new StringConverter(new class() { 59 | public function __toString() : string 60 | { 61 | return 'This is Foo'; 62 | } 63 | }); 64 | $this->assertSame('This is Foo', $converter->__toString()); 65 | } 66 | 67 | public function test_convert_resource_to_string() : void 68 | { 69 | $resource = \fopen(\sys_get_temp_dir() . '/foo', 'w'); 70 | $converter = new StringConverter($resource); 71 | $this->assertSame('Resource(stream)', $converter->__toString()); 72 | \fclose($resource); 73 | \unlink(\sys_get_temp_dir() . '/foo'); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## [3.2.2] - 2025-12-02 2 | 3 | ### Changed 4 | - [653fd3](https://github.com/coduo/php-to-string/commit/653fd3b35a87b1c8b062cc5323eb9136841c7047) - **Upgrade cache action from v2 to v4** - [@norberttech](https://github.com/norberttech) 5 | - [#18](https://github.com/coduo/php-to-string/pull/18) - **extended and adjusted CI to run on relevant PHP versions** - [@smoench](https://github.com/smoench) 6 | 7 | ## [3.2.1] - 2023-03-28 8 | 9 | ### Changed 10 | - [#16](https://github.com/coduo/php-to-string/pull/16) - **Add more examples about StringConverter usage** - [@peter279k](https://github.com/peter279k) 11 | - [f5b135](https://github.com/coduo/php-to-string/commit/f5b135b61adaaef91de8360961bf0b66bd796a6a) - **Delete FUNDING.yml** - [@norberttech](https://github.com/norberttech) 12 | 13 | ### Updated 14 | - [babb44](https://github.com/coduo/php-to-string/commit/babb445fe613b7c4f780451b640a2030633476b1) - **dependencies & tools** - [@norberttech](https://github.com/norberttech) 15 | - [746029](https://github.com/coduo/php-to-string/commit/7460296e14f15977a64c14b05c77d5fcce4fb764) - **static-analyze.yml** - [@norberttech](https://github.com/norberttech) 16 | - [0681cd](https://github.com/coduo/php-to-string/commit/0681cdf4b6cdac34ef592227833f695f3e5acb6f) - **testsuite.yml** - [@norberttech](https://github.com/norberttech) 17 | - [442b5f](https://github.com/coduo/php-to-string/commit/442b5ffc0bd17de21b4c5a1b12cbfbe12aae88e0) - **php-cs-fixer dependency** - [@norberttech](https://github.com/norberttech) 18 | 19 | ## [3.2.0] - 2021-02-23 20 | 21 | ### Changed 22 | - [1e6528](https://github.com/coduo/php-to-string/commit/1e6528fb7ffe4b44dabe4c9f536d29728d911b6a) - **Migrated from phpspec to phpunit, added integration with aeon-php/automation** - [@norberttech](https://github.com/norberttech) 23 | 24 | ### Fixed 25 | - [ae6aed](https://github.com/coduo/php-to-string/commit/ae6aedabe8dc30c269f8a758e22f818ad19dbf66) - **lowest supported version of phpunit** - [@norberttech](https://github.com/norberttech) 26 | 27 | ### Removed 28 | - [ba7b64](https://github.com/coduo/php-to-string/commit/ba7b647f3b1bf5a34d74bc6a1559533ecded8be6) - **symfony/intl dependency** - [@norberttech](https://github.com/norberttech) 29 | 30 | ## [3.1.0] - 2020-09-27 31 | 32 | ### Added 33 | - [4c3902](https://github.com/coduo/php-to-string/commit/4c39029921aa1ead4d156e81dc9eac4dfc121e11) - **poser.pugx.org badges** - [@norberttech](https://github.com/norberttech) 34 | 35 | ### Changed 36 | - [#14](https://github.com/coduo/php-to-string/pull/14) - **dependencies** - [@norberttech](https://github.com/norberttech) 37 | - [37176c](https://github.com/coduo/php-to-string/commit/37176cfff780473b5aedd89f5734d7cad6c7588e) - **master branch alias** - [@norberttech](https://github.com/norberttech) 38 | 39 | ## [3.0.0] - 2019-11-23 40 | 41 | ### Added 42 | - [#11](https://github.com/coduo/php-to-string/pull/11) - **missing dependency and moved from travis to github actions** - [@norberttech](https://github.com/norberttech) 43 | 44 | ### Changed 45 | - [6ee3db](https://github.com/coduo/php-to-string/commit/6ee3dbd06fbff934673f2e59094158cf187400b2) - **Update README.md** - [@norberttech](https://github.com/norberttech) 46 | - [d8b1dd](https://github.com/coduo/php-to-string/commit/d8b1dd1986b2da58dbdd83f19a910229c0802bf3) - **Run testsuite also on pushes to master** - [@norberttech](https://github.com/norberttech) 47 | - [#12](https://github.com/coduo/php-to-string/pull/12) - **Switch to short array notation** - [@norberttech](https://github.com/norberttech) 48 | 49 | ### Removed 50 | - [#13](https://github.com/coduo/php-to-string/pull/13) - **php 7.0 & 7.1 support** - [@norberttech](https://github.com/norberttech) 51 | 52 | ## [2.0.2] - 2019-08-09 53 | 54 | ### Added 55 | - [#8](https://github.com/coduo/php-to-string/pull/8) - **intl extension as required dependency** - [@teklakct](https://github.com/teklakct) 56 | 57 | ### Fixed 58 | - [#7](https://github.com/coduo/php-to-string/pull/7) - **minor typo** - [@sdaoudi](https://github.com/sdaoudi) 59 | 60 | ### Removed 61 | - [#9](https://github.com/coduo/php-to-string/pull/9) - **non supported php versions from Travis build** - [@norberttech](https://github.com/norberttech) 62 | 63 | ## [2.0.1] - 2016-01-20 64 | 65 | ### Changed 66 | - [4c1d7e](https://github.com/coduo/php-to-string/commit/4c1d7e2e76017719edc70e944ace0ec570748a78) - **Merge pull request #6 from jakzal/symfony-intl-3** - [@norzechowicz](https://github.com/norzechowicz) 67 | - [#6](https://github.com/coduo/php-to-string/pull/6) - **Remove an optional dependency on symfony/intl** - [@jakzal](https://github.com/jakzal) 68 | 69 | ## [2.0.0] - 2015-12-13 70 | 71 | ### Added 72 | - [#5](https://github.com/coduo/php-to-string/pull/5) - **support for php7** - [@norberttech](https://github.com/norberttech) 73 | 74 | ### Changed 75 | - [5a55f3](https://github.com/coduo/php-to-string/commit/5a55f3bd3af772175b458ce48648a36a1d15b54a) - **Merge pull request #5 from norzechowicz/php7-support** - [@norzechowicz](https://github.com/norzechowicz) 76 | 77 | ## [1.0.2] - 2015-12-13 78 | 79 | ### Changed 80 | - [#4](https://github.com/coduo/php-to-string/pull/4) - **travis.ci configuration file** - [@norberttech](https://github.com/norberttech) 81 | - [fb3f87](https://github.com/coduo/php-to-string/commit/fb3f879af3878310bd05c35fbec7256b4aeaf58c) - **Merge pull request #4 from norzechowicz/travis** - [@norzechowicz](https://github.com/norzechowicz) 82 | 83 | ## [1.0.1] - 2014-10-18 84 | 85 | ### Added 86 | - [a92b47](https://github.com/coduo/php-to-string/commit/a92b47db643541baa7ea9c61ea427a6896676685) - **symfony2/intl fixed phpspec extensions** - [@norberttech](https://github.com/norberttech) 87 | 88 | ### Changed 89 | - [a24f4c](https://github.com/coduo/php-to-string/commit/a24f4c97278fafa69cea2c180a036b2b207ab204) - **Update composer.json** - [@norberttech](https://github.com/norberttech) 90 | - [5ad9be](https://github.com/coduo/php-to-string/commit/5ad9be49ecfe0e832066bf86dca65ea9a197891e) - **Update README.md** - [@norberttech](https://github.com/norberttech) 91 | 92 | ## [v0.1.0] - 2014-05-08 93 | 94 | ### Changed 95 | - [420928](https://github.com/coduo/php-to-string/commit/42092807d4efab4c0c6c7782ab085978de4f4ce9) - **Travis.yml CS fix** - [@norberttech](https://github.com/norberttech) 96 | - [616f6f](https://github.com/coduo/php-to-string/commit/616f6f7dfd47056f39d332d34d9ade395715e6fd) - **Use PhpSpecDataProviderExtension to improve specs readabilty** - [@norberttech](https://github.com/norberttech) 97 | - [f519ef](https://github.com/coduo/php-to-string/commit/f519ef20ec15ba7030daa6315a3090e2a8964efa) - **Update README.md** - [@norberttech](https://github.com/norberttech) 98 | - [dc133b](https://github.com/coduo/php-to-string/commit/dc133bcded367ab1495846d934ef003f92143ee8) - **Update README.md** - [@norberttech](https://github.com/norberttech) 99 | - [f6034a](https://github.com/coduo/php-to-string/commit/f6034a859c7ce9e3b98521df7d27779cccfe7b01) - **Initial commit** - [@norberttech](https://github.com/norberttech) 100 | 101 | ### Fixed 102 | - [7e29aa](https://github.com/coduo/php-to-string/commit/7e29aa926156d7952ea070af19066eac830192a2) - **travis configuration** - [@norberttech](https://github.com/norberttech) 103 | 104 | ## Contributors 105 | 106 | - @jakzal 107 | - @norberttech 108 | - @norzechowicz 109 | - @peter279k 110 | - @sdaoudi 111 | - @smoench 112 | - @teklakct 113 | 114 | Generated by [Automation](https://github.com/aeon-php/automation) -------------------------------------------------------------------------------- /.php-cs-fixer.php: -------------------------------------------------------------------------------- 1 | files() 5 | ->in([ 6 | __DIR__ . '/src', 7 | __DIR__ . '/tests' 8 | ]); 9 | 10 | if (!\file_exists(__DIR__ . '/var')) { 11 | \mkdir(__DIR__ . '/var'); 12 | } 13 | 14 | if (!\file_exists(__DIR__ . '/var/cs-fixer')) { 15 | \mkdir(__DIR__ . '/var/cs-fixer'); 16 | } 17 | 18 | return (new PhpCsFixer\Config()) 19 | ->setRiskyAllowed(true) 20 | ->setCacheFile(__DIR__.'/var/cs-fixer/php_cs.cache') 21 | ->setRules([ 22 | 'align_multiline_comment' => true, 23 | 'array_indentation' => true, 24 | 'array_syntax' => ['syntax' => 'short'], 25 | 'blank_line_after_namespace' => true, 26 | 'blank_line_before_statement' => [ 27 | 'statements' => [ 28 | 'break', 29 | 'continue', 30 | 'declare', 31 | 'default', 32 | 'do', 33 | 'exit', 34 | 'for', 35 | 'foreach', 36 | 'goto', 37 | 'if', 38 | 'include', 39 | 'include_once', 40 | 'require', 41 | 'require_once', 42 | 'return', 43 | 'switch', 44 | 'throw', 45 | 'try', 46 | 'while', 47 | ], 48 | ], 49 | 'braces' => true, 50 | 'cast_spaces' => true, 51 | 'class_attributes_separation' => ['elements' => ['const' => 'one', 'method' => 'one', 'property' => 'one']], 52 | 'combine_consecutive_issets' => true, 53 | 'combine_consecutive_unsets' => true, 54 | 'compact_nullable_typehint' => true, 55 | 'concat_space' => ['spacing' => 'one'], 56 | 'constant_case' => true, 57 | 'declare_equal_normalize' => ['space' => 'none'], 58 | 'declare_strict_types' => true, 59 | 'dir_constant' => true, 60 | 'elseif' => true, 61 | 'encoding' => true, 62 | 'explicit_indirect_variable' => true, 63 | 'explicit_string_variable' => true, 64 | 'full_opening_tag' => true, 65 | 'fully_qualified_strict_types' => true, 66 | 'function_typehint_space' => true, 67 | 'function_declaration' => true, 68 | 'global_namespace_import' => [ 69 | 'import_classes' => false, 70 | 'import_constants' => false, 71 | 'import_functions' => false, 72 | ], 73 | 'heredoc_to_nowdoc' => true, 74 | 'increment_style' => [ 75 | 'style' => PhpCsFixer\Fixer\Operator\IncrementStyleFixer::STYLE_POST, 76 | ], 77 | 'indentation_type' => true, 78 | 'is_null' => true, 79 | 'line_ending' => true, 80 | 'list_syntax' => ['syntax' => 'short'], 81 | 'logical_operators' => true, 82 | 'lowercase_keywords' => true, 83 | 'lowercase_static_reference' => true, 84 | 'magic_constant_casing' => true, 85 | 'magic_method_casing' => true, 86 | 'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'], 87 | 'modernize_types_casting' => false, 88 | 'multiline_comment_opening_closing' => true, 89 | 'multiline_whitespace_before_semicolons' => true, 90 | 'native_constant_invocation' => false, 91 | 'native_function_casing' => false, 92 | 'native_function_invocation' => ['include' => ['@all']], 93 | 'native_function_type_declaration_casing' => true, 94 | 'new_with_braces' => false, 95 | 'no_alias_functions' => true, 96 | 'no_alternative_syntax' => true, 97 | 'no_blank_lines_after_class_opening' => true, 98 | 'no_blank_lines_after_phpdoc' => true, 99 | 'no_blank_lines_before_namespace' => false, 100 | 'no_closing_tag' => true, 101 | 'no_empty_comment' => true, 102 | 'no_empty_phpdoc' => true, 103 | 'no_empty_statement' => true, 104 | 'no_extra_blank_lines' => true, 105 | 'no_homoglyph_names' => true, 106 | 'no_leading_import_slash' => true, 107 | 'no_leading_namespace_whitespace' => true, 108 | 'no_mixed_echo_print' => ['use' => 'print'], 109 | 'no_multiline_whitespace_around_double_arrow' => true, 110 | 'no_null_property_initialization' => true, 111 | 'no_php4_constructor' => true, 112 | 'no_short_bool_cast' => true, 113 | 'echo_tag_syntax' => true, 114 | 'no_singleline_whitespace_before_semicolons' => true, 115 | 'no_spaces_after_function_name' => true, 116 | 'no_spaces_around_offset' => true, 117 | 'no_spaces_inside_parenthesis' => true, 118 | 'no_superfluous_elseif' => true, 119 | 'no_superfluous_phpdoc_tags' => false, 120 | 'no_trailing_comma_in_list_call' => true, 121 | 'no_trailing_comma_in_singleline_array' => true, 122 | 'no_trailing_whitespace' => true, 123 | 'no_trailing_whitespace_in_comment' => true, 124 | 'no_unneeded_control_parentheses' => true, 125 | 'no_unneeded_curly_braces' => true, 126 | 'no_unneeded_final_method' => true, 127 | 'no_unreachable_default_argument_value' => true, 128 | 'no_unset_on_property' => true, 129 | 'no_unused_imports' => true, 130 | 'no_useless_else' => true, 131 | 'no_useless_return' => true, 132 | 'no_whitespace_before_comma_in_array' => true, 133 | 'no_whitespace_in_blank_line' => true, 134 | 'non_printable_character' => true, 135 | 'normalize_index_brace' => true, 136 | 'object_operator_without_whitespace' => true, 137 | 'ordered_class_elements' => [ 138 | 'order' => [ 139 | 'use_trait', 140 | 'constant_public', 141 | 'constant_protected', 142 | 'constant_private', 143 | 'property_public_static', 144 | 'property_protected_static', 145 | 'property_private_static', 146 | 'property_public', 147 | 'property_protected', 148 | 'property_private', 149 | 'construct', 150 | 'method_public_static', 151 | 'destruct', 152 | 'magic', 153 | 'phpunit', 154 | 'method_public', 155 | 'method_protected', 156 | 'method_private', 157 | 'method_protected_static', 158 | 'method_private_static', 159 | ], 160 | 'sort_algorithm' => 'alpha' 161 | ], 162 | 'ordered_imports' => [ 163 | 'imports_order' => [ 164 | PhpCsFixer\Fixer\Import\OrderedImportsFixer::IMPORT_TYPE_CONST, 165 | PhpCsFixer\Fixer\Import\OrderedImportsFixer::IMPORT_TYPE_FUNCTION, 166 | PhpCsFixer\Fixer\Import\OrderedImportsFixer::IMPORT_TYPE_CLASS, 167 | ] 168 | ], 169 | 'ordered_interfaces' => [ 170 | 'direction' => 'ascend', 171 | 'order' => 'alpha', 172 | ], 173 | 'phpdoc_add_missing_param_annotation' => false, 174 | 'phpdoc_align' => ['align' => 'left'], 175 | 'phpdoc_annotation_without_dot' => true, 176 | 'phpdoc_indent' => true, 177 | 'phpdoc_no_access' => true, 178 | 'phpdoc_no_empty_return' => true, 179 | 'phpdoc_no_package' => true, 180 | 'phpdoc_order' => true, 181 | 'phpdoc_return_self_reference' => true, 182 | 'phpdoc_scalar' => true, 183 | 'phpdoc_separation' => true, 184 | 'phpdoc_single_line_var_spacing' => true, 185 | 'phpdoc_summary' => true, 186 | 'phpdoc_to_comment' => false, 187 | 'phpdoc_trim' => true, 188 | 'phpdoc_trim_consecutive_blank_line_separation' => true, 189 | 'phpdoc_types' => ['groups' => ['simple', 'meta']], 190 | 'phpdoc_types_order' => true, 191 | 'phpdoc_var_without_name' => true, 192 | 'pow_to_exponentiation' => true, 193 | 'protected_to_private' => true, 194 | 'return_assignment' => false, 195 | 'return_type_declaration' => ['space_before' => 'one'], 196 | 'self_accessor' => true, 197 | 'self_static_accessor' => true, 198 | 'semicolon_after_instruction' => true, 199 | 'set_type_to_cast' => true, 200 | 'short_scalar_cast' => true, 201 | 'simple_to_complex_string_variable' => true, 202 | 'simplified_null_return' => false, 203 | 'single_blank_line_at_eof' => true, 204 | 'single_import_per_statement' => true, 205 | 'single_line_after_imports' => true, 206 | 'single_quote' => true, 207 | 'standardize_not_equals' => true, 208 | 'strict_param' => true, 209 | 'ternary_to_null_coalescing' => true, 210 | 'trailing_comma_in_multiline' => true, 211 | 'trim_array_spaces' => true, 212 | 'unary_operator_spaces' => true, 213 | 'visibility_required' => [ 214 | 'elements' => [ 215 | 'const', 216 | 'method', 217 | 'property', 218 | ], 219 | ], 220 | 'void_return' => true, 221 | 'whitespace_after_comma_in_array' => true, 222 | ]) 223 | ->setFinder($finder); 224 | --------------------------------------------------------------------------------