Skip to content

feat: support re-importing objects exported via var_dump#56

Open
J0sh0nat0r wants to merge 3 commits into
goldspecdigital:masterfrom
J0sh0nat0r:master
Open

feat: support re-importing objects exported via var_dump#56
J0sh0nat0r wants to merge 3 commits into
goldspecdigital:masterfrom
J0sh0nat0r:master

Conversation

@J0sh0nat0r
Copy link
Copy Markdown

This PR implements the __set_state magic method for all objects, which allows them to be re-imported after being exported via var_export.

In addition 2 minor changes were made to the interface:

  • OAuthFlow::scopes now handles null correctly
  • Scham::items now accepts null, in-line with other methods

@macbookandrew
Copy link
Copy Markdown

@matthew-inamdar any chance you could look at this? This is preventing us from using php artisan config:cache in a number of Laravel applications (using the https://github.com/vyuldashev/laravel-openapi package which depends on this)

@matthew-inamdar
Copy link
Copy Markdown
Member

Thanks for this @J0sh0nat0r - I'll take a look at this over the weekend, but it seems like a great addition.

@JamesFreeman
Copy link
Copy Markdown

Thanks for this @J0sh0nat0r - I'll take a look at this over the weekend, but it seems like a great addition.

@matthew-inamdar, any updates on this? I ran into this issue, would be great if we could get it solved. Happy to lend a hand if there's anything outstanding to get it over the line 👍 .

@macbookandrew
Copy link
Copy Markdown

@matthew-inamdar any updates on this yet?

@olliescase
Copy link
Copy Markdown

Just want to +1 this as would help out my laravel application greatly 😅

@bluehaoran
Copy link
Copy Markdown

If you're here in 2025 and you need this patch (probably because you want to run php artisan config:cache), you can have it in your local PHP application.

  • Open the raw patch for this PR (https://patch-diff.githubusercontent.com/raw/goldspecdigital/oooas/pull/56.patch) in another tab, and save it to your local applciation, e.g. patches/goldspecdigital-oooas-src-openapi-php.patch
  • Add cweagans/composer-patches with Composer require (probably production, because you want to run ^^^ in prod)
  • Add a section like this to your composer.json file (I've inclded the
{
	"require": {
		"cweagans/composer-patches": "^1.7",
	},
	"config": {
		"allow-plugins": {
			"cweagans/composer-patches": true
		}
	},
	"extra": {
		"patches": {
			"goldspecdigital/oooas": [
				"patches/goldspecdigital-oooas-src-openapi-php.patch"
			]
		},
	}
}

This will apply this PR to your local after composer install and let you have this PR without it being merged.

(h/t to someone anonymous on the internet--I can't find the original documentation :( so I'm leaving this here also for my own future reference.)

@macbookandrew
Copy link
Copy Markdown

Here's another alternative I eventually developed to work around this issue, specifically for security schemes:

        config([
            'openapi.collections.default.security' => array_merge(
                config('openapi.collections.default.security', []),
                [SecurityRequirement::create('apiKey')->securityScheme((new apiKey())->build())]
            ),
        ]);

source

This is in the context of a package, so if you only need it in your app, then just this should be sufficient.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

6 participants