Page MenuHomePhorge

Modernize codebase to features available since PHP 5.5
AbandonedPublic

Authored by valerio.bozzolan on Mar 6 2023, 07:48.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Jun 15, 15:14
Unknown Object (File)
Mon, Jun 10, 22:02
Unknown Object (File)
Mon, Jun 10, 22:02
Unknown Object (File)
Mon, Jun 10, 22:02
Unknown Object (File)
Mon, Jun 10, 22:02
Unknown Object (File)
Mon, Jun 10, 22:01
Unknown Object (File)
Mon, Jun 10, 22:01
Unknown Object (File)
Mon, Jun 10, 22:01

Details

Summary

This refactor includes these scaring changes:

  • avoid id( new A() )->b() and adopt ( new A() )->b() - since PHP 5.4
  • avoid id( $a->b() )->c() and adopt just $a->b()->c() - since PHP 5.4
  • avoid dirname(__FILE__) and adopt __DIR__ - since PHP 5.3
  • avoid $foo ? $foo : $default and adopt $foo ?: $default - since PHP 5.3

To better understand and comment these old PHP features, see:

https://we.phorge.it/T15158

Note that all directories like /__tests__/ were skipped.

Ref T15158
Ref P6

Test Plan
  • I checked every single line with my big eyes
  • matrioska test: I hot-used my Arcanist to run arc diff and it worked

Diff Detail

Repository
rARC Arcanist
Branch
arcpatch-D25071
Lint
Lint Passed
Unit
Test Failures
Build Status
Buildable 126
Build 126: arc lint + arc unit

Unit TestsFailed

TimeTest
2,384 msArcanistJSHintLinterTestCase::testLinter
Lint emitted an unexpected set of messages for file "too-many-errors.lint-test". MISSING MESSAGES Message with severity "disabled" at "2:22" (E043)
329 msArcanistPhpcsLinterTestCase::testLinter
Lint emitted an unexpected set of messages for file "basics.lint-test". MISSING MESSAGES Message with severity "error" at "2:1"
45 msAbstractDirectedGraphTestCase::testCyclicGraph
1 assertion(s) passed.
45 msAbstractDirectedGraphTestCase::testEdgeLoadFailure
1 assertion(s) passed.
44 msAbstractDirectedGraphTestCase::testNonTreeGraph
1 assertion(s) passed.
View Full Test Results (2 Failed · 312 Passed · 28 Skipped)

Event Timeline

avoid to replace CLASS to self::class since it's probably nonsense

https://stackoverflow.com/q/75648554/3451846

valerio.bozzolan edited the summary of this revision. (Show Details)

skip the replacement of __CLASS__ to self::class since it can be just confusing

I have an ironical situation. This syntax is very supported:

# this is supported since PHP 5.0
$a->b()->c()

But:

# I'm trying to deprecate this
id( $a->b() )->c()
# but this is supported only in PHP 7.0
( $a->b() )->c()

# so to deprecate id() - we have to strip unuseful parenthesis to obtain this that is supported in PHP 5.0:
$a->b()->c()

simplify ( $a->b() )->$b() to just $a->b()->c() since the first it's only supported in PHP 7.0

Yes, $a->b()->c() just work since PHP 5.0 without using tricks like id( $a->b() )->c().

I would like to fix this lint:

Lint emitted an unexpected set of messages for file "basics.lint-test".
MISSING MESSAGES
    Message with severity "error" at "2:1"

SURPLUS MESSAGES
(No messages.)

But - believe me or not but - I truly does not understand what it would want.

I understand that this is... too much.

I will split this Diff in one that is only about with the modification about dirname() and nothing else, so it will be easy-peasy to review. And it will still be a step forward.