Skip to content

Commit

Permalink
cs fix: short "will return"
Browse files Browse the repository at this point in the history
  • Loading branch information
garak committed Jun 11, 2019
1 parent a7a5bdf commit d862fe9
Show file tree
Hide file tree
Showing 35 changed files with 220 additions and 221 deletions.
1 change: 1 addition & 0 deletions .php_cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ return PhpCsFixer\Config::create()
'declare_strict_types' => false,
'native_function_invocation' => true,
'fopen_flags' => ['b_mode' => true],
'php_unit_mock_short_will_return' => true,
])
->setFinder($finder)
;
4 changes: 2 additions & 2 deletions Metadata/Driver/AnnotationDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ public function loadMetadataForClass(\ReflectionClass $class): ?JMSClassMetadata
$classes[] = $class;
$class = $class->getParentClass();
} while (false !== $class);
$classes = array_reverse($classes, false);
$classes = \array_reverse($classes, false);
$properties = [];
foreach ($classes as $class) {
$properties = array_merge($properties, $class->getProperties());
$properties = \array_merge($properties, $class->getProperties());
}

foreach ($properties as $property) {
Expand Down
2 changes: 1 addition & 1 deletion Naming/CurrentDateTimeDirectoryNamer.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function directoryName($object, PropertyMapping $mapping): string
} else {
// see https://github.com/dustin10/VichUploaderBundle/issues/992
$msg = 'Not passing "date_time_property" option is deprecated and will be removed in version 2.';
@trigger_error($msg, E_USER_DEPRECATED);
@\trigger_error($msg, E_USER_DEPRECATED);
$dateTime = $this->dateTimeHelper->getTimestamp();
}

Expand Down
2 changes: 1 addition & 1 deletion Tests/Adapter/ODM/MongoDB/MongoDBAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function testGetObjectFromArgs(): void
$args
->expects($this->once())
->method('getDocument')
->will($this->returnValue($entity));
->willReturn($entity);

$adapter = new MongoDBAdapter();

Expand Down
2 changes: 1 addition & 1 deletion Tests/Adapter/ORM/DoctrineORMAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function testGetObjectFromArgs(): void
$args
->expects($this->once())
->method('getEntity')
->will($this->returnValue($entity));
->willReturn($entity);

$adapter = new DoctrineORMAdapter();

Expand Down
2 changes: 1 addition & 1 deletion Tests/Adapter/PHPCR/PHPCRAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function testGetObjectFromArgs(): void
$args
->expects($this->once())
->method('getObject')
->will($this->returnValue($entity));
->willReturn($entity);

$adapter = new PHPCRAdapter();

Expand Down
2 changes: 1 addition & 1 deletion Tests/Adapter/Propel/PropelORMAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function testGetObjectFromArgs(): void
$event
->expects($this->once())
->method('getSubject')
->will($this->returnValue(42));
->willReturn(42);

$this->assertSame(42, $this->adapter->getObjectFromArgs($event));
}
Expand Down
8 changes: 4 additions & 4 deletions Tests/EventListener/Doctrine/CleanListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ public function testPreUpdate(): void
->expects($this->once())
->method('isUploadable')
->with(DummyEntity::class)
->will($this->returnValue(true));
->willReturn(true);

$this->metadata
->expects($this->once())
->method('getUploadableFields')
->with(DummyEntity::class, self::MAPPING_NAME)
->will($this->returnValue([
->willReturn([
['propertyName' => 'field_name'],
]));
]);

$this->handler
->expects($this->once())
Expand All @@ -73,7 +73,7 @@ public function testPreUpdateSkipsNonUploadable(): void
->expects($this->once())
->method('isUploadable')
->with(DummyEntity::class)
->will($this->returnValue(false));
->willReturn(false);

$this->handler
->expects($this->never())
Expand Down
8 changes: 4 additions & 4 deletions Tests/EventListener/Doctrine/InjectListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ public function testPostLoad(): void
->expects($this->once())
->method('isUploadable')
->with(DummyEntity::class)
->will($this->returnValue(true));
->willReturn(true);

