Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Having trouble to prefix classes using last stable version #106

Closed
alexmigf opened this issue May 15, 2024 · 5 comments
Closed

Having trouble to prefix classes using last stable version #106

alexmigf opened this issue May 15, 2024 · 5 comments

Comments

@alexmigf
Copy link

I'm having trouble to prefix the libraries classes using the latest stable version, not sure what I'm doing wrong:

{
	"name": "something/something",
		"autoload": {
			"psr-4": {
				"SOMETHING\\": "includes/",
				"SOMETHING\\ELSE\\": "src/"
			},
			"classmap": [
				"vendor/"
			]
	},
	"extra": {
		"strauss": {
			"target_directory": "vendor",
			"namespace_prefix": "SOMETHING\\Vendor\\",
			"classmap_prefix": "SOMETHING_Vendor_",
			"constant_prefix": "SOMETHING_VENDOR_",
			"packages": [
			],
			"update_call_sites": false,
			"override_autoload": {
			},
			"exclude_from_copy": {
				"packages": [
				],
				"namespaces": [
				],
				"file_patterns": [
				]
			},
			"exclude_from_prefix": {
				"packages": [
					"symfony/polyfill-mbstring",
					"symfony/polyfill-iconv"
				],
				"namespaces": [
				],
				"patterns": [
				]
			},
			"namespace_replacement_patterns" : {
			},
			"delete_vendor_packages": false,
			"delete_vendor_files": false
		}
	},
	"config": {
		"platform-check": false
	}
}

I'm targeting vendor but I tried with lib and I get the same output.

@BrianHenryIE
Copy link
Owner

Works for me. You left out the require part of your composer.json so I tested with composer require psr/log and it looks alright. Maybe post a fuller example and specific file that is not prefixed as expected.

@alexmigf
Copy link
Author

Hi @BrianHenryIE,

The file is identical to the one above, except that I intentionally omitted the require statement, as it can be any library. I am testing with Dompdf, but the issue persists. The namespace has been correctly modified, and the class name remains Dompdf (I think it should be SOMETHING_Vendor_Dompdf).

@alexmigf
Copy link
Author

@BrianHenryIE

Do you have any idea what might be causing the issue?

@BrianHenryIE
Copy link
Owner

The classname is unchanged when inside a namespace. It is only changed in the global namespace where it could conflict with another. Once the namespace it exists in is renamed, the problem is solved.

I was considering removing the class renaming altogether in favour of moving things from the global namespace into their own namespace. But at the glacial pace of development, that's not going to change anytime soon.

@alexmigf
Copy link
Author

alexmigf commented Jul 8, 2024

Thank you for the information!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants