mirror of
https://github.com/wiosna-dev/common-library.git
synced 2026-03-12 09:31:51 +01:00
Coding standard > fix automatically
This commit is contained in:
@@ -8,3 +8,4 @@ Common and useful classes, methods, exceptions etc.
|
|||||||
3. Docker: use project-related binaries globally
|
3. Docker: use project-related binaries globally
|
||||||
4. StyleCI & PHP Coding Standards Fixer: update configuration
|
4. StyleCI & PHP Coding Standards Fixer: update configuration
|
||||||
5. Documentation > Docker > add paragraph for PHP Coding Standards Fixer
|
5. Documentation > Docker > add paragraph for PHP Coding Standards Fixer
|
||||||
|
6. Coding standard > fix automatically
|
||||||
|
|||||||
@@ -24,9 +24,8 @@ class Bundle
|
|||||||
* @param string $viewPath Path of the view / template, e.g. "MyDirectory/my-template"
|
* @param string $viewPath Path of the view / template, e.g. "MyDirectory/my-template"
|
||||||
* @param string $bundleName Full name of the bundle, e.g. "MyExtraBundle"
|
* @param string $bundleName Full name of the bundle, e.g. "MyExtraBundle"
|
||||||
* @param string $extension (optional) Extension of the view / template (default: "html.twig")
|
* @param string $extension (optional) Extension of the view / template (default: "html.twig")
|
||||||
* @return string|null
|
|
||||||
*
|
|
||||||
* @throws IncorrectBundleNameException
|
* @throws IncorrectBundleNameException
|
||||||
|
* @return string|null
|
||||||
*/
|
*/
|
||||||
public static function getBundleViewPath($viewPath, $bundleName, $extension = 'html.twig')
|
public static function getBundleViewPath($viewPath, $bundleName, $extension = 'html.twig')
|
||||||
{
|
{
|
||||||
@@ -65,9 +64,8 @@ class Bundle
|
|||||||
* Returns short name of bundle (without "Bundle")
|
* Returns short name of bundle (without "Bundle")
|
||||||
*
|
*
|
||||||
* @param string $fullBundleName Full name of the bundle, e.g. "MyExtraBundle"
|
* @param string $fullBundleName Full name of the bundle, e.g. "MyExtraBundle"
|
||||||
* @return string|null
|
|
||||||
*
|
|
||||||
* @throws IncorrectBundleNameException
|
* @throws IncorrectBundleNameException
|
||||||
|
* @return string|null
|
||||||
*/
|
*/
|
||||||
public static function getShortBundleName($fullBundleName)
|
public static function getShortBundleName($fullBundleName)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -68,9 +68,8 @@ class Date
|
|||||||
* The dates are returned in an array with indexes 'start' and 'end'.
|
* The dates are returned in an array with indexes 'start' and 'end'.
|
||||||
*
|
*
|
||||||
* @param int $period The period, type of period. One of DatePeriod class constants, e.g. DatePeriod::LAST_WEEK.
|
* @param int $period The period, type of period. One of DatePeriod class constants, e.g. DatePeriod::LAST_WEEK.
|
||||||
* @return null|DatePeriod
|
|
||||||
*
|
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
|
* @return null|DatePeriod
|
||||||
*/
|
*/
|
||||||
public static function getDatesForPeriod($period)
|
public static function getDatesForPeriod($period)
|
||||||
{
|
{
|
||||||
@@ -221,8 +220,8 @@ class Date
|
|||||||
/**
|
/**
|
||||||
* Returns current day of week
|
* Returns current day of week
|
||||||
*
|
*
|
||||||
* @return int
|
|
||||||
* @throws UnknownDatePartTypeException
|
* @throws UnknownDatePartTypeException
|
||||||
|
* @return int
|
||||||
*/
|
*/
|
||||||
public static function getCurrentDayOfWeek()
|
public static function getCurrentDayOfWeek()
|
||||||
{
|
{
|
||||||
@@ -243,8 +242,8 @@ class Date
|
|||||||
* @param int $month The month value
|
* @param int $month The month value
|
||||||
* @param int $day The day value
|
* @param int $day The day value
|
||||||
*
|
*
|
||||||
* @return int
|
|
||||||
* @throws UnknownDatePartTypeException
|
* @throws UnknownDatePartTypeException
|
||||||
|
* @return int
|
||||||
*/
|
*/
|
||||||
public static function getDayOfWeek($year, $month, $day)
|
public static function getDayOfWeek($year, $month, $day)
|
||||||
{
|
{
|
||||||
@@ -488,9 +487,8 @@ class Date
|
|||||||
* @param string $intervalTemplate (optional) Template used to build date interval. It should contain "%d" as the
|
* @param string $intervalTemplate (optional) Template used to build date interval. It should contain "%d" as the
|
||||||
* placeholder which is replaced with a number that represents each iteration.
|
* placeholder which is replaced with a number that represents each iteration.
|
||||||
* Default: interval for days.
|
* Default: interval for days.
|
||||||
* @return array
|
|
||||||
*
|
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
|
* @return array
|
||||||
*/
|
*/
|
||||||
public static function getDatesCollection(DateTime $startDate, $datesCount, $intervalTemplate = 'P%dD')
|
public static function getDatesCollection(DateTime $startDate, $datesCount, $intervalTemplate = 'P%dD')
|
||||||
{
|
{
|
||||||
@@ -535,9 +533,8 @@ class Date
|
|||||||
* @param int $end (optional) End of random partition
|
* @param int $end (optional) End of random partition
|
||||||
* @param string $intervalTemplate (optional) Template used to build date interval. The placeholder is replaced
|
* @param string $intervalTemplate (optional) Template used to build date interval. The placeholder is replaced
|
||||||
* with next, iterated value.
|
* with next, iterated value.
|
||||||
* @return DateTime
|
|
||||||
*
|
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
|
* @return DateTime
|
||||||
*/
|
*/
|
||||||
public static function getRandomDate(DateTime $startDate = null, $start = 1, $end = 100, $intervalTemplate = 'P%sD')
|
public static function getRandomDate(DateTime $startDate = null, $start = 1, $end = 100, $intervalTemplate = 'P%sD')
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -759,9 +759,8 @@ class MimeTypes
|
|||||||
* Returns mime type of given file
|
* Returns mime type of given file
|
||||||
*
|
*
|
||||||
* @param string $filePath Path of the file to check
|
* @param string $filePath Path of the file to check
|
||||||
* @return string
|
|
||||||
*
|
|
||||||
* @throws \RuntimeException
|
* @throws \RuntimeException
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function getMimeType($filePath)
|
public static function getMimeType($filePath)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1312,10 +1312,9 @@ class Miscellaneous
|
|||||||
* Returns inverted value of color for given color
|
* Returns inverted value of color for given color
|
||||||
*
|
*
|
||||||
* @param string $color Hexadecimal value of color to invert (with or without hash), e.g. "dd244c" or "#22a5fe"
|
* @param string $color Hexadecimal value of color to invert (with or without hash), e.g. "dd244c" or "#22a5fe"
|
||||||
* @return string
|
|
||||||
*
|
|
||||||
* @throws IncorrectColorHexLengthException
|
* @throws IncorrectColorHexLengthException
|
||||||
* @throws InvalidColorHexValueException
|
* @throws InvalidColorHexValueException
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function getInvertedColor($color)
|
public static function getInvertedColor($color)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -158,8 +158,8 @@ class QueryBuilderUtility
|
|||||||
* @param array|ArrayCollection $entities The entities to delete
|
* @param array|ArrayCollection $entities The entities to delete
|
||||||
* @param bool $flushDeleted (optional) If is set to true, flushes the deleted objects (default
|
* @param bool $flushDeleted (optional) If is set to true, flushes the deleted objects (default
|
||||||
* behaviour). Otherwise - not.
|
* behaviour). Otherwise - not.
|
||||||
* @return bool
|
|
||||||
* @throws OptimisticLockException
|
* @throws OptimisticLockException
|
||||||
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public static function deleteEntities(EntityManager $entityManager, $entities, $flushDeleted = true)
|
public static function deleteEntities(EntityManager $entityManager, $entities, $flushDeleted = true)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -34,9 +34,8 @@ class Reflection
|
|||||||
* @param object|string $class The object or name of object's class
|
* @param object|string $class The object or name of object's class
|
||||||
* @param bool $withoutInheritance (optional) If is set to true, only methods for given class are returned.
|
* @param bool $withoutInheritance (optional) If is set to true, only methods for given class are returned.
|
||||||
* Otherwise - all methods, with inherited methods too.
|
* Otherwise - all methods, with inherited methods too.
|
||||||
* @return array
|
|
||||||
*
|
|
||||||
* @throws ReflectionException
|
* @throws ReflectionException
|
||||||
|
* @return array
|
||||||
*/
|
*/
|
||||||
public static function getMethods($class, $withoutInheritance = false)
|
public static function getMethods($class, $withoutInheritance = false)
|
||||||
{
|
{
|
||||||
@@ -66,9 +65,8 @@ class Reflection
|
|||||||
* Returns constants of given class / object
|
* Returns constants of given class / object
|
||||||
*
|
*
|
||||||
* @param object|string $class The object or name of object's class
|
* @param object|string $class The object or name of object's class
|
||||||
* @return array
|
|
||||||
*
|
|
||||||
* @throws ReflectionException
|
* @throws ReflectionException
|
||||||
|
* @return array
|
||||||
*/
|
*/
|
||||||
public static function getConstants($class)
|
public static function getConstants($class)
|
||||||
{
|
{
|
||||||
@@ -82,9 +80,8 @@ class Reflection
|
|||||||
* Constants whose values are integers are considered only.
|
* Constants whose values are integers are considered only.
|
||||||
*
|
*
|
||||||
* @param object|string $class The object or name of object's class
|
* @param object|string $class The object or name of object's class
|
||||||
* @return int|null
|
|
||||||
*
|
|
||||||
* @throws ReflectionException
|
* @throws ReflectionException
|
||||||
|
* @return int|null
|
||||||
*/
|
*/
|
||||||
public static function getMaxNumberConstant($class)
|
public static function getMaxNumberConstant($class)
|
||||||
{
|
{
|
||||||
@@ -110,9 +107,8 @@ class Reflection
|
|||||||
*
|
*
|
||||||
* @param object|string $class The object or name of object's class
|
* @param object|string $class The object or name of object's class
|
||||||
* @param string $method Name of the method to find
|
* @param string $method Name of the method to find
|
||||||
* @return bool
|
|
||||||
*
|
|
||||||
* @throws ReflectionException
|
* @throws ReflectionException
|
||||||
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public static function hasMethod($class, $method)
|
public static function hasMethod($class, $method)
|
||||||
{
|
{
|
||||||
@@ -126,9 +122,8 @@ class Reflection
|
|||||||
*
|
*
|
||||||
* @param object|string $class The object or name of object's class
|
* @param object|string $class The object or name of object's class
|
||||||
* @param string $property Name of the property to find
|
* @param string $property Name of the property to find
|
||||||
* @return bool
|
|
||||||
*
|
|
||||||
* @throws ReflectionException
|
* @throws ReflectionException
|
||||||
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public static function hasProperty($class, $property)
|
public static function hasProperty($class, $property)
|
||||||
{
|
{
|
||||||
@@ -142,9 +137,8 @@ class Reflection
|
|||||||
*
|
*
|
||||||
* @param object|string $class The object or name of object's class
|
* @param object|string $class The object or name of object's class
|
||||||
* @param string $constant Name of the constant to find
|
* @param string $constant Name of the constant to find
|
||||||
* @return bool
|
|
||||||
*
|
|
||||||
* @throws ReflectionException
|
* @throws ReflectionException
|
||||||
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public static function hasConstant($class, $constant)
|
public static function hasConstant($class, $constant)
|
||||||
{
|
{
|
||||||
@@ -158,9 +152,8 @@ class Reflection
|
|||||||
*
|
*
|
||||||
* @param object|string $class The object or name of object's class
|
* @param object|string $class The object or name of object's class
|
||||||
* @param string $constant Name of the constant that contains a value
|
* @param string $constant Name of the constant that contains a value
|
||||||
* @return mixed
|
|
||||||
*
|
|
||||||
* @throws ReflectionException
|
* @throws ReflectionException
|
||||||
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public static function getConstantValue($class, $constant)
|
public static function getConstantValue($class, $constant)
|
||||||
{
|
{
|
||||||
@@ -182,9 +175,8 @@ class Reflection
|
|||||||
* dot-separated, e.g. "invoice.user.email".
|
* dot-separated, e.g. "invoice.user.email".
|
||||||
* @param bool $force (optional) If is set to true, try to retrieve value even if the object doesn't have
|
* @param bool $force (optional) If is set to true, try to retrieve value even if the object doesn't have
|
||||||
* property. Otherwise - not.
|
* property. Otherwise - not.
|
||||||
* @return mixed
|
|
||||||
*
|
|
||||||
* @throws ReflectionException
|
* @throws ReflectionException
|
||||||
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public static function getPropertyValue($object, $property, $force = false)
|
public static function getPropertyValue($object, $property, $force = false)
|
||||||
{
|
{
|
||||||
@@ -300,9 +292,8 @@ class Reflection
|
|||||||
* @param string $property Name of the property that contains a value
|
* @param string $property Name of the property that contains a value
|
||||||
* @param bool $force (optional) If is set to true, try to retrieve value even if the
|
* @param bool $force (optional) If is set to true, try to retrieve value even if the
|
||||||
* object does not have property. Otherwise - not.
|
* object does not have property. Otherwise - not.
|
||||||
* @return array
|
|
||||||
*
|
|
||||||
* @throws ReflectionException
|
* @throws ReflectionException
|
||||||
|
* @return array
|
||||||
*/
|
*/
|
||||||
public static function getPropertyValues($objects, $property, $force = false)
|
public static function getPropertyValues($objects, $property, $force = false)
|
||||||
{
|
{
|
||||||
@@ -461,9 +452,8 @@ class Reflection
|
|||||||
* constants. By default all properties are returned.
|
* constants. By default all properties are returned.
|
||||||
* @param bool $includeParents (optional) If is set to true, properties of parent classes are
|
* @param bool $includeParents (optional) If is set to true, properties of parent classes are
|
||||||
* included (recursively). Otherwise - not.
|
* included (recursively). Otherwise - not.
|
||||||
* @return array|ReflectionProperty
|
|
||||||
*
|
|
||||||
* @throws ReflectionException
|
* @throws ReflectionException
|
||||||
|
* @return array|ReflectionProperty
|
||||||
*/
|
*/
|
||||||
public static function getProperties($source, $filter = null, $includeParents = false)
|
public static function getProperties($source, $filter = null, $includeParents = false)
|
||||||
{
|
{
|
||||||
@@ -496,9 +486,8 @@ class Reflection
|
|||||||
* Returns a parent class or false if there is no parent class
|
* Returns a parent class or false if there is no parent class
|
||||||
*
|
*
|
||||||
* @param array|object|string $source An array of objects, namespaces, object or namespace
|
* @param array|object|string $source An array of objects, namespaces, object or namespace
|
||||||
* @return ReflectionClass|bool
|
|
||||||
*
|
|
||||||
* @throws ReflectionException
|
* @throws ReflectionException
|
||||||
|
* @return ReflectionClass|bool
|
||||||
*/
|
*/
|
||||||
public static function getParentClass($source)
|
public static function getParentClass($source)
|
||||||
{
|
{
|
||||||
@@ -514,8 +503,8 @@ class Reflection
|
|||||||
*
|
*
|
||||||
* @param array|object|string $class Class who child classes should be returned. An array of objects, strings,
|
* @param array|object|string $class Class who child classes should be returned. An array of objects, strings,
|
||||||
* object or string.
|
* object or string.
|
||||||
* @return array|null
|
|
||||||
* @throws CannotResolveClassNameException
|
* @throws CannotResolveClassNameException
|
||||||
|
* @return array|null
|
||||||
*/
|
*/
|
||||||
public static function getChildClasses($class)
|
public static function getChildClasses($class)
|
||||||
{
|
{
|
||||||
@@ -569,11 +558,10 @@ class Reflection
|
|||||||
*
|
*
|
||||||
* @param array|object|string $parentClass Class who child class should be returned. An array of objects,
|
* @param array|object|string $parentClass Class who child class should be returned. An array of objects,
|
||||||
* namespaces, object or namespace.
|
* namespaces, object or namespace.
|
||||||
* @return mixed
|
|
||||||
*
|
|
||||||
* @throws CannotResolveClassNameException
|
* @throws CannotResolveClassNameException
|
||||||
* @throws MissingChildClassesException
|
* @throws MissingChildClassesException
|
||||||
* @throws TooManyChildClassesException
|
* @throws TooManyChildClassesException
|
||||||
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public static function getOneChildClass($parentClass)
|
public static function getOneChildClass($parentClass)
|
||||||
{
|
{
|
||||||
@@ -605,9 +593,8 @@ class Reflection
|
|||||||
* @param string $property Name of the property
|
* @param string $property Name of the property
|
||||||
* @param int $filter (optional) Filter of properties. Uses ReflectionProperty class constants.
|
* @param int $filter (optional) Filter of properties. Uses ReflectionProperty class constants.
|
||||||
* By default all properties are allowed / processed.
|
* By default all properties are allowed / processed.
|
||||||
* @return null|ReflectionProperty
|
|
||||||
*
|
|
||||||
* @throws ReflectionException
|
* @throws ReflectionException
|
||||||
|
* @return null|ReflectionProperty
|
||||||
*/
|
*/
|
||||||
public static function getProperty($class, $property, $filter = null)
|
public static function getProperty($class, $property, $filter = null)
|
||||||
{
|
{
|
||||||
@@ -633,10 +620,9 @@ class Reflection
|
|||||||
* @param array|string $trait An array of strings or string
|
* @param array|string $trait An array of strings or string
|
||||||
* @param bool $verifyParents If is set to true, parent classes are verified if they use given
|
* @param bool $verifyParents If is set to true, parent classes are verified if they use given
|
||||||
* trait. Otherwise - not.
|
* trait. Otherwise - not.
|
||||||
* @return bool|null
|
|
||||||
*
|
|
||||||
* @throws CannotResolveClassNameException
|
* @throws CannotResolveClassNameException
|
||||||
* @throws ReflectionException
|
* @throws ReflectionException
|
||||||
|
* @return bool|null
|
||||||
*/
|
*/
|
||||||
public static function usesTrait($class, $trait, $verifyParents = false)
|
public static function usesTrait($class, $trait, $verifyParents = false)
|
||||||
{
|
{
|
||||||
@@ -678,9 +664,8 @@ class Reflection
|
|||||||
* If given class does not extend another, returns null.
|
* If given class does not extend another, returns null.
|
||||||
*
|
*
|
||||||
* @param array|object|string $class An array of objects, namespaces, object or namespace
|
* @param array|object|string $class An array of objects, namespaces, object or namespace
|
||||||
* @return string|null
|
|
||||||
*
|
|
||||||
* @throws ReflectionException
|
* @throws ReflectionException
|
||||||
|
* @return string|null
|
||||||
*/
|
*/
|
||||||
public static function getParentClassName($class)
|
public static function getParentClassName($class)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -766,10 +766,9 @@ class Regex
|
|||||||
* @param string $color Color to verify
|
* @param string $color Color to verify
|
||||||
* @param bool $throwException (optional) If is set to true, throws an exception if given color is invalid
|
* @param bool $throwException (optional) If is set to true, throws an exception if given color is invalid
|
||||||
* (default behaviour). Otherwise - not.
|
* (default behaviour). Otherwise - not.
|
||||||
* @return string|bool
|
|
||||||
*
|
|
||||||
* @throws IncorrectColorHexLengthException
|
* @throws IncorrectColorHexLengthException
|
||||||
* @throws InvalidColorHexValueException
|
* @throws InvalidColorHexValueException
|
||||||
|
* @return string|bool
|
||||||
*/
|
*/
|
||||||
public static function getValidColorHexValue($color, $throwException = true)
|
public static function getValidColorHexValue($color, $throwException = true)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -82,9 +82,8 @@ class TestService
|
|||||||
* Returns translated type (for testing purposes)
|
* Returns translated type (for testing purposes)
|
||||||
*
|
*
|
||||||
* @param string $type Type of something (for testing purposes)
|
* @param string $type Type of something (for testing purposes)
|
||||||
* @return string
|
|
||||||
*
|
|
||||||
* @throws UnknownTestTypeException
|
* @throws UnknownTestTypeException
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getTranslatedType($type)
|
public function getTranslatedType($type)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -353,7 +353,6 @@ class RepositoryTest extends BaseTestCase
|
|||||||
|
|
||||||
yield[
|
yield[
|
||||||
[
|
[
|
||||||
|
|
||||||
[],
|
[],
|
||||||
[],
|
[],
|
||||||
[
|
[
|
||||||
|
|||||||
Reference in New Issue
Block a user