$this->metadata
->expects($this->once())
->method('getUploadableFields')
->with(DummyEntity::class, self::MAPPING_NAME)
->will($this->returnValue([
->willReturn([
['propertyName' => 'field_name'],
]));
]);

$this->handler
->expects($this->once())
Expand All @@ -68,7 +68,7 @@ public function testPostLoadSkipsNonUploadable(): void
->expects($this->once())
->method('isUploadable')
->with(DummyEntity::class)
->will($this->returnValue(false));
->willReturn(false);

$this->handler
->expects($this->never())
Expand Down
4 changes: 2 additions & 2 deletions Tests/EventListener/Doctrine/ListenerTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ protected function setUp(): void
->expects($this->any())
->method('getObjectFromArgs')
->with($this->event)
->will($this->returnCallback(function () use ($that) {
->willReturnCallback(function () use ($that) {
return $that->object;
}));
});
}

/**
Expand Down
12 changes: 6 additions & 6 deletions Tests/EventListener/Doctrine/RemoveListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function testPreRemove(): void
->expects($this->once())
->method('isUploadable')
->with('VichUploaderEntityProxy')
->will($this->returnValue(true));
->willReturn(true);

$this->listener->preRemove($this->event);
}
Expand All @@ -60,7 +60,7 @@ public function testPreRemoveSkipNonUploadable(): void
->expects($this->once())
->method('isUploadable')
->with('VichUploaderEntityProxy')
->will($this->returnValue(false));
->willReturn(false);

$this->listener->preRemove($this->event);
}
Expand All @@ -74,15 +74,15 @@ public function testPostRemove(): void
->expects($this->once())
->method('isUploadable')
->with(DummyEntity::class)
->will($this->returnValue(true));
->willReturn(true);

$this->metadata
->expects($this->once())
->method('getUploadableFields')
->with(DummyEntity::class, self::MAPPING_NAME)
->will($this->returnValue([
->willReturn([
['propertyName' => 'field_name'],
]));
]);

$this->handler
->expects($this->once())
Expand All @@ -101,7 +101,7 @@ public function testPostRemoveSkipsNonUploadable(): void
->expects($this->once())
->method('isUploadable')
->with(DummyEntity::class)
->will($this->returnValue(false));
->willReturn(false);

$this->handler
->expects($this->never())
Expand Down
16 changes: 8 additions & 8 deletions Tests/EventListener/Doctrine/UploadListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ public function testPrePersist(): void
->expects($this->once())
->method('isUploadable')
->with(DummyEntity::class)
->will($this->returnValue(true));
->willReturn(true);

$this->metadata
->expects($this->once())
->method('getUploadableFields')
->with(DummyEntity::class, self::MAPPING_NAME)
->will($this->returnValue([
->willReturn([
['propertyName' => 'field_name'],
]));
]);

$this->handler
->expects($this->once())
Expand All @@ -68,7 +68,7 @@ public function testPrePersistSkipsNonUploadable(): void
->expects($this->once())
->method('isUploadable')
->with(DummyEntity::class)
->will($this->returnValue(false));
->willReturn(false);

$this->handler
->expects($this->never())
Expand All @@ -91,15 +91,15 @@ public function testPreUpdate(): void
->expects($this->once())
->method('isUploadable')
->with(DummyEntity::class)
->will($this->returnValue(true));
->willReturn(true);

$this->metadata
->expects($this->once())
->method('getUploadableFields')
->with(DummyEntity::class, self::MAPPING_NAME)
->will($this->returnValue([
->willReturn([
['propertyName' => 'field_name'],
]));
]);

$this->handler
->expects($this->once())
Expand All @@ -118,7 +118,7 @@ public function testPreUpdateSkipsNonUploadable(): void
->expects($this->once())
->method('isUploadable')
->with(DummyEntity::class)
->will($this->returnValue(false));
->willReturn(false);

$this->adapter
->expects($this->never())
Expand Down
6 changes: 3 additions & 3 deletions Tests/EventListener/Propel/ListenerTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ protected function setUp(): void
->expects($this->any())
->method('getObjectFromArgs')
->with($this->event)
->will($this->returnValue($this->object));
->willReturn($this->object);

$this->metadata
->expects($this->any())
->method('getUploadableFields')
->with(DummyEntity::class, self::MAPPING_NAME)
->will($this->returnValue([
->willReturn([
['propertyName' => self::FIELD_NAME],
]));
]);
}

/**
Expand Down
14 changes: 7 additions & 7 deletions Tests/Form/Type/VichFileTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,23 +82,23 @@ public function testBuildView(Product $object = null, array $options, array $var
->expects($this->any())
->method('resolveUri')
->with($object, $field)
->will($this->returnValue('resolved-uri'));
->willReturn('resolved-uri');

$parentForm = $this->createMock(FormInterface::class);
$parentForm
->expects($this->any())
->method('getData')
->will($this->returnValue($object));
->willReturn($object);

$form = $this->createMock(FormInterface::class);
$form
->expects($this->any())
->method('getParent')
->will($this->returnValue($parentForm));
->willReturn($parentForm);
$form
->expects($this->any())
->method('getName')
->will($this->returnValue($field));
->willReturn($field);

$uploadHandler = $this->createMock(UploadHandler::class);
$propertyMappingFactory = $this->createMock(PropertyMappingFactory::class);
Expand All @@ -112,21 +112,21 @@ public function testBuildView(Product $object = null, array $options, array $var
->expects($this->once())
->method('readProperty')
->with($object, 'originalName')
->will($this->returnValue($object->getImageOriginalName()));
->willReturn($object->getImageOriginalName());

$propertyMappingFactory
->expects($this->once())
->method('fromField')
->with($object, $field)
->will($this->returnValue($mapping));
->willReturn($mapping);
}

if ($options['download_label'] instanceof PropertyPath) {
$propertyAccessor
->expects($this->once())
->method('getValue')
->with($object, $options['download_label'])
->will($this->returnValue($object->getTitle()));
->willReturn($object->getTitle());
}
}

Expand Down
14 changes: 7 additions & 7 deletions Tests/Form/Type/VichImageTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,23 +148,23 @@ public function testLiipImagineBundleIntegration(): void
->expects($this->any())
->method('resolveUri')
->with($object, $field)
->will($this->returnValue('resolved-uri'));
->willReturn('resolved-uri');

$parentForm = $this->createMock(FormInterface::class);
$parentForm
->expects($this->any())
->method('getData')
->will($this->returnValue($object));
->willReturn($object);

$form = $this->createMock(FormInterface::class);
$form
->expects($this->any())
->method('getParent')
->will($this->returnValue($parentForm));
->willReturn($parentForm);
$form
->expects($this->any())
->method('getName')
->will($this->returnValue($field));
->willReturn($field);

$uploadHandler = $this->createMock(UploadHandler::class);
$propertyMappingFactory = $this->createMock(PropertyMappingFactory::class);
Expand All @@ -176,7 +176,7 @@ public function testLiipImagineBundleIntegration(): void
->expects($this->once())
->method('getBrowserPath')
->with('resolved-uri', 'product_sq200')
->will($this->returnValue('product_sq200/resolved-uri'));
->willReturn('product_sq200/resolved-uri');

$testedType = static::TESTED_TYPE;

Expand Down Expand Up @@ -222,13 +222,13 @@ public function testLiipImagineBundleIntegrationThrownExceptionIfNotAvailable():
$parentForm
->expects($this->any())
->method('getData')
->will($this->returnValue($object));
->willReturn($object);

$form = $this->createMock(FormInterface::class);
$form
->expects($this->any())
->method('getParent')
->will($this->returnValue($parentForm));
->willReturn($parentForm);

$view = new FormView();
$type = new $testedType($storage, $uploadHandler, $propertyMappingFactory, $propertyAccessor);
Expand Down
Loading

0 comments on commit d862fe9

Please sign in to comment.