• Stars
    star
    135
  • Rank 269,297 (Top 6 %)
  • Language
    PHP
  • License
    MIT License
  • Created over 1 year ago
  • Updated about 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Remove "final" keywords from classes and methods in vendor packages.

Unfinalize

Unleash the freedom lost with open source PHP packages marking classes and methods as final.


Unfinalize uses PHP CS Fixer to permanently remove final keywords from composer vendor packages:

- final class Foo
+ class Foo
{
-   final public function bar()
+   public function bar()
    {
        // ...
    }
}
  • Updates to PHP files are done safely, quickly, and performant.
  • Changes are stored permanently. There is no performance impact using Unfinalize.
  • No additional dependencies to your application. Unfinalize and its dependencies are compiled into a single phar file.

Installation

composer require stevebauman/unfinalize

Usage

Inside your composer.json file, add the vendor packages you want to remove the final keywords from inside:

{
    "unfinalize": [
        "vendor/package"
    ]
}

Add the unfinalize command to your composer.json so it runs on composer update:

{
  "scripts": {
    "post-update-cmd": [
      "@php vendor/bin/unfinalize run"
    ]
  }
}

Then, run composer update.

Options

--annotate={annotation}

If you would like final classes and methods to be marked with an annotation (@{annotation}) doc block after unfinalizing, you may add the --annotate option to the unfinalize command:

If an annotation already exists in a doc block then it will be left untouched.

{
  "scripts": {
    "post-update-cmd": [
      "@php vendor/bin/unfinalize run --annotate=internal"
    ]
  }
}

Which will produce:

Before:

final class Foo
{
    final public function bar()
    {
        // ...
    }
}

After:

/**
 * @internal
 */
class Foo
{
    /**
     * @internal
     */
    public function bar()
    {
        // ...
    }
}

--properties={protected/public}

If you would like to change the visibility of private properties to protected or public, you may add the --properties option to the unfinalize command with the new visibility to assign:

{
  "scripts": {
    "post-update-cmd": [
      "@php vendor/bin/unfinalize run --properties=protected"
    ]
  }
}

Which will produce:

Before:

class Foo
{
    private $bar;
}

After:

class Foo
{
    protected $bar;
}

--methods={protected/public}

If you would like to change the visibility of private methods to protected or public, you may add the --methods option to the unfinalize command with the new visibility to assign:

{
  "scripts": {
    "post-update-cmd": [
      "@php vendor/bin/unfinalize run --methods=public"
    ]
  }
}

Which will produce:

Before:

class Foo
{
    private function bar()
    {
    }
}

After:

class Foo
{
    public function bar()
    {
    }
}

--dry

Execute a dry run to see what files will be modified by Unfinalize:

vendor/bin/unfinalize run --dry

More Repositories

1

location

Detect a users location by their IP Address.
PHP
1,104
star
2

showcode

Create beautiful images of code.
Vue
456
star
3

purify

A Laravel wrapper for HTMLPurifier by ezyang
PHP
446
star
4

hypertext

A PHP HTML to pure text transformer.
PHP
148
star
5

curlwind

Generate Tailwind utility stylesheets on demand.
CSS
128
star
6

autodoc-facades

Auto-generate PHP doc annotations for Laravel facades
PHP
89
star
7

laravel-husk

A thin and light scaffolded Laravel Dusk environment.
PHP
88
star
8

translation

An easy database driven automatic translator for Laravel 5
PHP
75
star
9

eloquent-table

An HTML table generator for laravel collections
PHP
46
star
10

github-summarizer

A PHP GitHub summarizer using Chat GPT.
PHP
43
star
11

revision

Revisions for Eloquent Models
PHP
39
star
12

maintenance

A Preventative Maintenance Application (CMMS) for Laravel
PHP
37
star
13

log-reader

An easy log reader for Laravel 5
PHP
23
star
14

wmi

A package for WMI manipulation using PHP and COM.
PHP
10
star
15

calendar-helper

A Laravel calendar implementation with Google Calendar
PHP
8
star
16

helpdesk

An IT Helpdesk for managing issues and other related information.
PHP
6
star
17

maintenance-app

The Maintenance Application
JavaScript
6
star
18

pdf

A Dompdf Wrapper for Laravel.
PHP
5
star
19

platform-logs

A cartalyst's platform log manager
PHP
4
star
20

profilepicture-cli

Download all of your 4K images from https://ProfilePicture.ai automatically
PHP
4
star
21

laravel-husk-gridsome

PHP
3
star
22

platform-localization

A localization manager for cartalyst's platform
PHP
3
star
23

laravel-husk-nuxt

A Laravel Husk example using Nuxrt
PHP
3
star
24

Corp

An AdLDAP Helper Package for Larvel 4/5
PHP
2
star
25

administration

An administration backend scaffolding package for Laravel.
PHP
2
star
26

active

An active HTML class helper that echo's strings based on the current route.
PHP
2
star
27

showcode-api-docs

Showcode API docs
JavaScript
1
star
28

viewer

A presenter-like package but used for attaching modular views on a retrieved eloquent record
PHP
1
star
29

WinSchedule

Actual PHP task scheduling in Windows using COM.
PHP
1
star
30

stevebauman-blog

A repository for hosting blog comments for stevebauman.ca
1
star
31

flash

Sweet Alert flash notifications in Laravel.
PHP
1
star
32

WinPerm

A Windows File / Folder Permission Parser in PHP.
PHP
1
star