Skip to content

Commit d2a9c15

Browse files
committed
#188: Fix behavior of unparenthesized expressions will change in php v8
1 parent c053a0a commit d2a9c15

File tree

2 files changed

+34
-33
lines changed

2 files changed

+34
-33
lines changed

src/Blocks/ContentManager.php

+17-16
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ protected function setUse(string $path, bool $isTrait = false, bool $isLast = fa
5454
* @param string $name
5555
* @param null $extends
5656
*/
57-
protected function startClass(string $name, $extends = NULL): void
57+
protected function startClass(string $name, $extends = null): void
5858
{
5959
$this->sourceCode .= PhpInterface::PHP_CLASS . PhpInterface::SPACE . $name
6060
. PhpInterface::SPACE;
61-
if ($extends !== NULL) {
61+
if ($extends !== null) {
6262
$this->sourceCode .=
6363
PhpInterface::PHP_EXTENDS
6464
. PhpInterface::SPACE . $extends . PhpInterface::SPACE;
@@ -163,7 +163,8 @@ protected function createProperty(
163163
string $modifier,
164164
$value = PhpInterface::PHP_TYPES_NULL,
165165
bool $isString = false
166-
): void {
166+
): void
167+
{
167168
if ($value === PhpInterface::PHP_TYPES_NULL) { // drop null assignments as they are already nullable by default
168169
$this->sourceCode .= PhpInterface::TAB_PSR4 . $modifier . PhpInterface::SPACE . PhpInterface::DOLLAR_SIGN .
169170
$prop . PhpInterface::SEMICOLON . PHP_EOL;
@@ -362,17 +363,17 @@ public function closeRule(): void
362363
}
363364

364365
/**
365-
* @uses \SoliDry\Blocks\Controllers::setContent
366-
* @uses \SoliDry\Blocks\Config::setContent
366+
* @param string $basePath
367+
* @param string $postFix
367368
* @uses \SoliDry\Blocks\Migrations::setContent
368369
* @uses \SoliDry\Blocks\Entities::setContent
369370
* @uses \SoliDry\Blocks\FormRequest::setContent
370371
* @uses \SoliDry\Blocks\Tests::setContent
371372
*
372373
* Creates entities like *Controller, *FormRequest, BaseModel entities etc
373374
*
374-
* @param string $basePath
375-
* @param string $postFix
375+
* @uses \SoliDry\Blocks\Controllers::setContent
376+
* @uses \SoliDry\Blocks\Config::setContent
376377
*/
377378
public function createEntity(string $basePath, string $postFix = ''): void
378379
{
@@ -457,7 +458,7 @@ public function quoteParam(string $param): string
457458
protected function setBeforeProps(string $entityFile): void
458459
{
459460
$this->resourceCode = file_get_contents($entityFile);
460-
$end = mb_strpos($this->resourceCode, DefaultInterface::PROPS_START, NULL, PhpInterface::ENCODING_UTF8) - 3;
461+
$end = mb_strpos($this->resourceCode, DefaultInterface::PROPS_START, null, PhpInterface::ENCODING_UTF8) - 3;
461462
$this->sourceCode = mb_substr($this->resourceCode, 0, $end, PhpInterface::ENCODING_UTF8);
462463
}
463464

@@ -466,14 +467,14 @@ protected function setBeforeProps(string $entityFile): void
466467
*
467468
* @param string $till
468469
*/
469-
protected function setAfterProps($till = NULL): void
470+
protected function setAfterProps($till = null): void
470471
{
471-
$start = $this->setTabs() . mb_strpos($this->resourceCode, DefaultInterface::PROPS_END, NULL,
472-
PhpInterface::ENCODING_UTF8) - 3;
473-
if ($till === NULL) {
474-
$this->sourceCode .= mb_substr($this->resourceCode, $start, NULL, PhpInterface::ENCODING_UTF8);
472+
$start = $this->setTabs() . (mb_strpos($this->resourceCode, DefaultInterface::PROPS_END, null,
473+
PhpInterface::ENCODING_UTF8) - 3);
474+
if ($till === null) {
475+
$this->sourceCode .= mb_substr($this->resourceCode, $start, null, PhpInterface::ENCODING_UTF8);
475476
} else {
476-
$end = mb_strpos($this->resourceCode, $till, NULL, PhpInterface::ENCODING_UTF8) - 3;
477+
$end = mb_strpos($this->resourceCode, $till, null, PhpInterface::ENCODING_UTF8) - 3;
477478
$this->sourceCode .= mb_substr($this->resourceCode, $start, $end - $start, PhpInterface::ENCODING_UTF8);
478479
}
479480
}
@@ -483,8 +484,8 @@ protected function setAfterProps($till = NULL): void
483484
*/
484485
private function setAfterMethods(): void
485486
{
486-
$start = mb_strpos($this->resourceCode, DefaultInterface::METHOD_END, NULL, PhpInterface::ENCODING_UTF8) - 3;
487-
$this->sourceCode .= $this->setTabs() . mb_substr($this->resourceCode, $start, NULL,
487+
$start = mb_strpos($this->resourceCode, DefaultInterface::METHOD_END, null, PhpInterface::ENCODING_UTF8) - 3;
488+
$this->sourceCode .= $this->setTabs() . mb_substr($this->resourceCode, $start, null,
488489
PhpInterface::ENCODING_UTF8);
489490
}
490491

src/Blocks/EntitiesTrait.php

+17-17
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ trait EntitiesTrait
4747
* @param string $object
4848
* @return string
4949
*/
50-
public function getFormRequestEntity(string $version, string $object) : string
50+
public function getFormRequestEntity(string $version, string $object): string
5151
{
5252
return DirsInterface::MODULES_DIR . PhpInterface::BACKSLASH . strtoupper($version) .
5353
PhpInterface::BACKSLASH . DirsInterface::HTTP_DIR .
@@ -63,16 +63,16 @@ public function getFormRequestEntity(string $version, string $object) : string
6363
* @throws \Illuminate\Contracts\Container\BindingResolutionException
6464
* @throws \ReflectionException
6565
*/
66-
protected function setEntities() : void
66+
protected function setEntities(): void
6767
{
68-
$this->entity = Classes::cutEntity(Classes::getObjectName($this), DefaultInterface::CONTROLLER_POSTFIX);
69-
$formRequestEntity = $this->getFormRequestEntity(conf::getModuleName(), $this->entity);
68+
$this->entity = Classes::cutEntity(Classes::getObjectName($this), DefaultInterface::CONTROLLER_POSTFIX);
69+
$formRequestEntity = $this->getFormRequestEntity(conf::getModuleName(), $this->entity);
7070

7171
$this->formRequest = new $formRequestEntity();
72-
$this->props = get_object_vars($this->formRequest);
72+
$this->props = get_object_vars($this->formRequest);
7373

7474
$this->modelEntity = Classes::getModelEntity($this->entity);
75-
$this->model = new $this->modelEntity();
75+
$this->model = new $this->modelEntity();
7676

7777
$container = Container::getInstance();
7878
$this->response = $container->make(\SoliDry\Containers\Response::class);
@@ -88,12 +88,12 @@ protected function setEntities() : void
8888
* @throws \InvalidArgumentException
8989
* @throws \LogicException
9090
*/
91-
protected function saveBulk(Request $request) : Response
91+
protected function saveBulk(Request $request): Response
9292
{
93-
$meta = [];
93+
$meta = [];
9494
$collection = new Collection();
9595

96-
$json = Json::decode($request->getContent());
96+
$json = Json::decode($request->getContent());
9797
$jsonApiAttributes = Json::getBulkAttributes($json);
9898

9999
try {
@@ -158,12 +158,12 @@ protected function saveBulk(Request $request) : Response
158158
* @throws \SoliDry\Exceptions\AttributesException
159159
* @throws \LogicException
160160
*/
161-
protected function mutateBulk(Request $request) : Response
161+
protected function mutateBulk(Request $request): Response
162162
{
163-
$meta = [];
163+
$meta = [];
164164
$collection = new Collection();
165165

166-
$json = Json::decode($request->getContent());
166+
$json = Json::decode($request->getContent());
167167
$jsonApiAttributes = Json::getBulkAttributes($json);
168168

169169
try {
@@ -209,9 +209,9 @@ protected function mutateBulk(Request $request) : Response
209209
* @return Response
210210
* @throws \LogicException
211211
*/
212-
public function removeBulk(Request $request) : Response
212+
public function removeBulk(Request $request): Response
213213
{
214-
$json = Json::decode($request->getContent());
214+
$json = Json::decode($request->getContent());
215215
$jsonApiAttributes = Json::getBulkAttributes($json);
216216

217217
try {
@@ -248,7 +248,7 @@ public function removeBulk(Request $request) : Response
248248
private function getRelationType(string $objectName)
249249
{
250250
if (empty($this->generator->types[$objectName][ApiInterface::RAML_PROPS]
251-
[ApiInterface::RAML_RELATIONSHIPS][ApiInterface::RAML_TYPE]) === false
251+
[ApiInterface::RAML_RELATIONSHIPS][ApiInterface::RAML_TYPE]) === false
252252
) {
253253
return trim(
254254
$this->generator->types[$objectName][ApiInterface::RAML_PROPS]
@@ -264,7 +264,7 @@ private function getRelationType(string $objectName)
264264
*
265265
* @throws \ReflectionException
266266
*/
267-
private function setUseSoftDelete() : void
267+
private function setUseSoftDelete(): void
268268
{
269269
if ($this->isSoftDelete()) {
270270
$this->setUse(Classes::getObjectName(SoftDeletes::class), true, true);
@@ -274,7 +274,7 @@ private function setUseSoftDelete() : void
274274
/**
275275
* Sets property for Soft Delete op on model Entity
276276
*/
277-
private function setPropSoftDelete() : void
277+
private function setPropSoftDelete(): void
278278
{
279279
if ($this->isSoftDelete()) {
280280
$this->createPropertyArray(ModelsInterface::PROPERTY_DATES, PhpInterface::PHP_MODIFIER_PROTECTED, [ModelsInterface::COLUMN_DEL_AT]);

0 commit comments

Comments
 (0)